Skip to content

Slim firmware: only what brings /ext up stays in the internal flash - #149

Merged
JohnAmadis merged 3 commits into
masterfrom
feat/slim-flash
Oct 27, 2026
Merged

JohnAmadis merged 3 commits into
masterfrom
feat/slim-flash

Conversation

@JaxCalder

@JaxCalder JaxCalder commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • STM32F746G-DISCO internal flash image: ~1.00 MB -> 404 kB (-DCMAKE_BUILD_TYPE=MinSizeRel; Debug has no optimization and is ~485 kB).
  • flash.dmd of the board keeps only the way to /ext and the console (clocks, pins, usart1, SDRAM, DMA, QUADSPI, the chip, littlefs, systemd/devscan/console, ls/mount/umount/ymodem/mklittlefs) and automount (13 kB): with automount on /ext, umount /ext stopped its unit, which unmounted the SD card, and the car HMI on the card did not stop in time (the card stayed busy, minutes, system half stopped). Now umount /ext takes ~15 s, leaves the card and the HMI alone, and mount brings the units back.
  • Everything else is in the board's ext.dmd (and the common services in tools.dmd, which DMBOOT_EXT_TOOLS already sends to /ext): modules in /ext/bin, drivers/units/rules in /ext/cfg, loaded once /ext is mounted. Renode is the same as the board: run_renode_tests.sh formats the emulated flash, sends build/ext over the UART (ymodem_send.py --port tcp:HOST:PORT) and mounts /ext again (new step 4b).
  • Splash logo goes to /ext/views/ (built into build/ext, sent by upload-ext); it shows once /ext is mounted.
  • Upload fix. Uploading a fresh /ext stopped after ~75 modules: creating a file in a directory of that size makes littlefs compact it, which took up to 5.5 s with the default 16 byte reads (1.9 s with 64, 1.3 s with 256). ymodem_send.py waited 3 s for the answer to the header, sent it again, and sender and receiver lost each other (ACK and NAK). Now it waits up to 60 s for a header, and the ext unit mounts with read=256 (not part of the on-disk format). When the device does not answer, ymodem_send.py prints what it did say.
  • Docs updated.

Depends on

choco-technologies/dmdevfs#78 "A driver configured into a mounted instance learns about its friends" - without it dmwm8994 fails (I2C bus friend is not ready) because its drivers are now loaded from /ext/cfg/drivers.

Tested

  • Board: clean boot on a freshly formatted /ext + upload-ext (first try): dmview, carhmi, dmaudio@wm8994, eth0 (DHCP, ping), wlan0, telnetd, touch, rtc, rng, crypto, SD card with music. About 34 kB more main heap and 0.4 MB more SDRAM than with everything in the firmware.
  • Renode (scripts/run_renode_tests.sh): UART, SD card, LCD (splash logo from /ext), touch and QUADSPI pass; the network test is skipped (needs root).

Known

  • umount /ext still stops the units of /ext and prints dmdevmon ... did not stop within 5000 ms, killing it and Cannot disable module 'dmicmp' - required by module 'dmudp' (libraries are stopped without regard to their dependencies); harmless.
  • RTC calendar_set=0 (NTP never set it); there is no baseline to compare with.

🤖 Generated with Claude Code

JaxCalder and others added 3 commits October 26, 2026 08:40
The STM32F746G-DISCO firmware kept every driver, the network stack, the SD
card, the display and the audio in its 1 MB flash. Now flash.dmd of the board
holds the way to /ext and the console (clocks, pins, usart1, SDRAM, DMA,
QUADSPI, the chip, littlefs, systemd/devscan/console and ls/mount/umount/
ymodem/mklittlefs); the rest is in the new late.dmd files (common, MCU,
board), which DMBOOT_EXT_TOOLS sends to /ext instead of the firmware - their
drivers, units and rules to /ext/cfg, loaded once /ext is mounted. Renode
(DMBOOT_EXT_TOOLS=OFF) keeps everything in the firmware as before.

The splash logo moves to /ext/views too (the display driver is on /ext now);
splash.cmake builds a logo under the external flash's mount point into
build/ext. ymodem_send waits longer for the receiver after a file, which a
fresh littlefs sometimes needs.

Internal flash image: 1.00 MB -> 390 kB (MinSizeRel).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…-all

late.dmd is gone: the modules go to the board's ext.dmd, the common services
(dmdevmon, dmutc) to tools.dmd, which DMBOOT_EXT_TOOLS already sends to /ext.
Renode is no different from the board any more: run_renode_tests.sh formats
the emulated flash, sends build/ext over the UART (ymodem_send.py --port
tcp:HOST:PORT) and mounts /ext again, which starts the units.

The upload of a fresh /ext stopped after ~75 modules: creating a file in a
directory of that size makes littlefs compact it, which took up to 5.5 s with
the default 16 byte reads (1.9 s with 64, 1.3 s with 256). The sender waited 3 s
for the answer to the header, sent it again, and the two sides lost each other
(the receiver answered ACK and NAK). The sender now waits up to 60 s for a
header, and the ext unit mounts with read=256 (not part of the on-disk format).
When the device does not answer, ymodem_send says what it did say.

test_renode_ext.py no longer formats: /ext is filled before it runs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
automount was on /ext, so unmounting /ext stopped its unit, which unmounts the
cards it mounted - and the card holds the car HMI, which does not stop within
the time the unmount gives it (15 s): the HMI was killed, the card stayed busy
and `umount /ext` (so format-ext) took minutes and left the system half
stopped. With automount (and libautomount, dmblkid, its unit and rules) in
flash.dmd, umount /ext stops the units of /ext in ~15 s and the card and the
HMI stay; mount brings the units back. format-ext: 51 s -> 25 s.

The image grows by 13 kB: 404 kB.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@JohnAmadis
JohnAmadis merged commit 3930af8 into master Oct 27, 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