Skip to content

Read Zephyr and nRF Connect SDK partitions, add region spaces - #11

Merged
iharhl merged 1 commit into
mainfrom
feature/zephyr-partitions
Nov 14, 2026
Merged

iharhl merged 1 commit into
mainfrom
feature/zephyr-partitions

Conversation

@iharhl

@iharhl iharhl commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Summary

memmap from-partitions now also reads Zephyr's merged zephyr.dts and nRF Connect SDK Partition Manager files (partitions.yml, pm_static.yml), telling the formats apart by content. It builds on #10.

  • Zephyr devicetree
    • One column per flash with fixed-partitions, with addresses mapped through ranges the way Zephyr maps them. This includes 2-cell addresses and flash behind two levels of ranges.
    • erase-block-size becomes sectors, so partition edges are checked (W100).
    • fixed-subpartitions are nested and zoomed into.
    • Notes mark MCUboot's boot partition, slots and scratch.
    • SPI, QSPI and FlexSPI NOR flash is drawn in its own space from 0. Its size comes from the size property in bits, or from reg on older STM32 QSPI boards.
    • An unmerged board .dts, an overlay or zephyr.dts.pre is refused, with a hint to pass the build's merged file.
  • Partition Manager
    • One column per region. span containers are nested, even when they hold other containers.
    • Partitions with the same range become one block.
    • Notes mark MCUboot, the image header (mcuboot_pad), the nRF Secure Immutable Bootloader (NSIB) slots, TF-M and the app.
  • W114 (new): a partition that partly overlaps another, or lies outside its flash, is left out. In a pm_static.yml, a stale app entry gives way, since the build places app itself.
  • space: on top-level regions (core schema change)
    • Regions in different spaces may overlap, and placement and gap filling run per space.
    • A / column draws only the default space, and gives E020 when every region has a space.
    • A view with no columns gets one column per named-space region.
    • describe shows the space.
    • Configs without space render byte-identically, and every existing golden is unchanged.
  • ESP-IDF options: --sdkconfig, --flash-size, --table-offset and --bootloader-offset are refused for the new formats, since nothing in them would use those values.

Not done: the MCUboot image header and trailer are not marked for Zephyr builds, because the devicetree does not record them. There are no slot-size rules either, since those depend on the upgrade mode.

Testing

  • Ground truth:

    • 1,395 distinct zephyr.dts + devicetree_generated.h pairs from 311 repos (7,521 entries) all match the header's address and size macros.
    • 222 partitions.yml + pm_config.h pairs from 86 repos (2,144 entries) all match.
  • Corpus: 1,047 real files from 458 repos ran through the importer without a crash, and every warning and error was checked by hand.

    • Every W114 is a real problem, including two in the nRF Connect SDK's own nRF Desktop configurations.
    • Overlap errors (E011) went from 153 files to 0 with space.
  • Committed fixtures: five, each covering something the others don't:

    • nrf5340_subpartitions: subpartitions mapped by ranges;
    • mcxn947_flexspi: two levels of ranges, FlexSPI NOR;
    • stm32_mcuboot_scratch: STM32 base address, MCUboot scratch, QSPI sized by reg;
    • nrf5340_tfm_pm: nested containers, external flash, OTP;
    • a stale-app pm_static.yml.

    Each has a golden config, and two have golden SVGs.

  • Review: reviewed by a second model. Its findings are fixed and covered by tests.

  • uv run pytest (809 passed), uv run mypy and uv run ruff check are clean.

Docs: docs/from-partitions.md, README and AGENTS.md cover the new formats, W114 and the space recipe.

🤖 Generated with Claude Code

`memmap from-partitions` now also reads Zephyr's merged zephyr.dts and nRF
Connect SDK Partition Manager files (partitions.yml, pm_static.yml), telling
the formats apart by content.

- Devicetree: one column per flash with fixed-partitions, addresses mapped
  through `ranges`, erase-block-size as sectors, fixed-subpartitions nested
  and zoomed into, and notes for MCUboot's boot partition, slots and scratch.
  SPI, QSPI and FlexSPI flash is drawn in its own space from 0.
- Partition Manager: one column per region, `span` containers nested, and
  notes for MCUboot, the image header, NSIB, TF-M and the app.
- W114: a partition that partly overlaps another or lies outside its flash
  is left out. A stale `app` in pm_static.yml gives way.
- Regions take an optional top-level `space:`. Regions in different spaces
  may overlap, placement and gap filling run per space, and a `/` column
  draws only the default space.

Checked against the generated headers of real builds: 1395 devicetree builds
(7521 entries) and 222 Partition Manager builds (2144 entries), all matching.
Five fixtures cover what the readers need; docs/from-partitions.md has the
details.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iharhl
iharhl merged commit 049c6a8 into main Nov 14, 2026
3 checks passed
@iharhl
iharhl deleted the feature/zephyr-partitions branch November 14, 2026 10:42
@iharhl iharhl mentioned this pull request Nov 14, 2026
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.

1 participant