qemu/Makefile: Do not mount ROMFS partition on non-test targets. by agatti · Pull Request #19109 · micropython/micropython · GitHub
Skip to content

qemu/Makefile: Do not mount ROMFS partition on non-test targets.#19109

Open
agatti wants to merge 1 commit intomicropython:masterfrom
agatti:qemu-romfs-target-fix
Open

qemu/Makefile: Do not mount ROMFS partition on non-test targets.#19109
agatti wants to merge 1 commit intomicropython:masterfrom
agatti:qemu-romfs-target-fix

Conversation

@agatti
Copy link
Copy Markdown
Contributor

@agatti agatti commented Apr 15, 2026

Summary

This commit fixes a mistake introduced in #19051, where the test ROMFS partition would get mounted even on targets that do not need it to function (ie. repl).

Now the ROMFS image is mounted only for test targets: test, test_full, and test_natmod, and only if there's no explicit ROMFS partition being chosen to be mounted via the command line.

Testing

The interpreter for the VIRT_RV32 board was built and executed both for Make targets that require ROMFS and targets that don't, making sure the process would proceed as expected.

This was done using the version of Make that comes with Ubuntu 24.04, so hopefully this should work on the CI machine.

Generative AI

I did not use generative AI tools when creating this PR.

@dpgeorge
Copy link
Copy Markdown
Member

Comment thread ports/qemu/Makefile Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit hacky. Eg it'd be nice in the future to add the test//% target that unix and webassembly have (I find that very useful, eg make test//float).

How about this:

--- a/ports/qemu/Makefile
+++ b/ports/qemu/Makefile
@@ -220,17 +220,15 @@ CFLAGS += $(SPECS_FRAGMENT)
 LDFLAGS += $(SPECS_FRAGMENT)
 endif

-# Mount the ROMFS test image only if no other ROMFS partition has been mounted on slot 0.
+# Mount the ROMFS test image specifically for test runs (if there is a slot 0).

 ROMFS_TEST_IMAGE = assets/random_romfs.bin

 ifneq ($(MICROPY_HW_ROMFS_PART0_START),)
-ifeq ($(QEMU_ROMFS_IMG0),)
-QEMU_ARGS += -device loader,file=$(ROMFS_TEST_IMAGE),addr=$(MICROPY_HW_ROMFS_PART0_START),force-raw=on
-endif
+QEMU_TEST_ARGS = -device loader,file=$(ROMFS_TEST_IMAGE),addr=$(MICROPY_HW_ROMFS_PART0_START),force-raw=on
 endif

-RUN_TESTS_FULL_ARGS = -t execpty:"$(QEMU_SYSTEM) $(QEMU_ARGS) -serial pty -kernel ../ports/qemu/$<" $(RUN_TESTS_ARGS)
+RUN_TESTS_FULL_ARGS = -t execpty:"$(QEMU_SYSTEM) $(QEMU_ARGS) $(QEMU_TEST_ARGS) -serial pty -kernel ../ports/qemu/$<" $(RUN_TESTS_ARGS)

 ################################################################################
 # Source files and libraries

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know that test syntax existed. For those situations I've always used ./run-tests.py -d ... -i ..., good to know though.

Anyway, I've tested your change and it did work! Looking at this a bit more let me spot another small issue in the makefile, test_full doesn't add $(RUN_TESTS_EXTRA) to the test runner command line(s).

Probably test_full is only run by CI these days but maybe it'd be nice to eventually make it work there too. Yet another first time (human) contributors task :)

That said, I'll update the PR - thanks for the suggestion.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for updating.

Looking at this a bit more let me spot another small issue in the makefile, test_full doesn't add $(RUN_TESTS_EXTRA) to the test runner command line(s).

Yes indeed...

This commit fixes a mistake introduced in micropython#19051, where the test ROMFS
partition would get mounted even on targets that do not need it to
function (ie. `repl`).

Now the ROMFS image is mounted only for test targets: `test`,
`test_full`, and `test_natmod`, and only if there's no explicit ROMFS
partition being chosen to be mounted via the command line.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
@agatti agatti force-pushed the qemu-romfs-target-fix branch from 9c84737 to c567937 Compare April 22, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants