29
\$\begingroup\$

When someone says they "flashed" firmware to a device, I'm curious as to what this actually implies.

  1. Is firmware just a native binary that is stored in memory and that can be interpreted by the device's CPU (like any other EXE on a computer)? Or is firmware just data that acts as input to an immutable program already hardcoded/wired onto the device?
  2. If the latter example isn't firmware, what would you call it? For instance, let's say a device has some binary (someapp.exe) on it, and you cannot remove or modify this binary. The binary, when ran, takes input from a memory chip. You can "flash" data to this chip, and thus affect the input/configuration of someapp.exe that will take affect the next time it runs. If not firmware, what would this be called?
\$\endgroup\$
17
  • 12
    \$\begingroup\$ This is a really good question. It's a nice break from the slew of "My toaster doesn't toast. Can I put an arduino in it?" questions. \$\endgroup\$ Jul 14, 2014 at 19:10
  • 17
    \$\begingroup\$ Well, this question would be good, if not the major flaw in it: code is data, and data can be code - as far as Von Neumann architecture/model is concerned. Thus, the whole question is in vain - since code can be (and, usually is) treated as data and vice versa; also, to OP: why not check en.wikipedia.org/wiki/Firmware ? it has the answer to this very question, and to many other things concerning firmware - thus, while it is a nice break from "Can I plug a 12V light bulb into 230V socket" questions, it's still sub-par in my book... \$\endgroup\$
    – user20088
    Jul 14, 2014 at 21:17
  • 2
    \$\begingroup\$ I'm pretty sure the answer here is "yes". \$\endgroup\$ Jul 15, 2014 at 6:12
  • 7
    \$\begingroup\$ Machine code is just data input to the immutable wiring of the CPU. \$\endgroup\$
    – user253751
    Jul 15, 2014 at 7:48
  • 2
    \$\begingroup\$ Is a book words or letters? \$\endgroup\$
    – Nick T
    Jul 16, 2014 at 14:34

9 Answers 9

27
\$\begingroup\$

As often with such definitions, we agree in most cases, but there is no really firm boundary between what is firmware and what isn't. Firmware is

  • stored permanently (except for some knowledgeable person who can change it ...)
  • not intended to be changed (except ...)
  • operates on the processor without the help of other software (except ... you get it?)

As to data that is interpreted by a (firmware) interpreter: this is not often done in a professional setting, because it makes the product more expensive: more memory, CPU power, etc. is needed to achieve the same end goal. It is however sometimes used in hobbyist setting, often with a Basic interpreter in flash, and a (tokenized) Basic application stored in eeprom (or in Flash too). Check for instance the PICAXE and the various Basic stamps.

IMO in such a setting both the Basic interpreter and the Basic application should be called firmware.


An interesting use of a firmware interpreter that interprets stored code (which should IMO be considered firmware too) is the XBOX 360 startup. This excellent talk describes it in some detail.


Below MSalters wonders whether FPGA code / configuration data should be considered firmware.

In the aspects that matter most (it is information that is changeable late in the production process, but it is not intended to be changed at will by the end user) FPGA bits behave like firmware. That makes the question whether it is firmware according to any definition moot. The important point is that it can (and should) be written, handled and managed like firmware. (If it walks and quacks like a duck, is it a duck?)

Don't bother with definitions when they are not useful. Is microcode firmware? Does representation matter? Does context matter? Are the ROM bits for an IWM firmware?


Vaxquis' comment to OP's question prompted me to read the wiki article he links to. IMO the definition of firmware given there (persistent memory and program code and data stored in it) is troublesome. IMO the maps stored in a car navigation system are data, not firmware, no matter how they are stored (according to the wiki they should be firmware). And the apps in your iPhone or Android phone are applications, not firmware (according to the wiki they too should be firmware).

