Skip to content

Commit 757e3a3

Browse files
committed
Add basic _bleio implementation for zephyr-cp port
Adds basic scanning and advertising support. Uses BabbleSim to test on a host computer.
1 parent 8d17d0c commit 757e3a3

81 files changed

Lines changed: 3111 additions & 332 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/run-tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,10 @@ jobs:
9595
uses: ./.github/actions/deps/external
9696
- name: Build native sim target
9797
run: make -C ports/zephyr-cp -j2 BOARD=native_native_sim
98+
- name: Build bsim
99+
run: make -j 2 everything
100+
working-directory: ports/zephyr-cp/tools/bsim
101+
- name: Build native_nrf5340bsim
102+
run: make -C ports/zephyr-cp -j2 BOARD=native_nrf5340bsim
98103
- name: Run Zephyr tests
99104
run: make -C ports/zephyr-cp test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,6 @@ TAGS
107107

108108
# windsurf rules
109109
.windsurfrules
110+
111+
# git-review-web outputs
112+
.review

AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Capture CircuitPython output by finding the matching device in `/dev/serial/by-id`
2+
- You can mount the CIRCUITPY drive by doing `udisksctl mount -b /dev/disk/by-label/CIRCUITPY` and access it via `/run/media/<user>/CIRCUITPY`.
3+
- `circup` is a command line tool to install libraries and examples to CIRCUITPY.

locale/circuitpython.pot

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,10 @@ msgstr ""
13321332
msgid "Invalid ROS domain ID"
13331333
msgstr ""
13341334

1335+
#: ports/zephyr-cp/common-hal/_bleio/Adapter.c
1336+
msgid "Invalid advertising data"
1337+
msgstr ""
1338+
13351339
#: ports/espressif/common-hal/espidf/__init__.c py/moderrno.c
13361340
msgid "Invalid argument"
13371341
msgstr ""
@@ -3811,6 +3815,7 @@ msgid "non-hex digit"
38113815
msgstr ""
38123816

38133817
#: ports/nordic/common-hal/_bleio/Adapter.c
3818+
#: ports/zephyr-cp/common-hal/_bleio/Adapter.c
38143819
msgid "non-zero timeout must be > 0.01"
38153820
msgstr ""
38163821

@@ -4294,6 +4299,7 @@ msgid "timeout duration exceeded the maximum supported value"
42944299
msgstr ""
42954300

42964301
#: ports/nordic/common-hal/_bleio/Adapter.c
4302+
#: ports/zephyr-cp/common-hal/_bleio/Adapter.c
42974303
msgid "timeout must be < 655.35 secs"
42984304
msgstr ""
42994305

ports/zephyr-cp/AGENTS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- Build a board by doing `make BOARD=<vendor>_<board_name>`.
2+
- The corresponding configuration files are in `boards/<vendor>/<board_name>`
3+
- The files (not folders) in `boards/` directory are used by Zephyr.
4+
- To flash it on a board do `make BOARD=<vendor>_<board_name> flash`.
5+
- Zephyr board docs are at `zephyr/boards/<vendor>/<board_name>`.

ports/zephyr-cp/Kconfig.sysbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ config NET_CORE_BOARD
88
default "nrf5340dk/nrf5340/cpunet" if $(BOARD) = "nrf5340dk"
99
default "nrf7002dk/nrf5340/cpunet" if $(BOARD) = "nrf7002dk"
1010
default "nrf5340_audio_dk/nrf5340/cpunet" if $(BOARD) = "nrf5340_audio_dk"
11+
default "nrf5340bsim/nrf5340/cpunet" if $(BOARD) = "nrf5340bsim"
1112

1213
config NET_CORE_IMAGE_HCI_IPC
1314
bool "HCI IPC image on network core"

ports/zephyr-cp/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ BUILD ?= build-$(BOARD)
88

99
TRANSLATION ?= en_US
1010

11-
.PHONY: $(BUILD)/zephyr-cp/zephyr/zephyr.elf flash debug run clean menuconfig all clean-all test fetch-port-submodules
11+
12+
.PHONY: $(BUILD)/zephyr-cp/zephyr/zephyr.elf flash recover debug run clean menuconfig all clean-all test fetch-port-submodules
1213

