Skip to content

zephyr-cp: add a partition layout check for cptools - #11273

Merged
tannewt merged 1 commit into
adafruit:mainfrom
MakerClassCZ:zephyr-cp-partition-check
Aug 31, 2026
Merged

zephyr-cp: add a partition layout check for cptools#11273
tannewt merged 1 commit into
adafruit:mainfrom
MakerClassCZ:zephyr-cp-partition-check

Conversation

@lynt-smitka

Copy link
Copy Markdown

Follow-up to #11234 and #11271, which fix the same issue on four boards:
an overlay deletes the partitions node its board DTS declares, rebuilds it, and drops the ranges;. Nothing complains at build time and the partitions resolve to bare offsets.

This adds the check that would have caught them. It reads the edt.pickle a build has already produced, so it needs no build of its own and can run right after the board builds in CI:

    python cptools/check_partitions.py                    # every build-* dir
    python cptools/check_partitions.py build-<board>

It verifies that mapped partitions resolve inside their device, that nothing overlaps or runs past the end, and reports how many partitions it inspected, so a board whose overlay defines none is not mistaken for a verified one.

Run against the build directories I had to hand it flags the boards #11271 fixes and passes the rest.

The same idea, in more complete form the bootloader repo needed, is adafruit/adaboot#1 - there the layouts are the artifact rather than a side effect, so it resolves each board itself instead of reading a build.

Tests parse real device tree source rather than stand-in objects, so they exercise the checks against devicetree as edtlib resolves it.

Board overlays routinely delete the partitions node their board DTS declares
and rebuild it so the board gets a CIRCUITPY filesystem. Dropping the
ranges; while doing so costs nothing at build time and everything at
runtime: devicetree stops translating the partition addresses, so they
resolve to bare offsets. On RP2040 that turns off
RP2_REQUIRES_SECOND_STAGE_BOOT and builds the UF2 for the wrong address; on
a board whose flash is not based at 0 it makes every flash_area offset
underflow.

check_partitions.py reads the edt.pickle a build has already produced, so it
costs no build time -- point it at build directories after building, or run
it with no arguments to check every build directory in the port. It verifies
that mapped partitions resolve inside their device, that nothing overlaps or
runs past the end, and reports how many partitions it inspected so a board
that defines none is not mistaken for a verified one.

Tests parse real device tree source, so they exercise the checks against
devicetree as edtlib resolves it.
@lynt-smitka
lynt-smitka force-pushed the zephyr-cp-partition-check branch from d959e7d to ae9850a Compare August 29, 2026 15:10

@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!

@tannewt
tannewt merged commit d0285f1 into adafruit:main Aug 31, 2026
14 of 15 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