An old joke in hardware engineering circles says, contrary to popular belief, electronic gizmos don’t run on electricity. They run on smoke. When something goes wrong, the smoke (sometimes accompanied by flames) escapes, and the device stops working.
OK, so that’s not entirely true. Electronic gadgets do, in fact, run on electricity.
It’s also true that hardware engineers in general, have a peculiar sense of humor. (Full disclosure: Software developers are just as bad. When they all get together, that’s when the “pun” begins.)
All joking aside, let’s explore how firmware and embedded software work:
Firmware and Embedded Software: A Review
The terms “firmware” and “embedded software” have been used somewhat interchangeably in recent years. Sometimes you’ll even see the redundant term “embedded firmware.” Let’s use the following definitions:
Firmware is the low-level software operating the hardware of a microprocessor- or microcontroller-based device. It enables components to interact with each other and implements communications protocols, among other tasks. Firmware is stored in permanent or semi-permanent non-volatile memory (which retains its state when the power is turned off), so it is immediately available to the processor when the power is turned on.
Embedded software is higher-level software for a specific device, resembling application software on a PC. Embedded software runs the user interface (if any) and implements the logic that enables the device to execute real-world tasks.
Embedded software is stored in a rewriteable storage medium, such as a mechanical or solid-state disk drive or USB dongle. An embedded software program is copied to the system’s main memory before it is executed.
The distinction can be subtle at times. Given two similar devices from different design teams, one might have certain tasks handled by the embedded software, whereas the other might relegate the same tasks to the firmware. Some simpler devices have only firmware, and nothing that would qualify as “embedded software.”
It all depends on the product’s intended use, design goals, constraints, and roadmap for future development.
How Firmware Works
The nuts-and-bolts of firmware is that it is a series of machine-language instructions. The firmware program might be written in a higher-level language, but the code is translated to machine-language instructions before being stored in the non-volatile memory.
The machine-language instructions are specific to the microprocessor on which it runs. The same firmware usually can’t run on different processors, because different processors have different sets of instructions that they recognize.
When the device is powered on, the first thing that happens is the firmware starts sending instructions, in sequence, to the processor, which executes them. What happens next depends on the device and the design of the system and its firmware.
Some examples include:
In a PC, there are several pieces of firmware, including firmware for the various input/output controllers and adapters as well as firmware (known as the basic input-output system, or BIOS) that executes on the microprocessor (or one of the microprocessors, if the system has more than one).
The BIOS tells the processor:
- Where to find the storage device that stores the operating system
- To load the OS programs into memory
- Start executing them.
Once the OS starts running, the BIOS’s job is done.
In many devices, the firmware includes a power-on self-test (POST) routine, which checks to ensure all the hardware components are accessible to the processor and are responding properly. Depending on the device, there may or may not be an indication to the user (or to another system) that something went wrong during the POST.
Firmware can range from the trivially simple to the extraordinarily complex. In some systems, such as wireless routers, the firmware can include an entire Linux-like operating system. Again, it all depends on how the device is expected to be used.
FYI: Firmware might need to be updated to fix bugs, add functionality, or patch security holes. On some devices, the firmware can be updated, and on others, it can’t.
On devices for which firmware can be updated, the non-volatile memory where the firmware is stored is erased and the new firmware stored. This is usually accomplished by connecting the device to an external machine, such as a PC, although some devices (like mobile phones) can have firmware updated over a Wi-Fi connection.
How Embedded Software Works
Embedded software works more like a PC application. Its executable code is stored on a disk drive or similar medium, and when it’s time for it to run, the code is copied into the device’s main memory for the processor to access and execute.
Embedded software can be an operating system. For example, in a smart TV, the Android or Roku operating system is loaded and runs to support other apps (which also constitute embedded software).
But not all devices have or need an operating system. The choice comes down to sophistication: In a device where resources (such as memory, communications adapters, etc.) are shared by multiple programs, an OS is needed to direct traffic and ensure the programs don’t conflict with each other.
In a simple, single-function device, no OS is required. The embedded software, if any, is loaded (as directed by the firmware) to the main memory, and off it goes.
Because of how embedded software is stored, it’s easier to update than firmware. For that reason, functionality that is expected to change over the course of the product roadmap might be implemented in embedded software rather than in firmware.
The Future of Software is Device-Oriented
As the cost of microprocessor and microcontroller chips has lowered and their performance and capabilities have increased, they have become the go-to technology for even the simplest devices. With this trend, firmware and embedded software are becoming more important and prevalent. More developers than ever are spending their time developing firmware and embedded software. Software isn’t just for “computers” anymore.
At AndPlus, we understand this trend and are happy to be on the front lines. We enjoy the challenge of developing firmware and embedded software for new, innovative devices. Bring us the ideas you want to fly. We’ll help you give them wings.