Skip to content

Commit 246a7ab

Browse files
authored
Merge pull request #11576 from dhalbert/zephyr-cp-optional-console
zephyr-cp: dynamic buses on the Feather nRF52840 boards
2 parents 6cda07f + 4d20eae commit 246a7ab

31 files changed

Lines changed: 818 additions & 484 deletions

File tree

‎.github/workflows/build-board-custom.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
- name: Set up python
7373
uses: actions/setup-python@v6
7474
with:
75-
python-version: 3.x
75+
python-version: "3.14" # minify_html has no Python 3.15 wheel yet
7676
- name: Board to port
7777
id: board-to-port
7878
run: |

‎.github/workflows/build-boards.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- name: Set up python
4040
uses: actions/setup-python@v6
4141
with:
42-
python-version: ${{ inputs.port == 'zephyr-cp' && '3.13' || '3.x' }}
42+
python-version: ${{ inputs.port == 'zephyr-cp' && '3.13' || '3.14' }} # minify_html has no Python 3.15 wheel yet
4343

4444
- name: Set up port
4545
id: set-up-port

‎.github/workflows/build-mpy-cross.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: Set up python
3838
uses: actions/setup-python@v6
3939
with:
40-
python-version: 3.x
40+
python-version: "3.14" # minify_html has no Python 3.15 wheel yet
4141
- name: Set up submodules
4242
uses: ./.github/actions/deps/submodules
4343
with:

‎.github/workflows/build.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: Set up python
4343
uses: actions/setup-python@v6
4444
with:
45-
python-version: 3.x
45+
python-version: "3.14" # minify_html has no Python 3.15 wheel yet
4646
- name: Duplicate USB VID/PID check
4747
run: python3 -u -m tools.ci_check_duplicate_usb_vid_pid
4848
- name: Set up submodules
@@ -135,7 +135,7 @@ jobs:
135135
- name: Set up python
136136
uses: actions/setup-python@v6
137137
with:
138-
python-version: 3.x
138+
python-version: "3.14" # minify_html has no Python 3.15 wheel yet
139139
- name: Set up submodules
140140
uses: ./.github/actions/deps/submodules
141141
- name: Versions
@@ -177,7 +177,7 @@ jobs:
177177
- name: Set up python
178178
uses: actions/setup-python@v6
179179
with:
180-
python-version: 3.x
180+
python-version: "3.14" # minify_html has no Python 3.15 wheel yet
181181
- name: Set up submodules
182182
uses: ./.github/actions/deps/submodules
183183
with:

‎.github/workflows/create-website-pr.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Set up python
2727
uses: actions/setup-python@v6
2828
with:
29-
python-version: 3.x
29+
python-version: "3.14" # minify_html has no Python 3.15 wheel yet
3030
- name: Set up submodules
3131
uses: ./.github/actions/deps/submodules
3232
with:

‎.github/workflows/pre-commit.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Set up python
3131
uses: actions/setup-python@v6
3232
with:
33-
python-version: 3.x
33+
python-version: "3.14" # minify_html has no Python 3.15 wheel yet
3434
- name: Set up submodules
3535
uses: ./.github/actions/deps/submodules
3636
- name: Set up external

‎ports/zephyr-cp/Makefile‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,25 @@ endif
6161
# When DEBUG=1, apply additional Kconfig fragments for debug-friendly settings.
6262
DEBUG_CONF_FILE ?= $(CURDIR)/debug.conf
6363
ifeq ($(DEBUG),1)
64-
ifneq ($(CP_BOARD_CONF),)
65-
CP_BOARD_CONF := $(CP_BOARD_CONF);$(DEBUG_CONF_FILE)
66-
else
67-
CP_BOARD_CONF := $(DEBUG_CONF_FILE)
64+
CP_BOARD_CONF := $(strip $(CP_BOARD_CONF) $(DEBUG_CONF_FILE))
65+
endif
66+
# When CONSOLE=1 (implied by DEBUG=1), apply the board's console.overlay, if it has one, and the
67+
# port's console.conf. Boards whose console pins are also user pins enable the Zephyr UART console
68+
# only then.
69+
CONSOLE ?= $(DEBUG)
70+
CP_BOARD_CONSOLE_OVERLAY :=
71+
ifeq ($(CONSOLE),1)
72+
CP_BOARD_CONSOLE_OVERLAY := $(wildcard $(CP_BOARD_DIR)/console.overlay)
73+
ifneq ($(CP_BOARD_CONSOLE_OVERLAY),)
74+
CP_BOARD_CONF := $(strip $(CP_BOARD_CONF) $(CURDIR)/console.conf)
6875
endif
6976
endif
70-
# Always pass the conf file, even if empty. This undoes DEBUG=1 when it's omitted on a later run.
71-
# Quoted because with DEBUG=1 the value is a semicolon-separated list, and an unquoted semicolon
72-
# would end the shell command.
77+
CP_BOARD_CONF := $(subst $(eval) ,;,$(CP_BOARD_CONF))
78+
# Always pass the conf and console overlay files, even if empty. This undoes DEBUG=1 or CONSOLE=1
79+
# when it's omitted on a later run. Quoted because the conf value can be a semicolon-separated
80+
# list, and an unquoted semicolon would end the shell command.
7381
WEST_CMAKE_ARGS += -Dzephyr-cp_EXTRA_CONF_FILE="$(CP_BOARD_CONF)"
82+
WEST_CMAKE_ARGS += -Dzephyr-cp_EXTRA_DTC_OVERLAY_FILE="$(CP_BOARD_CONSOLE_OVERLAY)"
7483

