Five firmware decisions to make before the first board
Published · By National Front Corp.
The firmware decisions that are hardest to change after the first board are the choice of microcontroller, whether to use an RTOS or run bare metal, how the device will boot securely and receive updates, the power budget, and how the firmware will be tested and held to a coding standard. Each one shapes the schematic: memory size, pins, power rails, test access and security hardware. Settle them in writing before layout, while changing your mind costs an afternoon instead of a board revision.
Which microcontroller, and will you still be able to buy it?
Choose the microcontroller for what the firmware must do over the product’s life, not only for the prototype:
- Memory headroom. Leave room for features added after launch and, if updates are stored internally, for a second firmware image. Firmware grows; flash and RAM do not.
- Peripherals and timing. Confirm that the interfaces, timers, analog inputs and low-power modes you need are available together, on the pins you need, at the same time.
- Security features. Support for secure boot, hardware cryptography, protected key storage, a unique device identifier and a way to lock the debug port.
- Supply and lifecycle. Check the vendor’s longevity commitment, current lead times and whether pin-compatible family members exist with more or less memory. A microcontroller rarely has a true second source, so a compatible family is your fallback.
- Toolchain and support. The compiler, debugger, quality of the vendor’s software kit, published errata and the community around the part.
Evaluate the shortlisted parts on development boards with a small slice of the real firmware. A proof of concept at this stage is inexpensive and often decisive, especially when radio range or power consumption is uncertain.
Do you need an RTOS, or is bare metal enough?
Bare metal means the firmware runs a main loop with interrupt handlers and no operating system. It suits devices with one main job and simple timing: a small footprint, full control and fewer moving parts.
A real-time operating system (RTOS) such as FreeRTOS, Zephyr or Eclipse ThreadX provides tasks, scheduling, timers and communication between tasks. It earns its place when the device must handle several activities with different timing at once, such as a sensor sampled at a fixed rate, a radio stack and a user interface. Many networking, Bluetooth and USB stacks are designed to run under an RTOS.
The costs are real: RAM for each task’s stack, new failure modes such as priority inversion and deadlock, and a larger system to understand. Decide on the basis of the concurrency and timing the device actually needs, write down why, and size the memory accordingly. If the product falls under a functional safety standard, check whether you need an RTOS that comes with certification evidence.
How will the device boot securely and receive updates?
Every connected device will need a fix after it ships. The update path, and the security around it, has to be designed into the hardware:
- A root of trust. An immutable bootloader, in ROM or in protected flash, verifies the signature of the firmware before running it.
- Keys. Decide where the public key lives on the device, how device keys are provisioned at the factory, and how the private signing key is protected, ideally in a hardware security module.
- Update storage. Two firmware slots, in internal or external flash, let the device download a new image while running the old one, then switch only after verifying it.
- Recovery. If an update is interrupted or the new image fails to start, the device returns to the last working version instead of becoming unusable.
- Anti-rollback. A version counter prevents anyone from installing an older, vulnerable image.
- Transport. Over the air through Wi-Fi, cellular or Bluetooth, or through a wired connection, each with its own implications for power, cost and security.
Open-source bootloaders such as MCUboot implement much of this and are a sound starting point. Lock the debug port on production units, or the rest of the chain can be bypassed.
What is the power budget?
Write a power budget before choosing the battery or the regulator. For each operating mode (sleep, sensing, processing, transmitting), estimate the current drawn and the fraction of time spent in it. The weighted average is what drains the battery, and on many battery-powered devices the sleep current and how often the device wakes matter more than the peak.
The budget should account for:
- the peak current of radio transmissions and motors, which the battery and regulator must supply without a brownout;
- battery capacity at the lowest operating temperature and after ageing, not the nominal figure on the datasheet;
- leakage from every part on the board, including pull-up resistors and sensors left powered;
- the energy cost of updates, which download and write large images.
Design the board so current can be measured on each power rail, with a jumper or a sense resistor. Then measure real consumption early and compare it with the budget; when the two disagree, the firmware is often the cause.
How will you test the firmware and keep it maintainable?
Decide how you will prove the firmware works before the first board exists, because testing needs support from the hardware:
- Unit tests on a computer. Logic that does not touch hardware, such as protocols, calculations and state machines, runs fastest and most often off the target.
- Static analysis. Tools that check every build for defects and for compliance with your coding standard.
- Hardware-in-the-loop (HIL) tests. The real firmware runs on the real board while a test system drives its inputs, power and network conditions and checks its outputs automatically. This is how a team repeats tests such as power loss during an update, sensor faults and long-running behaviour on every change.
- Board access. A debug header, a serial console, test pads and a way to power-cycle the board remotely. These have to be on the layout; they cannot be added to a board that already exists.
Pick a coding standard at the same time. MISRA C is the common choice for C on safety-related and industrial devices, and the SEI CERT C standard focuses on security. Adopting a standard from the first commit is far cheaper than retrofitting it into an existing codebase.
What does the EU Cyber Resilience Act change?
If the product will be sold in the European Union, the Cyber Resilience Act, Regulation (EU) 2024/2847, turns several of these decisions into obligations. It applies to products with digital elements, which covers most connected hardware and the firmware inside it. This section is general information, not legal advice.
Two dates matter for products being designed now:
- From 11 September 2026, manufacturers must report actively exploited vulnerabilities and severe incidents affecting their products, starting with an early warning within 24 hours of becoming aware of them. The reporting obligations also cover products already on the market.
- From 11 December 2027, the main obligations apply: essential cybersecurity requirements for the product and for vulnerability handling, a conformity assessment, technical documentation and CE marking.
Among those requirements, products must be made available without known exploitable vulnerabilities, with a secure default configuration and with a way to receive security updates throughout a support period that must generally be at least five years, unless the product is expected to be in use for less time. Manufacturers must also identify and document the software components in the product, including in a software bill of materials. A device without a secure update path, or with too little memory to hold one, will struggle to meet those requirements for years after launch.
Our embedded development team starts from the hardware and makes these constraints explicit before the firmware is written, with a safe field-update path designed in from the start. When the enclosure and electronics are being designed at the same time, product development brings the disciplines together under the same requirements. If you are about to lay out a board, an exploratory meeting is a good moment to go through the list.
Questions we hear often
- When should firmware engineers join a hardware project?
- Before the schematic is finished. Firmware engineers check that the microcontroller has the memory, peripherals and security features the software will need, that the board gives them debug and test access, and that pins, clocks and power domains support the planned behaviour. Bringing them in after the first board is built usually means either a board revision or firmware workarounds that make the product harder to maintain.
- Can we change the microcontroller after the first board?
- Yes, but it is expensive. A new microcontroller usually means a new board revision, new drivers and board support, a new round of testing and sometimes a different toolchain or RTOS port. Moving to a pin-compatible part in the same family is the cheapest case. Keeping hardware access behind a thin abstraction layer in the firmware reduces the cost if the change ever becomes necessary.
- What is MISRA C, and do we need it?
- MISRA C is a set of guidelines for writing C that avoids undefined, unspecified and error-prone parts of the language. It originated in the automotive industry and is widely used in safety-related and industrial firmware. It is not a law, but many customers and safety standards expect it or an equivalent. Compliance is checked with static analysis tools, and every justified exception is recorded as a documented deviation.
- Does the EU Cyber Resilience Act apply to products made outside the EU?
- Yes, if they are placed on the EU market. The Cyber Resilience Act applies to products with digital elements made available in the European Union, wherever the manufacturer is based, with exclusions for products covered by their own sector rules, such as medical devices and motor vehicles. Importers and distributors carry obligations too. This is general information, not legal advice; confirm the scope for your product with counsel.