ports/unix,windows: Add embedded romfs support with auto-mount.#43
Draft
andrewleech wants to merge 1 commit intomasterfrom
Draft
ports/unix,windows: Add embedded romfs support with auto-mount.#43andrewleech wants to merge 1 commit intomasterfrom
andrewleech wants to merge 1 commit intomasterfrom
Conversation
Add support for an embedded romfs image linked directly into the unix/windows binary. When built with ROMFS_IMG=path/to/romfs.img, the image is embedded as a .rodata section via objcopy and registered as a read-only filesystem at startup. Auto-mount the embedded romfs at /rom and (when present) prepend it to sys.path. If the romfs contains main.py or main.mpy, it is executed in preference to the file-system search after startup. The unix port also gains a 'make romfs ROMFS_DIR=...' target to build a romfs image from a directory using mpremote. The same plumbing is added to the windows port (with PE-COFF objcopy output and a separate vfs_rom_ioctl.c since the Windows variant uses MICROPY_VFS_ROM_IOCTL_USE_EXTERNAL=1 to avoid pulling the ioctl helper into main.c). Also adds MICROPY_ENABLE_COMPILER=0 guards in the unix main.c so the port can be built without the compiler when only pre-compiled .mpy modules are needed (relevant when shipping a frozen-only application binary). Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
|
Code size report: |
ce2c0c9 to
9f396bb
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.
Summary
Adds support for an embedded romfs image linked into the unix/windows binary. With
ROMFS_IMG=path/to/romfs.imgthe image is embedded as a.rodatasection viaobjcopyand registered as a read-only filesystem at startup. Auto-mount at/romand (when present) prepend tosys.path. If the romfs containsmain.pyormain.mpy, it is executed in preference to the file-system search.Also adds a
make romfs ROMFS_DIR=...target on both ports for building images via mpremote, andMICROPY_ENABLE_COMPILER=0guards in unixmain.cso the port can be built compiler-less when only frozen.mpymodules are needed.Testing
Unix build with and without
ROMFS_IMG; Windows mingw build with embedded romfs; auto-execution ofmain.mpyfrom/rom.