Skip to content

Commit 090ce9d

Browse files
committed
MicroPython: Enable Bluetooth support for Pico W builds.
1 parent 9d96d06 commit 090ce9d

File tree

12 files changed

+64
-34
lines changed

12 files changed

+64
-34
lines changed

.github/workflows/micropython.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ on:
77
types: [created]
88

99
env:
10-
MICROPYTHON_VERSION: v1.20.0
11-
WORKFLOW_VERSION: v0
10+
MICROPYTHON_VERSION: 856e08b1931b88271816a2f60648f6ff332235b2
11+
WORKFLOW_VERSION: v1
1212

1313
jobs:
1414
deps:
@@ -53,6 +53,7 @@ jobs:
5353
git submodule update --init ../../lib/mbedtls
5454
git submodule update --init ../../lib/micropython-lib
5555
git submodule update --init ../../lib/tinyusb
56+
git submodule update --init ../../lib/btstack
5657
5758
- name: Build mpy-cross
5859
if: steps.cache.outputs.cache-hit != 'true'

micropython/board/PICO_W/board.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"Breadboard friendly",
88
"Castellated Pads",
99
"Micro USB",
10-
"WiFi"
10+
"WiFi",
11+
"Bluetooth"
1112
],
1213
"id": "rp2-pico-w",
1314
"images": [

micropython/board/PICO_W/manifest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22

33
require("bundle-networking")
44

5+
# Bluetooth
6+
require("aioble")
7+
58
include("../manifest_picow.py")
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
# cmake file for Raspberry Pi Pico W
2+
3+
# The C malloc is needed by cyw43-driver Bluetooth and Pimoroni Pico modules
4+
set(MICROPY_C_HEAP_SIZE 4096)
5+
26
set(MICROPY_PY_LWIP ON)
37
set(MICROPY_PY_NETWORK_CYW43 ON)
48

5-
# Board specific version of the frozen manifest
6-
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
9+
# Bluetooth
10+
set(MICROPY_PY_BLUETOOTH ON)
11+
set(MICROPY_BLUETOOTH_BTSTACK ON)
12+
set(MICROPY_PY_BLUETOOTH_CYW43 ON)
713

8-
set(MICROPY_C_HEAP_SIZE 4096)
14+
# Board specific version of the frozen manifest
15+
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)

micropython/board/PICO_W_ENVIRO/board.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"Breadboard friendly",
88
"Castellated Pads",
99
"Micro USB",
10-
"WiFi"
10+
"WiFi",
11+
"Bluetooth"
1112
],
1213
"id": "rp2-pico-w",
1314
"images": [

micropython/board/PICO_W_ENVIRO/manifest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
require("bundle-networking")
55
require("umqtt.simple")
66

7+
# Bluetooth
8+
require("aioble")
9+
710
freeze("../../modules_py", "pimoroni.py")
811
freeze("../../modules_py", "boot.py")
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
# cmake file for Pimoroni Enviro with Raspberry Pi Pico W
22
set(MICROPY_BOARD PICO_W)
33

4+
# The C malloc is needed by cyw43-driver Bluetooth and Pimoroni Pico modules
5+
set(MICROPY_C_HEAP_SIZE 4096)
6+
47
set(MICROPY_PY_LWIP ON)
58
set(MICROPY_PY_NETWORK_CYW43 ON)
69

7-
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
10+
# Bluetooth
11+
set(MICROPY_PY_BLUETOOTH ON)
12+
set(MICROPY_BLUETOOTH_BTSTACK ON)
13+
set(MICROPY_PY_BLUETOOTH_CYW43 ON)
814

9-
set(MICROPY_C_HEAP_SIZE 4096)
15+
# Board specific version of the frozen manifest
16+
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)

