Skip to content

rp2 builds: --keep-fs keeps a board's filesystem through a firmware update - #386

Merged
bdbarnett merged 2 commits into
mainfrom
rp2-keep-fs
Nov 10, 2026
Merged

bdbarnett merged 2 commits into
mainfrom
rp2-keep-fs

Conversation

@bdbarnett

Copy link
Copy Markdown
Contributor

An rp2 build that doesn't fit beside the board's default filesystem is autosized: the firmware gets the image's size plus headroom, rounded up to 64 KB, and the filesystem gets the rest. That figure is worked out again in every new build folder, so a newer image only a little bigger can come out with a smaller filesystem than the one on your board, and flashing it leaves the board with an empty one. Two RPI_PICO builds with the same modules show it: images of 1,398,144 and 1,460,520 bytes get 576 KB and 512 KB filesystems, although the newer image fits beside 576 KB with 46 KB to spare.

--keep-fs SIZE builds beside the filesystem a board already has. If the image fits, the filesystem stays where it is. If it doesn't, the build stops and says what size would fit, instead of moving it. autosize's own message now says how to ask a board for its size (rp2.Flash().ioctl(4, 0) * ioctl(5, 0)), and the guide to fitting firmware on a small flash has a section on keeping a board's files.

Checked with RPI_PICO builds of displayif,lvgl,pydevices. --keep-fs 512K linked on the first try beside 512 KB. --keep-fs 576K linked on the first try beside 576 KB, where a fresh build without it autosizes to 512 KB. --keep-fs 640K stopped, saying 512 KB would fit. On a Waveshare RP2040-Touch-LCD-1.28 with a 512 KB filesystem holding 28 files, flashing the 512K image, and then the board's previous image again, left every file with the same hash. New unit tests cover the size parsing and the two autosized sizes above. MicropythonLibPatches.test_applies_once fails here with and without this change, because the local micropython-lib checkout lacks the file it looks for.

Not checked: CI, and esp32, whose app partition autosize has the same habit and isn't changed here.

…pdate

autosize works an rp2 filesystem's size out again in each new build folder,
from the image's size plus headroom, rounded to 64 KB. Two RPI_PICO images
with the same modules, 1,398,144 and 1,460,520 bytes, come out with 576 KB
and 512 KB filesystems, so flashing the newer one over the older moves the
filesystem and the board comes up empty, although the newer image fits
beside 576 KB with 46 KB to spare.

--keep-fs SIZE builds beside the filesystem the board already has, and
stops with the size that would fit instead of moving it when the image
doesn't. autosize's message says how to read the size on a board.

Checked on a Waveshare RP2040-Touch-LCD-1.28 with a 512 KB filesystem and
28 files: an RPI_PICO build with --keep-fs 512K linked first time with a
512 KB filesystem, and after flashing it, and then the earlier image again,
every file hashed the same.
@bdbarnett
bdbarnett merged commit 5477920 into main Nov 10, 2026
33 checks passed
@bdbarnett
bdbarnett deleted the rp2-keep-fs branch November 10, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant