diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 91a3b5b..c936a13 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -26,6 +26,7 @@ jobs: RELEASE_FILE: ${{ matrix.name }}-${{ github.event.release.tag_name || github.sha }}-micropython CI_PROJECT_ROOT: ${{ github.workspace }}/src-${{ github.sha }} CI_BUILD_ROOT: ${{ github.workspace }} + CI_USE_ENV: 1 steps: - name: Compiler Cache Fixup diff --git a/boards/manifest-common.py b/boards/manifest-common.py index 9e3b1da..75e820e 100644 --- a/boards/manifest-common.py +++ b/boards/manifest-common.py @@ -9,8 +9,8 @@ require("sdcard") # Bluetooth require("aioble") -freeze("../../pimoroni-pico/micropython/modules_py", "pimoroni.py") -freeze("../../pimoroni-pico/micropython/modules_py", "boot.py") -freeze("../../pimoroni-pico/micropython/modules_py", "lte.py") +freeze("$(MPY_DIR)/../pimoroni-pico/micropython/modules_py", "pimoroni.py") +freeze("$(MPY_DIR)/../pimoroni-pico/micropython/modules_py", "boot.py") +freeze("$(MPY_DIR)/../pimoroni-pico/micropython/modules_py", "lte.py") freeze("../modules/wireless") \ No newline at end of file diff --git a/boards/multicore_lockout.patch b/boards/multicore_lockout.patch deleted file mode 100644 index 8ae338b..0000000 --- a/boards/multicore_lockout.patch +++ /dev/null @@ -1,103 +0,0 @@ -From c51bb5124feb6a3afa9a7612a65b6bab5774e63e Mon Sep 17 00:00:00 2001 -From: graham sanderson -Date: Sun, 2 Feb 2025 12:14:31 -0600 -Subject: [PATCH 1/2] add multicore_lockout_victim_deinit. clear lockedout_flag - for core1 during core1 reset - ---- - .../pico_multicore/include/pico/multicore.h | 7 +++++ - src/rp2_common/pico_multicore/multicore.c | 26 ++++++++++++++----- - 2 files changed, 27 insertions(+), 6 deletions(-) - -diff --git a/src/rp2_common/pico_multicore/include/pico/multicore.h b/src/rp2_common/pico_multicore/include/pico/multicore.h -index c452b9822..20eba780d 100644 ---- a/src/rp2_common/pico_multicore/include/pico/multicore.h -+++ b/src/rp2_common/pico_multicore/include/pico/multicore.h -@@ -449,6 +449,13 @@ static inline uint multicore_doorbell_irq_num(uint doorbell_num) { - */ - void multicore_lockout_victim_init(void); - -+/*! \brief Stop the current core being able to be a "victim" of lockout (i.e. forced to pause in a known state by the other core) -+ * \ingroup multicore_lockout -+ * -+ * This code unhooks the intercore FIFO IRQ, and the FIFO mayt be used for any other purpose after this. -+ */ -+void multicore_lockout_victim_deinit(void); -+ - /*! \brief Determine if \ref multicore_lockout_victim_init() has been called on the specified core. - * \ingroup multicore_lockout - * -diff --git a/src/rp2_common/pico_multicore/multicore.c b/src/rp2_common/pico_multicore/multicore.c -index c495b4ae3..f8f5660db 100644 ---- a/src/rp2_common/pico_multicore/multicore.c -+++ b/src/rp2_common/pico_multicore/multicore.c -@@ -23,12 +23,11 @@ - #endif - #endif - --// note that these are not reset by core reset, however for now, I think people resetting cores --// and then relying on multicore_lockout for that core without re-initializing, is probably --// something we can live with breaking. --// --// whilst we could clear this in core 1 reset path, that doesn't necessarily catch all, --// and means pulling in this array even if multicore_lockout is not used. -+// Note that there is no automatic way for us to clear these flags when a particular core is reset, and yet -+// we DO ideally want to clear them, as the `multicore_lockout_victim_init()` checks the flag for the current core -+// and is a no-op if set. We DO have a new `multicore_lockout_victim_deinit()` method, which can be called in a pinch after -+// the reset before calling `multicore_lockout_victim_init()` again, so that is good. We will reset the flag -+// for core1 in `multicore_reset_core1()` though as a convenience since most people will use that to reset core 1. - static bool lockout_victim_initialized[NUM_CORES]; - - void multicore_fifo_push_blocking(uint32_t data) { -@@ -118,6 +117,9 @@ void multicore_reset_core1(void) { - bool enabled = irq_is_enabled(irq_num); - irq_set_enabled(irq_num, false); - -+ // Core 1 will be in un-initialized state -+ lockout_victim_initialized[1] = false; -+ - // Bring core 1 back out of reset. It will drain its own mailbox FIFO, then push - // a 0 to our mailbox to tell us it has done this. - *power_off_clr = PSM_FRCE_OFF_PROC1_BITS; -@@ -243,6 +245,18 @@ void multicore_lockout_victim_init(void) { - lockout_victim_initialized[core_num] = true; - } - -+void multicore_lockout_victim_deinit(void) { -+ uint core_num = get_core_num(); -+ if (lockout_victim_initialized[core_num]) { -+ // On platforms other than RP2040, these are actually the same IRQ number -+ // (each core only sees its own IRQ, always at the same IRQ number). -+ uint fifo_irq_this_core = SIO_FIFO_IRQ_NUM(core_num); -+ irq_remove_handler(fifo_irq_this_core, multicore_lockout_handler); -+ irq_set_enabled(fifo_irq_this_core, false); -+ lockout_victim_initialized[core_num] = false; -+ } -+} -+ - static bool multicore_lockout_handshake(uint32_t magic, absolute_time_t until) { - uint irq_num = SIO_FIFO_IRQ_NUM(get_core_num()); - bool enabled = irq_is_enabled(irq_num); - -From cd9ee9704228d839057b623426ca5b1aa741c0a1 Mon Sep 17 00:00:00 2001 -From: graham sanderson -Date: Mon, 3 Feb 2025 12:08:22 -0600 -Subject: [PATCH 2/2] typo - ---- - src/rp2_common/pico_multicore/include/pico/multicore.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/rp2_common/pico_multicore/include/pico/multicore.h b/src/rp2_common/pico_multicore/include/pico/multicore.h -index 20eba780d..5eb49ddce 100644 ---- a/src/rp2_common/pico_multicore/include/pico/multicore.h -+++ b/src/rp2_common/pico_multicore/include/pico/multicore.h -@@ -452,7 +452,7 @@ void multicore_lockout_victim_init(void); - /*! \brief Stop the current core being able to be a "victim" of lockout (i.e. forced to pause in a known state by the other core) - * \ingroup multicore_lockout - * -- * This code unhooks the intercore FIFO IRQ, and the FIFO mayt be used for any other purpose after this. -+ * This code unhooks the intercore FIFO IRQ, and the FIFO may be used for any other purpose after this. - */ - void multicore_lockout_victim_deinit(void); - diff --git a/boards/pico2_w_cyw43.patch b/boards/pico2_w_cyw43.patch deleted file mode 100644 index 5771b38..0000000 --- a/boards/pico2_w_cyw43.patch +++ /dev/null @@ -1,43 +0,0 @@ -From ea32e6dfb5232ad7d0ebba7da40dda68da05bc76 Mon Sep 17 00:00:00 2001 -From: Peter Harper -Date: Fri, 24 Jan 2025 18:47:52 +0000 -Subject: [PATCH] Fix unreliable writes to cyw43. - -We use a pio and dma to write to the cyw43 chip using spi. Normally you -write an address and then read the data from that address, so the pio -program does does a write then read. - -If you just want to write data in the case of uploading firmware we -use the fdebug_tx_stall flag to work out if the pio has stalled waiting -to write more data. - -The theory is that this flag will also get set if the bus is busy. So -we mistakenly think a write to cyw43 has completed. - -Wait for the dma write to complete before waiting for the pio to stall. - -Fixes #2206 ---- - src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c b/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c -index bcc7284f1..787eeff5d 100644 ---- a/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c -+++ b/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c -@@ -308,11 +308,13 @@ int cyw43_spi_transfer(cyw43_int_t *self, const uint8_t *tx, size_t tx_length, u - - dma_channel_configure(bus_data->dma_out, &out_config, &bus_data->pio->txf[bus_data->pio_sm], tx, tx_length / 4, true); - -+ pio_sm_set_enabled(bus_data->pio, bus_data->pio_sm, true); -+ dma_channel_wait_for_finish_blocking(bus_data->dma_out); -+ - uint32_t fdebug_tx_stall = 1u << (PIO_FDEBUG_TXSTALL_LSB + bus_data->pio_sm); - bus_data->pio->fdebug = fdebug_tx_stall; -- pio_sm_set_enabled(bus_data->pio, bus_data->pio_sm, true); - while (!(bus_data->pio->fdebug & fdebug_tx_stall)) { -- tight_loop_contents(); // todo timeout -+ tight_loop_contents(); - } - __compiler_memory_barrier(); - pio_sm_set_enabled(bus_data->pio, bus_data->pio_sm, false); diff --git a/ci/micropython.sh b/ci/micropython.sh index 3d7f624..46da9c6 100644 --- a/ci/micropython.sh +++ b/ci/micropython.sh @@ -9,15 +9,6 @@ PIMORONI_PICO_VERSION="feature/picovector2-and-layers" PY_DECL_VERSION="v0.0.3" DIR2UF2_VERSION="v0.0.9" -if [ -z ${CI_PROJECT_ROOT+x} ]; then - SCRIPT_PATH="$(dirname $0)" - CI_PROJECT_ROOT=$(realpath "$SCRIPT_PATH/..") -fi - -if [ -z ${CI_BUILD_ROOT+x} ]; then - CI_BUILD_ROOT=$(pwd) -fi - function log_success { echo -e "$(tput setaf 2)$1$(tput sgr0)" @@ -53,12 +44,6 @@ function ci_micropython_clone { git submodule update --init lib/tinyusb git submodule update --init lib/btstack cd "$CI_BUILD_ROOT" - cd "$CI_BUILD_ROOT/micropython/lib/pico-sdk" - log_inform "HACK: cyw43 stability backport for Pico2 W. See: https://github.com/raspberrypi/pico-sdk/pull/2209" - git apply "$CI_PROJECT_ROOT/boards/pico2_w_cyw43.patch" - log_inform "HACK: backport multicore lockout fix. See: https://github.com/raspberrypi/pico-sdk/pull/2223" - git apply "$CI_PROJECT_ROOT/boards/multicore_lockout.patch" - cd "$CI_BUILD_ROOT" } function ci_tools_clone { @@ -102,8 +87,8 @@ function ci_cmake_configure { BOARD=$1 TOOLS_DIR="$CI_BUILD_ROOT/tools" MICROPY_BOARD_DIR=$CI_PROJECT_ROOT/boards/$BOARD - if [ ! -f "$MICROPY_BOARD_DIR/mpconfigboard.cmake" ]; then - log_warning "Invalid board: $MICROPY_BOARD_DIR" + if [ ! -f "$MICROPY_BOARD_DIR/mpconfigboard.h" ]; then + log_warning "Invalid board: \"$BOARD\". Run with ci_cmake_configure ." return 1 fi USER_C_MODULES_FILE="$CI_PROJECT_ROOT/boards/usermod-common.cmake" @@ -112,6 +97,7 @@ function ci_cmake_configure { -DPICOTOOL_FORCE_FETCH_FROM_GIT=1 \ -DPICO_BUILD_DOCS=0 \ -DPICO_NO_COPRO_DIS=1 \ + -DPICOTOOL_FETCH_FROM_GIT_PATH="$TOOLS_DIR/picotool" \ -DPIMORONI_PICO_PATH="$CI_BUILD_ROOT/pimoroni-pico" \ -DPIMORONI_TOOLS_DIR="$TOOLS_DIR" \ -DUSER_C_MODULES="$USER_C_MODULES_FILE" \ @@ -124,6 +110,10 @@ function ci_cmake_configure { function ci_cmake_build { BOARD=$1 MICROPY_BOARD_DIR=$CI_PROJECT_ROOT/boards/$BOARD + if [ ! -f "$MICROPY_BOARD_DIR/mpconfigboard.h" ]; then + log_warning "Invalid board: \"$BOARD\". Run with ci_cmake_build ." + return 1 + fi BUILD_DIR="$CI_BUILD_ROOT/build-$BOARD" ccache --zero-stats || true cmake --build $BUILD_DIR -j 2 @@ -137,3 +127,11 @@ function ci_cmake_build { cp "$BUILD_DIR/firmware-with-filesystem.uf2" $BOARD-with-filesystem.uf2 fi } + +if [ -z ${CI_USE_ENV+x} ] || [ -z ${CI_PROJECT_ROOT+x} ] || [ -z ${CI_BUILD_ROOT+x} ]; then + SCRIPT_PATH="$(dirname $0)" + CI_PROJECT_ROOT=$(realpath "$SCRIPT_PATH/..") + CI_BUILD_ROOT=$(pwd) +fi + +ci_debug \ No newline at end of file