\$\endgroup\$
2
  • \$\begingroup\$ I'm now wondering whether an FPGA program counts as firmware. Intuitively, yes, but it doesn't operate on a processor. And yet it's a classical case of bits which are halfway between code and data. \$\endgroup\$
    – MSalters
    Jul 16, 2014 at 8:26
  • \$\begingroup\$ The TI 99/4 computer (1979) included an interpreter in ROM for a language called GPL, and a BASIC interpreter written in GPL. An essential feature of GPL was that it could run code stored in GROM chips (which were designed for primarily-sequential access and could be made physically smaller and cheaper than random-access ROM) so the TI 99/4 may be viewed as a mass-market personal computer whose design is analogous to that of the BASIC stamp. \$\endgroup\$
    – supercat
    Sep 25, 2015 at 18:08
14
\$\begingroup\$

Firmware is program code that is stored in non-volatile memory, such as flash memory. The term is most often used in connection with embedded systems. It can be on the same chip as the processor, or on a separate device.

\$\endgroup\$
5
  • \$\begingroup\$ Thanks @Leon Heller (+1) - is there a name for the 2nd example above, where one is essentially "flashing" input data to a fixed binary on a chip? Or is this generally not practiced? Thanks again! \$\endgroup\$ Jul 14, 2014 at 19:07
  • \$\begingroup\$ It's just data. It can be stored in volatile or no-volatile memory. \$\endgroup\$ Jul 14, 2014 at 19:19
  • \$\begingroup\$ The term I would use for your #2 would be a "look-up table". An example I can think of would be sine function values used for a numerically-controlled oscillator. \$\endgroup\$
    – kjgregory
    Jul 14, 2014 at 19:55
  • 1
    \$\begingroup\$ @KGregory It can be a lookup table, it can be an interpreted program, it can be image data... \$\endgroup\$
    – glglgl
    Jul 14, 2014 at 21:32
  • \$\begingroup\$ @glglgl agreed. I might argue that those can be considered forms of look-up-table, but I think we are beside the point now. \$\endgroup\$
    – kjgregory
    Jul 15, 2014 at 15:00
9
\$\begingroup\$

I think both options are sort of correct, just looking at the microprocessor at different levels of abstraction. What you're referring to as your immutable binary would be the hardware itself, which is fairly limited in what it can do. Fetch instruction address 0x0000, decode instruction, fetch supplied address/register, execute, increment instruction counter. That's the microprocessor pipeline, and you can't change it. You control what the microcontroller does by storing instructions in memory, which are then sequentially read out. So basically, yes, firmware is just input data for an immutable program, at a low level of abstraction. Usually, though, it's easier to imagine the firmware as a special program that controls the microprocessor because conceptually it's easier that way.

\$\endgroup\$
2
  • \$\begingroup\$ Love this answer, +1, well done for emphasizing data and code are the same thing in the end. \$\endgroup\$
    – Vality
    Jul 16, 2014 at 10:49
  • \$\begingroup\$ They're the same for Von Neumann architecture, at least. Once you've got separate buses, you can start to argue that they're different things, although it's all just bits in the end. \$\endgroup\$ Jul 16, 2014 at 15:05
8
\$\begingroup\$

It is actually both.

One example of firmware is the PC BIOS, one section of the BIOS is executable but other parts of the BIOS itself is actually data, specifically in tables for display to enumerate different functions of a BIOS ROM, regardless of the type of technology it is based on. Often times the data is stored in either, another flash memory, battery or capacitor backed RAM either CMOS SRAM or another compatible memory chip technology.

Firmware, is a generic term used for unchanging / non volatile memory, it's there and accessible as per the power cycle for as long as there is nothing electrically wrong with the circuit or in the case of a programming cycle stuck on, for EEPROMs or Flash ROMs.

Firmware by definition, is the lowest level of access, that initializes, tests hardware you have installed in your system or embedded components and gives low level routines (sometimes seen as BIOS function calls) that your operating system needs to be able to use the components in your system. In the old days, the BIOS or Basic Input Output System also included a programming language called "BASIC", such as the Commodore 64 and other personal computers of the 1970s, of course there were older computers that had BASIC built into them for the use by professional computer scientists as well. If you ever hear of a character or symbol ROM that's a form of pure data for the executive or program ROM to get the system to go to that character ROM and look up characters in a sequence or dump the entire chip into RAM to work with it there.

The default PROM, EPROM, EEPROM, Flash programmers burn firmware on a chip as with the suffix of .hex or .bin, which are similar formats, it depends on your application you're using to send to the chip, the firmware.

