Say you make a system/gadget with a Pi and a bunch of sensors that the Pi gathers data from. Is the software on the Pi reading the data count as firmware? or the Raspbian OS itself?
1 Answer
I would say no, although the concept is I think abstract enough that depending on the specifics of the context it might be considered such -- why and when to use such a label may be more about convention rather than any strict legal definition. A defining characteristic might be considered the fact that firmware often operates from non-volatile memory (NVM), that is, memory which "can retain stored information even after power is removed", but while "historically, firmware were [sic] built-into the device's ROM or Flash memory", this is not necessarily the case today (see comments below for examples), and while NVM categorically includes storage (such as an SD card), code that resides on storage (such as the entire OS) is generally not firmware: Another provisional distinction or definition of firmware vs. software might be that software is loaded into system RAM and executes from there under the supervision of the operating system, while firmware is more likely to be loaded into a device's own memory and run by it largely independent of, although of course in service to, the operating system. For normal software, the kernel is intermediary between it and any hardware, a sort of inversion of this role (firmware services the kernel, the kernel services userland software).1
Drivers are kernel space code that (amongst other things) may load firmware (eg., on linux, the stuff in /lib/firmware
) from storage into a device's own RAM (eg. graphics cards) or NVM. What does set firmware apart is that it probably does not run from system RAM, since this would make it dependent on the OS kernel and the various pitfalls of a multi-tasking environment (while devices that can exploit direct memory access may use firmware to do it, I think the system RAM would be used to hold data more than code).
However, on the Pi the GPU firmware is stored on the boot partition of the SD card, which is initialized by the GPU and the code run from GPU memory -- which of course is just a share of the board RAM, although since that is a hardware configuration set before the OS boots, the GPU portion would not really be "system memory".
- This definition would exclude userland code that reads sensors via the system (including the use of
mmap
, which is what Pi-specific GPIO libraries usually do) from being considered "firmware".
-
1I disagree with your definition; if a hardware peripheral loads code from NVM into RAM and then executes it, most would definitely still consider that firmware. In fact, since NVM is costly, it has become very common for devices to not carry their own firmware; it must be loaded by a driver on power-up, or the device will not work. Wifi hardware is a good example of this: on Linux, you need to ensure the firmware packages are installed so it can be loaded on the wifi card by the driver. Without that, it simply won't work.– marcelmCommented Nov 27, 2020 at 0:07
-
1Other examples include AMD and NVidia GPUs, and - for some functionality, Intel CPUs. This answer is also a good overview of the situation. And finally, you say the Raspberry Pi GPU firmware is loaded onto the GPU's NVM, but the GPU firmware proper (
start.elf
) is only loaded half-way through the boot process from the SD card, into GPU RAM. See also this thread.– marcelmCommented Nov 27, 2020 at 0:09 -
1Finally, you seem to be using Wikipedia for your definition, but nowhere on that page can I find the requirement that firmware execute from NVM. In fact, further down that same article agrees with my point of view: "Some low-cost peripherals no longer contain non-volatile memory for firmware, and instead rely on the host system to transfer the device control program from a disk file or CD."– marcelmCommented Nov 27, 2020 at 0:14
-
1
-
@marcelm I appreciate you taking the time to point out my naivete -- I would not claim to be an expert on the topic of hardware mechanics. I've re-worked this a fair bit to reflect what you've said; it would be great if you have a few minutes to read it again to make sure I haven't fudged any details too grotesquely (eg., my assertion that firmware may be loaded into a device's own RAM but is unlikely to run from the system RAM itself). Or, as Ghanima suggests, to write an answer of your own.– goldilocks ♦Commented Nov 27, 2020 at 19:07