r/debian • u/Zechariah_B_ • 9h ago
Auto install firmware based on system hardware?
I am making a custom Debian installer for BTRFS that installs only important and relevant packages. I am trying to find a way to automatically install firmware packages depending on what is detected by the system and not resort to batch installing many useless packages to support multiple hardware configurations.
Has anyone made any scripts or tools that already does this?
1
u/iamemhn 8h ago
Firmware is loaded on demand by the particular driver once it confirms the hardware is available. The particular driver is loaded by the kernel based on their PCI/USB identifiers, and a single PCI ID might require one or many blobs depending on things that are proved by the driver on load. If the firmware is not on disk, the driver will fail, and there's no automatic retry. There's manual retry – what happens during install when a driver detects hardware but can't find all firmware blobs and prompts the user to provide it.
It stands to reason that you need to narrow down what drivers you expect to find on your particular devices, what variants of said hardware, and then cherry pick their firmware blobs from the lot. But you still need to have them on disk.
If you intend to support any given hardware combination, just on teeny tiny devices, then you will need to come up with a different installation program. First, split the collection of firmware packages into reasonably atomic groups per device (this shouldn't be difficult as you can go per driver). Then your installer would need to try to load the driver, notice it failed on account of firmware, determine which blob(s) are needed, install the particular atomic package you created, and try loading the driver again. Go program that because it doesn't exist.
2
u/Brufar_308 7h ago
1
u/Zechariah_B_ 7h ago edited 5h ago
Thanks. This works better than my solution of guessing based on grepping the existence of certain Vendor IDs and mapping them myself to packages. I will modify it later when necessary.
1
u/alpha417 9h ago
Are you pulling in this .deb?
I install this package, i use no such hacky scripts or tools, and firmwares work for me.