429. Firmware updates
This page covers updating the firmware inside a machine’s devices with fwupd: an SSD’s controller, a dock, a USB peripheral, and the system firmware itself (the BIOS or UEFI, the embedded controller) where the vendor publishes it as a UEFI capsule. The firmware files the kernel loads for its drivers, and CPU microcode, are a different thing; they come with packages and are covered in Microcode and firmware. How fwupd finds the EFI system partition when udisks does not name it, and what it writes there, is explained in Thunderbolt, phones, smart cards and firmware updates and Where the kernel is kept.
Installation
| Port | Provides |
|---|---|
| fwupd | The daemon, fwupdmgr (its client), fwupdtool (the same engine run directly as root), and the LVFS remotes, every download remote switched off |
| fwupd-snapshot | The LVFS metadata as it stood when the release was cut, which the kdos-snapshot local remote reads, so firmware is listed with no network |
| fwupd-efi | fwupdx64.efi, the EFI program that hands a staged capsule to the firmware at the next boot |
| discover | Discover’s firmware backend, which lists the same updates on its Updates page and installs them through the daemon |
All four are on the image, live and installed. fwupd has no service script and nothing starts it at boot: the system bus starts it the first time a client calls it, through the setuid dbus-daemon-launch-helper. The recipe deletes the GRUB hook fwupd would install, since KDOS boots with Limine:
meson compile -C build
DESTDIR=$PKG meson install --no-rebuild -C build
rm -rf "$PKG/etc/grub.d"
ports/core/boot/fwupd/build.sh, lines 45–47
Configuration
/etc/fwupd/fwupd.conf
The recipe writes fwupd’s configuration whole. Its one setting says where the EFI system partition is mounted:
cat > "$PKG/etc/fwupd/fwupd.conf" <<'EOF'
[fwupd]
# use `man 5 fwupd.conf` for documentation
EspLocation=/boot/efi
EOF
chmod 640 "$PKG/etc/fwupd/fwupd.conf"
ports/core/boot/fwupd/build.sh, lines 49–54
/boot/efi is where the installer mounts the ESP of an installed system, in the fstab it writes (src/system/kinstall-core/install.c):
if (esp_uuid[0]) {
char l[256];
snprintf(l, sizeof(l),
"UUID=%s\t/boot/efi\tvfat\tdefaults,umask=0077\t0 2\n",
esp_uuid);
cat(fst, sizeof(fst), l);
src/system/kinstall-core/install.c, lines 2946–2951
fwupd asks udisks for the ESP. When udisks names none, the recipe’s patch describes the FAT filesystem mounted at EspLocation itself, from sysfs and the udev database; a path that is not a FAT mount point is refused, so a machine with nothing mounted there has no ESP rather than a wrong one (ports/core/boot/fwupd/esp-mount-path.patch, first hunk):
--- a/libfwupdplugin/fu-context.c
+++ b/libfwupdplugin/fu-context.c
@@ -2010,6 +2010,19 @@
/* nothing found */
if (priv->esp_volumes->len == 0) {
g_autoptr(GPtrArray) devices = NULL;
+ g_autofree gchar *esp_location = fu_context_get_config_str(self, "EspLocation");
+
+ /* no udisks: a configured ESP mount point is described from sysfs */
+ if (esp_location != NULL && esp_location[0] != '\0') {
+ g_autoptr(GError) error_mnt = NULL;
+ g_autoptr(FuVolume) vol =
+ fu_volume_new_esp_from_mount_path(esp_location, &error_mnt);
+ if (vol != NULL) {
+ fu_context_add_esp_volume(self, vol);
+ return g_ptr_array_ref(priv->esp_volumes);
+ }
+ g_debug("EspLocation %s: %s", esp_location, error_mnt->message);
+ }
/* check if udisks2 is working */
devices = fu_common_get_block_devices(error);
ports/core/boot/fwupd/esp-mount-path.patch, lines 1–22
The remotes
Where metadata comes from is a set of remotes. The one KDOS enables is kdos-snapshot, a local remote that reads the LVFS metadata the release carries, from fs/usr/share/fwupd/remotes.d/kdos-snapshot.conf:
# The LVFS firmware metadata as of this KDOS release, offline.
#
# A local remote: fwupd reads the metadata file below and downloads nothing
# to list what firmware applies, so Discover's Updates page and
# `fwupdmgr get-updates` answer with no network. The file is the LVFS's own
# firmware.xml.zst, taken by ports/fwupd-snapshot on the day of the release,
# checked against the LVFS signature beside it, and installed by the
# fwupd-snapshot package; it is as current as the release that carries it.
#
# A cabinet is fetched from FirmwareBaseURI when somebody installs an update,
# and fwupd checks it against the hash this metadata records before flashing.
#
# The LVFS download remote ships disabled (fwupd's -Dlvfs=disabled): an
# enabled download remote is refreshed by Discover's firmware backend every
# time Discover starts. `fwupdmgr enable-remote lvfs` turns live metadata on,
# and OrderAfter lets it win over this snapshot once it has been fetched.
# ---------------------------------
[fwupd Remote]
Enabled=true
Title=KDOS firmware snapshot (Linux Vendor Firmware Service)
MetadataURI=file:///usr/share/fwupd/remotes.d/kdos-snapshot/firmware.xml.zst
FirmwareBaseURI=https://fwupd.org/downloads
PrivacyURI=https://lvfs.readthedocs.io/en/latest/privacy.html
OrderAfter=lvfs
ApprovalRequired=false
AutomaticReports=false
AutomaticSecurityReports=false
fs/usr/share/fwupd/remotes.d/kdos-snapshot.conf
Nothing in the system downloads metadata on its own: there is no refresh timer, and the LVFS’s own download remote, /etc/fwupd/remotes.d/lvfs.conf, is installed switched off:
-Dlvfs=disabled \
ports/core/boot/fwupd/build.sh, lines 43–43
Discover’s firmware backend refreshes every enabled download remote each time it starts, so an enabled LVFS remote would be a download at every start of the software centre. Upstream’s vendor-directory remote, for firmware a vendor package drops under /usr/share/fwupd/remotes.d/vendor/firmware, stays enabled; lvfs-testing and lvfs-embargo stay off. Installing an update fetches its cabinet from FirmwareBaseURI, a download somebody started. The build turns off Passim, so nothing is fetched from or shared with other machines on the local network, and the peer-to-peer policy is none:
-Dpassim=disabled \
-Dp2p_policy=none \
ports/core/boot/fwupd/build.sh, lines 27–28
The EFI loader
fwupd-efi builds the capsule loader with a KDOS SBAT entry:
meson setup build --prefix=/usr --libdir=lib --buildtype=release \
-Dgenpeimg=disabled \
-Defi_sbat_distro_id=kdos \
-Defi_sbat_distro_summary=KDOS \
-Defi_sbat_distro_pkgname=$name \
-Defi_sbat_distro_version=$version-$release \
-Defi_sbat_distro_url=https://kdos.dev/
ports/core/boot/fwupd-efi/build.sh, lines 12–18
It is unsigned. KDOS requires Secure Boot to be off in any case; see Known gaps.
UEFI variables
A capsule update is armed through a UEFI variable, and fwupd reads the firmware’s own update table (the ESRT) through /sys/firmware/efi. rcS mounts efivarfs on every UEFI boot (fs/etc/init.d/rcS):
# efivarfs is not in fstab because it exists only on a UEFI boot, and a BIOS
# boot would fail the line. Without it /sys/firmware/efi/efivars is an empty
# directory: efibootmgr reports no EFI variables, the installer cannot write
# its NVRAM boot entry or see Secure Boot, fwupd has no UEFI devices, and
# kdos-bootctl can neither arm an update's BootNext trial nor, in mark-good,
# clear one.
if [ -d /sys/firmware/efi/efivars ] && ! mountpoint -q /sys/firmware/efi/efivars; then
mount -t efivarfs -o nosuid,nodev,noexec efivarfs /sys/firmware/efi/efivars
fi
fs/etc/init.d/rcS, lines 131–139
Usage
Reading needs no privilege: fwupdmgr get-devices, get-remotes, get-updates, get-history and security answer any account. polkit answers everything that changes something from the caller’s elogind session, by fwupd’s policy defaults and /etc/polkit-1/rules.d/50-kdos.rules. That rule sorts before fwupd’s own and holds the unsigned system firmware flash, org.freedesktop.fwupd.update-internal, at an administrator’s password even at the machine. Signed firmware, the system’s (update-internal-trusted) or a device’s (update-hotplug-trusted), keeps fwupd’s own answer: anybody at the machine installs it with no password, which is how Discover installs what the LVFS lists. Downgrading signed firmware still asks. Plasma’s authentication agent asks for a password where one is needed, in Discover and for fwupdmgr in Konsole alike. A command from an SSH login or another account with no session at the machine runs with sudo. See sudo, PAM and polkit. Listing needs no network; installing an update fetches its file from the LVFS.
Every fwupdmgr command on a machine with no ESP mounted, the live medium among them, starts with WARNING: UEFI ESP partition not detected or configured, and every one on KDOS with WARNING: This package has not been validated, it may not work properly., fwupd’s notice for a build its upstream has not validated. Neither stops the command.
Seeing what fwupd can update
fwupdmgr get-deviceslists every device fwupd recognises, its current firmware version, and whether it can be updated. Devices it can only identify, such as a virtual DVD drive or the processor’s microcode version, are listed too, with no Updatable flag.fwupdmgr get-remoteslists the remotes and whether each is enabled.
Updating
From the desktop, Discover’s Updates page lists a device’s newer firmware beside the other updates, with the vendor’s release notes, and installs it. From a terminal:
fwupdmgr get-updateslists the newer firmware the snapshot names for these devices, with the vendor’s release notes. With nothing updatable it saysNo updatable devicesand exits 2.fwupdmgr updatedownloads and applies it, device by device, and asks for confirmation.- While a device is being flashed, fwupd holds an elogind shutdown and sleep inhibitor, so a power-off or suspend asked for meanwhile waits for it.
- A device updated while running, such as a dock, an SSD or a USB device, is done when the command returns; some ask to be unplugged or the machine restarted.
- System firmware is staged, not applied: fwupd writes the capsule to the ESP under
EFI/kdos/fw/(orEFI/UpdateCapsule/), copiesfwupdx64.efitoEFI/kdos/and sets a one-timeBootNext.fwupdmgroffers to restart the machine itself, through elogind; or reboot from the desktop. That boot runsfwupdx64.efi, which hands the capsule to the firmware;BootNextlasts one boot, so the boot after it is the ordinary one, through Limine. - After the reboot,
fwupdmgr get-historyshows whether the update succeeded; before any update it saysNo history.
Step 5 has not been carried out on any machine; see Known gaps.
Reading the host security report
fwupdmgr security prints fwupd’s Host Security ID report: which platform protections the firmware and the processor have turned on. fwupd is built with this report enabled. In a virtual machine it prints only HSI unavailable for unprivileged hypervisor and exits 1.
Firmware published since the release
The snapshot is as current as the release. To list firmware the LVFS has published since:
sudo fwupdmgr enable-remote lvfs. The LVFS remote then outranks the snapshot, and Discover refreshes its metadata each time it starts.fwupdmgr refresh, to fetch it now.
sudo fwupdmgr disable-remote lvfs goes back to the snapshot alone.
The live medium and an installed system
The live medium mounts no ESP, so fwupd offers nothing that needs one: only devices updated over their own bus, such as USB devices and docks. There sudo fwupdtool esp-list says No ESP or BDP found and exits 3. An installed system booted through UEFI has the ESP at /boot/efi, and capsule updates are offered there too. A machine booted through BIOS has no UEFI variables and no ESRT, so it has no capsule updates at all.
Tips
sudo fwupdtool esp-listprints the ESP fwupd found, which is the quickest way to see that theEspLocationroute works on this machine.- A device whose vendor does not publish to the LVFS is not listed by
get-updates, however old its firmware is, and neither is firmware published after the release while the LVFS remote is off. kdos doctorchecks the setuid bit ofdbus-daemon-launch-helper; without it the system bus cannot start fwupd at all.- fwupd writes nothing into Limine’s configuration, and the recipe removes the GRUB hook it would otherwise install (see Installation).
Troubleshooting
fwupdmgr cannot connect to the daemon. The bus failed to start it.
- Run
kdos doctorand look for thedbus-daemon-launch-helperline in its Desktop section. A missing setuid bit, or the wrong group, stops every bus-started system service. - Check the system bus:
service status dbus. - Run the engine without the daemon:
sudo fwupdtool get-devices. If that works, the problem is the activation, not fwupd.
fwupdmgr says Failed to obtain auth. The command changes something (refresh, update, enable-remote and the like) and polkit refused it because no administrator’s password was given: the prompt was cancelled, the password typed was not an administrator’s (a member of wheel), or the command ran outside the session at the machine, where no agent can ask. Run it with sudo.
No UEFI device is listed on an installed machine.
findmnt /boot/efi: the ESP must be mounted there.findmnt /sys/firmware/efi/efivars:rcSmounts it on a UEFI boot. No output on a machine that booted through UEFI (/sys/firmware/efiexists) means the mount failed; mount it by hand with the line fromrcSabove.ls /sys/firmware/efi/esrt/entries: no entries means the firmware publishes nothing fwupd can update.sudo fwupdtool esp-list: no ESP here means the patched lookup did not describe the mount; check that/etc/fwupd/fwupd.confstill saysEspLocation=/boot/efi.
The capsule was staged but nothing happened at reboot. Check that Secure Boot is off in firmware setup; with it on, the firmware refuses to start the unsigned fwupdx64.efi. Then sudo fwupdmgr get-history for fwupd’s record of the attempt.
get-updates says there is no metadata. fwupdmgr get-remotes shows whether kdos-snapshot is enabled; its files are in /usr/share/fwupd/remotes.d/kdos-snapshot/, which the fwupd-snapshot package installs.
Known gaps
- A UEFI firmware (capsule) update has not been applied
- Secure Boot is not supported
- Broad hardware support is not a goal
See also
- Thunderbolt, phones, smart cards and firmware updates: fwupd, the ESP route and the loader
- Where the kernel is kept: what fwupd writes on the ESP
- sudo, PAM and polkit: who is asked for a password, and where
- Offline by construction: why nothing refreshes the metadata on its own
- Microcode and firmware: the firmware files drivers load, and CPU microcode
- Boot menu and kernel parameters: the Limine menu the boot after a staged capsule returns to