Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions ports/zephyr-cp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,25 @@ endif
# When DEBUG=1, apply additional Kconfig fragments for debug-friendly settings.
DEBUG_CONF_FILE ?= $(CURDIR)/debug.conf
ifeq ($(DEBUG),1)
ifneq ($(CP_BOARD_CONF),)
CP_BOARD_CONF := $(CP_BOARD_CONF);$(DEBUG_CONF_FILE)
else
CP_BOARD_CONF := $(DEBUG_CONF_FILE)
CP_BOARD_CONF := $(strip $(CP_BOARD_CONF) $(DEBUG_CONF_FILE))
endif
# When CONSOLE=1 (implied by DEBUG=1), apply the board's console.overlay, if it has one, and the
# port's console.conf. Boards whose console pins are also user pins enable the Zephyr UART console
# only then.
CONSOLE ?= $(DEBUG)
CP_BOARD_CONSOLE_OVERLAY :=
ifeq ($(CONSOLE),1)
CP_BOARD_CONSOLE_OVERLAY := $(wildcard $(CP_BOARD_DIR)/console.overlay)
ifneq ($(CP_BOARD_CONSOLE_OVERLAY),)
CP_BOARD_CONF := $(strip $(CP_BOARD_CONF) $(CURDIR)/console.conf)
endif
endif
# Always pass the conf file, even if empty. This undoes DEBUG=1 when it's omitted on a later run.
# Quoted because with DEBUG=1 the value is a semicolon-separated list, and an unquoted semicolon
# would end the shell command.
CP_BOARD_CONF := $(subst $(eval) ,;,$(CP_BOARD_CONF))
# Always pass the conf and console overlay files, even if empty. This undoes DEBUG=1 or CONSOLE=1
# when it's omitted on a later run. Quoted because the conf value can be a semicolon-separated
# list, and an unquoted semicolon would end the shell command.
WEST_CMAKE_ARGS += -Dzephyr-cp_EXTRA_CONF_FILE="$(CP_BOARD_CONF)"
WEST_CMAKE_ARGS += -Dzephyr-cp_EXTRA_DTC_OVERLAY_FILE="$(CP_BOARD_CONSOLE_OVERLAY)"

# Boards can opt into building the MCUboot bootloader (and thus BLE OTA
# updates) by shipping a sysbuild.conf fragment. It sets sysbuild-level
Expand Down
6 changes: 6 additions & 0 deletions ports/zephyr-cp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ make BOARD=nordic_nrf5340dk
This uses Zephyr's cmake to generate Makefiles that then delegate to
`tools/cpbuild/build_circuitpython.py` to build the CircuitPython bits in parallel.

`DEBUG=1` adds the debug Kconfig settings in `debug.conf`. `CONSOLE=1` (implied
by `DEBUG=1`) applies a board's `console.overlay`, if it has one, together with
the port's `console.conf`, which turns the Zephyr UART console back on. Boards
whose console UART pins are also user pins, such as the Feather nRF52840, have
the Zephyr UART console only in those builds.

## Native simulator build container

Building the native sim requires `libsdl2-dev:i386` and other 32bit dependencies that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
// constructed, and de-initializes it on release. (I2C0 is the fixed sensor
// bus, SPI2 the fixed display bus, and QSPI the fixed external flash.)
//
// See "nRF serial instances" in internal-modules/iobroker/README.md for how
// the instances are shared and allocated.
//
// I2C1 and SPI1 are the same peripheral instance (0x40004000), so only one
// mode can be enabled: I2C is the more useful dynamic bus on the CLUE.
// SPI1 is left disabled; UART1 is enabled by neither overlay because UART0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
CONFIG_BOARD_SERIAL_BACKEND_CDC_ACM=n

# No Zephyr UART console by default (see board.overlay); a CONSOLE=1 build turns
# it back on in console.conf.
CONFIG_UART_CONSOLE=n
CONFIG_LOG_BACKEND_UART=n

