Skip to content

zephyr: Add Seeed Studio's XIAO BLE NRF52840 SENSE board. #17679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

bikeNomad
Copy link
Contributor

Summary

This PR adds Zephyr support for Seeed Studio's XIAO BLE NRF52840 SENSE board.

It also provides a good example of a richer Zephyr port than the default, adding:

  • Frozen modules (including asyncio, upysh, aioble, neopixel, and aiorepl).
  • Enough MicroPython features to support using aioble (at least for the temp_sensor.py example)
  • JSON, random, re, struct, etc.
  • Support for my Zephyr ADC code (see PR zephyr: Add ADC support #17615)
  • Mounted LFS2 filesystem using the 2MiB flash mounted as /flash

You can build it in the usual way:

$ cd ports/zephyr
$ west build -b xiao_ble/nrf52840/sense . 

This will produce a .uf2 file in build/zephyr/zephyr.uf2 that can be copied into the XIAO-SENSE USB drive that appears when you double-click the RESET button.

Testing

I have tested this on several of these boards, with and without my ADC (#17615) and zensor.Sensor.attr_set() (#17653) PRs.

I have run the aioble temp_sensor.py example but haven't done much more with the BLE.

Trade-offs and Alternatives

The build size is as follows:

Memory region         Used Size  Region Size  %age Used
           FLASH:      428864 B       788 KB     53.15%
             RAM:      165908 B       256 KB     63.29%
        IDT_LIST:          0 GB        32 KB      0.00%

@dpgeorge
Copy link
Member

Thanks for the contribution, this is a nice addition.

I've opened #17680 which should help simplify this PR.

@dpgeorge dpgeorge added this to the release-1.26.0 milestone Jul 15, 2025
@bikeNomad bikeNomad force-pushed the ned/zephyr-add-xiao-ble-nrf52840-sense branch from 3857a69 to 469d4f0 Compare July 15, 2025 18:59
@ned-pcs
Copy link
Contributor

ned-pcs commented Jul 15, 2025

@dpgeorge OK, simplified using your PR #17680. Will re-base when you merge it into mainline.

@ned-pcs
Copy link
Contributor

ned-pcs commented Jul 15, 2025

The additional features defined in mpconfigport-xiao.h add 12224 bytes of flash and 12 bytes of RAM size.

@Blafy
Copy link

Blafy commented Jul 16, 2025

Great !
Do you have a plan to implement a disable flag for the p25q16h ?
This little flash is IMO a bad addition on this board, as it requires to be put into suspend mode to keep the nice low power of the NRF chip ...

@bikeNomad
Copy link
Contributor Author

bikeNomad commented Jul 16, 2025

@Blafy asks:

Great ! Do you have a plan to implement a disable flag for the p25q16h ? This little flash is IMO a bad addition on this board, as it requires to be put into suspend mode to keep the nice low power of the NRF chip ...

Good question. Not using this flash means that instead of 2MiB filesystem we'd have only 32KiB, at least without partition modification.

The stock "Storage" partition (given the original overlay; see nrf52840_partition_uf2_sdv7.dtsi ) on the NRF chip is only 32kB in size (156kB is given to the SoftDevice that we don't use, and 48kB is saved for the UF2 bootloader). The way these boards are set up at the factory includes the UF2 bootloader and SoftDevice. Using MCUBoot and two app partitions (see nrf52840_partition.dtsi) still only leaves 32kB of storage space.

Although the newest Adafruit UF2 bootloader allows for having no SoftDevice (thus maybe letting us use the 156kiB space for /flash instead), I haven't tried this.

As for putting it into suspend mode, I would hope that the nordic,qspi-nor driver would do this when possible. I've seen current consumption in the 1-2mA range even without the new lightsleep code.

@dpgeorge
Copy link
Member

This can now be rebased, because the mpconfigport.h changes were merged.

Also, this PR is currently blocked behind #17616 (ADC support), which may take some time to resolve. If you want to get this PR in now (before ADC support) then please remove all the ADC and io-channel stuff from this PR. Otherwise this PR can wait, no hurry.

Signed-off-by: Ned Konz <ned@metamagix.tech>
…rd files.

Signed-off-by: Ned Konz <ned@metamagix.tech>
…ython#17680.

@dpgeorge's PR micropython#17680 defines the standard Zephyr config based on MICROPY_CONFIG_ROM_LEVEL_BASIC.
This allows for simplifying the XIAO BLE board's mpconfigport-xiao.h.

Signed-off-by: Ned Konz <ned@metamagix.tech>
Signed-off-by: Ned Konz <ned@metamagix.tech>
…ectory.

Signed-off-by: Ned Konz <ned@metamagix.tech>
@bikeNomad bikeNomad force-pushed the ned/zephyr-add-xiao-ble-nrf52840-sense branch from 1672be8 to 7b7a69b Compare July 31, 2025 15:30
Signed-off-by: Ned Konz <ned@metamagix.tech>
@ned-pcs
Copy link
Contributor

ned-pcs commented Jul 31, 2025

This can now be rebased, because the mpconfigport.h changes were merged.

Also, this PR is currently blocked behind #17616 (ADC support), which may take some time to resolve. If you want to get this PR in now (before ADC support) then please remove all the ADC and io-channel stuff from this PR. Otherwise this PR can wait, no hurry.

OK, rebased and removed ADC stuff from mpconfigport.h and the overlay.


# Enable MicroPython's VFS and mount a littlefs filesystem on boot
CONFIG_MICROPY_VFS_LFS2=y
CONFIG_MICROPY_VFS_FAT=y
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these will be enabled by default from prj.conf, right?

If so, I suggest removing everything from here that's already the default in prj.conf, to keep this file minimal. Otherwise in the future when people add other boards, they copy this file and there are more and more duplicated settings.

#undef MICROPY_CONFIG_ROM_LEVEL
#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES)

#define MICROPY_PY_SYS_MODULES (1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already the default (in py/mpconfig.h), so can be removed.

#include "../mpconfigport.h"

#undef MICROPY_CONFIG_ROM_LEVEL
#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you set this before including ../mpconfigport.h then it doesn't need to be undef'd.

@@ -0,0 +1,8 @@
# freeze("../modules")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment can be removed.

# freeze("../modules")
include("$(MPY_DIR)/extmod/asyncio")

# Require a micropython-lib module.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is not really correct, it was copied from the example manifest.

You could remove it, or change it to something like "Require some useful micropython-lib modules."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy