41

I'm being confused by the use of firmware in the context of Linux.

My understanding of firmware & driver is that firmware is the code that runs on the bare metal of a device such as a Bluetooth IC, or keyboard controller, or video card, or a single-purpose micro-controller. The firmware exposes an interface for the OS to use its services.

The driver, in comparison, is the software that the kernel uses to communicate with previously mentioned interfaces provided by the firmware. Thus, a video driver, a keyboard driver, a bluetooth radio driver.

So why is it that I keep reading about Linux firmware files having to be installed (e.g. here). Do these get uploaded into the hardware? Are these files used by the kernel? What is the meaning of firmware in this context?

AdminBee
  • 21,637
  • 21
  • 47
  • 71
wopwop
  • 513
  • 1
  • 4
  • 4
  • 1
    Generally speaking: Software is a program. Hardware is a physical device. Firmware is a program integrated _into_ hardware; typically for the purposes of configuring how the hardware works (so it is sort of between software and hardware, just as 'firm' is between 'soft' and 'hard' on a scale of bluntless). Generally, firmware is OS-agnostic (for example, the RAID configuration on an SCSI RAID controller). – DopeGhoti Apr 19 '17 at 17:27
  • Just to add to DopeGhoti's comment, many devices now allow live firmware loading making them more flexible/evolutive than fixed implementations. – Julie Pelletier Apr 19 '17 at 17:37
  • 1
    @DopeGhoti it doesn’t just configure the hardware, it runs on the hardware. Some firmware is very complex indeed and basically runs a mini-OS. – Stephen Kitt Apr 19 '17 at 17:53
  • I agree, though I would assert that "software integrated into hardware" implies that the hardware is that upon which said software runs. (: – DopeGhoti Apr 19 '17 at 18:20

1 Answers1

50

In the Linux kernel context, firmware is software which runs on another processor in the system, e.g. a wireless controller, a GPU, a SCSI controller... This software used to be stored in ROM (of various types) attached to the relevant controller, but to reduce costs and make upgrades simpler, controllers now tend to rely on the host operating system to load their firmware for them.

So firmware files aren’t used by the kernel, they’re loaded by the kernel onto other pieces of hardware. This is also what makes it vaguely acceptable to have software without source code in FLOSS systems: the argument goes that it’s not running on the main CPU but on another device.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
  • 1
    You are being very benevolent with your use of "vaguely acceptable". – Rui F Ribeiro Apr 19 '17 at 20:01
  • 3
    Not everyone can be RMS. – DopeGhoti Apr 19 '17 at 20:37
  • 2
    That's not just in the Linux kernel context, it's a fairly general definition of “firmware” in the context of a multi-processor system. – Gilles 'SO- stop being evil' Nov 27 '17 at 07:40
  • So does **/etc/lib/firmwares** actually contain firmwares and *not* **drivers** loaded by the kernel at boot? But wireless controller and graphic cards have their own ROM with a firmware burned by the manufacturer. – defalt Nov 27 '17 at 08:10
  • 5
    @defalt yes, `/lib/firmware` (singular, no `/etc`) contains firmware used by other devices. Many devices (including wireless controllers and GPUs) need firmware provided by the host system, even though they may have their own ROM (or flash) containing firmware. – Stephen Kitt Nov 27 '17 at 08:12
  • 2
    Upvoted for clarity. Though I'd suggest saying "generally runs" in the first sentence as some firmware is executed by the CPU itself, e.g.,CPU microcode and the system firmware for the PC platform, BIOS and its successor UEFI. – Anthony Geoghegan Jan 21 '18 at 20:07
  • 1
    @Anthony thanks! I’d argue that, *in the context of the question*, BIOS/UEFI firmware isn’t covered (since the kernel never loads it). Microcode is an interesting issue though — it’s not quite like other types of firmware, but it’s loaded by the kernel using the same code paths as device firmware... – Stephen Kitt Jan 21 '18 at 22:08
  • For the sake of completeness: to manage firmware [in Linux we use Fwupd](https://www.addictivetips.com/ubuntu-linux-tips/update-computer-firmware-in-linux/), in Ubuntu we have an extra [client tool fwupdmgr](http://manpages.ubuntu.com/manpages/bionic/man1/fwupdmgr.1.html) – loved.by.Jesus Nov 18 '20 at 13:03
  • @loved that’s not quite the same firmware as discussed in this question; the question concerns firmware which is handled by the kernel. `fwupd` updates firmware in flash chips in devices. – Stephen Kitt Nov 18 '20 at 13:30
  • @StephenKitt That's quite confusing for non-experts. Could you give a link? Would it be appropriate to add an explanation to your answer? – loved.by.Jesus Nov 18 '20 at 17:47