Skip to content

Add an embedded-files build config for Duet 3 MB6HC - #1267

Open
meeloo wants to merge 3 commits into
Duet3D:3.7-devfrom
meeloo:build/embedded-mb6hc-config
Open

Add an embedded-files build config for Duet 3 MB6HC#1267
meeloo wants to merge 3 commits into
Duet3D:3.7-devfrom
meeloo:build/embedded-mb6hc-config

Conversation

@meeloo

@meeloo meeloo commented Aug 22, 2026

Copy link
Copy Markdown

Adds Makefiles/Duet3_MB6HC_embedded.mk, a build config for MB6HC with -DUSE_EMBEDDED_FILES, plus Scripts/BuildEmbeddedFiles.py to build the filesystem image and Scripts/CrcAppender.py to append the firmware CRC.

Why it might be worth having: Pins_Duet3_MB6HC.h already has a USE_EMBEDDED_FILES branch, but nothing builds it, which is how it came to be broken in three separate ways (see the three bugfix PRs). A config that builds it is what makes those bugs visible and those fixes testable.

It is kept out of the default all: target, like the other special-purpose configs. Its helper targets are renamed rather than inherited: sharing duet3mb6hc-prebuild, duet3mb6hc-libs and clean-Duet3_MB6HC with the normal config made make warn about overridden commands and made clean-Duet3_MB6HC silently clean the embedded build directory.

The order in BuildEmbeddedFiles.py then CrcAppender.py is not interchangeable: an embedded image links with _firmware_crc == _firmware_end, so the filesystem must be appended and vector slot 7 moved before the CRC is computed. Both scripts refuse to run if slot 7 is not where they expect rather than checksumming the wrong extent.

My use case is an emulator, which has no SD card, so this may be too niche for upstream. Offered because the three bugfix PRs cannot be exercised without it

meeloo added 3 commits August 22, 2026 11:41
Derived from Duet3_MB6HC.mk with -DUSE_EMBEDDED_FILES. Kept out of the default
all: target like the other special-purpose configs. Its helper targets are
renamed rather than inherited: sharing duet3mb6hc-prebuild, duet3mb6hc-libs and
clean-Duet3_MB6HC with the normal config made make warn about overridden
commands and made clean-Duet3_MB6HC silently clean the embedded build directory.

Needs the USE_EMBEDDED_FILES compile fix to build.
Companion to CrcAppender.py. Builds the structure EmbeddedFiles.cpp expects at
_firmware_end: magic 0x543C2BEF, directoriesOffset, numFiles, then a descriptor
per file, with every offset relative to _firmware_end.

The part that is easy to get wrong is the CRC. A USE_EMBEDDED_FILES image links
with _firmware_crc == _firmware_end, so vector slot 7 initially points at where the
filesystem is about to go. Since AppMain CRCs everything below the address in that
slot, the slot has to be moved past the filesystem - which this does, so
CrcAppender.py must run after this tool and not before. Both refuse to run against
an image whose slot 7 is not where they expect, rather than silently CRCing the
wrong extent and leaving a board blinking on the bench.

Verified end to end under the Renode emulator: the firmware accepts its own CRC,
finds /sys/config.g and executes it.
An image with the filesystem appended must have vector slot 7 moved past it
before the CRC is computed, or the firmware rejects its own checksum and the
board sits in a 3-blink loop.
@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@meeloo

meeloo commented Aug 22, 2026

Copy link
Copy Markdown
Author

I have read the Duet3D CLA v2.0 and I hereby sign it

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.

1 participant