diff --git a/ports/zephyr-cp/boards/adafruit/circuitplayground_bluefruit_zephyr/autogen_board_info.toml b/ports/zephyr-cp/boards/adafruit/circuitplayground_bluefruit_zephyr/autogen_board_info.toml new file mode 100644 index 00000000000..dab44fc4f84 --- /dev/null +++ b/ports/zephyr-cp/boards/adafruit/circuitplayground_bluefruit_zephyr/autogen_board_info.toml @@ -0,0 +1,136 @@ +# This file is autogenerated when a board is built. Do not edit. Do commit it to git. Other scripts use its info. +name = "Adafruit Industries LLC Circuit Playground Bluefruit" + +[modules] +__future__ = true +_bleio = true # Zephyr board has _bleio +_eve = false +_pew = false +_pixelmap = true # Zephyr board has neopixel_write +_stage = false +adafruit_bus_device = true +adafruit_pixelbuf = true # Zephyr board has neopixel_write +aesio = true +alarm = false +analogbufio = false +analogio = true # Zephyr board has analogio +atexit = true +audiobusio = false +audiocore = false +audiodelays = false +audiofilewriter = false +audiofilters = false +audiofreeverb = false +audioi2sin = false +audioio = false +audiomixer = false +audiomp3 = false +audiopwmio = false +audiospeed = false +aurora_epaper = false +bitbangio = true +bitmapfilter = true # Zephyr board has busio +bitmaptools = true # Zephyr board has busio +bitops = false +board = true # Always enabled +busdisplay = true # Zephyr board has busio +busio = true # Zephyr board has busio +camera = false +canio = false +codeop = true +countio = false +digitalio = true +displayio = true # Zephyr board has busio +dotclockframebuffer = false +dualbank = false +emmcio = false +epaperdisplay = true # Zephyr board has busio +floppyio = false +fontio = true # Zephyr board has busio +fourwire = true # Zephyr board has busio +framebufferio = true # Zephyr board has busio +frequencyio = false +getpass = true +gifio = true # Zephyr board has busio +gnss = false +hardwarekey = false +hashlib = true +hmac = false +hostnetwork = false +i2cdisplaybus = true # Zephyr board has busio +i2cioexpander = false +i2ctarget = false +imagecapture = false +ipaddress = false +is31fl3741 = false +jpegio = true # Zephyr board has busio +keypad = true +keypad_demux = true +locale = true +lvfontio = true # Zephyr board has busio +math = true +max3421e = false +mcp4822 = false +mdns = false +memorymap = false +memorymonitor = false +microcontroller = true +mii = false +mipidsi = false +msgpack = true +neopixel_write = true # Zephyr board has neopixel_write +nvm = true # Board has NVM partition +onewireio = false +os = true +paralleldisplaybus = false +picogame = false +ps2io = false +pulseio = false +pwmio = true # Zephyr board has pwmio +qrio = false +qspibus = false +rainbowio = true +random = true +rclcpy = false +rgbmatrix = false +rotaryio = true # Zephyr board has rotaryio +rtc = false +sdcardio = true # Zephyr board has busio +sdioio = false +sharpdisplay = true # Zephyr board has busio +socketpool = false +spitarget = false +ssl = false +storage = true # Zephyr board has flash +struct = true +supervisor = true +synthio = false +terminalio = true # Zephyr board has busio +tilepalettemapper = true # Zephyr board has busio +time = true +touchio = true +traceback = true +uheap = false +usb = false +usb_audio = false +usb_cdc = true +usb_hid = true +usb_host = false +usb_host_audio = false +usb_host_bulk = false +usb_midi = false +usb_video = false +ustack = false +vectorio = true # Zephyr board has busio +warnings = true +watchdog = true # Zephyr board has watchdog +wifi = false +zephyr_display = false +zephyr_kernel = false +zlib = true +# extmod modules shared with MicroPython +asyncio = true +binascii = true +json = true +re = true +select = true diff --git a/ports/zephyr-cp/boards/adafruit/circuitplayground_bluefruit_zephyr/board.conf b/ports/zephyr-cp/boards/adafruit/circuitplayground_bluefruit_zephyr/board.conf new file mode 100644 index 00000000000..14455847fb0 --- /dev/null +++ b/ports/zephyr-cp/boards/adafruit/circuitplayground_bluefruit_zephyr/board.conf @@ -0,0 +1,18 @@ +CONFIG_BOARD_SERIAL_BACKEND_CDC_ACM=n + +# The board overlay deletes the Zephyr chosen console/shell/mcumgr nodes: +# CircuitPython drives USB CDC ACM through its own usb_cdc bindings. Turn off +# Zephyr's UART console so nothing references the deleted +# DT_CHOSEN(zephyr_console). SERIAL stays on for the dynamically routed UART. +CONFIG_UART_CONSOLE=n +CONFIG_LOG_BACKEND_UART=n + +# The CPB has a bare nRF52840, so pin numbers are aQFN73 package pins. +CONFIG_IOBROKER_PACKAGE_NRF52840_AQFN73=y + +# PWM instances are enabled in board.overlay with disconnected outputs so +# iobroker can allocate them at runtime for neopixel_write and pwmio. +CONFIG_PWM=y + +# SAADC for analogio testing/use (pads resolve to AIN through iobroker) +CONFIG_ADC=y diff --git a/ports/zephyr-cp/boards/adafruit/circuitplayground_bluefruit_zephyr/board.overlay b/ports/zephyr-cp/boards/adafruit/circuitplayground_bluefruit_zephyr/board.overlay new file mode 100644 index 00000000000..6829088e22e --- /dev/null +++ b/ports/zephyr-cp/boards/adafruit/circuitplayground_bluefruit_zephyr/board.overlay @@ -0,0 +1,280 @@ +/* Partition layout is owned by the mcuboot fork + * (dts/adafruit/adafruit_circuitplayground_bluefruit.dtsi) and applied to + * this image by sysbuild. This overlay only adds board/app config. */ +/* No Zephyr console by default, so TX/RX are free for busio.UART. A CONSOLE=1 + * build puts the console back on UART0 (console.overlay). */ +/ { + chosen { + /delete-property/ zephyr,console; + /delete-property/ zephyr,shell-uart; + /delete-property/ zephyr,uart-mcumgr; + /delete-property/ zephyr,bt-mon-uart; + /delete-property/ zephyr,bt-c2h-uart; + }; +}; + +&zephyr_udc0 { + /delete-node/ board_cdc_acm_uart; +}; + +// UART0, I2C0, I2C1, SPI2 and SPI3 are 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. (QSPI is the fixed external +// flash. The onboard sensors, such as the LIS3DH on +// ACCELEROMETER_SCL/ACCELEROMETER_SDA, have no devicetree nodes, so no I2C +// instance needs to be fixed.) +// +// 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, and two I2C +// instances let board.I2C() and the accelerometer bus be open at once. +// SPI1 is left disabled; UART1 is enabled by neither overlay because UART0 +// already provides a dynamic serial instance. + +&pinctrl { + uart0_dyn_default: uart0_dyn_default { + group1 { + psels = , + ; + }; + }; + + uart0_dyn_sleep: uart0_dyn_sleep { + group1 { + psels = , + ; + }; + }; + + i2c0_dyn_default: i2c0_dyn_default { + group1 { + psels = , + ; + }; + }; + + i2c0_dyn_sleep: i2c0_dyn_sleep { + group1 { + psels = , + ; + }; + }; + + i2c1_dyn_default: i2c1_dyn_default { + group1 { + psels = , + ; + }; + }; + + i2c1_dyn_sleep: i2c1_dyn_sleep { + group1 { + psels = , + ; + }; + }; + + spi2_dyn_default: spi2_dyn_default { + group1 { + psels = , + , + ; + }; + }; + + spi2_dyn_sleep: spi2_dyn_sleep { + group1 { + psels = , + , + ; + }; + }; + + spi3_dyn_default: spi3_dyn_default { + group1 { + psels = , + , + ; + }; + }; + + spi3_dyn_sleep: spi3_dyn_sleep { + group1 { + psels = , + , + ; + }; + }; + + pwm0_dyn_default: pwm0_dyn_default { + group1 { + psels = , + , + , + ; + }; + }; + + pwm0_dyn_sleep: pwm0_dyn_sleep { + group1 { + psels = , + , + , + ; + }; + }; + + pwm1_dyn_default: pwm1_dyn_default { + group1 { + psels = , + , + , + ; + }; + }; + + pwm1_dyn_sleep: pwm1_dyn_sleep { + group1 { + psels = , + , + , + ; + }; + }; + + pwm2_dyn_default: pwm2_dyn_default { + group1 { + psels = , + , + , + ; + }; + }; + + pwm2_dyn_sleep: pwm2_dyn_sleep { + group1 { + psels = , + , + , + ; + }; + }; + + pwm3_dyn_default: pwm3_dyn_default { + group1 { + psels = , + , + , + ; + }; + }; + + pwm3_dyn_sleep: pwm3_dyn_sleep { + group1 { + psels = , + , + , + ; + }; + }; +}; + +// The upstream board uses the legacy UART driver for UART0, which can't be +// de-initialized, so iobroker could not route it again once it was released. +// Instead, use the UARTE driver, which can be deinited. +&uart0 { + compatible = "nordic,nrf-uarte"; + status = "okay"; + zephyr,deferred-init; + current-speed = <115200>; + pinctrl-0 = <&uart0_dyn_default>; + pinctrl-1 = <&uart0_dyn_sleep>; + pinctrl-names = "default", "sleep"; +}; + +// The upstream board fixes I2C0 to SCL/SDA with the legacy TWI driver. Use +// TWIM like I2C1 so iobroker can route it. +&i2c0 { + compatible = "nordic,nrf-twim"; + status = "okay"; + zephyr,deferred-init; + pinctrl-0 = <&i2c0_dyn_default>; + pinctrl-1 = <&i2c0_dyn_sleep>; + pinctrl-names = "default", "sleep"; +}; + +&i2c1 { + status = "okay"; + zephyr,deferred-init; + pinctrl-0 = <&i2c1_dyn_default>; + pinctrl-1 = <&i2c1_dyn_sleep>; + pinctrl-names = "default", "sleep"; +}; + +// SPI1 shares the 0x40004000 instance with I2C1, which is enabled above, so +// leave SPI1 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"; +}; + +// 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"; +}; diff --git a/ports/zephyr-cp/boards/adafruit/circuitplayground_bluefruit_zephyr/circuitpython.toml b/ports/zephyr-cp/boards/adafruit/circuitplayground_bluefruit_zephyr/circuitpython.toml new file mode 100644 index 00000000000..d558c03185e --- /dev/null +++ b/ports/zephyr-cp/boards/adafruit/circuitplayground_bluefruit_zephyr/circuitpython.toml @@ -0,0 +1,62 @@ +CIRCUITPY_BUILD_EXTENSIONS = ["hex", "uf2"] +USB_VID=0x239A +USB_PID=0x8046 +NAME="Circuit Playground Bluefruit" + +# Non-Zephyr build of the same board; nvm and CIRCUITPY must sit where it puts them. +counterpart = "nordic/circuitplayground_bluefruit" + +# Status RGB LED, driven with neopixel_write; name from [pins]. +STATUS_NEOPIXEL = "NEOPIXEL" + + +[pins] +# Pin names copied from the ports/ counterpart board's pins.c and resolved +# to nRF52840 aQFN73 package pin numbers through the package pin map +# selected in board.conf. +AUDIO = 27 # P0.26 +D12 = 27 # P0.26 +SPEAKER = 27 # P0.26 +A1 = 3 # P0.02 +D6 = 3 # P0.02 +SCK = 3 # P0.02 +A2 = 2 # P0.29 +D9 = 2 # P0.29 +MISO = 2 # P0.29 +A3 = 16 # P0.03 +D10 = 16 # P0.03 +MOSI = 16 # P0.03 +A4 = 30 # P0.04 +D3 = 30 # P0.04 +SCL = 30 # P0.04 +A5 = 32 # P0.05 +D2 = 32 # P0.05 +SDA = 32 # P0.05 +A6 = 14 # P0.30 +D0 = 14 # P0.30 +RX = 14 # P0.30 +D1 = 54 # P0.14 +TX = 54 # P0.14 +LIGHT = 15 # P0.28 +A8 = 15 # P0.28 +TEMPERATURE = 1 # P0.31 +A9 = 1 # P0.31 +BUTTON_A = 48 # P1.02 +D4 = 48 # P1.02 +BUTTON_B = 4 # P1.15 +D5 = 4 # P1.15 +SLIDE_SWITCH = 41 # P1.06 +D7 = 41 # P1.06 +POWER_SWITCH = 33 # P0.06 +D35 = 33 # P0.06 +LED = 17 # P1.14 +L = 17 # P1.14 +D13 = 17 # P1.14 +NEOPIXEL = 65 # P0.13 +D8 = 65 # P0.13 +MICROPHONE_CLOCK = 67 # P0.17 +MICROPHONE_DATA = 55 # P0.16 +ACCELEROMETER_INTERRUPT = 5 # P1.13 +ACCELEROMETER_SDA = 7 # P1.10 +ACCELEROMETER_SCL = 18 # P1.12 +SPEAKER_ENABLE = 45 # P1.04 diff --git a/ports/zephyr-cp/boards/adafruit/circuitplayground_bluefruit_zephyr/console.overlay b/ports/zephyr-cp/boards/adafruit/circuitplayground_bluefruit_zephyr/console.overlay new file mode 100644 index 00000000000..095c4aa1d2d --- /dev/null +++ b/ports/zephyr-cp/boards/adafruit/circuitplayground_bluefruit_zephyr/console.overlay @@ -0,0 +1,18 @@ +/* Applied after board.overlay in CONSOLE=1 and DEBUG=1 builds: the Zephyr + * console on UART0, fixed to the TX/RX pins. TX/RX are then not available to + * busio.UART. */ +/ { + chosen { + zephyr,console = &uart0; + zephyr,shell-uart = &uart0; + zephyr,uart-mcumgr = &uart0; + zephyr,bt-mon-uart = &uart0; + zephyr,bt-c2h-uart = &uart0; + }; +}; + +&uart0 { + /delete-property/ zephyr,deferred-init; + pinctrl-0 = <&uart0_default>; + pinctrl-1 = <&uart0_sleep>; +}; diff --git a/ports/zephyr-cp/boards/board_aliases.cmake b/ports/zephyr-cp/boards/board_aliases.cmake index d636b047aab..0c7bb2f5f79 100644 --- a/ports/zephyr-cp/boards/board_aliases.cmake +++ b/ports/zephyr-cp/boards/board_aliases.cmake @@ -26,6 +26,7 @@ macro(cp_board_alias alias target) endif() endmacro() +cp_board_alias(adafruit_circuitplayground_bluefruit_zephyr adafruit_circuitplayground_bluefruit/nrf52840/uf2) cp_board_alias(adafruit_clue_nrf52840_zephyr adafruit_clue_nrf52840/nrf52840/uf2) cp_board_alias(adafruit_feather_nrf52840_zephyr adafruit_feather_nrf52840/nrf52840/uf2) cp_board_alias(adafruit_feather_nrf52840_sense_zephyr adafruit_feather_nrf52840/nrf52840/sense/uf2) diff --git a/ports/zephyr-cp/zephyr-config/west.yml b/ports/zephyr-cp/zephyr-config/west.yml index 8f58a697aad..12c81f8467d 100644 --- a/ports/zephyr-cp/zephyr-config/west.yml +++ b/ports/zephyr-cp/zephyr-config/west.yml @@ -10,11 +10,11 @@ manifest: path: modules/bsim_hw_models/nrf_hw_models - name: mcuboot url: https://github.com/adafruit/adaboot - revision: 298d868d9534a705605744dea5899a4d35fdd70e + revision: ba4851fb048c4593d886ffa7936fb708fbf4cb38 path: bootloader/mcuboot - name: zephyr url: https://github.com/adafruit/zephyr - revision: 3ab36efea64edda80e45ece016753e3686bb763f + revision: 3567aee7fc2caa322fd534fbf4ed0c705d6c5a62 clone-depth: 100 import: # Skip what no CircuitPython board can use, so west update fetches 37