3

I seek a way to determine which of the firmware (i.e. binary blobs to support hardware) my laptop actually uses.

The package that bundles the binary blobs on my distro archlinux is:

core/linux-firmware (package size ~180MiB , installed ~730MiB in ~2500 blob files)

my laptop is very likely only using a few of those files anyway. This question is to seek out how those can be determined. Some online search has suggested to simply grep the dmesg for the needle firmware (https://wiki.gentoo.org/wiki/Linux_firmware#Searching_for_loaded_firmware). While this indeed appears to provide some insight I am unsure if this is best/only/correct way. It appears to me

  1. the word firware appears in dmesg output in contextes not related to actual binary blobs
  2. the respective kernel source code parts, have not a uniform output with regard to displaying firmware loaded information (unsure though)
[root@thinkbox ~]# dmesg | grep -i firmware
[    0.111955] Spectre V2 : Enabling Restricted Speculation for firmware calls
[    0.161877] ACPI: [Firmware Bug]: BIOS _OSI(Linux) query ignored
[   10.440450] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[   10.493359] i915 0000:00:02.0: [drm] Finished loading DMC firmware i915/skl_dmc_ver1_27.bin (v1.27)
[   10.581810] iwlwifi 0000:04:00.0: loaded firmware version 36.ca7b901d.0 8000C-36.ucode op_mode iwlmvm
[   10.766097] Bluetooth: hci0: Firmware revision 0.0 build 10 week 41 2018
[   11.947004] psmouse serio2: trackpoint: IBM TrackPoint firmware: 0x0e, buttons: 3/3
[ 4855.262357] Bluetooth: hci0: Minimum firmware build 1 week 10 2014
[ 4855.268828] Bluetooth: hci0: Found device firmware: intel/ibt-11-5.sfi
[ 4857.277466] Bluetooth: hci0: Waiting for firmware download to complete
[ 4857.278204] Bluetooth: hci0: Firmware loaded in 1962276 usecs
[ 4857.297293] Bluetooth: hci0: Firmware revision 0.0 build 10 week 41 2018
[20995.531309] Bluetooth: hci0: Minimum firmware build 1 week 10 2014
[20995.531314] Bluetooth: hci0: Found device firmware: intel/ibt-11-5.sfi
[20997.352132] Bluetooth: hci0: Waiting for firmware download to complete
[20997.352924] Bluetooth: hci0: Firmware loaded in 1778914 usecs
[20997.370079] Bluetooth: hci0: Firmware revision 0.0 build 10 week 41 2018
[22827.736960] Bluetooth: hci0: Minimum firmware build 1 week 10 2014
[22827.737757] Bluetooth: hci0: Found device firmware: intel/ibt-11-5.sfi
[22829.202536] Bluetooth: hci0: Waiting for firmware download to complete
[22829.202753] Bluetooth: hci0: Firmware loaded in 1430656 usecs
[22829.219920] Bluetooth: hci0: Firmware revision 0.0 build 10 week 41 2018

edit: replaced output screenshot with text copy

2
  • I would personally dmesg|grep however, if this way does not suit you, I think you can simply locate the directory where the associated files are installed (usually /lib/firmware), ensure that associated filesystem is mounted atime (not noatime) then reboot and list the directory sorting per access time (--time=u)
    – MC68020
    Commented Dec 29, 2021 at 11:34
  • 1
    I think this is the best (most reliable) way of doing it: Know which firmware my linux kernel has loaded since booting Commented Dec 29, 2021 at 14:27

2 Answers 2

2

Here's probably the worst and the easiest way to find it out:

  1. sudo mv /lib/firmware /lib/firmware.bak
  2. reboot
  3. check dmesg for not found firmware files
  4. sudo mv /lib/firmware.bak /lib/firmware
  5. Now create e.g. /lib/firmware.needed and copy files from /lib/firmware to this directory (while retaining the required directory structure).
  6. After that delete the package and mv /lib/firmware.needed /lib/firmware.

You're all set.

There's no magical command to do it automatically. I can only think of using inotifywait -r /lib/firmware very early during the boot process and logging its output which is considerably more complicated. If you're using initrd (most people do) that's going to be even more complicated.


@MarcusMüller has offered a very neat idea which is worth trying. Please, enable the atime option for your root filesystem, reboot, and then run this command:

find /lib/firmware -atime -1

This should theoretically show all the files in /lib/firmware accessed during the past 24 hours which should hopefully include all the required firmware files.

7
  • note that you might not even get any visible display, or keyboard interaction, or network without the firmware :) But other than that, excellent idea! Commented Dec 29, 2021 at 12:00
  • Couldn't you just enable atime on the file system that /lib/firmware resides on? Commented Dec 29, 2021 at 12:01
  • 2
    atime sounds like a nice idea. I've had this feature disabled since forever. The only issue is: the kernel might load the firmware files while the root FS is still mounted RO, so atimes won't be updated. It's worth checking out though. Commented Dec 29, 2021 at 14:01
  • I assume you meant mv instead of rm?
    – slebetman
    Commented Nov 1, 2022 at 6:43
  • 1
    OK, fixed. :-) @nyov this command does nothing. Commented Nov 1, 2022 at 13:41
1

AFAIK, even easier, if you are using a standard linux kernel, and at least 2 days after your last update of /lib/firmware, reboot and run the following command:

find /lib/firmware -atime 2

Note that this only finds firmware for devices you have used since that update; if you have, say, a scanner that needs firmware and you haven't switched it on recently, the command above won't list it.

This command works because the linux kernel these days defaults to "lazyatime,relatime", which means update "atime" if (a) the file's being accessed for the first time since the last change or modification or (b) the file's being accessed for the first time in over 24 hours. The command uses "-atime 2" for rounding reasons explained in "man find". The reboot is necessary to get the kernel to reload firmware.

If it doesn't work, update your "/etc/fstab" to replace "noatime" and similar mount options for your rootfs with "lazyatime", which works best for almost all use cases.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .