diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 9a486089..9e70ff89 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -7,8 +7,8 @@ on: types: [created] env: - MICROPYTHON_VERSION: v1.20.0 - WORKFLOW_VERSION: v0 + MICROPYTHON_VERSION: 856e08b1931b88271816a2f60648f6ff332235b2 + WORKFLOW_VERSION: v1 jobs: deps: @@ -53,6 +53,7 @@ jobs: git submodule update --init ../../lib/mbedtls git submodule update --init ../../lib/micropython-lib git submodule update --init ../../lib/tinyusb + git submodule update --init ../../lib/btstack - name: Build mpy-cross if: steps.cache.outputs.cache-hit != 'true' diff --git a/micropython/board/PICO_W/board.json b/micropython/board/PICO_W/board.json index 353072f7..5ed50780 100644 --- a/micropython/board/PICO_W/board.json +++ b/micropython/board/PICO_W/board.json @@ -7,7 +7,8 @@ "Breadboard friendly", "Castellated Pads", "Micro USB", - "WiFi" + "WiFi", + "Bluetooth" ], "id": "rp2-pico-w", "images": [ diff --git a/micropython/board/PICO_W/manifest.py b/micropython/board/PICO_W/manifest.py index 4a75556e..95782f97 100644 --- a/micropython/board/PICO_W/manifest.py +++ b/micropython/board/PICO_W/manifest.py @@ -2,4 +2,7 @@ include("$(PORT_DIR)/boards/manifest.py") require("bundle-networking") +# Bluetooth +require("aioble") + include("../manifest_picow.py") \ No newline at end of file diff --git a/micropython/board/PICO_W/mpconfigboard.cmake b/micropython/board/PICO_W/mpconfigboard.cmake index 5a158651..9182e843 100644 --- a/micropython/board/PICO_W/mpconfigboard.cmake +++ b/micropython/board/PICO_W/mpconfigboard.cmake @@ -1,8 +1,15 @@ # cmake file for Raspberry Pi Pico W + +# The C malloc is needed by cyw43-driver Bluetooth and Pimoroni Pico modules +set(MICROPY_C_HEAP_SIZE 4096) + set(MICROPY_PY_LWIP ON) set(MICROPY_PY_NETWORK_CYW43 ON) -# Board specific version of the frozen manifest -set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) +# Bluetooth +set(MICROPY_PY_BLUETOOTH ON) +set(MICROPY_BLUETOOTH_BTSTACK ON) +set(MICROPY_PY_BLUETOOTH_CYW43 ON) -set(MICROPY_C_HEAP_SIZE 4096) \ No newline at end of file +# Board specific version of the frozen manifest +set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) \ No newline at end of file diff --git a/micropython/board/PICO_W_ENVIRO/board.json b/micropython/board/PICO_W_ENVIRO/board.json index 755ba103..a85d7e04 100644 --- a/micropython/board/PICO_W_ENVIRO/board.json +++ b/micropython/board/PICO_W_ENVIRO/board.json @@ -7,7 +7,8 @@ "Breadboard friendly", "Castellated Pads", "Micro USB", - "WiFi" + "WiFi", + "Bluetooth" ], "id": "rp2-pico-w", "images": [ diff --git a/micropython/board/PICO_W_ENVIRO/manifest.py b/micropython/board/PICO_W_ENVIRO/manifest.py index c4c9c685..153a4cef 100644 --- a/micropython/board/PICO_W_ENVIRO/manifest.py +++ b/micropython/board/PICO_W_ENVIRO/manifest.py @@ -4,5 +4,8 @@ include("$(PORT_DIR)/boards/manifest.py") require("bundle-networking") require("umqtt.simple") +# Bluetooth +require("aioble") + freeze("../../modules_py", "pimoroni.py") freeze("../../modules_py", "boot.py") diff --git a/micropython/board/PICO_W_ENVIRO/mpconfigboard.cmake b/micropython/board/PICO_W_ENVIRO/mpconfigboard.cmake index b1241f6d..4644016a 100644 --- a/micropython/board/PICO_W_ENVIRO/mpconfigboard.cmake +++ b/micropython/board/PICO_W_ENVIRO/mpconfigboard.cmake @@ -1,9 +1,16 @@ # cmake file for Pimoroni Enviro with Raspberry Pi Pico W set(MICROPY_BOARD PICO_W) +# The C malloc is needed by cyw43-driver Bluetooth and Pimoroni Pico modules +set(MICROPY_C_HEAP_SIZE 4096) + set(MICROPY_PY_LWIP ON) set(MICROPY_PY_NETWORK_CYW43 ON) -set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) +# Bluetooth +set(MICROPY_PY_BLUETOOTH ON) +set(MICROPY_BLUETOOTH_BTSTACK ON) +set(MICROPY_PY_BLUETOOTH_CYW43 ON) -set(MICROPY_C_HEAP_SIZE 4096) \ No newline at end of file +# Board specific version of the frozen manifest +set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) \ No newline at end of file diff --git a/micropython/board/PICO_W_ENVIRO/pico_sdk.patch b/micropython/board/PICO_W_ENVIRO/pico_sdk.patch index dbc20edb..614370bb 100644 --- a/micropython/board/PICO_W_ENVIRO/pico_sdk.patch +++ b/micropython/board/PICO_W_ENVIRO/pico_sdk.patch @@ -1,5 +1,5 @@ diff --git a/src/rp2_common/pico_runtime/runtime.c b/src/rp2_common/pico_runtime/runtime.c -index f9018d0..ae8c479 100644 +index 144ace1..52bb6c9 100644 --- a/src/rp2_common/pico_runtime/runtime.c +++ b/src/rp2_common/pico_runtime/runtime.c @@ -20,6 +20,7 @@ @@ -58,19 +58,19 @@ index f9018d0..ae8c479 100644 // (basically anything in aeabi that uses bootrom) diff --git a/src/rp2_common/pico_standard_link/crt0.S b/src/rp2_common/pico_standard_link/crt0.S -index d061108..e48d870 100644 +index 7d29f76..799ce19 100644 --- a/src/rp2_common/pico_standard_link/crt0.S +++ b/src/rp2_common/pico_standard_link/crt0.S -@@ -10,6 +10,8 @@ +@@ -11,6 +11,8 @@ + #include "hardware/regs/addressmap.h" #include "hardware/regs/sio.h" - #include "pico/asm_helper.S" #include "pico/binary_info/defs.h" +#include "hardware/regs/resets.h" +#include "hardware/regs/rosc.h" #ifdef NDEBUG #ifndef COLLAPSE_IRQS -@@ -226,6 +228,23 @@ _reset_handler: +@@ -225,6 +227,23 @@ _reset_handler: cmp r0, #0 bne hold_non_core0_in_bootrom @@ -94,7 +94,7 @@ index d061108..e48d870 100644 // In a NO_FLASH binary, don't perform .data copy, since it's loaded // in-place by the SRAM load. Still need to clear .bss #if !PICO_NO_FLASH -@@ -252,6 +271,10 @@ bss_fill_test: +@@ -251,6 +270,10 @@ bss_fill_test: cmp r1, r2 bne bss_fill_loop @@ -105,7 +105,7 @@ index d061108..e48d870 100644 platform_entry: // symbol for stack traces // Use 32-bit jumps, in case these symbols are moved out of branch range // (e.g. if main is in SRAM and crt0 in flash) -@@ -311,6 +334,19 @@ data_cpy_table: +@@ -310,6 +333,18 @@ data_cpy_table: runtime_init: bx lr @@ -120,13 +120,12 @@ index d061108..e48d870 100644 +.thumb_func +runtime_reset_peripherals: + bx lr -+ + // ---------------------------------------------------------------------------- // If core 1 somehow gets into crt0 due to a spectacular VTOR mishap, we need to // catch it and send back to the sleep-and-launch code in the bootrom. Shouldn't -@@ -335,3 +371,9 @@ hold_non_core0_in_bootrom: - .align 2 +@@ -350,3 +385,9 @@ spacer_section .heap + .p2align 2 .equ HeapSize, PICO_HEAP_SIZE .space HeapSize + @@ -135,4 +134,3 @@ index d061108..e48d870 100644 +.align 4 +runtime_wakeup_gpio_state: +.word 0x00000000 -\ No newline at end of file diff --git a/micropython/board/PICO_W_INKY/board.json b/micropython/board/PICO_W_INKY/board.json index 755ba103..a85d7e04 100644 --- a/micropython/board/PICO_W_INKY/board.json +++ b/micropython/board/PICO_W_INKY/board.json @@ -7,7 +7,8 @@ "Breadboard friendly", "Castellated Pads", "Micro USB", - "WiFi" + "WiFi", + "Bluetooth" ], "id": "rp2-pico-w", "images": [ diff --git a/micropython/board/PICO_W_INKY/manifest.py b/micropython/board/PICO_W_INKY/manifest.py index 657bf9f9..17514700 100644 --- a/micropython/board/PICO_W_INKY/manifest.py +++ b/micropython/board/PICO_W_INKY/manifest.py @@ -5,5 +5,8 @@ require("bundle-networking") require("urllib.urequest") require("umqtt.simple") +# Bluetooth +require("aioble") + freeze("../../modules_py", "pimoroni.py") freeze("../../modules_py", "boot.py") \ No newline at end of file diff --git a/micropython/board/PICO_W_INKY/mpconfigboard.cmake b/micropython/board/PICO_W_INKY/mpconfigboard.cmake index be167d17..e06f0cb7 100644 --- a/micropython/board/PICO_W_INKY/mpconfigboard.cmake +++ b/micropython/board/PICO_W_INKY/mpconfigboard.cmake @@ -1,9 +1,16 @@ # cmake file for Pimoroni Inky with Raspberry Pi Pico W set(MICROPY_BOARD PICO_W) +# The C malloc is needed by cyw43-driver Bluetooth and Pimoroni Pico modules +set(MICROPY_C_HEAP_SIZE 4096) + set(MICROPY_PY_LWIP ON) set(MICROPY_PY_NETWORK_CYW43 ON) -set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) +# Bluetooth +set(MICROPY_PY_BLUETOOTH ON) +set(MICROPY_BLUETOOTH_BTSTACK ON) +set(MICROPY_PY_BLUETOOTH_CYW43 ON) -set(MICROPY_C_HEAP_SIZE 4096) \ No newline at end of file +# Board specific version of the frozen manifest +set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) \ No newline at end of file diff --git a/micropython/board/PICO_W_INKY/pico_sdk.patch b/micropython/board/PICO_W_INKY/pico_sdk.patch index dbc20edb..614370bb 100644 --- a/micropython/board/PICO_W_INKY/pico_sdk.patch +++ b/micropython/board/PICO_W_INKY/pico_sdk.patch @@ -1,5 +1,5 @@ diff --git a/src/rp2_common/pico_runtime/runtime.c b/src/rp2_common/pico_runtime/runtime.c -index f9018d0..ae8c479 100644 +index 144ace1..52bb6c9 100644 --- a/src/rp2_common/pico_runtime/runtime.c +++ b/src/rp2_common/pico_runtime/runtime.c @@ -20,6 +20,7 @@ @@ -58,19 +58,19 @@ index f9018d0..ae8c479 100644 // (basically anything in aeabi that uses bootrom) diff --git a/src/rp2_common/pico_standard_link/crt0.S b/src/rp2_common/pico_standard_link/crt0.S -index d061108..e48d870 100644 +index 7d29f76..799ce19 100644 --- a/src/rp2_common/pico_standard_link/crt0.S +++ b/src/rp2_common/pico_standard_link/crt0.S -@@ -10,6 +10,8 @@ +@@ -11,6 +11,8 @@ + #include "hardware/regs/addressmap.h" #include "hardware/regs/sio.h" - #include "pico/asm_helper.S" #include "pico/binary_info/defs.h" +#include "hardware/regs/resets.h" +#include "hardware/regs/rosc.h" #ifdef NDEBUG #ifndef COLLAPSE_IRQS -@@ -226,6 +228,23 @@ _reset_handler: +@@ -225,6 +227,23 @@ _reset_handler: cmp r0, #0 bne hold_non_core0_in_bootrom @@ -94,7 +94,7 @@ index d061108..e48d870 100644 // In a NO_FLASH binary, don't perform .data copy, since it's loaded // in-place by the SRAM load. Still need to clear .bss #if !PICO_NO_FLASH -@@ -252,6 +271,10 @@ bss_fill_test: +@@ -251,6 +270,10 @@ bss_fill_test: cmp r1, r2 bne bss_fill_loop @@ -105,7 +105,7 @@ index d061108..e48d870 100644 platform_entry: // symbol for stack traces // Use 32-bit jumps, in case these symbols are moved out of branch range // (e.g. if main is in SRAM and crt0 in flash) -@@ -311,6 +334,19 @@ data_cpy_table: +@@ -310,6 +333,18 @@ data_cpy_table: runtime_init: bx lr @@ -120,13 +120,12 @@ index d061108..e48d870 100644 +.thumb_func +runtime_reset_peripherals: + bx lr -+ + // ---------------------------------------------------------------------------- // If core 1 somehow gets into crt0 due to a spectacular VTOR mishap, we need to // catch it and send back to the sleep-and-launch code in the bootrom. Shouldn't -@@ -335,3 +371,9 @@ hold_non_core0_in_bootrom: - .align 2 +@@ -350,3 +385,9 @@ spacer_section .heap + .p2align 2 .equ HeapSize, PICO_HEAP_SIZE .space HeapSize + @@ -135,4 +134,3 @@ index d061108..e48d870 100644 +.align 4 +runtime_wakeup_gpio_state: +.word 0x00000000 -\ No newline at end of file