397. Microcode and firmware
Much hardware will not work properly until the operating system hands it a binary file supplied by its maker. This page is for anyone whose Wi-Fi, sound or graphics card comes up without one, or who wants to check that their processor is running current microcode. It covers CPU microcode (the processor’s own correction patches, loaded at every boot), the firmware files drivers load, the Intel audio DSP (digital signal processor) firmware, the wireless regulatory database, and firmware updates for the devices themselves through fwupd. It says which port provides each, where each lands, how to check that the machine is using it, and what to do when a device comes up without it. Why microcode is carried the way it is, and what the early loader requires, is explained in Microcode; the firmware choices are in Hardware.
Installation
| Port | Provides | Where it lands |
|---|---|---|
| intel-ucode | Intel CPU microcode, as one bundle | /usr/lib/firmware/intel-ucode.bin |
| linux-firmware | Upstream’s firmware tree, zstd-compressed, less the families no x86 kernel loads, as eight vendor ports: firmware-intel, firmware-amd (AMD CPU microcode is part of it), firmware-mediatek and firmware-realtek on the image, firmware-nvidia, firmware-qualcomm, firmware-broadcom and firmware-misc one sudo kdos firmware sync away |
/usr/lib/firmware/, with AMD’s microcode under amd-ucode/ |
| firmware-map | Which vendor port ships each firmware file, for kdos firmware sync |
/usr/share/kdos/firmware-map |
| sof-firmware | Intel Sound Open Firmware: the audio DSP firmware and its topology files | /usr/lib/firmware/intel/ |
| wireless-regdb | The signed table of radio channels and power levels per country | /usr/lib/firmware/regulatory.db and regulatory.db.p7s |
| fwupd | fwupdmgr and the daemon that updates device firmware from the LVFS |
/usr/bin/fwupdmgr, /etc/fwupd/ |
| fwupd-efi | The EFI program that hands a UEFI capsule to the firmware at the next boot | Placed on the ESP by fwupd when it stages an update |
/lib is a link to /usr/lib on KDOS, so the two spellings name the same files. All of these but the four vendor ports left off the image are installed on it. None of them has a service script: the kernel reads firmware files when a driver asks, the microcode is read before any filesystem exists, and fwupd is started by the system bus on first use.
The microcode does not reach the processor from /usr/lib/firmware. The image build copies it into the front of the initramfs, uncompressed, which is the only place the kernel’s early loader looks; late loading is off in the kernel.
Configuration
Microcode
The Intel bundle is the concatenation of upstream’s intel-ucode/ directory. The recipe then walks it record by record and stops the build when a record’s header is not microcode or a record runs past the end of the file:
install -d "$PKG/usr/lib/firmware"
cat intel-ucode/* > "$PKG/usr/lib/firmware/intel-ucode.bin"
chmod 644 "$PKG/usr/lib/firmware/intel-ucode.bin"
_bundle="$PKG/usr/lib/firmware/intel-ucode.bin"
_end=$(stat -c %s "$_bundle")
_off=0
_n=0
while [ "$_off" -lt "$_end" ]; do
_hdr=$(od -An -tu4 -j "$_off" -N 40 -v "$_bundle")
set -- $_hdr
if [ "$1" != "1" ]; then
echo "ERROR: intel-ucode: record at $_off is not microcode" >&2
exit 1
fi
_size=$9
[ "$8" = "0" ] && _size=2048
if [ "$_size" -le 0 ] || [ $((_off + _size)) -gt "$_end" ]; then
echo "ERROR: intel-ucode: record at $_off runs past the bundle" >&2
exit 1
fi
_off=$((_off + _size))
_n=$((_n + 1))
done
echo "intel-ucode: $_n microcode records, $_end bytes, walk ends clean"
install -Dm644 license "$PKG/usr/share/licenses/$name/LICENSE"
ports/core/boot/intel-ucode/build.sh
The image build turns both vendors’ files into the uncompressed archive the early loader scans (script/phases/70_image/090_initramfs.sh):
# ---------------------------------------------------------------------------
# CPU microcode
# ---------------------------------------------------------------------------
# The early loader runs before the initramfs is decompressed and before any
# filesystem exists: it scans the raw initrd image for the literal paths
# kernel/x86/microcode/{GenuineIntel,AuthenticAMD}.bin. Three consequences,
# and getting any one wrong means the microcode is silently never applied:
#
# - this cpio must NOT be compressed, and the blobs inside it must not be
# either, whatever form linux-firmware ships them in: the early loader
# cannot decompress. A `.bin` is copied as it is and a `.bin.zst` is
# expanded on the way in.
# - it must come FIRST in the file, ahead of the gzipped part.
# - CONFIG_MICROCODE_LATE_LOADING is off, so this is the only path there is.
# /usr/lib/firmware/intel-ucode.bin is never read at runtime.
#
# A vendor whose microcode is installed and yields an empty file stops the
# build. An initramfs without microcode boots with no symptom, so nothing
# later would notice.
UCODE=/kdos/build/ucode
rm -rf $UCODE
mkdir -p $UCODE/kernel/x86/microcode
if [ -f /usr/lib/firmware/intel-ucode.bin ]; then
cp /usr/lib/firmware/intel-ucode.bin \
$UCODE/kernel/x86/microcode/GenuineIntel.bin
if [ ! -s $UCODE/kernel/x86/microcode/GenuineIntel.bin ]; then
echo "FATAL: /usr/lib/firmware/intel-ucode.bin is empty." >&2
exit 1
fi
echo "Microcode: Intel bundle carried"
elif [ -f /var/lib/kpkg/db/intel-ucode ]; then
echo "FATAL: intel-ucode is installed but /usr/lib/firmware/intel-ucode.bin is not." >&2
exit 1
else
echo "Microcode: no intel-ucode.bin — Intel CPUs will run BIOS microcode"
fi
# One AMD container per family, concatenated in the order the shell sorts them;
# the loader walks the containers and matches on the equivalence table.
if [ -d /usr/lib/firmware/amd-ucode ]; then
for BLOB in /usr/lib/firmware/amd-ucode/microcode_amd*.bin \
/usr/lib/firmware/amd-ucode/microcode_amd*.bin.zst; do
[ -f "$BLOB" ] || continue
case "$BLOB" in
*.zst) zstd -d -c "$BLOB" >> $UCODE/kernel/x86/microcode/AuthenticAMD.bin ;;
*) cat "$BLOB" >> $UCODE/kernel/x86/microcode/AuthenticAMD.bin ;;
esac
done
if [ ! -s $UCODE/kernel/x86/microcode/AuthenticAMD.bin ]; then
echo "FATAL: /usr/lib/firmware/amd-ucode/ holds no microcode_amd*.bin or .bin.zst" >&2
echo " container, so AMD CPUs would run BIOS microcode." >&2
exit 1
fi
echo "Microcode: AMD containers carried"
else
echo "Microcode: no amd-ucode/ — AMD CPUs will run BIOS microcode"
fi
UCODE_CPIO=/kdos/build/ucode.cpio
rm -f $UCODE_CPIO
if [ -n "$(ls -A $UCODE/kernel/x86/microcode)" ]; then
( cd $UCODE && find . | LC_ALL=C sort | cpio -o -H newc --reproducible ) \
> $UCODE_CPIO 2>/dev/null
fi
script/phases/70_image/090_initramfs.sh, lines 1608–1672
Device firmware
linux-firmware is installed with upstream’s own script, so the alias links drivers ask for exist, and then the firmware for hardware an x86 kernel cannot drive is removed. Every vendor port runs the same build.sh, which gives each file and link to one vendor by its path (a link by the file it resolves to) and keeps its own share; firmware-map records the whole split instead:
fw_vendor() {
case "$1" in
i915/* | xe/* | intel/* | iwlwifi-* | qat_* | isci/*) vendor=intel ;;
amdgpu/* | radeon/* | amd/* | amd-ucode/* | amdnpu/* | amdtee/* | r128/*) vendor=amd ;;
nvidia/*) vendor=nvidia ;;
rtl_bt/* | rtl_nic/* | rtlwifi/* | rtw88/* | rtw89/* | realtek/*) vendor=realtek ;;
mediatek/* | rt[0-9]*) vendor=mediatek ;;
brcm/* | cypress/* | bnx2/* | bnx2x/* | tigon/*) vendor=broadcom ;;
ath[0-9]*/* | ath3k-* | ar3k/* | ar5523.* | ar7010* | ar9170-* | ar9271.* | carl9170-* | htc_* | qca/* | qcom/* | wil6210.*) vendor=qualcomm ;;
*) vendor=misc ;;
esac
}
fw="$SRC_ROOT/firmware"
rm -rf "$fw"
./copy-firmware.sh --zstd "$fw"
find "$fw/qcom" -mindepth 1 -maxdepth 1 \
! -name aic100 ! -name aic200 ! -name qdu100 ! -name 'sdx*' ! -name 'prog_firehose_*' \
-exec rm -rf {} +
find "$fw/mellanox" -name 'mlxsw_spectrum*.mfa2*' \
! -name 'mlxsw_spectrum-13.2010.1006.mfa2*' \
! -name 'mlxsw_spectrum2-29.2010.1006.mfa2*' \
! -name 'mlxsw_spectrum3-30.2010.1006.mfa2*' \
-exec rm -f {} +
rm -f "$fw"/mrvl/prestera/mvsw_prestera_fw-v2.0.img* "$fw"/mrvl/prestera/mvsw_prestera_fw-v3.0.img*
while IFS= read -r l; do
case "$(readlink "$l")" in
qcom/*) [ -e "$l" ] || rm -f "$l" ;;
esac
done < <(find "$fw" -maxdepth 1 -type l)
dangling=0
while IFS= read -r l; do
[ -e "$l" ] || { echo "dangling firmware symlink: $l" >&2; dangling=$((dangling + 1)); }
done < <(find "$fw" -type l)
if [ "$dangling" -ne 0 ]; then
echo "ERROR: $dangling dangling firmware symlink(s)" >&2
exit 1
fi
ports/core/boot/firmware-map/build.sh, lines 12–51
The SOF firmware and topologies, without which an Intel DSP loads and makes no sound:
install -dm755 "$PKG/lib/firmware/intel"
for d in sof sof-tplg sof-ipc4 sof-ipc4-lib sof-ipc4-tplg sof-ace-tplg; do
[ -e "$d" ] && cp -a "$d" "$PKG/lib/firmware/intel/"
done
ports/core/boot/sof-firmware/build.sh, lines 12–16
The regulatory database and the country
The database is rebuilt from upstream’s db.txt and checked against upstream’s signature, because the kernel loads regulatory.db only when a valid regulatory.db.p7s sits beside it:
[ -f regulatory.db.p7s ] || { echo "regulatory.db.p7s missing — an unsigned db is the same as no db"; exit 1; }
python3 db2fw.py regulatory.db.built db.txt
ca=()
for cert in sforshee.x509.pem wens.x509.pem; do
[ -f "$cert" ] && ca+=("$cert")
done
[ ${#ca[@]} -gt 0 ] || { echo "no upstream signing certificate in the tarball"; exit 1; }
cat "${ca[@]}" > regdb-ca.pem
openssl smime -verify -binary -inform DER \
-in regulatory.db.p7s -content regulatory.db.built \
-CAfile regdb-ca.pem -purpose any -out /dev/null ||
{ echo "regulatory.db built from db.txt does not match upstream's signature"; exit 1; }
install -dm755 "$PKG/lib/firmware"
install -m644 regulatory.db.built "$PKG/lib/firmware/regulatory.db"
install -m644 regulatory.db.p7s "$PKG/lib/firmware/regulatory.db.p7s"
ports/core/boot/wireless-regdb/build.sh, lines 12–30
The country is a module option, /etc/modprobe.d/kdos-regdom.conf. No file in fs/ ships it; the installer writes it from the time zone you choose, and kdos-settingsd, which serves org.freedesktop.timedate1, writes it whenever the time zone is set, from System Settings’ Date & Time page or timedatectl-style clients, as a two-letter code taken from zone.tab, from src/daemons/kdos-settingsd/store.c:
if (!zone_country(zone, cc)) {
unlink(reg);
return 0;
}
if (ks_etc_path(dir, sizeof(dir), "modprobe.d"))
kb_mkdir_p(dir);
snprintf(body, sizeof(body),
"# Written by kdos-settingsd from the timezone (%s): the country\n"
"# the Wi-Fi radio's channels and transmit power are set for.\n"
"options cfg80211 ieee80211_regdom=%s\n", zone, cc);
/* The regulatory domain is the radio's, and a machine with no radio
* still has a time zone: failing here does not fail the zone. */
kb_write_file_atomic(reg, body);
src/daemons/kdos-settingsd/store.c, lines 1003–1015
A zone with no country, such as UTC, removes the file and returns the running radio to the world domain, 00. On a machine installed with the zone Europe/Berlin, the file reads:
# Written by the KDOS installer from the timezone (Europe/Berlin):
# the country the Wi-Fi radio's channels and transmit
# power are set for.
options cfg80211 ieee80211_regdom=DE
and after boot iw reg get begins global / country DE: DFS-ETSI, and on a machine with a wireless device kdos doctor reports [ ok ] regulatory.db signed and loaded (regdom DE).
fwupd
The recipe writes fwupd’s configuration, which tells it where the ESP 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
On the image this is /etc/fwupd/fwupd.conf (readable by root only), whose one setting is EspLocation=/boot/efi. Nothing refreshes the LVFS metadata on a schedule: fwupd lists firmware from the snapshot the release carries. Both are covered on Firmware updates.
Usage
Checking the microcode
- Run
kdos doctor. Its Kernel section reports whether the initramfs carries microcode for this processor’s vendor, as[ ok ] AMD microcode in the initrdor[ ok ] Intel microcode in the initrd, followed by(revision …)when the kernel exposes the running revision. - For the revision alone:
cat /sys/devices/system/cpu/cpu0/microcode/version. A virtual machine has no such file, and the doctor line then carries no revision. - For what the kernel did with it at boot:
dmesg | grep -i microcode. On real hardware the early loader prints the revision it applied; a virtual machine prints no loader line at all, only the CPU-bug lines that mention microcode, such asTransient Scheduler Attacks: Vulnerable: No microcode.
kdos doctor searches /boot/initramfs.cpio.gz, the image’s copy in the root. The copy an installed machine boots is the one in its slot’s directory on the ESP; to list its microcode archive, see Looking inside.
Getting newer microcode
The microcode the machine loads is the copy in the initramfs, and only the image build writes the base initramfs. Installing a newer intel-ucode or firmware-amd package updates /usr/lib/firmware and changes nothing the early loader reads; a kernel update appends modules to the same base. Newer microcode reaches the processor only through an image built from a tree that carries it: the live medium of that image loads it, and so does a machine installed from it.
A device that needs firmware
- Ask for the plan:
sudo kdos firmware sync --dry-run. It prints one line per vendor port the devices’ drivers or the kernel’s failed loads need, such asfirmware-qualcomm the kernel could not load ath11k/WCN6855/hw2.0/amss.bin, andsudo kdos firmware syncinstalls them, prebuilt. Withoutsudothe kernel log is not readable and only the drivers decide. The same plan is what the session’s notice names. - Look for the driver’s request:
dmesg | grep -i firmware. A missing file is named there. - Check that the file is installed:
ls /usr/lib/firmware/<path>*. Most files carry a.zstsuffix; the kernel reads compressed firmware itself. A file that is not:grep ' <path>$' /usr/share/kdos/firmware-mapnames the port that ships it. - Find the package that owns it:
kdos why /usr/lib/firmware/<path>.zst. It prints the package and version, and the recipe path, for examplepackage wireless-regdb 2026.09.03-1andrecipe /ports/core/boot/wireless-regdb/kpkgbuildforregulatory.db. - Run
kdos doctorfor the checks it makes of SOF audio firmware and of NVIDIA GSP firmware.
Setting the Wi-Fi country
Set the time zone, which sets the country with it: System Settings → Date & Time, or from a terminal
dbus-send --system --print-reply --dest=org.freedesktop.timedate1 \ /org/freedesktop/timedate1 org.freedesktop.timedate1.SetTimezone \ string:Europe/Berlin boolean:truekdos-settingsd asks polkit, which lets the person at the machine do it; it writes
/etc/modprobe.d/kdos-regdom.conf, headed# Written by kdos-settingsd from the timezone (Europe/Berlin), and runsiw reg setfor this boot, soiw reg getreadscountry DE: DFS-ETSIstraight away.To set a country for this boot only:
sudo iw reg set FR.Check:
iw reg getshows the country in force now.kdos doctorreads the country the kernel’scfg80211module was loaded with, which comes from the file, so it reports[ ok ] regulatory.db signed and loaded (regdom DE)from the next boot; until then, and after aniw reg setalone, it warns that the domain is00on a machine with a wireless device and reports[skip]on one with none.
On the live medium no time zone has been chosen, so the file is absent and the radio is on the world domain until you set one: iw reg get begins global / country 00: DFS-UNSET.
Updating device firmware
- See what the LVFS offers for this machine:
sudo fwupdmgr get-updates. - Apply it:
sudo fwupdmgr update. - Firmware for the system itself, shipped as a UEFI capsule, is staged on the ESP, which the recipe’s configuration names as
/boot/efi, and is applied at the next boot.
The live medium mounts nothing at /boot/efi, so a capsule cannot be staged from it. No capsule update has been staged and booted (Known gaps).
Tips
- An initramfs without microcode has no symptom: the processor keeps the revision the firmware loaded.
kdos doctoris the check. - The image build stops when a vendor’s microcode is installed and yields nothing, and prints
Microcode: no …and carries on when a vendor’s source is absent altogether. Read those lines in the initramfs step’s log on the build machine,build/logs/70_image/<N>_initramfs.sh.log, when a doctor warning appears; a build that carried both printsMicrocode: Intel bundle carriedandMicrocode: AMD containers carried. - On a machine without the hardware, as in a virtual machine,
kdos doctorstill checks that the files are installed: it reports[ ok ] SOF firmware installed (no SOF audio device here)and the same for NVIDIA GSP firmware, and[skip]for the regulatory database when there is no wireless device and the kernel’scfg80211module has not been loaded with a country. regulatory.db.p7smust sit besideregulatory.db. Without the signature the kernel ignores the database.
Troubleshooting
kdos doctor: the initrd carries no Intel (or AMD) microcode. The image was built without that vendor’s files. Check the image phase’s log for the Microcode: lines from 090_initramfs.sh. On the machine there is nothing to repair; the next image carries it once the port is installed in the build.
No sound on an Intel laptop. kdos doctor names the case: an SOF device bound with /usr/lib/firmware/intel/sof absent, or the firmware present without sof-tplg. Check that the package is installed (ls /var/lib/kpkg/db/sof-firmware), then dmesg | grep -i sof for the file the driver asked for.
Wi-Fi finds no 5 GHz networks, or only some channels. The regulatory domain is 00. Run iw reg get; set the country as in Setting the Wi-Fi country. If kdos doctor says the signature is missing, the wireless-regdb package is damaged; reinstall it.
fwupdmgr finds no UEFI device. fwupdmgr get-devices then begins WARNING: UEFI ESP partition not detected or configured, and get-updates ends in No updatable devices. On the live medium that is expected. On an installed machine, check that /boot/efi is mounted (findmnt /boot/efi) and that rcS mounted efivarfs (findmnt /sys/firmware/efi/efivars); without it no firmware variable is visible.
A GPU, Wi-Fi or Bluetooth adapter comes up without its firmware. Run sudo kdos firmware sync, then read the file name from dmesg and check it as in A device that needs firmware. On the live medium a Qualcomm or Broadcom Wi-Fi card has no firmware until then, so the command needs Ethernet or a USB-tethered phone. A file that is absent although its vendor port is installed, and that kdos firmware sync --dry-run reports as one no port ships, is either one of the families the recipe leaves out, or newer than the upstream release the recipe pins.
Known gaps
linux-firmwareleaves out what an x86 kernel cannot load- The installation medium carries four vendors’ firmware
- A UEFI firmware (capsule) update has not been applied
kdos doctorcannot check hardware a machine does not have- Broad hardware support is not a goal
- Secure Boot is not supported, which also leaves
fwupdx64.efiunsigned
See also
- Microcode: the early loader and what it requires of the archive
- Firmware, Microcode and Thunderbolt, phones, smart cards and firmware updates
- kdos doctor and kdos firmware
- The initramfs and the rescue shell: looking inside an initramfs with the microcode archive in front
- Boot menu and kernel parameters: adding a kernel parameter for one boot or for every boot
- Updating: checking, fetching and applying an update, which installs newer firmware packages under
/usr/lib/firmware