Firmware testing for hardware prototypes: HIL test benches, automation, and AI-generated test cases
Firmware that works on your desk can still lock up when the battery sags, the radio drops, or an update is cut off halfway. Firmware testing is how you find that before a user does. Here is how we layer firmware tests on a hardware prototype, when a HIL test bench is worth building, how to automate it, and where AI-generated test cases genuinely help.
November 5, 202610 min read

Written by Konstantin Dolgan, Ph.D., NPDP
Founder & CEO, Product Development Engineer
Published November 5, 2026

What is firmware testing?
Firmware testing is the practice of verifying the software that runs directly on a product's microcontroller or processor: that it reads sensors correctly, drives outputs correctly, communicates reliably, and recovers safely from faults such as power loss, bad input, or a failed update. It differs from app or web software testing because the code depends on real hardware, real timing, and real electrical signals.
On a prototype, firmware testing answers practical questions. Does the device start the same way every time? What happens at low battery? Does it recover if the Bluetooth link drops mid-transfer? Can a field update be interrupted without bricking the unit?
The firmware testing layers for a hardware prototype
We do not pick one kind of test. We stack cheap, fast tests under slower, more realistic ones, so most bugs are caught where they are cheapest to fix.
Layer | What runs where | What it catches | Typical tools (examples, not endorsements) |
|---|---|---|---|
1. Unit tests on a computer | Individual C or C++ modules compiled for a PC, hardware calls replaced with test doubles | Logic errors, math, state machines, parsers, edge values | Unity, Ztest, GoogleTest |
2. Software in the loop (SIL) and emulation | Compiled firmware against a simulated environment, or on an emulated chip and peripherals | Integration between modules, protocol handling, scenarios that need no real hardware | Renode, QEMU, vendor simulators |
3. On-target tests | Tests running on the real microcontroller on your prototype board | Compiler and chip-specific behavior, peripheral drivers, memory and timing | Unity or Ztest on target, pytest-embedded over serial |
4. Hardware in the loop (HIL) | Real board connected to a bench that simulates sensors, loads, power and faults through real I/O | Timing, I/O, power sequencing, fault handling, recovery | Custom bench with a lab power supply, I/O hardware and a test runner |
5. System and beta tests | Complete prototypes with real mechanics, in the real environment, with users | Everything the bench cannot model: mechanics, environment, real users | Bench checklists, field logging, a beta program |
A few of the tools above, so you know what they are: Unity is a unit-testing framework written in ANSI C that is designed to be portable from 8-bit microcontrollers to 64-bit systems (ThrowTheSwitch, Unity).
Zephyr's Ztest provides assertion macros and a test structure that can be used for unit testing modules or for integration testing (Zephyr Project, Ztest).
Renode is Antmicro's open-source framework for emulating CPUs, peripherals, sensors and multi-node systems so teams can develop and test without the physical hardware (Renode).
pytest-embedded is an open-source pytest plugin from Espressif designed for embedded testing, with services for serial ports and emulators (pytest-embedded on GitHub).
Layer 5 is a different job, covered in our guide to hardware beta testing. Where all of these sit in a program is in stages of product testing and their purposes.
SIL vs HIL: which one does your prototype need?
Short answer: usually both, at different times. SIL runs your compiled code in a simulated environment, so it is fast, cheap, and available before boards arrive. HIL runs the code on the real controller hardware connected to a simulated environment through real analog and digital signals, so it catches what SIL cannot.
MathWorks describes SIL as testing the compiled control code in a simulated environment, and HIL as connecting the real controller hardware to a real-time simulated plant using actual analog and digital signals, which gives higher-fidelity testing of I/O, timing, and communication (MathWorks, Hardware-in-the-Loop).
NI adds that running the code on the actual controller is what exposes timing, synchronization, and execution flaws that are typically not present in a SIL environment (NI, What Is Hardware-in-the-Loop).
Question | SIL (software in the loop) | HIL (hardware in the loop) |
|---|---|---|
Needs a prototype board? | No | Yes |
Speed and cost per run | Fast, cheap, runs on any computer | Slower, needs a bench per board |
Real timing, interrupts, peripherals | No (or emulated) | Yes |
Power, brownout, sensor wiring faults | Only as models | Yes, with real signals |
Best for | Logic, protocols, state machines, early development | Drivers, timing, power and fault handling, release checks |
When we use it | From the first line of firmware | From the first stable board revision |
For a simple Class B product (one mechanism or simple electronics), unit tests plus a few on-target tests are often enough. For Class C and D products (several mechanisms, a custom board with firmware, or several subsystems working together), a HIL bench usually earns its keep.
How to build a HIL test bench for a prototype
A HIL test bench does not have to be an automotive-grade rack. For most prototypes it is a bench that can power the board, pretend to be its sensors and loads, inject faults, and run a script.
NI lists the core elements of a HIL system as the device under test, I/O and bus interfaces to connect to it, real-time compute, application software to run and automate test cases, and simulation models, with optional fault insertion, signal conditioning, and emulated loads (NI). Here is how we scale that down for a prototype.
1. Start from requirements and risks
List what the firmware must do and what must never happen. If you ran a design FMEA, its failure modes and detection controls are a ready-made test list (see DFMEA for prototypes). Each test gets a measurable pass limit tied to a requirement.
2. Decide what is real and what is simulated
Keep the controller board real. Simulate what is slow, dangerous, expensive, or hard to control by hand: a battery that sags, a motor that stalls, a sensor that reads out of range, a radio link that drops. MathWorks notes that HIL lets engineers test fault scenarios and edge cases without risking expensive equipment (MathWorks).
3. Wire the I/O, Power, and Reset
A programmable power supply lets the script control voltage and current, which is how you test brownout and low battery.
Add a way to reset and reflash the board from the script, inputs that stand in for sensors (DAC outputs, signal generators, or a second microcontroller that emulates a sensor bus), and measurement of the board's outputs.
For repeatable contact to test pads, the bench often sits on a pogo pin fixture; our test fixture design guide covers that part.
4. Script the tests
Use a test runner that sets up each scenario, measures, compares against limits, and saves a record per run. OpenHTF is an open-source Python hardware testing framework originally created at Google that structures tests as phases with measurements and limits (OpenHTF on GitHub). Pytest-embedded is another option for serial-connected devices. Keep limits in one file and version the scripts with the firmware and board revision.
5. Prove the bench
Run the suite on a known-good board several times before trusting it. A bench that fails good boards wastes more time than no bench.
6. Keep it safe
If the product has mains voltage, large batteries, or moving parts, add current limits, interlocks, and guards, and treat the bench as lab equipment. MathWorks notes that typical controller HIL uses low-voltage signals, and that power HIL with amplifiers is a separate, higher-energy setup (MathWorks).
Hardware test automation: run firmware tests on every build
The real value of a bench shows up when it runs without anyone babysitting it. Hardware test automation means every firmware change is built, flashed to a board on the bench, and run through the same suite, with results stored next to the commit. NI lists test automation up to continuous integration pipelines as an extension of a HIL system (NI).
What we automate first on a prototype, in order:
- Unit tests on every commit (seconds, no hardware)
- A short smoke test on the real board: boots, reports version, basic I/O works
- The fault and recovery tests: brownout, reset, communication dropouts, interrupted update
- A longer soak test overnight before a build goes to users or a manufacturer
Automated testing of embedded systems does not replace an engineer at the bench. It makes sure the bugs you already fixed stay fixed.
AI-generated test cases: where they help and where they fail
AI tools are genuinely useful in firmware testing, mostly for writing and thinking, not for judging. Our split:
Task | Where AI helps | What engineers own |
|---|---|---|
Test ideas and edge cases | Proposing boundary values, odd sequences, and fault combinations from the requirements (for example: reset during a flash write, sensor stuck at full scale, two buttons pressed during boot) | Which cases are physically possible and worth bench time |
Unit test code | Drafting test scaffolding and test doubles for a module | Reviewing every assertion; running and keeping only tests that build, pass reliably, and add coverage |
HIL scripts | Drafting instrument commands, logging, and report formatting | Pass limits from requirements, safety interlocks, sign-off |
Results | Summarizing failures across runs, grouping by test and board, flagging drift | Root cause and the fix |
The best evidence we know of for AI test generation comes from software, not firmware, but the lesson transfers.
Meta reported that its TestGen-LLM tool, which uses large language models to improve existing human-written tests, filters every generated test so that only tests that build, pass reliably, and increase coverage are kept. In its evaluation on Instagram's Reels and Stories products, 75% of generated test cases built correctly, 57% passed reliably, and 25% increased coverage (Alshahwan et al., Meta, arXiv 2402.09171).
In other words, a large share of raw AI output was not usable until it was filtered by actually running it.
NIST's Generative AI Profile names confabulation, confidently stated but false content, as a core generative AI risk, and also warns about over-reliance on AI output and about exposing sensitive data (NIST AI 600-1).
For firmware tests that gives us three rules: an AI-generated test only counts after it runs on the bench and is reviewed. Pass limits come from the requirements, never from the model. And schematics, source code, and test data only go into tools whose data terms we have checked.
For the wider tool picture, see AI tools for hardware prototyping in 2026, and for on-device AI products, edge AI hardware prototyping.
What to test in prototype firmware: a checklist
Startup and power
- Cold boot, warm reset, and watchdog reset all reach a known state
- Brownout and low battery: defined behavior, no corrupted settings
- Power removed during a settings write or flash write
Inputs and outputs
- Every sensor at minimum, maximum, out of range, disconnected, and noisy
- Buttons: bounce, long press, presses during boot
- Outputs and actuators: correct, and safe when the firmware faults
Communication
- Link loss and reconnect (Bluetooth, Wi-Fi, cellular, USB, wired buses)
- Malformed or unexpected messages do not crash the device
Updates and recovery
- Firmware update interrupted at several points still recovers
- Version reporting matches the build; rollback works if supported
Timing and endurance
- Worst-case timing for time-critical tasks measured on target
- Overnight or multi-day soak with logging
Records
- Each run logged with firmware version, board revision, bench version, and result
Firmware testing for regulated products
If your product is a medical device, plan the firmware testing to fit the software life cycle standard from the start.
IEC 62304 defines life cycle requirements for medical device software and applies when software is itself a medical device or an embedded or integral part of one (IEC 62304:2006, IEC Webstore).
For automotive and aerospace controllers, MathWorks notes that HIL testing supports requirements-based testing under standards such as ISO 26262 and DO-178 (MathWorks).
Retrofitting traceability later is much harder than keeping requirement IDs on tests from day one. See also design verification and validation.
What we need from you to plan firmware testing
- Requirements or a spec, even a rough one, plus what must never happen
- Schematic, PCB files, and BOM for the current board revision
- Firmware source or access to the repository, with the toolchain used
- How the product is powered (battery type, charger, mains) and how it communicates
- Whether the product will receive updates after launch
- Any regulatory path (medical, automotive, industrial, wireless certification)
- Two or more prototype boards, ideally one we can dedicate to the bench
Firmware testing services at LA NPDT
LA NPDT does design, engineering, and prototyping in-house at our facility in Ruston, Louisiana: electronics and firmware, plus 3D printing, CNC machining, urethane casting, and bridge tooling.
The same team that writes the firmware builds the prototype and the bench, so when a test fails we can tell whether it is the code, the board, or the mechanics, and fix it in the same build. We use AI to speed up test ideas, test code, and log reviews, and our engineers set the limits and sign off the results.
Our view is practical: test in layers, automate the tests you will run more than a few times, and build a HIL bench when faults are risky, slow to create by hand, or will keep coming back with every update. If a product is simple enough that a short on-target test list covers it, we say so.
How much firmware testing a project needs depends on its complexity class.
We sort every product into four classes: Class A, a single simple part with no moving parts or electronics (for example, a plastic or rubber kitchen utensil); Class B, one mechanism or simple electronics; Class C, multiple mechanisms or medium electronics with firmware. And Class D, complex products with multiple subsystems.
Typical costs for each class are in one place on our homepage: product development costs by complexity. As with all our work, equipment and machine time are part of labor, and materials are billed separately.
If you want the plan first, our Stage 1: Review/Analysis + Plan is a fixed $800 single payment. Or see our electronic design services and rapid prototyping, or book a free 20-minute initial consultation. Phone: +1 318-200-0526.
Frequently asked questions
What is firmware testing?
Firmware testing verifies the software that runs on a product's microcontroller: that it reads inputs, drives outputs, and communicates correctly, and that it recovers safely from faults like power loss, bad input, or an interrupted update, on the real hardware.
What is the difference between SIL and HIL testing?
SIL (software in the loop) runs compiled firmware in a simulated environment, with no real hardware. HIL (hardware in the loop) runs the firmware on the real controller board, connected to a simulated environment through real electrical signals, so it catches timing, I/O, and power problems SIL cannot.
What is a HIL test bench?
A HIL test bench is a setup that powers a real controller board and simulates its sensors, loads, power conditions, and faults through real inputs and outputs, while a script runs test cases and records results. For a prototype it can be a programmable power supply, I/O hardware, and a test runner.
Does a prototype need HIL testing?
Not always. A simple product may only need unit tests and a short on-target test list. A HIL bench pays off when firmware is retested after every change, when faults are risky or slow to create by hand, or when the product will receive updates after launch.
Can AI generate firmware test cases?
Yes, AI can propose edge cases and draft test code and bench scripts. Generated tests only count after they build, pass reliably on the bench, and are reviewed by an engineer, and pass limits must come from the product requirements, not from the AI.
How is firmware testing different from software testing?
Firmware testing depends on real hardware: timing, interrupts, power, sensors, and electrical faults. Ordinary software testing mostly runs on standard computers. Firmware teams use the same unit testing ideas but add on-target tests and hardware in the loop benches.
Not sure how much firmware testing your prototype needs?
Talk with an engineer about which tests matter, whether a HIL bench is worth it yet, and what your board needs for it. Phone: +1 318-200-0526.
Sources
Services related to this guide
- Electronic design servicesSchematic, PCB layout, firmware and bring-up, through to production handoff.
- Rapid prototypingWorking prototypes in days, from 3D printing to vacuum casting.
- Product design servicesIndustrial design and CAD taken all the way to manufacturable files.
- Product development examplesReal projects we designed, prototyped and shipped.


