Firmware for robots and drones
A robot is a computer that can bump into things. Its firmware has hard deadlines, more than one processor, and an update path that must never run while the machine moves.
Key characteristics
- Typical split
- Linux computer plus real-time microcontrollers
- Hard limits
- Control loop timing and watchdogs
- Update rule
- Only when parked with motors disabled
- Works with
- Zephyr, FreeRTOS, bare metal, Yocto Project, Buildroot
Robots and drones put firmware in a harder spot than most connected products. Control loops often have deadlines measured in fractions of a millisecond. Sensors arrive at different rates and have to be lined up in time. Most designs have a Linux computer and several microcontrollers that must agree about what the machine is doing. And an update that goes wrong can leave a machine stuck mid-task, or moving when it should not.
We write the microcontroller firmware, help define the line between it and the Linux side, and build an update path that respects the fact that the machine moves.
Real-time constraints
Motor control is the clearest case. A current loop, a velocity loop and a position loop each run at a fixed rate, and a late cycle shows up as noise, heat, vibration or a jerk. What matters is the worst case, not the average: one late cycle per minute can be enough to fail a test.
On the microcontroller we usually:
- Run control loops from hardware timers and interrupts with priorities set on purpose, not by default.
- Move sensor and motor data with DMA so the processor is free for the loop.
- Avoid dynamic memory allocation and unbounded work in the control path.
- Measure loop timing on real hardware and keep the measurement in the test suite, so a later change that adds jitter fails a build instead of a field trial.
- Use watchdogs that put the motors into a safe state, not only reset the processor.
Sensor fusion (inertial sensors, encoders, cameras, range sensors) depends on timestamps more than on clever math. Sampling on the microcontroller with a shared time base, then fusing where the compute is, avoids a whole class of bugs. Bare metal, FreeRTOS or Zephyr all work for this; the RTOS selection worksheet helps you choose on your own criteria.
Linux plus microcontroller splits
Most robots split the work between an embedded Linux computer and one or more microcontrollers. Where the line falls is one of the most important architecture decisions you make.
| Job | Usually runs on | Why |
|---|---|---|
| Current and velocity loops | Microcontroller | Needs short, fixed timing that a general-purpose OS does not promise |
| Sensor sampling and timestamps | Microcontroller | Keeps samples on one clock, close to the hardware |
| Sensor fusion | Either | Depends on the rate and the compute needed |
| Perception, mapping and planning | Linux | Needs memory, accelerators and large libraries |
| Fleet connectivity and updates | Linux | Has the network stack and the storage for images |
| Safe stop when the other side goes quiet | Microcontroller | Must work when Linux is busy, crashed or rebooting |
The interface between the two sides needs as much care as either side. We define it as a versioned protocol over UART, SPI, CAN or USB, with a heartbeat in both directions. If the microcontroller stops hearing from Linux, it stops the motors in a defined way. On the Linux side we build images with the Yocto Project or Buildroot; see embedded Linux.
Safe updates on moving machines
A robot has several images to update (the Linux root file system and each microcontroller) and they must stay compatible with each other. The update path we build follows a few rules:
- Only in a safe state. The robot is docked or parked, the motors are disabled, the propellers are stopped and the battery has enough charge to finish. The machine refuses an update otherwise, whatever the server says.
- Release as a set. The Linux image and the microcontroller images that go with it ship as one signed release with a compatibility table. Nothing runs a mixed set the release did not test.
- A/B everywhere. Linux uses A/B root file systems (with RAUC, SWUpdate or Mender). Each microcontroller uses a bootloader such as MCUboot with two image slots, a signature check and a test-then-confirm step that reverts if the new image never confirms.
- Roll back together. If any part of the set fails its checks, the whole machine returns to the last set that worked.
- Prove it before work. After an update, the robot runs a short self-test (sensors read, motors respond, heartbeat present) before it accepts a task. A drone does this on the ground, never in flight.
Fleet rollouts then go out in waves, starting with machines you can reach. Our over-the-air updates page covers signing, rollback and staged rollouts in detail, and the staged rollout planner shows how wave sizes turn into days.
Testing what moves
Timing bugs and update bugs both hide until hardware is involved. We build hardware-in-the-loop rigs with a motor or actuator on the bench, simulated or recorded sensor input, and timing measurement, and run them from CI on every change. Tests include pulling power during each stage of an update and killing the Linux side to check the microcontroller stops safely. See test automation.
Where to start
Request a firmware review. We read your schematics, code, interface definitions and update plan, and send back a written plan with the risks ranked and the order of work. The firmware architecture section of Field Update covers more of these decisions.
Send us your board and your plan.
A firmware review reads your schematics, code, flash layout and update plan, and ends with a written plan: what to build first, what could go wrong in the field and how updates will reach your devices.
Or email sales@fumbar.com, or call (720) 675-4202.