micropython/board/PICO_W_ENVIRO/pico_sdk.patch

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/src/rp2_common/pico_runtime/runtime.c b/src/rp2_common/pico_runtime/runtime.c
2-
index f9018d0..ae8c479 100644
2+
index 144ace1..52bb6c9 100644
33
--- a/src/rp2_common/pico_runtime/runtime.c
44
+++ b/src/rp2_common/pico_runtime/runtime.c
55
@@ -20,6 +20,7 @@
@@ -58,19 +58,19 @@ index f9018d0..ae8c479 100644
5858
// (basically anything in aeabi that uses bootrom)
5959

6060
diff --git a/src/rp2_common/pico_standard_link/crt0.S b/src/rp2_common/pico_standard_link/crt0.S
61-
index d061108..e48d870 100644
61+
index 7d29f76..799ce19 100644
6262
--- a/src/rp2_common/pico_standard_link/crt0.S
6363
+++ b/src/rp2_common/pico_standard_link/crt0.S
64-
@@ -10,6 +10,8 @@
64+
@@ -11,6 +11,8 @@
65+
#include "hardware/regs/addressmap.h"
6566
#include "hardware/regs/sio.h"
66-
#include "pico/asm_helper.S"
6767
#include "pico/binary_info/defs.h"
6868
+#include "hardware/regs/resets.h"
6969
+#include "hardware/regs/rosc.h"
7070

7171
#ifdef NDEBUG
7272
#ifndef COLLAPSE_IRQS
73-
@@ -226,6 +228,23 @@ _reset_handler:
73+
@@ -225,6 +227,23 @@ _reset_handler:
7474
cmp r0, #0
7575
bne hold_non_core0_in_bootrom
7676

@@ -94,7 +94,7 @@ index d061108..e48d870 100644
9494
// In a NO_FLASH binary, don't perform .data copy, since it's loaded
9595
// in-place by the SRAM load. Still need to clear .bss
9696
#if !PICO_NO_FLASH
97-
@@ -252,6 +271,10 @@ bss_fill_test:
97+
@@ -251,6 +270,10 @@ bss_fill_test:
9898
cmp r1, r2
9999
bne bss_fill_loop
100100

@@ -105,7 +105,7 @@ index d061108..e48d870 100644
105105
platform_entry: // symbol for stack traces
106106
// Use 32-bit jumps, in case these symbols are moved out of branch range
107107
// (e.g. if main is in SRAM and crt0 in flash)
108-
@@ -311,6 +334,19 @@ data_cpy_table:
108+
@@ -310,6 +333,18 @@ data_cpy_table:
109109
runtime_init:
110110
bx lr
111111

@@ -120,13 +120,12 @@ index d061108..e48d870 100644
120120
+.thumb_func
121121
+runtime_reset_peripherals:
122122
+ bx lr
123-
+
124123
+
125124
// ----------------------------------------------------------------------------
126125
// If core 1 somehow gets into crt0 due to a spectacular VTOR mishap, we need to
127126
// catch it and send back to the sleep-and-launch code in the bootrom. Shouldn't
128-
@@ -335,3 +371,9 @@ hold_non_core0_in_bootrom:
129-
.align 2
127+
@@ -350,3 +385,9 @@ spacer_section .heap
128+
.p2align 2
130129
.equ HeapSize, PICO_HEAP_SIZE
131130
.space HeapSize
132131
+
@@ -135,4 +134,3 @@ index d061108..e48d870 100644
135134
+.align 4
136135
+runtime_wakeup_gpio_state:
137136
+.word 0x00000000
138-
\ No newline at end of file

micropython/board/PICO_W_INKY/board.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"Breadboard friendly",
88
"Castellated Pads",
99
"Micro USB",
10-
"WiFi"
10+
"WiFi",
11+
"Bluetooth"
1112
],
1213
"id": "rp2-pico-w",
1314
"images": [

micropython/board/PICO_W_INKY/manifest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
require("urllib.urequest")
66
require("umqtt.simple")
77

8+
# Bluetooth
9+
require("aioble")
10+
811
freeze("../../modules_py", "pimoroni.py")
912
freeze("../../modules_py", "boot.py")

0 commit comments

Comments
 (0)