From 3c2ba020c83d152afd997a0b2064c280138dd0d3 Mon Sep 17 00:00:00 2001 From: liquidraver <504870+liquidraver@users.noreply.github.com> Date: Tue, 14 Apr 2026 13:17:36 +0200 Subject: [PATCH] Add simple xiao nrf support --- build.sh | 1 + zephcore/CMakeLists.txt | 2 +- zephcore/boards/example_board/README.md | 1 + .../xiao_nrf52840/Kconfig.xiao_nrf52840 | 5 + .../boards/nrf52840/xiao_nrf52840/board.cmake | 13 + .../boards/nrf52840/xiao_nrf52840/board.conf | 10 + .../nrf52840/xiao_nrf52840/board.overlay | 6 + .../boards/nrf52840/xiao_nrf52840/board.yml | 9 + .../xiao_nrf52840_nrf52840-pinctrl.dtsi | 66 +++++ .../xiao_nrf52840/xiao_nrf52840_nrf52840.dts | 231 ++++++++++++++++++ .../xiao_nrf52840/xiao_nrf52840_nrf52840.yaml | 20 ++ .../xiao_nrf52840_nrf52840_defconfig | 10 + zephcore/boards/supported_boards.md | 1 + 13 files changed, 374 insertions(+), 1 deletion(-) create mode 100644 zephcore/boards/nrf52840/xiao_nrf52840/Kconfig.xiao_nrf52840 create mode 100644 zephcore/boards/nrf52840/xiao_nrf52840/board.cmake create mode 100644 zephcore/boards/nrf52840/xiao_nrf52840/board.conf create mode 100644 zephcore/boards/nrf52840/xiao_nrf52840/board.overlay create mode 100644 zephcore/boards/nrf52840/xiao_nrf52840/board.yml create mode 100644 zephcore/boards/nrf52840/xiao_nrf52840/xiao_nrf52840_nrf52840-pinctrl.dtsi create mode 100644 zephcore/boards/nrf52840/xiao_nrf52840/xiao_nrf52840_nrf52840.dts create mode 100644 zephcore/boards/nrf52840/xiao_nrf52840/xiao_nrf52840_nrf52840.yaml create mode 100644 zephcore/boards/nrf52840/xiao_nrf52840/xiao_nrf52840_nrf52840_defconfig diff --git a/build.sh b/build.sh index 56eea04..6fbe551 100644 --- a/build.sh +++ b/build.sh @@ -16,6 +16,7 @@ nRF_boards=( rak_wismesh_tag ikoka_nano_30dbm sensecap_solar + xiao_nrf52840 ) ESP32_boards=( diff --git a/zephcore/CMakeLists.txt b/zephcore/CMakeLists.txt index 74bb059..e3deecd 100644 --- a/zephcore/CMakeLists.txt +++ b/zephcore/CMakeLists.txt @@ -222,7 +222,7 @@ set(ZEPHCORE_COMMON_CONF "${CMAKE_CURRENT_SOURCE_DIR}/boards/common/zephcore_com # Detect platform from board name and add platform-specific common config # For boards with qualifiers like "wio_tracker_l1/nrf52840", check both the full BOARD # string and the BOARD_QUALIFIERS which contains just the qualifier (e.g., "nrf52840") -if(BOARD MATCHES ".*nrf52.*" OR BOARD MATCHES "rak4631" OR BOARD MATCHES "rak_wismesh_tag" OR BOARD MATCHES "rak3401_1watt" OR BOARD MATCHES "wio_tracker" OR BOARD MATCHES "ikoka_nano" OR BOARD MATCHES "t1000_e" OR BOARD MATCHES "thinknode_m1" OR BOARD MATCHES "thinknode_m3" OR BOARD MATCHES "thinknode_m6" OR BOARD MATCHES "promicro_lr2021" OR BOARD MATCHES "sensecap_solar") +if(BOARD MATCHES ".*nrf52.*" OR BOARD MATCHES "rak4631" OR BOARD MATCHES "rak_wismesh_tag" OR BOARD MATCHES "rak3401_1watt" OR BOARD MATCHES "wio_tracker" OR BOARD MATCHES "ikoka_nano" OR BOARD MATCHES "t1000_e" OR BOARD MATCHES "thinknode_m1" OR BOARD MATCHES "thinknode_m3" OR BOARD MATCHES "thinknode_m6" OR BOARD MATCHES "promicro_lr2021" OR BOARD MATCHES "sensecap_solar" OR BOARD MATCHES "xiao_nrf52840") set(ZEPHCORE_PLATFORM_CONF "${CMAKE_CURRENT_SOURCE_DIR}/boards/common/nrf52_common.conf") elseif(DEFINED BOARD_QUALIFIERS AND BOARD_QUALIFIERS MATCHES ".*nrf52.*") set(ZEPHCORE_PLATFORM_CONF "${CMAKE_CURRENT_SOURCE_DIR}/boards/common/nrf52_common.conf") diff --git a/zephcore/boards/example_board/README.md b/zephcore/boards/example_board/README.md index d3a6413..50ec8a9 100644 --- a/zephcore/boards/example_board/README.md +++ b/zephcore/boards/example_board/README.md @@ -13,6 +13,7 @@ Supported Boards | RAK3401 1W | `west build -b rak3401_1watt zephcore` | UF2 drag-drop or `west flash` | | Wio Tracker L1 | `west build -b wio_tracker_l1 zephcore` | UF2 drag-drop or `west flash` | | SenseCAP Solar | `west build -b sensecap_solar zephcore` | UF2 drag-drop or `west flash` | +| XIAO nRF52840 | `west build -b xiao_nrf52840 zephcore` | UF2 drag-drop or `west flash` | | T1000-E | `west build -b t1000_e zephcore` | UF2 drag-drop or `west flash` | | ThinkNode M1 | `west build -b thinknode_m1 zephcore` | UF2 drag-drop or `west flash` | | ThinkNode M3 | `west build -b thinknode_m3 zephcore` | UF2 drag-drop or `west flash` | diff --git a/zephcore/boards/nrf52840/xiao_nrf52840/Kconfig.xiao_nrf52840 b/zephcore/boards/nrf52840/xiao_nrf52840/Kconfig.xiao_nrf52840 new file mode 100644 index 0000000..536c8e9 --- /dev/null +++ b/zephcore/boards/nrf52840/xiao_nrf52840/Kconfig.xiao_nrf52840 @@ -0,0 +1,5 @@ +# Copyright (c) 2025 ZephCore +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_XIAO_NRF52840 + select SOC_NRF52840_QIAA diff --git a/zephcore/boards/nrf52840/xiao_nrf52840/board.cmake b/zephcore/boards/nrf52840/xiao_nrf52840/board.cmake new file mode 100644 index 0000000..56ba274 --- /dev/null +++ b/zephcore/boards/nrf52840/xiao_nrf52840/board.cmake @@ -0,0 +1,13 @@ +# Copyright (c) 2025 ZephCore +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(jlink "--device=nRF52840_xxAA" "--speed=4000") +board_runner_args(pyocd "--target=nrf52840" "--frequency=4000000") + +set(OPENOCD_NRF5_SUBFAMILY "nrf52") + +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) +include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/openocd-nrf5.board.cmake) +include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake) +include(${ZEPHYR_BASE}/boards/common/nrfutil.board.cmake) diff --git a/zephcore/boards/nrf52840/xiao_nrf52840/board.conf b/zephcore/boards/nrf52840/xiao_nrf52840/board.conf new file mode 100644 index 0000000..17ec807 --- /dev/null +++ b/zephcore/boards/nrf52840/xiao_nrf52840/board.conf @@ -0,0 +1,10 @@ +# Seeed XIAO nRF52840 + Wio-SX1262 (headers) +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_ZEPHCORE_BOARD_NAME="XIAO nRF52840" + +CONFIG_BT_DIS_MODEL_NUMBER_STR="Seeed XIAO nRF52840" + +CONFIG_ZEPHCORE_SD_FWID=0x0123 + +CONFIG_ZEPHCORE_MAX_CONTACTS=510 diff --git a/zephcore/boards/nrf52840/xiao_nrf52840/board.overlay b/zephcore/boards/nrf52840/xiao_nrf52840/board.overlay new file mode 100644 index 0000000..4262dbe --- /dev/null +++ b/zephcore/boards/nrf52840/xiao_nrf52840/board.overlay @@ -0,0 +1,6 @@ +/* + * Seeed XIAO nRF52840 — QSPI /ext for contacts (no GPS aliases) + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "../../common/qspi-ext.dtsi" diff --git a/zephcore/boards/nrf52840/xiao_nrf52840/board.yml b/zephcore/boards/nrf52840/xiao_nrf52840/board.yml new file mode 100644 index 0000000..4c639f7 --- /dev/null +++ b/zephcore/boards/nrf52840/xiao_nrf52840/board.yml @@ -0,0 +1,9 @@ +# Copyright (c) 2025 ZephCore +# SPDX-License-Identifier: Apache-2.0 + +board: + name: xiao_nrf52840 + full_name: Seeed XIAO nRF52840 (Wio-SX1262) + vendor: seeed + socs: + - name: nrf52840 diff --git a/zephcore/boards/nrf52840/xiao_nrf52840/xiao_nrf52840_nrf52840-pinctrl.dtsi b/zephcore/boards/nrf52840/xiao_nrf52840/xiao_nrf52840_nrf52840-pinctrl.dtsi new file mode 100644 index 0000000..480e11f --- /dev/null +++ b/zephcore/boards/nrf52840/xiao_nrf52840/xiao_nrf52840_nrf52840-pinctrl.dtsi @@ -0,0 +1,66 @@ +/* + * Seeed XIAO nRF52840 + Wio-SX1262 (headers) — pin control + * SPDX-License-Identifier: Apache-2.0 + * + * MeshCore variants/xiao_nrf52 variant.cpp + platformio.ini: + * - SPI2 (SX1262): SCK=P1.13, MOSI=P1.15, MISO=P1.14 (D8–D10) + * - I2C0: SDA=P1.12, SCL=P1.11 (MeshCore PIN_WIRE_SDA=D7, PIN_WIRE_SCL=D6) + * - QSPI P25Q16H: same as other XIAO nRF52840 designs + */ + +&pinctrl { + spi2_default: spi2_default { + group1 { + psels = , + , + ; + }; + }; + + spi2_sleep: spi2_sleep { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; + + i2c0_default: i2c0_default { + group1 { + psels = , + ; + }; + }; + + i2c0_sleep: i2c0_sleep { + group1 { + psels = , + ; + low-power-enable; + }; + }; + + qspi_default: qspi_default { + group1 { + psels = , + , + , + , + , + ; + }; + }; + + qspi_sleep: qspi_sleep { + group1 { + psels = , + , + , + , + , + ; + low-power-enable; + }; + }; +}; diff --git a/zephcore/boards/nrf52840/xiao_nrf52840/xiao_nrf52840_nrf52840.dts b/zephcore/boards/nrf52840/xiao_nrf52840/xiao_nrf52840_nrf52840.dts new file mode 100644 index 0000000..d2ae968 --- /dev/null +++ b/zephcore/boards/nrf52840/xiao_nrf52840/xiao_nrf52840_nrf52840.dts @@ -0,0 +1,231 @@ +/* + * Seeed XIAO nRF52840 + Wio-SX1262 on headers + * SPDX-License-Identifier: Apache-2.0 + * + * MeshCore variants/xiao_nrf52 (plain XIAO, no GPS): + * - SX1262: CS/RST/BUSY/DIO1/RXEN = P0.04/28/29/03/05 (D4–D1, D5) + * - SPI: P1.13/14/15 (D8–D10); DIO2 RF switch; TCXO 1.8V + * - LEDs: red P0.26 (D11, MeshCore P_LORA_TX_LED), blue P0.06 (D12), green P0.30 (D13), active-low + * - User button: D0 = P0.02 + * - Battery: AIN7 P0.31, divider enable P0.14 (D14), active-low enable + * - I2C: P1.12 SDA / P1.11 SCL (MeshCore Wire on D7/D6 when LoRa uses D4/D5) + * - UART0 not used (pins shared with I2C in this layout) + */ + +/dts-v1/; +#include +#include +#include +#include +#include +#include "xiao_nrf52840_nrf52840-pinctrl.dtsi" + +/delete-node/ &boot_partition; +/delete-node/ &slot0_partition; +/delete-node/ &slot1_partition; +/delete-node/ &storage_partition; + +/ { + model = "Seeed XIAO nRF52840"; + compatible = "seeed,xiao-nrf52840"; + + chosen { + zephyr,code-partition = &code_partition; + zephyr,console = &cdc_acm_uart; + zephyr,shell-uart = &cdc_acm_uart; + }; + + leds { + compatible = "gpio-leds"; + + /* MeshCore LED_STATE_ON 0 → active-low */ + led_red: led_0 { + gpios = <&gpio0 26 GPIO_ACTIVE_LOW>; + label = "LED red (LoRa TX)"; + }; + + led_blue: led_1 { + gpios = <&gpio0 6 GPIO_ACTIVE_LOW>; + label = "LED blue"; + }; + + led_green: led_2 { + gpios = <&gpio0 30 GPIO_ACTIVE_LOW>; + label = "LED green"; + }; + }; + + buttons: buttons { + compatible = "gpio-keys"; + + user_button: button_0 { + gpios = <&gpio0 2 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + zephyr,code = ; + label = "User"; + }; + }; + + user_btn_longpress { + compatible = "zephyr,input-longpress"; + input = <&buttons>; + input-codes = ; + short-codes = ; + long-codes = ; + long-delay-ms = <1000>; + }; + + user_btn_multitap { + compatible = "zephcore,input-multi-tap"; + input-codes = ; + tap-codes = ; + tap-delay-ms = <400>; + }; + + vbat_enable: vbat-enable { + compatible = "regulator-fixed"; + regulator-name = "vbat-enable"; + enable-gpios = <&gpio0 14 GPIO_ACTIVE_LOW>; + }; + + zephyr,user { + io-channels = <&adc 7>; + /* MeshCore: mV ≈ raw * 3 * 3 / 4096 at 12-bit internal 3.0V ref */ + vbat-mv-multiplier = <9000>; + }; + + aliases { + led0 = &led_blue; + led1 = &led_green; + lora-tx-led = &led_red; + sw0 = &user_button; + lora0 = &lora; + watchdog0 = &wdt0; + }; +}; + +®0 { + status = "okay"; +}; + +®1 { + regulator-initial-mode = ; +}; + +&adc { + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + + channel@7 { + reg = <7>; + zephyr,gain = "ADC_GAIN_1_6"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,input-positive = ; + zephyr,resolution = <12>; + }; +}; + +&uicr { + nfct-pins-as-gpios; +}; + +&gpiote { + status = "okay"; +}; + +&gpio0 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&uart0 { + status = "disabled"; +}; + +&i2c0 { + compatible = "nordic,nrf-twim"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c0_default>; + pinctrl-1 = <&i2c0_sleep>; + pinctrl-names = "default", "sleep"; + + #include "../../common/sensors-i2c.dtsi" +}; + +&spi2 { + compatible = "nordic,nrf-spim"; + status = "okay"; + cs-gpios = <&gpio0 4 GPIO_ACTIVE_LOW>; + pinctrl-0 = <&spi2_default>; + pinctrl-1 = <&spi2_sleep>; + pinctrl-names = "default", "sleep"; + + lora: lora@0 { + compatible = "semtech,sx1262"; + reg = <0>; + reset-gpios = <&gpio0 28 GPIO_ACTIVE_LOW>; + busy-gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>; + dio1-gpios = <&gpio0 3 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; + rx-enable-gpios = <&gpio0 5 GPIO_ACTIVE_HIGH>; + dio2-tx-enable; + dio3-tcxo-voltage = ; + tcxo-power-startup-delay-ms = <5>; + spi-max-frequency = <8000000>; + rx-boosted; + }; +}; + +&qspi { + status = "okay"; + pinctrl-0 = <&qspi_default>; + pinctrl-1 = <&qspi_sleep>; + pinctrl-names = "default", "sleep"; + + qspi_flash: qspi_flash@0 { + compatible = "nordic,qspi-nor"; + reg = <0>; + writeoc = "pp"; + readoc = "fastread"; + sck-frequency = <16000000>; + jedec-id = [85 60 15]; + sfdp-bfp = [ + e5 20 f1 ff ff ff ff 01 44 eb 08 6b 08 3b 04 bb + ee ff ff ff ff ff 00 ff ff ff 00 ff 0c 20 0f 52 + 10 d8 00 ff + ]; + size = <16777216>; + has-dpd; + t-enter-dpd = <3000>; + t-exit-dpd = <50000>; + }; +}; + +zephyr_udc0: &usbd { + compatible = "nordic,nrf-usbd"; + status = "okay"; + + cdc_acm_uart: cdc_acm_uart { + compatible = "zephyr,cdc-acm-uart"; + }; +}; + +#include "../../common/nrf52_partitions_sdv7.dtsi" + +&qspi_flash { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + qspi_storage_partition: partition@0 { + label = "qspi_storage"; + reg = <0x00000000 0x00200000>; + }; + }; +}; +#include "../../common/nrf52_wakeup.dtsi" diff --git a/zephcore/boards/nrf52840/xiao_nrf52840/xiao_nrf52840_nrf52840.yaml b/zephcore/boards/nrf52840/xiao_nrf52840/xiao_nrf52840_nrf52840.yaml new file mode 100644 index 0000000..cd85ea6 --- /dev/null +++ b/zephcore/boards/nrf52840/xiao_nrf52840/xiao_nrf52840_nrf52840.yaml @@ -0,0 +1,20 @@ +identifier: xiao_nrf52840/nrf52840 +name: Seeed XIAO nRF52840 +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +ram: 256 +flash: 1024 +supported: + - adc + - ble + - gpio + - i2c + - spi + - usb_device + - qspi + - lora +vendor: seeed diff --git a/zephcore/boards/nrf52840/xiao_nrf52840/xiao_nrf52840_nrf52840_defconfig b/zephcore/boards/nrf52840/xiao_nrf52840/xiao_nrf52840_nrf52840_defconfig new file mode 100644 index 0000000..f0f7210 --- /dev/null +++ b/zephcore/boards/nrf52840/xiao_nrf52840/xiao_nrf52840_nrf52840_defconfig @@ -0,0 +1,10 @@ +# Copyright (c) 2025 ZephCore +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_ARM_MPU=y +CONFIG_HW_STACK_PROTECTION=y +CONFIG_GPIO=y +CONFIG_SERIAL=y +CONFIG_CONSOLE=y +CONFIG_BUILD_OUTPUT_UF2=y +CONFIG_USE_DT_CODE_PARTITION=y diff --git a/zephcore/boards/supported_boards.md b/zephcore/boards/supported_boards.md index 5c32df9..30781ab 100644 --- a/zephcore/boards/supported_boards.md +++ b/zephcore/boards/supported_boards.md @@ -15,6 +15,7 @@ thinknode_m6 rak_wismesh_tag ikoka_nano_30dbm sensecap_solar +xiao_nrf52840 ``` > **RAK WisMesh Pocket** (WisBlock pocket): use `-b rak4631` — same board string and firmware as **RAK4631**.