7584
# Boards can opt into building the MCUboot bootloader (and thus BLE OTA
7685
# updates) by shipping a sysbuild.conf fragment. It sets sysbuild-level

‎ports/zephyr-cp/README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ make BOARD=nordic_nrf5340dk
2828
This uses Zephyr's cmake to generate Makefiles that then delegate to
2929
`tools/cpbuild/build_circuitpython.py` to build the CircuitPython bits in parallel.
3030

31+
`DEBUG=1` adds the debug Kconfig settings in `debug.conf`. `CONSOLE=1` (implied
32+
by `DEBUG=1`) applies a board's `console.overlay`, if it has one, together with
33+
the port's `console.conf`, which turns the Zephyr UART console back on. Boards
34+
whose console UART pins are also user pins, such as the Feather nRF52840, have
35+
the Zephyr UART console only in those builds.
36+
3137
## Native simulator build container
3238

3339
Building the native sim requires `libsdl2-dev:i386` and other 32bit dependencies that

‎ports/zephyr-cp/boards/adafruit/clue_nrf52840_zephyr/board.overlay‎

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* Partition layout is owned by the mcuboot fork
22
* (dts/adafruit/adafruit_clue_nrf52840.dtsi) and applied to this image by
33
* sysbuild. This overlay only adds board/app config. */
4+
/* No Zephyr console by default, so TX/RX are free for busio.UART. A CONSOLE=1
5+
* build puts the console back on UART0 (console.overlay). */
46
/ {
57
chosen {
68
/delete-property/ zephyr,console;
@@ -15,11 +17,15 @@
1517
/delete-node/ board_cdc_acm_uart;
1618
};
1719

18-
// UART0, I2C1 and SPI3 are enabled with all pins disconnected and marked
19-
// zephyr,deferred-init so nothing is claimed at boot: the iobroker
20+
// UART0, I2C0, I2C1 and SPI3 are enabled with all pins disconnected and
21+
// marked zephyr,deferred-init so nothing is claimed at boot: the iobroker
2022
// initializes and routes a device to arbitrary pins when a busio object is
21-
// constructed, and de-initializes it on release. (I2C0 is the fixed sensor
22-
// bus, SPI2 the fixed display bus, and QSPI the fixed external flash.)
23+
// constructed, and de-initializes it on release. (SPI2 is the fixed display
24+
// bus and QSPI the fixed external flash. The onboard sensors are on SCL/SDA
25+
// but have no devicetree nodes, so I2C0 does not need to be fixed.)
26+
//
27+
// See "nRF serial instances" in internal-modules/iobroker/README.md for how
28+
// the instances are shared and allocated.
2329
//
2430
// I2C1 and SPI1 are the same peripheral instance (0x40004000), so only one
2531
// mode can be enabled: I2C is the more useful dynamic bus on the CLUE.
@@ -41,6 +47,20 @@
4147
};
4248
};
4349

50+
i2c0_dyn_default: i2c0_dyn_default {
51+
group1 {
52+
psels = <NRF_PSEL_DISCONNECTED(TWIM_SDA)>,
53+
<NRF_PSEL_DISCONNECTED(TWIM_SCL)>;
54+
};
55+
};
56+
57+
i2c0_dyn_sleep: i2c0_dyn_sleep {
58+
group1 {
59+
psels = <NRF_PSEL_DISCONNECTED(TWIM_SDA)>,
60+
<NRF_PSEL_DISCONNECTED(TWIM_SCL)>;
61+
};
62+
};
63+
4464
i2c1_dyn_default: i2c1_dyn_default {
4565
group1 {
4666
psels = <NRF_PSEL_DISCONNECTED(TWIM_SDA)>,
@@ -144,7 +164,11 @@
144164
};
145165
};
146166

167+
// The upstream board uses the legacy UART driver for UART0, which can't be
168+
// de-initialized, so iobroker could not route it again once it was released.
169+
// Instead, use the UARTE driver, which can be deinited.
147170
&uart0 {
171+
compatible = "nordic,nrf-uarte";
148172
status = "okay";
149173
zephyr,deferred-init;
150174
current-speed = <115200>;
@@ -153,6 +177,17 @@
153177
pinctrl-names = "default", "sleep";
154178
};
155179

180+
// The upstream board fixes I2C0 to SCL/SDA with the legacy TWI driver. Use
181+
// TWIM like I2C1 so iobroker can route it.
182+
&i2c0 {
183+
compatible = "nordic,nrf-twim";
184+
status = "okay";
185+
zephyr,deferred-init;
186+
pinctrl-0 = <&i2c0_dyn_default>;
187+
pinctrl-1 = <&i2c0_dyn_sleep>;
188+
pinctrl-names = "default", "sleep";
189+
};
190+
156191
&i2c1 {
157192
status = "okay";
158193
zephyr,deferred-init;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* Applied after board.overlay in CONSOLE=1 and DEBUG=1 builds: the Zephyr
2+
* console on UART0, fixed to the TX/RX pins. TX/RX are then not available to
3+
* busio.UART. */
4+
/ {
5+
chosen {
6+
zephyr,console = &uart0;
7+
zephyr,shell-uart = &uart0;
8+
zephyr,uart-mcumgr = &uart0;
9+
zephyr,bt-mon-uart = &uart0;
10+
zephyr,bt-c2h-uart = &uart0;
11+
};
12+
};
13+
14+
&uart0 {
15+
/delete-property/ zephyr,deferred-init;
16+
pinctrl-0 = <&uart0_default>;
17+
pinctrl-1 = <&uart0_sleep>;
18+
};

0 commit comments

Comments
 (0)