zephyr/boards: Add XIAO BLE NRF52840 SENSE board.

This commit adds Zephyr support for the XIAO BLE NRF52840 SENSE board from
Seeed Studio.

It also provides a good example of a richer Zephyr port than the default,
adding:
- Frozen modules (including asyncio, upysh, aioble and aiorepl).
- Enough MicroPython features to support using aioble (at least for the
  `temp_sensor.py` example).
- JSON, random, re, struct, etc.

Signed-off-by: Ned Konz <ned@metamagix.tech>
This commit is contained in:
Ned Konz
2025-10-01 14:16:44 -07:00
committed by Damien George
parent 4c11f64faa
commit 7bb78fb6df
4 changed files with 164 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
# Kconfig configuration for Seeed Studio's XIAO nRF52840 Sense
CONFIG_NETWORKING=n
CONFIG_CONSOLE_SUBSYS=n
# for PDM microphone, set these three to y
# and also enable in overlay
CONFIG_AUDIO=n
CONFIG_AUDIO_DMIC=n
CONFIG_AUDIO_DMIC_NRFX_PDM=n
# Enable Bluetooth
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_DEVICE_NAME="XIAO BLE nRF52840 Sense"
CONFIG_BT_GATT_DYNAMIC_DB=y
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_L2CAP_TX_MTU=252
CONFIG_BT_BUF_ACL_RX_SIZE=256
CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION=n
CONFIG_MICROPY_HEAP_SIZE=98304
CONFIG_MAIN_STACK_SIZE=8192
# Enable drivers for peripherals
CONFIG_GPIO=y
CONFIG_I2C=y
CONFIG_SPI=y
CONFIG_PWM=y
CONFIG_ADC=y
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_DISK_ACCESS=n
CONFIG_MICROPY_FROZEN_MODULES=y
CONFIG_MICROPY_FROZEN_MANIFEST="boards/xiao_ble_nrf52840_sense/manifest.py"
CONFIG_MICROPY_CONFIGFILE="boards/xiao_ble_nrf52840_sense/mpconfigport.h"
# CONFIG_DYNAMIC_THREAD=y
CONFIG_THREAD_CUSTOM_DATA=y
CONFIG_THREAD_MONITOR=y
CONFIG_THREAD_STACK_INFO=y
CONFIG_LOG=n
CONFIG_FP16=n
CONFIG_BOOT_BANNER=n

View File

@@ -0,0 +1,79 @@
/*
* Copyright (c) 2025 NED KONZ <NED@METAMAGIX.TECH>
*
* SPDX-License-Identifier: Apache-2.0
*/
// Replace default on-chip flash with external flash
/delete-node/ &storage_partition;
// 16Mib (2MiB) flash, mount as /flash
&p25q16h {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
storage_partition: partition@0 {
label = "storage";
reg = <0x00000000 0x200000>;
};
};
};
/ {
zephyr,user {
io-channels = <&adc 0>, <&adc 1>, <&adc 4>, <&adc 5>, <&adc 7>;
};
};
&adc {
#address-cells = <1>;
#size-cells = <0>;
channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1_6";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,input-positive = <NRF_SAADC_AIN0>; /* P0.02 */
zephyr,resolution = <12>;
};
channel@1 {
reg = <1>;
zephyr,gain = "ADC_GAIN_1_6";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,input-positive = <NRF_SAADC_AIN1>; /* P0.03 */
zephyr,resolution = <12>;
};
channel@4 {
reg = <4>;
zephyr,gain = "ADC_GAIN_1_6";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,input-positive = <NRF_SAADC_AIN4>; /* P0.28 */
zephyr,resolution = <12>;
};
channel@5 {
reg = <5>;
zephyr,gain = "ADC_GAIN_1_6";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,input-positive = <NRF_SAADC_AIN5>; /* P0.29 */
zephyr,resolution = <12>;
};
// AIN7: battery reading
channel@7 {
reg = <7>;
zephyr,gain = "ADC_GAIN_1_6";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,input-positive = <NRF_SAADC_AIN7>; /* P0.31 */
zephyr,resolution = <12>;
};
};

View File

@@ -0,0 +1,7 @@
include("$(MPY_DIR)/extmod/asyncio")
freeze("$(PORT_DIR)/modules")
require("upysh")
require("aioble")
require("aiorepl")

View File

@@ -0,0 +1,27 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES)
#include "../mpconfigport.h"