zephyr-cp: check that a board's layout matches its non-Zephyr build - #11310
Merged
Conversation
Boards that CircuitPython also builds from ports/raspberrypi or ports/nordic must keep nvm and the CIRCUITPY drive exactly where that build has them, or switching firmware between the two loses the user's data. Until now the only check was a person with the board in hand; adafruit#11272 found a 4 KB nvm offset error that way. check_partitions.py now reads a `counterpart = "<port>/<board>"` key from the Zephyr board's circuitpython.toml, derives the expected placement from the counterpart's own mpconfigboard.mk/.h and mpconfigport.h the way those files derive it (raspberrypi: nvm after CIRCUITPY_FIRMWARE_SIZE, the drive after nvm and the saves partition; nordic: bootloader at the top of flash, internal filesystem and nvm below it, or the whole external chip as the drive) and compares it with the resolved devicetree. The eight boards with a counterpart declare it. On the current tree seven match; feather_nrf52840_sense_zephyr puts nvm at 0xf2000+0x2000 while ports/nordic/feather_bluefruit_sense has it at 0xf3000+0x1000 (CIRCUITPY_INTERNAL_NVM_SIZE 4096). That is fixed separately. Also adds --board for build directories not named build-<board>, and tests for the reference derivation against the real board files.
tannewt
approved these changes
Sep 4, 2026
tannewt
left a comment
Member
There was a problem hiding this comment.
Thanks! I'll integrate this into my bootloader changes that are coming. Don't worry about the partitions now. The files that define the partitions are going to move into the bootloader. Still nice to have this CP specific check here though.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This extends cptools/check_partitions.py from #11273 with a comparison against the non-Zephyr build of the same board. Users switch between the two builds, so nvm and the CIRCUITPY drive should have the same place and size in both to keep user's data.
The Zephyr board names its twin in circuitpython.toml (counterpart = "raspberrypi/raspberry_pi_pico_w"). The check reads the twin's mpconfigboard.mk/.h and mpconfigport.h, works out where that build puts nvm and CIRCUITPY, and compares it with the devicetree. The eight boards with a twin declare it. #11272 verified the RP2 placement on hardware; this keeps it there without the hardware. --board names the board for build directories not called build-.
Run over all 29 boards on main (west build --cmake-only per board, ~10 s, no compile):
full output:
25 boards pass, 4 don't:
adafruit_feather_nrf52840_sense_zephyr: nvm 0xf2000+0x2000 copied from the Express; feather_bluefruit_sense/mpconfigboard.h sets CIRCUITPY_INTERNAL_NVM_SIZE (4096), so that build has it at 0xf3000+0x1000.st_stm32h750b_dk: partitions node without ranges;, both partitions resolve outside ext_flash; the base partition@0 (128 MB) is not deleted either.st_stm32wba65i_dk1: circuitpy_partition runs 64 KB into storage_partition at 0x1e0000.nordic_nrf54h20dk: the overlay grows slot0_partition to 656 KB to take the slot1 space, but cpurad_slot0_partition sits at 0x92000, between the two app slots; the app image overlaps the radio core's slot by 328 KB.I can fix the first three (Sense nvm, h750b ranges; + partition@0, wba65i overlap) here on in follow-up PRs.
nrf54h20dkneeds your decision: with CONFIG_BT=n no radio, PPR or FLPR image is built, so the app could take 656 KB (drop cpurad_slot0, what the overlay meant), 768 KB (PPR/FLPR too) or up to 1424 KB (both radio slots), depending on whether a BLE controller on cpurad is planned.Once the four are fixed, the check can run in CI: either one line in the Makefile after west build, which covers every board build, or a separate job doing west build --cmake-only plus the check for all boards. Today either would fail on them.
The script was made with AI assistance.