Also, there are firmware blob files, these are executables in the form of libraries and routines that are loaded at run-time, a good example of that is wireless hardware drivers, they contain enough code to run all the hardware in those cards via your computer system. The only difference is the card and USB based firmware isn't actually store on them but on your hard disc and loaded into memory. It works as a translation service layer and filter, essentially. It is both data and code too.

My basis of this is that I actually write BIOSes for other computers and embedded systems (for example, wireless firmware, which is actually loaded when your operating system starts, then begins to load the low level hardware drivers, that also include run-time firmware). It's called firmware because it doesn't ever change it's routines unless you get an update from the manufacturer and then the update overwrites the old. Acts as the new firmware in this case until new stuff is found to be updated, if not, then that's the firmware you use when your operating system loads.

I agree, it shouldn't be called firmware because it's not technically on the chip as a permanent solutions and needs a special tool and application to up the firmware (in the case of the old BIOSes vs. that of flash memories).

Got any more questions, I'd be glad to answer them for you.

\$\endgroup\$
6
\$\begingroup\$

Firmware is code that has been made in some sort of development environment, just like software code, but then it gets boiled down to machine-code so that the cpu can understand it. If you dump the memory of a microcontroller or some other chip, you'll notice that it looks nothing like C code or what we program it in.

So you don't program a .EXE to it, since that is a compiled program to be run in some sort of OS environment. You'll be programming usually a .hex, or maybe a .elf, it really depends on the device you are programming, but it doesn't matter because you aren't concerned with the file-types since your compiler will instead compile the code down into machine code and place it in the chips on-chip flash or into whatever storage scheme it has.

Firmware is generally immutable in that environmental conditionals have to be programmed in. You cannot change firmware code and leave it be, you have to make the change, compile it, and re-flash the device.

  • Generally software code is code that is to be run on top of an operating system.
  • Firmware code is the information that is run on the bare metal of the chip. Firmware can either be the actual application program or it can be a simple operating system, that you can then load software onto through means of removable storage or flashing RAM in the embedded world. This level can go down all the way to binary code, because that is still code.
  • Once you start working directly with voltage, you have reached the hardware level.
