Skip to content

zephyr-cp: check that a board's layout matches its non-Zephyr build - #11310

Merged
tannewt merged 1 commit into
adafruit:mainfrom
MakerClassCZ:zephyr-cp-layout-parity
Sep 4, 2026
Merged

zephyr-cp: check that a board's layout matches its non-Zephyr build#11310
tannewt merged 1 commit into
adafruit:mainfrom
MakerClassCZ:zephyr-cp-layout-parity

Conversation

@lynt-smitka

Copy link
Copy Markdown

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:

adafruit_clue_nrf52840_zephyr: ok (5 partitions checked, matches ports/nordic/clue_nrf52840_express)
adafruit_feather_nrf52840_sense_zephyr:
  FAIL  nvm_partition: 0xf2000+0x2000, nordic/feather_bluefruit_sense has it at 0xf3000+0x1000
adafruit_feather_nrf52840_zephyr: ok (5 partitions checked, matches ports/nordic/feather_nrf52840_express)
adafruit_feather_rp2040_zephyr: ok (5 partitions checked, matches ports/raspberrypi/adafruit_feather_rp2040)
native_native_sim: ok (3 partitions checked)
native_nrf5340bsim: ok (2 partitions checked)
native_nrf54lm20bsim: ok (2 partitions checked)
nordic_nrf5340dk: ok (3 partitions checked)
nordic_nrf54h20dk:
  FAIL  cpuapp_slot0_partition (ends 0xe4000) overlaps cpurad_slot0_partition (starts 0x92000) on mram1x
nordic_nrf54l15dk: ok (4 partitions checked)
nordic_nrf54l15tag: ok (4 partitions checked)
nordic_nrf54lm20dk: ok (5 partitions checked)
nordic_nrf7002dk: ok (3 partitions checked)
nxp_frdm_mcxn947: ok (5 partitions checked)
nxp_frdm_rw612: ok (6 partitions checked)
nxp_mimxrt1170_evk: ok (5 partitions checked)
raspberrypi_rpi_pico2_w_zephyr: ok (4 partitions checked, matches ports/raspberrypi/raspberry_pi_pico2_w)
raspberrypi_rpi_pico2_zephyr: ok (4 partitions checked, matches ports/raspberrypi/raspberry_pi_pico2)
raspberrypi_rpi_pico_w_zephyr: ok (5 partitions checked, matches ports/raspberrypi/raspberry_pi_pico_w)
raspberrypi_rpi_pico_zephyr: ok (5 partitions checked, matches ports/raspberrypi/raspberry_pi_pico)
renesas_da14695_dk_usb: ok (4 partitions checked)
renesas_ek_ra6m5: ok (1 partitions checked)
renesas_ek_ra8d1: ok (1 partitions checked)
silabs_siwx917_dk2605a: ok (11 partitions checked)
st_nucleo_n657x0_q: ok (1 partitions checked)
st_nucleo_u575zi_q: ok (4 partitions checked)
st_stm32h750b_dk:
  FAIL  storage_partition: resolves to 0x7800000, outside ext_flash (0x90000000-0x98000000) -- address translation is broken; does the partitions node declare ranges;?
  FAIL  circuitpy_partition: resolves to 0x7808000, outside ext_flash (0x90000000-0x98000000) -- address translation is broken; does the partitions node declare ranges;?
st_stm32h7b3i_dk: ok (2 partitions checked)
st_stm32wba65i_dk1:
  FAIL  circuitpy_partition (ends 0x200000) overlaps storage_partition (starts 0x1e0000) on flash0

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. nrf54h20dk needs 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.

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.
@dhalbert
dhalbert requested a review from tannewt September 4, 2026 21:02

@tannewt tannewt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@tannewt
tannewt merged commit 03777c3 into adafruit:main Sep 4, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants