The information needed before starting
A firmware developer works very close to the hardware. Without documentation of the board, they have to reconstruct it, which takes time and introduces risk. Before starting, it helps to gather:
- The complete schematic, at the correct revision, ideally with the layout or at least the component placement.
- The exact part number of the microcontroller or module (family, memory, package), and the datasheets of the driven components: sensors, actuators, converters, radio modules.
- The pinout in use: which pins drive what, and which pins set the boot configuration.
- A description of the expected behavior: operating modes, sequences, error handling, target power consumption.
- External interfaces: protocol and format of the data exchanged with a PC, an application, a server or another device.
- The existing firmware, if any, with its sources and build toolchain.
- At least one working board, preferably two, for development and testing.
Common programming interfaces
Firmware is loaded into the microcontroller’s memory through a dedicated interface. The choice depends on the microcontroller family and must be planned at the schematic stage: an accessible connector or test points avoid a lot of trouble, both in production and in maintenance.
| Interface | Typical use | To provide on the board |
|---|---|---|
| SWD (Serial Wire Debug) | ARM Cortex-M microcontrollers: programming and debugging | SWDIO, SWCLK, ground, reference voltage, ideally reset |
| JTAG | Many processors and FPGAs: programming, debugging, boundary-scan testing | TCK, TMS, TDI, TDO, ground, voltage reference |
| Serial bootloader (UART) | Loading without a debug probe, via a built-in or added bootloader | Accessible serial link, boot mode selection pins |
| USB (for example DFU) | Updates by the user or in the workshop without dedicated tools | USB port connected to the microcontroller, suitable boot mode |
| ISP / UPDI | AVR microcontrollers, depending on generation | Accessible dedicated pins |
Toolchain and development environment
The toolchain comprises the compiler, the vendor libraries or a real-time operating system, the development environment and the programming probe. Depending on the family, you will come across, for example, GCC for ARM, the environments provided by microcontroller vendors, ESP-IDF for Espressif chips, or systems such as Zephyr or FreeRTOS. Common probes include vendor probes and generic CMSIS-DAP-compatible probes.
The key point for the customer is reproducibility: it must be possible to rebuild exactly the same binary later, on another machine. That means documenting the versions of tools and libraries, and keeping the sources under version control.
The deliverables to insist on
Firmware delivered only as a binary file makes the customer dependent on the developer. The following deliverables make it possible to maintain, fix and reprogram the board independently:
- The complete source code, in a version control repository, with an identified version number for each delivery.
- The corresponding binaries (.hex, .bin or .elf formats depending on the tools).
- Build instructions: tools, versions, options, dependencies.
- The programming procedure: required hardware, commands, protection settings, verification after loading.
- A description of the memory map and of stored parameters (configuration, calibration, identifiers).
- A test report describing what was tested, on which board and with what result.
- The list of third-party libraries and their licenses.
Planning for firmware updates
A deployed product will almost always need updating: fixing a defect, adding a feature, following a protocol change. The method must be decided early, because it has consequences for the hardware and for available memory.
The simplest method is to reprogram the board with a probe, in the workshop. A bootloader allows updates over a serial or USB link, without specialized tools. Over-the-air updates (OTA) demand more: enough memory to store the new image while the old one keeps running, verification of the image’s integrity and authenticity before activating it, and a mechanism to roll back to the previous version if the new firmware does not boot correctly. A power failure during an update must never leave the board unusable.
Firmware security basics
Security is not added at the end; it is planned together with the architecture. Without aiming for absolute protection, a few basic measures significantly reduce the risks:
- Enable the microcontroller’s memory read-out protection on production boards, knowing its effects: some protection levels are irreversible and permanently disable debugging.
- Disable or lock the debug interfaces in production when the product justifies it.
- Never write passwords, keys or access tokens in plain text in the source code or in the repository.
- Prefer per-device secrets over a key shared across the whole series, and consider a secure element if the stakes justify it.
- Sign firmware images and verify the signature before any update.
- Use secure boot and memory encryption when the microcontroller offers them and the product requires it.
Frequently asked questions
What deliverables should I require from a firmware developer?
At a minimum: the source code under version control, the matching binaries, build instructions with tool versions, and the programming procedure. Without them, the board cannot be maintained without its original developer.
What is read-out protection?
It is a microcontroller setting that prevents the firmware from being read back through the debug interface. It protects the code against simple copying, but some levels are permanent: enable it only with full knowledge of the consequences.
Should over-the-air updates be planned from the first prototype?
Not necessarily, but you need to decide early whether they will be needed, because they require extra memory and a verification mechanism. Adding them late may force a change of microcontroller.