8

As per my understanding, the firmware is what controls the hardware, and drivers interacts with the firmware to control the hardware. Is that correct?

In Linux, what are the APIs or functions which interact with the firmware? Is the firmware code independent of any OS (e.g. Linux or Windows)?

TemplateRex
  • 69,038
  • 19
  • 164
  • 304
foo_l
  • 591
  • 2
  • 10
  • 28

2 Answers2

8

Firmware is the software that runs on the device. A driver is the software that tells your operating system how to communicate with the device. All the devices having firmware are generally programed in to the device (either with a ROM chip, or a programmable ROM chip), but there are some devices where the firmware is loaded into the device at initialization time. Every device does not have the frimware.

  1. More technically "Firmware is software that is uploaded to a microprocessor or programmable logic on the hardware device itself. Examples of hardware that use firmware are HP printers that receive their code from the USB port at power up, wireless network interfaces that upload firmware at start up, routers that can update themselves from the internet, etc... In general, the ability to upload firmware to a device is a plus. it allows for product improvements to be added after the initial sale. These include fixing bugs in the product, responding to security issues, or responding to changes in the regulatory environment; Examples: FCC opening or restricting allowable bandwidths, power consumption, safety."
  2. In General: A driver is a kernel module that talks to hardware; firmware is software that runs on the hardware that talks to the driver.
Community
  • 1
  • 1
suneet saini
  • 592
  • 3
  • 16
  • "...firmware is software that runs on the hardware that talks to the driver." Can you please let me know how it talks to the driver? thanks. – foo_l Apr 22 '13 at 13:46
  • @foo_l there are numerous different ways, though there may sometimes be similarity between devices of the same make/family, or even sometimes between category of device across manufacturers. Still there are far too many possibilities to enumerate. – Chris Stratton Apr 22 '13 at 14:41
  • The `firmware` does more than talk to the driver. Often the *device* has a CPU and the `firmware` is the software that runs on the separate and completely independent CPU. One job is to communicate via *SPI*, *I2C*, *USB*, *PCI*, etc. Ie, some **BUS** as noted. The `firmware` maybe an **FPGA** gate list or configuration information and not *real* software at all. – artless noise Apr 22 '13 at 15:33
  • As in the first point "..Firmware is software that is uploaded to a microprocessor or programmable logic on the hardware device itself." It is based on the logic; firmware provides the Kernel level APIs through which a Device Driver can be designed. – suneet saini Apr 23 '13 at 06:39
1

This depends on the way of connection between device and PC. For PCI boards there is set of Linux kernel mode API. Another set of kernel mode API is used to communicate with device connected through USB port. For Ethernet and WiFi connection you can use sockets API, communication is done completely in user mode. Devices, connected through serial port are also handled with user-mode API - they are treated as files in the Linux OS.

Generally, device firmware does not depend on the host system OS. It depends, however, on the OS (if any) running on the device itself. Firmware code may be written in plain C without any OS, or running under real-time OS. Modern devices may contain full-featured OS like embedded Linux or Windows. In this case, the whole OS with the programs specific to this device, are considered device firmware. For example, Android OS for specific mobile device.

Alex F
  • 42,307
  • 41
  • 144
  • 212
  • Thanks for the reply. But still I could not understand the interaction between firmware and drivers. Can a driver work without a firmware? – foo_l Apr 22 '13 at 12:46
  • Your question is not clear. "Can a driver work without a firmware?". Driver can work without hardware at all - for example, file system driver. You need to narrow your question to some specific device class. – Alex F Apr 22 '13 at 12:51
  • Read this: http://lwn.net/Kernel/LDD3/ Chapter 9: Communicating with Hardware Chapter 10: Interrupt Handling – Alex F Apr 22 '13 at 14:21
  • 1
    Not all devices contain firmware - some may be nothing more than a few logic gates hanging off a bus. – Chris Stratton Apr 22 '13 at 14:39
  • @ChrisStratton - agree, I just try to answer the question about driver-firmware communication. – Alex F Apr 22 '13 at 14:41