Firmware Engineering

By: Kenny Fok
Date: November 28, 2022

What is Firmware originally?

A common question asked is what is firmware? Firmware is a set of computer instructions stored in an electronic non-volatile memory device such as ROM (Read-Only-Memory). Originally, Firmware was designed to be a small set of specialized instructions, which serve as a "bridge" between hardware and software. Software, in this context, refers to the set of computer instructions executed by Central Processing Unit (CPU) such as Operating System (OS). For example, when Personal Computer (PC) is first powered up, it shows a simple text message on the screen before OS is started. That simple text message is from the BIOS (Basic Input Output System), which is firmware for the bootup process. BIOS firmware comes pre-installed on a personal computer and is the first software to run when the computer is turned on.

Picture of PC architecture

What is Firmware nowadays?

As Integrated Circuits (IC), and Microprocessors have advanced in the modern days, Embedded systems have grown exponentially in the past several years in both consumer and industrial space. So what is firmware in computer systems today? Let's first look into what Embedded system are. An Embedded system is a computer using Microprocessor, Digital Signal Processors (DSP), or Application Specific Integrated Circuits (ASIC) as the core hardware processor. Embedded systems are typically designed for specific application and usage. For example, GPS Tracker, Smart Exercise Bike, Smart light bulbs are examples of Embedded systems, and they are also IoT devices. In fact, most of the IoT devices are examples of Embedded systems. Household items, such as a microwave oven, washing machine, and dishwashers also use Embedded systems to provide flexibility.

What is Firmware in Embedded systems? Computer instructions running in Embedded systems are often referred to as Firmware. Embedded Firmware stores software in a chip to control a particular device. Many of these Embedded systems run on a Microprocessor and contain memory devices such as Flash memory. It also has key components such as sensors (aka chip, System on Chip (SoC)). These systems typically only have Firmware to provide all of its functions.

Picture of an Embedded System

Challenges for Firmware Development

Firmware Development is very different than typical Software Development. In this section, we will explore some key challenges and constraints for Firmware Development.

Large selections of Microprocessors/DSP/ASIC in the market

In general Computer systems space, the processors are converged into several brands. Unlike its counterpart, there are more than hundreds of brands of Microprocessors / DSP / ASCII in the Embedded systems space. Each brand of Microprocessor has their own development environment, toolchain, and system libraries. So what does this mean for Firmware development? As you can imagine, Firmware development heavily depends on the selection of the specific Microprocessor and is not easy to port from one Microprocessor to another.

Divergence of Microprocessors space also complicates the design process. For an optimal design process, the Engineering team should first understand the product requirements, and then select a list of best appropriate Microprocessors from the market. However, with a large variety of Microprocessors, the Engineering team is typically limited on their selections based on their familiar brand of Microprocessors, which often leads to a less effective design.

Performance

What is Firmware performance? Performance depends on the Microprocessor speed & primitive level of operating system. For example, it can only perform one operation at a time. If Firmware is spending too long on computing the average of all sensor data, it may miss the sensor reading.

Memory

A common question is what is Firmware's memory capacity? Run-time memory is typically one of the most expensive components in Embedded systems, making it very limited. These constraints prevent many traditional algorithms to be implemented in Embedded systems.

For example, if a feature is to read sensor data (say, 1 byte each) every millisecond and to provide average every minute, a traditional algorithm would keep all of the sensor data for a minute in run-time memory and perform averaging every minute. However, this would require 60K bytes of run-time memory, which is a lot for Embedded systems. Firmware Engineers will need to implement different algorithms to accommodate this.

Similar scenarios also apply to storage, which imposes tight constraints on code size. Firmware Engineers need to write optimal code and often apply some non-textbook techniques such as making complicated macros for repeating code blocks (Bad for readability)

Power Consumption

Most of the Embedded systems especially IoT devices are battery-powered, so Firmware needs to put the Microprocessor to sleep as much and as long as possible. Firmware only wakes up the Microprocessor when absolutely necessary to save power.

For example, Firmware uses event-driven instead of polling to wake up the Microprocessor. When the Microprocessor is awaken, Firmware needs to perform all the operations as soon and as efficiently as possible.

Flash Wear Out

What is Firmware's flash memory component? It is composed of a large number of cells, and each cell has a limited write cycle such as 100,000 writes. If Firmware exceeds the write cycle limit, the corresponding cell will no longer be accessible (i.e., data lost). During Firmware development, Engineers need to apply leveling techniques to prolong the lifetime of the Flash.

Limited Debug capabilities

Unlike Desktop/Cloud counterparts, most of the Embedded systems have limited debug features such as a limited number of breakpoints, and debug output not being easily available. Furthermore, enabling debug capabilities on Embedded systems usually impacts the execution timing, which may mask the problem (i.e., the problem no showing with debug enabled). Firmware Engineers need to apply various debug "innovative" techniques in Embedded systems such as flashing on-board LEDs to indicate the state, and sending signals (1s and 0s) to hardware pin for debug output via Logic Analyzer.

Updating Firmware:

What is the process of updating Firmware? In the past, Firmware of the device is permanently "burned" into a non-volatile memory device and can not be updated. If an update is needed, the corresponding memory device will be replaced physically. In the modern days, most Firmware can be updated. For example, in the past (1990s), updating PC's BIOS requires end user to physically replace the BIOS on the motherboard. Nowadays, it is a matter of clicking several buttons for updating BIOS.

For modern Embedded systems, updating Firmware during the product life cycle is mostly required due to several reasons:

  • More complicated system, which requires to have bug fixes and maintenance periodically
  • End users expect to have added features or bug fixes after product launch
  • Both of the above items got amplified with the recent growth of IoT devices in the world

There are two general ways to update firmware:

  • 1: Tethered (using a cable connected to the device)
  • 2: Over-The-Air (OTA) (updating it via any type of wireless communication)

If the firmware update process encounters an error, it would "brick" the system (i.e., the system will not longer working). Firmware Engineers will need to implement many safeguards to handle this unexpected issues such as:

  • Having a robust secure bootloader which allows to recover
  • Having a A/B partitions for keeping the "Last-know-good" firmware
  • Having a mechanism to enter secure bootloader

How to identify the "right" Firmware Engineer(s)?

Now, we know a bit more about Firmware and its challenges. However, it can be difficult to decide what is the best Firmware Engineer. As you can imagine, identifying the competent and experienced Firmware Engineers is extremely difficult. If you are looking for rapid prototyping for your device/product (typically at the proof-of-concept phase), it is even more challenging to identify the "right" Firmware Engineer(s), who has experience with the platform. Companies providing a wide range of Firmware/Embedded Engineering Services are likely to be more effective in terms of time and budgetary.

Are you looking for Firmware Engineering services? Learn more about our services!