1314
$(BUILD)/zephyr-cp/zephyr/zephyr.elf:
1415
python cptools/pre_zephyr_build_prep.py $(BOARD)
@@ -26,6 +27,9 @@ $(BUILD)/firmware.exe: $(BUILD)/zephyr-cp/zephyr/zephyr.elf
2627
flash: $(BUILD)/zephyr-cp/zephyr/zephyr.elf
2728
west flash -d $(BUILD)
2829

30+
recover: $(BUILD)/zephyr-cp/zephyr/zephyr.elf
31+
west flash --recover -d $(BUILD)
32+
2933
debug: $(BUILD)/zephyr-cp/zephyr/zephyr.elf
3034
west debug -d $(BUILD)
3135

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
set(pca10056_BOARD_ALIAS nrf52840dk/nrf52840)
22
set(renesas_ek_ra6m5_BOARD_ALIAS ek_ra6m5)
33
set(renesas_ek_ra8d1_BOARD_ALIAS ek_ra8d1)
4+
set(renesas_da14695_dk_usb_BOARD_ALIAS da14695_dk_usb)
45
set(native_native_sim_BOARD_ALIAS native_sim)
6+
set(native_nrf5340bsim_BOARD_ALIAS nrf5340bsim/nrf5340/cpuapp)
57
set(nordic_nrf54l15dk_BOARD_ALIAS nrf54l15dk/nrf54l15/cpuapp)
68
set(nordic_nrf54h20dk_BOARD_ALIAS nrf54h20dk/nrf54h20/cpuapp)
79
set(nordic_nrf5340dk_BOARD_ALIAS nrf5340dk/nrf5340/cpuapp)
810
set(nordic_nrf7002dk_BOARD_ALIAS nrf7002dk/nrf5340/cpuapp)
911
set(nxp_frdm_mcxn947_BOARD_ALIAS frdm_mcxn947/mcxn947/cpu0)
12+
set(nxp_frdm_rw612_BOARD_ALIAS frdm_rw612)
1013
set(nxp_mimxrt1170_evk_BOARD_ALIAS mimxrt1170_evk@A/mimxrt1176/cm7)
1114
set(st_stm32h7b3i_dk_BOARD_ALIAS stm32h7b3i_dk)
15+
set(st_stm32wba65i_dk1_BOARD_ALIAS stm32wba65i_dk1)
1216
set(st_nucleo_u575zi_q_BOARD_ALIAS nucleo_u575zi_q/stm32u575xx)
1317
set(st_nucleo_n657x0_q_BOARD_ALIAS nucleo_n657x0_q/stm32n657xx)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CONFIG_BT=y
2+
CONFIG_BT_PERIPHERAL=y
3+
CONFIG_BT_CENTRAL=y
4+
CONFIG_BT_BROADCASTER=y
5+
CONFIG_BT_OBSERVER=y
6+
CONFIG_BT_EXT_ADV=y
7+
8+
CONFIG_BT_DEVICE_APPEARANCE_DYNAMIC=y
9+
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
10+
CONFIG_BT_DEVICE_NAME_MAX=28
11+
CONFIG_BT_L2CAP_TX_MTU=253
12+
13+
# BT Buffers
14+
CONFIG_BT_BUF_CMD_TX_SIZE=255
15+
CONFIG_BT_BUF_EVT_RX_COUNT=16
16+
CONFIG_BT_BUF_EVT_RX_SIZE=255
17+
CONFIG_BT_BUF_ACL_TX_COUNT=3
18+
CONFIG_BT_BUF_ACL_TX_SIZE=251
19+
CONFIG_BT_BUF_ACL_RX_COUNT_EXTRA=1
20+
CONFIG_BT_BUF_ACL_RX_SIZE=255
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
&flash0 {
2+
partitions{
3+
circuitpy_partition: partition@118000 {
4+
label = "circuitpy";
5+
reg = <0x118000 (DT_SIZE_M(4) - DT_SIZE_K(1120))>;
6+
};
7+
};
8+
};
9+
10+
#include "../app.overlay"

0 commit comments

Comments
 (0)