\$\endgroup\$
2
  • 2
    \$\begingroup\$ "but then it gets boiled down to machine-code so that the cpu can understand it." Just like software code as well, as long as it is written in C or something alike. \$\endgroup\$
    – glglgl
    Jul 14, 2014 at 21:30
  • 1
    \$\begingroup\$ What the processors understand is, yes, binary but they have something called mnemomic operation codes (op codes, as it's seen in the industry) for those of us that still program in Assembly Language, which happens to be one step above Machine Language [Binary]). \$\endgroup\$
    – user49380
    Jul 15, 2014 at 17:41
0
\$\begingroup\$

Firmware is a generic term that generally is used to specify something that lives halfway between the software world and the hardware world.

Hardware is difficult to change. Software is easy to change. Firmware isn't as hard to change as hardware, but is harder to change than software.

It could be used to discuss executable code, data, or configuration information (as in FPGA/PLD/etc) which can be changed.

\$\endgroup\$
1
  • \$\begingroup\$ In a broad sense of the word and definition that's true. Although, those chips aren't actually code nor data. The compiler when complete creates logical designs, as either complete solutions or glue logic to piece different parts of a system together. Instead of using physical 74 and 54 series logic gates and registers to make a solution. I am actually glad you brought this up, Adam. \$\endgroup\$
    – user49380
    Jul 16, 2014 at 17:25
0
\$\begingroup\$

To explain more of what firmware is from the inside sense.

Firmware, is code that executes on very specific hardware, meaning it's op codes are specific to the hardware it's written for, it can be a family of chips or interfaces or meant for just one item.

Essentially what firmware does is this;

  1. Has hardwired instructions for a given processor to undertake and execute, this is called a "bootstrap". Which the most bootable computers have this in their BIOS.

  2. Initialize said hardware via the instruction in the firmware.

  3. Load in / up the jump table.

  4. Make the access to registers on a given device accessible.

  5. Hand off control to the exiting routine once the BIOS has been used after a cold (powered off state) or warm start (normal reboot or reset pin has been used).

  6. Most BIOSes (firmware) are designed for a specific chipset in mind and root out all the functions of those and flesh out any data that something could be attached to a given busline in a computer or embedded device.

  7. Hard discs are a good example of a storage solution that in and of itself is an embedded device, that too has a BIOS on it and has a form of firmware on a chip.

Essentially, all firmware is, is a bunch of instructions that another processor does to get functionality out of a said device. It's software that is loaded into a physical device, upon losing power, it will be there when the device regains power.

Technically, you can use any programming or scripting language to create binary files. You just have to know how the processor you are going to be targeting works, the actual op codes, the internal register (let alone what they're for), to learn binary and hexadecimal number systems and how to create an assembler that can save your code in assembly language. After that is complete then you can task another program to convert it into binary, then save it as a .bin or .hex file.

If you want to know how Ada, C, C++, D and other programming languages convert their "tokens" which is their native code that is chopped up into pseudo op-codes into machine language. There are several books that I recommend you read, some are quite elementary and are centered around very specific processors but it's good to learn on. I will give you one book for the time being, because I don't want to drown you or anyone else that reading this in information.

  1. Crafting A Compiler with 'C' by Charles N. Fischer & Richard J. LeBlanc, Jr.
  2. Do visit this site, it's based on the x86 chipset found in the IBM PC; http://www.laynetworks.com/assembly%20tutorials.htm

That is the introduction to assembly language programming on PCs at the very beginning. It talks about handling interrupts (hardware and software interrupts) and many other topics, it explains more in depth what a BIOS actually does and how to work with it.

Unlike assembly language and machine language, you can get away with a lot more in Ada, C, C++, D, if you don't know your hardware specifics. In assembly and machine language, if you don't know what you're doing, either something bad will happen or the code won't work. I prefer the latter case, not working vs. something bad.

Note: About the answer above, about flash RAM, there is no such thing, there are flash ROMs but not flash RAMs. Flash ROMs have the firmware in them, the RAMs that are battery or capacitor backed, or have another flash ROM that contains parameters for the BIOS's options you've set.

There is code in firmware on how to store or clear the data memory (versus the program memory / firmware itself), if it's a flash ROM or a RAM chip. On PCs if you BIOS password gets garbled or you don't remember it (or someone is messing with you), you can open the case and find the two pins called, "CMOS CLR / CMOS CLEAR / BIOS RESET / BIOS RST", shorting those two pins together also clears the memory, all you would need to do after that is to hit the reset button, when the two pins are still shorted. That clears the password and allows you full access to your PC BIOS (assuming you have a newer computer from 1990s on).

On new PCs, you have flash memory for the firmware and you have battery backed SRAM (doesn't constantly need to be refreshed like DRAM chips, it's based on an older technology).

\$\endgroup\$
0
\$\begingroup\$

In terms of Embedded Systems, Flashing Firmware means you have erased the ROM of a Micro-controller using a flashing device and re-written it with new code. This Firmware to be flashed is in HEX Form.

In terms of OS related Terminology, it is also flashed in the ROM but this time it is the responsibility of an OS to flash it when an update comes.

\$\endgroup\$
0
\$\begingroup\$

I believe that using the "historical" perspective, might give a more basic understanding of what firmware is.
It first starts with "hard-ware." To provide/create a given function, one could use tubes, relays, transistors, & ICs. You would use a number of these components and you would create a device that performed the required function. This was considered "hard-ware" because if you wanted (or needed) to change the function, you would need to unsolder wires, sockets, etc. and this was "hard" to do. Thus, this method of implementing a function became know as using hardware. Using a CPU, RAM, and code, became another method of creating a function, and became known as "soft-ware" because it was very "easy" to make design changes." However, there was also a need (mostly from manufacturers), to complete as much of a design as early as possible, but be capable of making "last minute" design changes as easy and cost-effective as possible. The use of ROMs allowed this flexibility up to the point of "first ship." EEPROMS allow changes even after "first ship" (in the field). The code needed/used for the ROMs and PROMs was give the name of "firmware."

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.