zephyr-cp: add a partition layout check for cptools - #11273
Open
lynt-smitka wants to merge 1 commit into
Open
Conversation
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
force-pushed
the
zephyr-cp-partition-check
branch
from
August 29, 2026 15:10
d959e7d to
ae9850a
Compare
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.
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:
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.