Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Suggestion: "config.txt"-based control for inc/exclusion of /boot/firmware files #29

Open
britkig opened this issue Jan 28, 2025 · 2 comments

Comments

@britkig
Copy link

britkig commented Jan 28, 2025

Can I suggest a feature for achieving even-smaller resultant images, by allowing a user to supply a "config.txt" file, which could be read to manipulate the inclusion/exclusion of files that normally end up in /boot/firmware? For example, lets say a user has this in their config.txt file...
...against this text string (for example, destined for a headless Compute Module 4 with on-board storage, but no WiFi/Bluetooth module)...

#arch=v8+
#model=bcm2711-rpi-cm4
disable_overscan=1
disable_splash=1
dtoverlay=disable-bt
dtoverlay=disable-wifi
dtoverlay=i2c-fan,emc2301,i2c_csi_dsi
dtparam=watchdog=on
gpu_mem=16

This could instruct to add the bcm2711-rpi-cm4.dtb device tree base, the latest Pi arm64 v8+ kernel8.img, and, through via a match-all regex expression with the multi-line flag...

^dtoverlay=(.+?)[,\n$]

...to include the disable-bt, disable-wifi and i2c-fan device tree overlays. Another possibility is, by searching for gpu_mem=16, to determine whether or not to use the smaller fixup4cd.dat and start4cd.elf firmware files over the full size fixup4.dat and start.elf ones (subject to if the intended Pi board/CPU model uses them).

@roliver-rpi
Copy link
Contributor

(@tdewey-rpi for visibility)

Hi @britkig , thank you for opening this issue.

Device tree blobs/overlay end up being a relatively small part of the generated images:

$ find . -name '*.dtb*' -exec du -ch {} + | tail -1
2.7M	total

The same cannot be said for the various firmware files:

$ find . -name '*.dat' -o -name '*.elf' -exec du -ch {} + | tail -1
22M	total

Removing non-'cd' FW files alone would represent a ~20M saving in the gpu_mem=16 case.

@britkig
Copy link
Author

britkig commented Jan 31, 2025

In regards to dtoverlays, yes, but maybe that can be opt-in as a "comfort" feature for those seeking a maximum reduction.

In the same vein, the main DTB files, and as of writing there's 26 of them, make up ~1.22MiB, and yet only one will ever get used once-installed. Maybe the detection can be achieved with one-or-more always-commented #model=bcm2711-rpi-cm4 using the regex...

^#model=(.+)$

This part can be reduced to less than 85KB.

Then, there's the kernel, five of those in the official firmware repository amounting to ~41MB, only need one of them in a deployment install, so another average ~30MB in savings can be achieved there by using just the one; could be fished out with:

^#arch=(.+)$

The result is below 10MB as of kernel version 6.6.74.

Since opening this issue thread, I have spotted another avenue for kernel-linked reductions, but it's outside of /boot/firmware, so I'll explore in opening a new issue on that once I've an A-to-B way on it.

@britkig britkig changed the title "config.txt"-based control for inc/exclusion of /boot/firmware files Feature Suggestion: "config.txt"-based control for inc/exclusion of /boot/firmware files Jan 31, 2025
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

No branches or pull requests

2 participants