Skip to content

rp2: Bump to SDK 2.3.0, port to include based linker scripts, fix silent ROMFS overflow#19415

Open
Gadgetoid wants to merge 3 commits into
micropython:masterfrom
pimoroni:patch-rp2-incl-linker
Open

rp2: Bump to SDK 2.3.0, port to include based linker scripts, fix silent ROMFS overflow#19415
Gadgetoid wants to merge 3 commits into
micropython:masterfrom
pimoroni:patch-rp2-incl-linker

Conversation

@Gadgetoid

Copy link
Copy Markdown
Contributor

Replaces: #19251

Summary

This PR does three things:

  1. Bump Pico SDK to v2.3.0 - https://github.com/raspberrypi/pico-sdk/releases/tag/2.3.0 (because it's necessary for this to work, and I expect this change will be rebased out)
  2. Migrate the downstream linker scripts to upstream's new include-based mechanism, effectively a rebase of rp2: Update to use include linker scripts #19251
  3. Include ROMFS in the linker, so we don't just quietly leave the same trap that tracking the user filesystem in the linker script fixed.

Testing

TBC

Trade-offs and Alternatives

We probably lose some visibility about The Big Picture by swapping very explicit downstream linker scripts with these piecemeal ones, but I think we should defer to Pico SDK when possible.

Generative AI

I used generative AI tools when creating this PR, but a human has checked the
code and is responsible for the code and the description above.

Gadgetoid and others added 3 commits July 3, 2026 16:52
Required by the include-based linker script support that follows.

Signed-off-by: Phil Howard <github@gadgetoid.com>
Pico SDK 2.3.0 makes its default linker script overridable via includes,
so the port no longer needs to carry a full copy. Replace the monolithic
memmap_mp_rp2040.ld and memmap_mp_rp2350.ld with memmap_mp_rp2.ld, which
includes the SDK default, plus small override fragments under memmap_rp2/,
memmap_rp2040/ and memmap_rp2350/ that supply only the MicroPython parts:
the FLASH/FLASH_FS split, moving gc/vm/parse into RAM, and the GC heap and
stack layout.

Memory region boundaries are unchanged.

Co-authored-by: Phil Howard <github@gadgetoid.com>
Signed-off-by: Phil Howard <github@gadgetoid.com>
ROMFS is carved off the top of the code space (just below the user
filesystem) by rp2_flash.c, but the FLASH region only excluded the
filesystem, so the application region overlapped ROMFS. A firmware that
grew into ROMFS was not caught by the linker, only by a debug-only
runtime assert.

Add MICROPY_HW_ROMFS_BYTES as a CMake variable, feeding both a linker
defsym and a compile definition from one source, and give ROMFS its own
FLASH_ROMFS region so the FLASH application region excludes it. The
linker now fails at build time if the firmware overlaps ROMFS. With the
default of 0 bytes the layout is unchanged.

Signed-off-by: Phil Howard <github@gadgetoid.com>
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.51%. Comparing base (964803a) to head (bd8e7b7).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #19415   +/-   ##
=======================================
  Coverage   98.51%   98.51%           
=======================================
  Files         177      177           
  Lines       22927    22927           
=======================================
  Hits        22586    22586           
  Misses        341      341           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

Code size report:

Reference:  nrf: Restore interrupt-based I2C with nrfx v3. [964803a]
Comparison: rp2: Reserve the ROMFS partition in the linker script. [merge of bd8e7b7]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:    +0 +0.000% TEENSY40
        rp2: +9740 +1.025% RPI_PICO_W[incl -200(bss)]
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@Gadgetoid

Copy link
Copy Markdown
Contributor Author

rp2: +9740 +1.025% RPI_PICO_W[incl -200(bss)]

🤔 I think that's the implicit bugfix kicking in.

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