Skip to content

Smaller firmware: no comments in /cfg, ls and dmramfs on /ext, an empty dmffs as the root - #150

Merged
JohnAmadis merged 4 commits into
masterfrom
feat/smaller-firmware
Oct 28, 2026
Merged

JohnAmadis merged 4 commits into
masterfrom
feat/smaller-firmware

Conversation

@JaxCalder

Copy link
Copy Markdown
Contributor

What

Three steps that take the internal flash image of the stm32f746g-disco from ~402 kB to ~382 kB (MinSizeRel), on top of the slim firmware (#149):

  1. No comments in the /cfg image. The .ini and .rules files lose their comment lines and empty lines before the image is made (scripts/strip_comments.cmake, STRIP of dmboot_embed_dmffs, option DMBOOT_STRIP_CONFIG_COMMENTS, ON). config_fs 15.7 kB → 4.9 kB. The files in DMBOOT_CONFIG_DIR are not touched, the image is made from a copy; comments after a value stay.
  2. ls and dmramfs to tools.dmd, i.e. to /ext/bin with DMBOOT_EXT_TOOLS (in the firmware without it): −9.8 kB of modules.dmp.
  3. The root file system is a read-only dmffs embedded in the image (.embedded.root_fs, 38 bytes, with /mnt – automount cannot make that one itself) instead of a dmramfs, and /tmp is a dmramfs mounted by a unit (configs/common/services/tmp.ini). With the tools on /ext the unit lands in /ext/cfg/services, so /tmp appears once /ext is mounted.

Behaviour change

/ is read-only, and nothing can be written before /ext is up (then /tmp is). Something that writes to /tmp early needs to wait for the tmp unit (after=tmp).

Tested

STM32F746G-DISCO, firmware flashed and upload-ext: ls / → mnt cfg eviews dev ext tmp; mkdir /tmp/x works, mkdir /foo is refused; the SD card is mounted at /mnt/DMODOS by automount; carhmi, networkd, dmview and dmaudio run. After flash.dmd changes a stale build/dmf keeps the old modules: remove dmf/<module>.* and modules/flash.download_complete (not new, but easy to hit here).

Not run: Renode, other boards (ls and dmramfs stay in the firmware where there is no DMBOOT_EXT_TOOLS).

🤖 Generated with Claude Code

JaxCalder and others added 4 commits October 28, 2026 12:34
…ty dmffs as the root

Strip the comments: the .ini and .rules files of the /cfg image lose their comment
and empty lines (scripts/strip_comments.cmake, STRIP of dmboot_embed_dmffs, option
DMBOOT_STRIP_CONFIG_COMMENTS, ON): config_fs 15.7 kB -> 4.9 kB. The files in
DMBOOT_CONFIG_DIR are not touched, only the copy the image is made from.

Move ls and dmramfs to tools.dmd (/ext/bin with DMBOOT_EXT_TOOLS, the firmware
without it): -9.8 kB of modules.dmp. The root file system was a dmramfs, so it is now
a read-only dmffs of its own embedded in the image (.embedded.root_fs, 38 bytes, with
/mnt - automount cannot make that one itself), and /tmp is a dmramfs mounted by a unit
(configs/common/services/tmp.ini; in /ext/cfg/services when the tools are on /ext, so
it starts once /ext is mounted).

The internal flash image is about 382 kB (402 kB before), MinSizeRel on the
STM32F746G-DISCO. Tested on the board: / lists mnt cfg eviews dev ext tmp, /tmp can be
written to, mkdir /foo is refused, the SD card is mounted at /mnt.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The line was broken when the option of the comment stripping was added in front of it:
set(DMBOOT_EVIEWS_DIR"...") leaves DMBOOT_EVIEWS_DIR empty in a fresh build directory, so
dmf-get got "--views-dir --package-dir ..." and failed with "Cannot specify both module
name and dependencies file". It went unnoticed in a build directory that had the value in
its cache already.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
echo > /test.txt cannot work any more: / is a read-only dmffs. The test waits for /tmp (the
tmp unit mounts it once /ext is mounted, which is after the shell is up) and writes there.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
modules/CMakeLists.txt takes configs/common/services/tmp.ini from the sources of the firmware;
the fixture of the test is a minimal source tree and has to have it too.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@JohnAmadis
JohnAmadis merged commit 64433f2 into master Oct 28, 2026
5 checks passed
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