# Pin numbers are module pins (MDBT50Q-1MV2 carries the aQFN73 inside).
# The feathers use the MDBT50Q-1MV2 module, so pin numbers are module pins.
CONFIG_IOBROKER_PACKAGE_MDBT50Q_1MV2=y
Expand Down
Original file line number Diff line number Diff line change
@@ -1,244 +1,7 @@
/* Partition layout is owned by the mcuboot fork
* (dts/adafruit/adafruit_feather_nrf52840.dtsi) and applied to this image by
* sysbuild. This overlay only adds board/app config. */
/ {
chosen {
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,uart-mcumgr = &uart0;
zephyr,bt-mon-uart = &uart0;
zephyr,bt-c2h-uart = &uart0;
};
};
/* Same as the Feather nRF52840 Express, whose upstream board is the same
* apart from the LED pin and the SHT3XD node below. */
#include "../feather_nrf52840_zephyr/board.overlay"

&zephyr_udc0 {
/delete-node/ board_cdc_acm_uart;
};

// Bus instances enabled with all pins disconnected and marked
// zephyr,deferred-init so nothing is claimed at boot: the iobroker
// initializes and routes a device to arbitrary pins when a busio object is
// constructed, and de-initializes it on release: I2C1, SPI2, SPI3 and UART1.
// (The fixed I2C0 is the Stemma QT bus with the SHT31 sensor, and UART0 the
// console. The formerly fixed SPI1 is dropped: it had no device attached and
// its instance is the same peripheral as I2C1, so only one mode can be
// enabled.)

&pinctrl {
i2c1_dyn_default: i2c1_dyn_default {
group1 {
psels = <NRF_PSEL_DISCONNECTED(TWIM_SDA)>,
<NRF_PSEL_DISCONNECTED(TWIM_SCL)>;
};
};

i2c1_dyn_sleep: i2c1_dyn_sleep {
group1 {
psels = <NRF_PSEL_DISCONNECTED(TWIM_SDA)>,
<NRF_PSEL_DISCONNECTED(TWIM_SCL)>;
};
};

spi2_dyn_default: spi2_dyn_default {
group1 {
psels = <NRF_PSEL_DISCONNECTED(SPIM_SCK)>,
<NRF_PSEL_DISCONNECTED(SPIM_MOSI)>,
<NRF_PSEL_DISCONNECTED(SPIM_MISO)>;
};
};

spi2_dyn_sleep: spi2_dyn_sleep {
group1 {
psels = <NRF_PSEL_DISCONNECTED(SPIM_SCK)>,
<NRF_PSEL_DISCONNECTED(SPIM_MOSI)>,
<NRF_PSEL_DISCONNECTED(SPIM_MISO)>;
};
};

spi3_dyn_default: spi3_dyn_default {
group1 {
psels = <NRF_PSEL_DISCONNECTED(SPIM_SCK)>,
<NRF_PSEL_DISCONNECTED(SPIM_MOSI)>,
<NRF_PSEL_DISCONNECTED(SPIM_MISO)>;
};
};

spi3_dyn_sleep: spi3_dyn_sleep {
group1 {
psels = <NRF_PSEL_DISCONNECTED(SPIM_SCK)>,
<NRF_PSEL_DISCONNECTED(SPIM_MOSI)>,
<NRF_PSEL_DISCONNECTED(SPIM_MISO)>;
};
};

uart1_dyn_default: uart1_dyn_default {
group1 {
psels = <NRF_PSEL_DISCONNECTED(UART_TX)>,
<NRF_PSEL_DISCONNECTED(UART_RX)>;
};
};

uart1_dyn_sleep: uart1_dyn_sleep {
group1 {
psels = <NRF_PSEL_DISCONNECTED(UART_TX)>,
<NRF_PSEL_DISCONNECTED(UART_RX)>;
};
};

pwm0_dyn_default: pwm0_dyn_default {
group1 {
psels = <NRF_PSEL_DISCONNECTED(PWM_OUT0)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT1)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT2)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT3)>;
};
};

pwm0_dyn_sleep: pwm0_dyn_sleep {
group1 {
psels = <NRF_PSEL_DISCONNECTED(PWM_OUT0)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT1)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT2)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT3)>;
};
};

pwm1_dyn_default: pwm1_dyn_default {
group1 {
psels = <NRF_PSEL_DISCONNECTED(PWM_OUT0)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT1)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT2)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT3)>;
};
};

pwm1_dyn_sleep: pwm1_dyn_sleep {
group1 {
psels = <NRF_PSEL_DISCONNECTED(PWM_OUT0)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT1)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT2)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT3)>;
};
};

