Skip to content

Commit 4d20eae

Browse files
dhalbertclaude
andcommitted
zephyr-cp: dynamic I2C0 and UARTE UART0 on the CLUE
The upstream board fixes I2C0 to SCL/SDA with the legacy TWI driver, which the board-bus rule no longer allows on a board that uses iobroker. Make it a dynamic TWIM instance; the onboard sensors on SCL/SDA have no devicetree nodes, so it doesn't need to be fixed. The upstream board also uses the legacy UART driver for UART0, the CLUE's only UART instance. It can't be de-initialized, so after the first busio.UART was released, no UART could be created again. Use UARTE. Add a console.overlay, so a CONSOLE=1 build puts the Zephyr console on TX/RX, as on the Feathers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent b75f40f commit 4d20eae

2 files changed

Lines changed: 54 additions & 4 deletions

File tree

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

Lines changed: 36 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,12 @@
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.)
2326
//
2427
// See "nRF serial instances" in internal-modules/iobroker/README.md for how
2528
// the instances are shared and allocated.
@@ -44,6 +47,20 @@
4447
};
4548
};
4649

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+
4764
i2c1_dyn_default: i2c1_dyn_default {
4865
group1 {
4966
psels = <NRF_PSEL_DISCONNECTED(TWIM_SDA)>,
@@ -147,7 +164,11 @@
147164
};
148165
};
149166

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.
150170
&uart0 {
171+
compatible = "nordic,nrf-uarte";
151172
status = "okay";
152173
zephyr,deferred-init;
153174
current-speed = <115200>;
@@ -156,6 +177,17 @@
156177
pinctrl-names = "default", "sleep";
157178
};
158179

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+
159191
&i2c1 {
160192
status = "okay";
161193
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)