pwm2_dyn_default: pwm2_dyn_default {
group1 {
psels = <NRF_PSEL_DISCONNECTED(PWM_OUT0)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT1)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT2)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT3)>;
};
};

pwm2_dyn_sleep: pwm2_dyn_sleep {
group1 {
psels = <NRF_PSEL_DISCONNECTED(PWM_OUT0)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT1)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT2)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT3)>;
};
};

pwm3_dyn_default: pwm3_dyn_default {
group1 {
psels = <NRF_PSEL_DISCONNECTED(PWM_OUT0)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT1)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT2)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT3)>;
};
};

pwm3_dyn_sleep: pwm3_dyn_sleep {
group1 {
psels = <NRF_PSEL_DISCONNECTED(PWM_OUT0)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT1)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT2)>,
<NRF_PSEL_DISCONNECTED(PWM_OUT3)>;
};
};
};

&i2c1 {
status = "okay";
zephyr,deferred-init;
pinctrl-0 = <&i2c1_dyn_default>;
pinctrl-1 = <&i2c1_dyn_sleep>;
pinctrl-names = "default", "sleep";
};

// SPI1 is the same peripheral instance as I2C1, so leave it disabled.
&spi1 {
status = "disabled";
};

&spi2 {
status = "okay";
zephyr,deferred-init;
pinctrl-0 = <&spi2_dyn_default>;
pinctrl-1 = <&spi2_dyn_sleep>;
pinctrl-names = "default", "sleep";
};

&spi3 {
status = "okay";
zephyr,deferred-init;
pinctrl-0 = <&spi3_dyn_default>;
pinctrl-1 = <&spi3_dyn_sleep>;
pinctrl-names = "default", "sleep";
};

&uart1 {
status = "okay";
zephyr,deferred-init;
current-speed = <115200>;
pinctrl-0 = <&uart1_dyn_default>;
pinctrl-1 = <&uart1_dyn_sleep>;
pinctrl-names = "default", "sleep";
};

&uart0 {
status = "okay";
};

// PWM instances, same scheme: all four outputs disconnected and deferred
// init, so iobroker can hand an instance to neopixel_write and pwmio and
// route its outputs at runtime.

&pwm0 {
status = "okay";
zephyr,deferred-init;
pinctrl-0 = <&pwm0_dyn_default>;
pinctrl-1 = <&pwm0_dyn_sleep>;
pinctrl-names = "default", "sleep";
};

&pwm1 {
status = "okay";
zephyr,deferred-init;
pinctrl-0 = <&pwm1_dyn_default>;
pinctrl-1 = <&pwm1_dyn_sleep>;
pinctrl-names = "default", "sleep";
};

&pwm2 {
status = "okay";
zephyr,deferred-init;
pinctrl-0 = <&pwm2_dyn_default>;
pinctrl-1 = <&pwm2_dyn_sleep>;
pinctrl-names = "default", "sleep";
};

&pwm3 {
status = "okay";
zephyr,deferred-init;
pinctrl-0 = <&pwm3_dyn_default>;
pinctrl-1 = <&pwm3_dyn_sleep>;
pinctrl-names = "default", "sleep";
};

#include "../../../app.overlay"

/* Enable the SAADC for analogio (AIN0..AIN7 are on P0.02..P0.05 and P0.28..P0.31). */
&adc {
status = "okay";
};
// CircuitPython drives the SHT31 from Python, so drop the Zephyr sensor node
// on the now dynamic I2C0.
/delete-node/ &SHT3XD;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* Same console setup as the Feather nRF52840 Express. */
#include "../feather_nrf52840_zephyr/console.overlay"
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
CONFIG_BOARD_SERIAL_BACKEND_CDC_ACM=n

# No Zephyr UART console by default (see board.overlay); a CONSOLE=1 build turns
# it back on in console.conf.
CONFIG_UART_CONSOLE=n
CONFIG_LOG_BACKEND_UART=n

# Pin numbers are module pins (MDBT50Q-1MV2 carries the aQFN73 inside).
# The feathers use the MDBT50Q-1MV2 module, so pin numbers are module pins.
CONFIG_IOBROKER_PACKAGE_MDBT50Q_1MV2=y
Expand Down
Loading
Loading