Test Firmware Without the Board

One bug in a sensor driver costs about 10 minutes per try on a board and about 2 seconds on your laptop. Pick where you test, then count the tries.

Learn how to run firmware tests on your own computer with fakes, in an emulator, on a bench rig and in a CI pipeline, and know which bugs each place can and cannot find.

Press a place to test, then drag the number of tries. Watch the bars and the test report change. Then we build, piece by piece, the host test, the fake sensor, the fault, the emulator and the pipeline that make that gap real.

You need a little C and a rough idea of what a SPI sensor driver does (lesson 5 of this series builds one). We build the rest from zero.

Part of the series Firmware from Zero to Expertise. Built from primary sources: the Memfault Interrupt unit-testing and Renode posts, the Renode and Unity and CMock documentation, the ST LIS3DH datasheet and the TinyUSB hardware-in-the-loop page. The list is in the Field Guide.

Hunt one driver bug

12

The 2 s and 10 min per try are one author's reported iteration cycle before and after host tests (Memfault Interrupt, “Embedded C/C++ Unit Testing Basics”). The 8 s is the length of a Renode Robot Framework test in that post (8.35 s) and in the Renode docs (8.10 s). Your numbers will differ: these are one team's, not a law. The bug is a byte-order swap, 0x03E8 read as 0xE803, which is −6141 as a signed 16-bit number.

Chapter 0

The Board Is Not in the Room

See why firmware is slow to test, and why moving the test off the board changes how fast you can learn

Picture a fitness band that counts steps. A customer writes in: the count jumps backwards by thousands now and then. You find the cause in the sensor driver, a function that reads three bytes over a wire and turns them into a number. You change one line.

Now you must find out if that line fixed it. You build the program, plug in the board, and flash it, which means you copy the new program into the chip’s permanent memory. You reset the chip. You shake the board the way the customer did. You read a log. The log still looks wrong, so you change another line and start again.

Each loop takes minutes. One engineer on the Memfault engineering blog reports a cycle of about 10 minutes before testing on a laptop, and about 2 seconds after. That is 300 times faster. The engineer also says the test took two days to write, so the gain is real but it is not free.

Firmware, host and target

Firmware is the program that runs inside a small device, such as the band, with no operating system between it and the chip. The chip with your firmware on it is the target. Your laptop, where you write and build the code, is the host.

A test is a small program that calls your code with inputs you chose and compares the output with the answer you expected. A unit test checks one small piece, such as one function, on its own. If the answers differ, the test fails and prints both numbers.

The key idea of this lesson is simple. Most firmware bugs are bugs in logic: a wrong bit, a wrong index, a missing check. Logic does not need the chip. If you can run the same C code on the host, the loop gets short. The hard part is the places where your code touches the chip, and the rest of the lesson is about those places.

Feel the gap before the explanation

Below is one try on the target and one try on the host, drawn to the same scale. The board’s cost is mostly not the build or the flash. It is the time you spend putting the device into the situation that shows the bug. Press the button and watch both clocks.

Run one try on each

Top: one try on the real board, split into steps. Bottom: one try on the host. Both bars use the same scale, 0 to 10 minutes. Press Run one try; the cursor shows elapsed time.

The 10 minutes and the 2 seconds are the totals reported by one author (Memfault Interrupt). The split of the 10 minutes into five steps is our illustration, not a measurement.

The sliver at the bottom is the whole point. When one try costs 2 seconds, you can afford to try often, to print everything, and to write down the bug as a test so it never returns. When one try costs 10 minutes, you think harder before each try and you try less. Slow loops make engineers careful in the wrong way.

The board still matters

A laptop is not a chip. It has a different processor, a different word size, a different clock and no sensor on a wire. Some bugs only live on the board: a wire that is too long, a clock set too fast, a chip that answers one nanosecond late. A test on the host cannot find them.

So there is no single best place to test. There is a ladder of places. At the bottom is the cheap host test that runs in milliseconds. Above it are fakes that stand in for the chip, an emulator (a program that pretends to be the whole chip, running your real firmware file), a bench rig where a real board is wired to a computer, and finally the field. Each rung is slower and more real.

The craft is to push every bug to the lowest rung that can find it. The hero at the top of this page showed the price of not doing so. Chapter 1 draws the ladder and the matrix of which bugs live on which rung.

Plain version. Test the logic where tests are cheap. Test the wires where the wires are. Never use the expensive place for a question the cheap place can answer.

Why this lesson comes after drivers

Our running example is the same device as in the drivers lesson: an accelerometer on a SPI bus. A driver is the code that talks to one chip through its registers. A SPI bus (serial peripheral interface) moves bytes between the processor and the chip on four wires, one byte out for every byte in.

We use the ST LIS3DH, a real three-axis accelerometer, because its datasheet is public and its register map is small. Every register address and bit you will see comes from that datasheet. The sensor itself is a model in this page, and we say so each time.

If SPI or registers are new, the short version is this. The chip has numbered memory cells called registers. To read one, the processor sends the cell’s number and the chip sends back the value. Chapter 4 shows the exact bytes.

The road

  1. The ladder of places: host, fakes, emulator, bench, field, and the matrix of what each finds.
  2. Seams: how to cut your code so the same driver runs on the chip and on the host.
  3. Test doubles: stubs, fakes and mocks, and when to use each.
  4. Red, green: a virtual SPI sensor, a failing test, a fix.
  5. Making things fail: fault injection for the error paths no bench shows you.
  6. Time and interrupts: a fake clock, and a race you can force on purpose.
  7. Emulation: Renode runs the real firmware file on a modelled chip.
  8. Bench rigs and CI: hardware in the loop, and a pipeline that orders it all.
  9. Field Guide: numbers, a checklist, the core code, sources.
A bug in how a driver turns three received bytes into a number takes 12 tries to fix. Where is the cheapest place to find it?

Chapter 1

Which Bugs Live Where

Place five ways of testing on one ladder, and learn which kinds of bug each rung can and cannot find

You have eight bugs on your desk. A ring buffer that drops the last byte. A command byte that is wrong. A clock that runs at the wrong speed. A write that is cut by a power loss. A race between the main loop and an interrupt. You have a week, one board and a laptop. Where do you look for each?

The question has a good answer, and it comes from four properties of any test. Speed is how long one run takes. Control is how easily you can force the exact situation, such as a sensor that does not answer. Fidelity is how much the test is like the real product. Cost is the money and the human time to run it, many times, for every change.

No place wins on all four. The host is fast, easy to control and cheap, but low in fidelity. The field has perfect fidelity and no control. Every rung of the ladder trades one for another.

The five rungs

Host unit tests. You compile your C for the laptop and run it. Pure logic works there with no changes: a ring buffer, a parser, a unit conversion, a state machine. Nothing talks to a chip, so nothing needs a fake.

Host tests with fakes. The code under test touches hardware, for example the driver sends bytes over SPI. On the host you replace the hardware with a fake, a small program that behaves like the chip. This rung also lets you inject faults and move a fake clock. Chapters 2 to 6 live here.

Emulation. A program such as Renode pretends to be the whole chip, including the processor. It runs your real firmware file, the same one you flash, not a host build. Chapter 7 covers it.

Hardware in the loop (HIL). A real board sits on a bench, wired to a computer that flashes it, feeds it inputs and reads its outputs. It is the first rung with real silicon and real wires. Chapter 8 covers it.

The field. Real devices, in real hands, in real heat. Everything is true there and you control nothing. You still need it, but you want it to find as few bugs as possible.

RungWhat runsTypical time per runWeak at
Host unitYour C, compiled for the laptopmilliseconds to 2 s (Interrupt)Anything that touches a chip
Host with fakesYour driver plus a fake chipabout the sameAnything the fake gets wrong
EmulatorThe real firmware file on a modelled chipabout 8 s for a short Renode testParts the model leaves out
Bench (HIL)The real firmware on a real boardminutes, plus flashingHard to cause rare faults
FieldThe product, in usedays to monthsEverything: you control nothing

The matrix

The device below holds the eight bugs and five rungs. Each cell says whether a rung catches the bug, maybe catches it, or cannot. These are our judgments from the sources and from the chapters ahead, not measurements. Switch rungs on and off. The read-out counts what you catch for sure, what you only might catch, and what escapes to your customer.

Build a test strategy

Press a rung to switch it on or off. Start with only Host unit. Add rungs until nothing is red.

Our judgment, not data. “Maybe” means it depends on how good your model, rig or luck is. Chapters 4 to 8 show why each cell is what it is.

Reading the matrix

Look at the first row. A ring buffer that drops the last byte is pure logic. The host catches it, and so does every rung above, but the host catches it in 2 seconds. The cheapest rung that finds a bug is the rung you should use for that bug.

Look at the third row, a datasheet misread. Suppose you read the datasheet wrongly and believe the command byte for a read is 0x28. You write the driver that way. You then write the fake from the same belief, so the fake agrees with the driver. The test passes. The real chip disagrees. Only a rung with the real chip can see it.

This is the most important limit of everything in Chapters 2 to 6. A fake is your understanding of the chip, written as code. It tests that your driver matches your understanding. It does not test that your understanding is right. The same holds for an emulator model, though a model written by someone else, from their own reading of the manual, is a second opinion.

A bug, three ways to find it

Take the sixth row: the clock is set to the wrong speed. Symptom: the sensor is sampled at 400 Hz when you asked for 100 Hz, and the processor wakes four times as often, which costs battery. Measurement: on a bench, count the interrupt edges per second, or read the clock register back. Fix: correct the divider. The host cannot show this, because the laptop has its own clock. An emulator can, if its model has the chip’s clock block.

Compare the last row, a power cut in the middle of a write to flash. Symptom: one unit in thousands boots to garbage after a battery pull. A bench with a switchable supply can cut power at random moments, but it needs thousands of cycles. On the host, a fake flash that you tell to stop after the third byte reproduces the same state in one run. Here the host is not only faster. It is the only place where you can pick the exact instant.

The rule of the ladder. Move each bug down to the lowest rung that can see it. Keep the higher rungs for what only they can see: wires, clocks, real timing, and the places where your model could be wrong.
You misread the datasheet and wrote both the driver and its fake with the same wrong command byte. Which rung first shows the bug?

Chapter 2

Cut the Code at a Seam

Split a driver so the same logic runs on the chip and on your laptop, with one small file that changes

You copy your sensor driver to your laptop and try to compile it. The first line fails: the chip vendor’s header file is not there. You delete that line. The next fails: a function that sends bytes over SPI does not exist. You write an empty one. The program builds, you run it, and it crashes at once.

The crash comes from a line like *(volatile uint32_t *)0x40013000 = value;. On the chip, that address is a control register in the peripheral region, and the write talks to hardware. On a laptop, nothing lives at that address, and the operating system stops your program. The driver is tied to the chip by a rope you cannot see.

A seam is a place where you can swap one piece of behaviour for another without editing the code around it. In firmware, the best seam sits exactly where your code meets the hardware.

One function is the whole boundary

Look at what a sensor driver really needs from the world. It needs to send some bytes and get some bytes back. Everything else, such as building the command byte and turning two bytes into a number, is plain arithmetic. So we give the driver one tiny interface to the world and nothing else.

c/* spi_bus.h : the seam. The driver sees only this. */
bool spi_xfer(const uint8_t *tx, uint8_t *rx, size_t n);

/* lis3dh.c : the code under test. No chip headers, no registers. */
int16_t lis3dh_read_x_mg(void) {
    uint8_t tx[3] = { 0x80 | 0x40 | 0x28, 0, 0 };   /* read, auto-increment, OUT_X_L */
    uint8_t rx[3] = { 0 };
    spi_xfer(tx, rx, 3);
    return (int16_t)(rx[1] | (rx[2] << 8));  /* low byte first */
}

Two files can satisfy spi_bus.h. The first, hal_spi_stm32.c, writes to the real peripheral. The second, fake_spi_lis3dh.c, is an array in RAM that plays the part of the chip. The driver cannot tell them apart. This trick is called link-time substitution: the compiler sees the same function name, and the build decides which file provides it.

The device below shows the two builds. Switch between them and watch which file the linker receives, and which one the driver’s call lands in.

Swap the file behind the seam

Pick the build, then the seam style. The arrow shows where the driver’s call lands. The line below shows what the compiler is given.

File names are illustrative. The compiler name arm-none-eabi-gcc is the standard GNU Arm embedded compiler; the host build uses the laptop’s own compiler.

The second style: pass the bus in

Link-time substitution needs the build system to choose files. A second seam style needs no build tricks. You bundle the bus calls into a small struct of function pointers and hand it to the driver when you create it. This is dependency injection: the driver receives what it depends on, instead of reaching for it.

ctypedef struct {
    bool (*xfer)(const uint8_t *tx, uint8_t *rx, size_t n);
} spi_ops_t;

void lis3dh_init(lis3dh_t *d, const spi_ops_t *bus);   /* firmware: &real_ops. test: &fake_ops. */

The pointer style costs one extra indirection call and one extra argument. It lets one test program use two fakes at once, for two sensors on two buses, which link-time substitution cannot do. Link-time substitution costs nothing at run time and keeps call sites clean. Both are fine. Pick one per project and keep to it.

Where the seam goes

Put the seam as close to the hardware as you can, and keep the file behind it boring. The real hal_spi_stm32.c should be a few dozen lines that move bytes and nothing else. Every line behind the seam is a line your host tests cannot see. The smaller that file, the less you rely on the bench.

The Interrupt post gives matching advice: each test should use one real module, with everything else stubbed or faked. It also warns against rewriting old code just to test it. Add seams to new modules first, and ask for them in code review.

What changes between laptop and chip

Even with a clean seam, the same C can behave differently on the two machines. The usual causes are small.

A fourth help is coverage, a report of which lines your tests ran. The Interrupt post builds it with lcov. Treat it with care: it shows that a path was taken, not that the path was checked. A test with no assertion still gives coverage.

Worked example, step by step. (1) The driver called HAL_SPI_TransmitReceive directly. (2) We wrote spi_xfer as a one-line wrapper, with the same arguments. (3) The driver now calls spi_xfer. (4) The wrapper stays in hal_spi_stm32.c. (5) A second file, fake_spi_lis3dh.c, defines spi_xfer over an array. (6) The host build lists the fake, the firmware build lists the real file. No line of lis3dh.c changed between builds.
Your driver reads a register by writing to a fixed address. What is the smallest change that lets it run on the host?

Chapter 3

Stubs, Fakes and Mocks

Choose the right stand-in for each dependency, and keep the test about your code and not about the stand-in

A film crew uses a stunt double when the real actor should not jump off the roof. The double looks right from far away and does one job. Tests use the same idea. Your code depends on a SPI bus, a clock, a mutex, a flash chip, a logger. In a host test you replace each one with a test double: a stand-in with the same interface and a simpler inside.

There are three kinds that matter. People use the names loosely, so we use the Interrupt post’s definitions and stay with them.

Stub, fake, mock

A stub is “a trivial implementation that returns canned values.” It is usually one line: return 0;. Use it for a dependency your test does not care about, such as a function that counts analytics events. If a stub grows past a few lines, it wants to be a fake.

A fake is “a working implementation” with a simpler inside. A key/value store that keeps its data in RAM instead of flash is a fake. So is a mutex that counts how many times it was locked. A fake has real behaviour, so you can run long scenarios against it.

A mock is “an implementation that is controlled by the unit test.” The test tells it what to return, and afterward asks what it was called with and how many times. A mock is the most powerful and the most wordy of the three.

DoubleHas real behaviour?Who drives it?Best for
StubNo: canned answerNobodyA dependency you ignore
FakeYes, simpler insideYour code, through its interfaceLong scenarios, state, many calls
MockNo: scripted answersThe testExact calls, forced errors

Try the choice yourself. Each card describes a dependency and a goal. Pick the double that fits.

Pick the double

Press Stub, Fake or Mock on each card. A right pick turns green with the reason; a wrong pick turns red. You may try again.

The first four scenarios and their answers follow the Memfault Interrupt post (analytics stub, RAM key/value store, mutex that counts locks, malloc forced to NULL). The wording of each card is ours.

A mock for the driver, written by hand

Here is a mock for our seam from Chapter 2. It remembers what the driver sent, replies with bytes the test chose, and counts calls. The test then checks all three. A framework can write this for you: CMock, from the Unity project, reads a header and generates mock functions such as Dependency_ExpectAndReturn(1, 2, 3), and reports a failure in _Verify if the real calls differ. The hand version shows what is inside.

c/* mock_spi.c : lives in the test folder, never in the firmware */
static struct { uint8_t sent[8]; uint8_t reply[8]; size_t calls; } mock_spi;

bool spi_xfer(const uint8_t *tx, uint8_t *rx, size_t n) {
    memcpy(mock_spi.sent, tx, n);          /* remember what the driver sent */
    memcpy(rx, mock_spi.reply, n);         /* answer with what the test chose */
    mock_spi.calls++;
    return true;
}

/* test_lis3dh.c (Unity) */
void test_read_x_sends_E8_once_and_decodes_1000_mg(void) {
    memset(&mock_spi, 0, sizeof mock_spi);
    const uint8_t r[] = { 0x00, 0xE8, 0x03 };   /* dummy, X_L, X_H: 0x03E8 = 1000 */
    memcpy(mock_spi.reply, r, sizeof r);
    TEST_ASSERT_EQUAL_INT16(1000, lis3dh_read_x_mg());
    TEST_ASSERT_EQUAL_HEX8(0xE8, mock_spi.sent[0]);   /* 0x80 | 0x40 | 0x28 */
    TEST_ASSERT_EQUAL_INT(1, mock_spi.calls);
}

Read the three assertions. The first checks the result: the number the driver returns. The second checks an interaction: the first byte on the wire. The third checks a count. Result checks are robust. Interaction checks pin down how the code works inside, so use them where the exact bytes are the contract, as they are on a bus.

A fake that catches a bug nobody wrote a test for

The Interrupt post builds a key/value store on top of the littlefs filesystem. In its test the flash is littlefs’s own emulated block device, and the mutex is a fake that tracks a lock_count in a table of 256 slots. At the end of every test, the teardown asserts that all locks are released.

That one line in teardown caught a real bug. The read function returned early on some failure paths without unlocking the mutex. No test had been written for that. The fake knew the rule “every lock needs an unlock” and applied it to every test for free. A fake can hold an invariant for you.

How doubles go wrong

Symptom: you refactor the driver and twenty tests fail, though the numbers it returns are still right. Measurement: read the failing assertions. They check the order or count of internal calls. Fix: keep interaction checks for contracts that really exist, such as bytes on a bus, and check results for the rest.

Symptom: all tests pass and the board fails. Measurement: compare the fake’s behaviour with the datasheet line by line. The fake can be too kind: it answers instantly, never returns errors, and never changes under you. Fix: give the fake the chip’s bad habits (Chapter 5) and check it on a bench against one real chip.

Write shared fakes and stubs early and reuse them. The Interrupt post advises it, and also says tests should be quick: a few milliseconds is ideal, and one second is the worst you should accept.

You want to test a log module that writes to flash, with thousands of writes and reads, and no chip. Which double fits best?

Chapter 4

Write the Failing Test First

Build a fake SPI accelerometer from its datasheet, watch three tests turn red, and fix each bug until they turn green

The accelerometer on your desk is a small chip with three axes. You ask it, over four wires, “what is the acceleration on X?” and it answers with two bytes. You have not got the board yet. The board is on a ship. But the datasheet is here, and a driver can be written and tested from a datasheet alone.

First we need to know exactly what goes on the wire. The ST LIS3DH datasheet describes a register map: numbered cells inside the chip. You read a cell by sending its number. The first byte of every SPI exchange is a command byte with three parts.

Bits of the first byteNameMeaning (LIS3DH datasheet, section 6.2)
bit 7 (0x80)RW1 means read. 0 means write.
bit 6 (0x40)MS1 means the address goes up by one after each byte, so one transfer reads several registers.
bits 5 to 0AD(5:0)The register address.

The datasheet numbers these bits in the order they are sent: its “bit 0” is the first one on the wire, which is the top bit of the byte. The chip then sends its data, most significant bit first.

Two exchanges, byte by byte

Who are you? Register 0x0F, named WHO_AM_I, holds the fixed value 0x33. Reading it proves the chip is there and the wires work. Send 0x8F (that is 0x80 for read, plus 0x0F) and then one dummy byte 0x00. The chip’s answer to the second byte is 0x33. SPI is full duplex, so the first byte received, while you send the command, is meaningless.

What is X? The X reading lives in OUT_X_L at 0x28 (low byte) and OUT_X_H at 0x29 (high byte). The datasheet says the value is a two’s complement number, and that with the default setting (BLE = 0) the low byte sits at the lower address. Send 0xE8 (that is 0x80 | 0x40 | 0x28: read, auto-increment, address 0x28), then two dummy bytes. You receive: dummy, low byte, high byte.

If X is +1000 mg, that is 0x03E8, so you receive 0x00, 0xE8, 0x03. If X is −1000 mg, two’s complement gives 0x10000 − 1000 = 0xFC18, so you receive 0x00, 0x18, 0xFC. We use a scale of 1 mg per count, which is the datasheet’s typical sensitivity at the ±2 g setting (its Table 3). The chip’s alignment of the 12-bit and 16-bit modes differs; our model keeps one simple rule and says so.

The fake chip

A fake LIS3DH is a 64-byte array, one byte for each possible register address, and one function that follows the three rules above. WHO_AM_I holds 0x33 and cannot be written. The test sets the OUT registers to whatever acceleration it wants. About 15 lines of C do the job, and the device below runs the same logic in JavaScript.

Red, green

Test-driven development has a short rhythm. You write a test for behaviour that does not exist yet and watch it fail (red). You write the least code that makes it pass (green). You tidy up with the tests as a safety net. The first step matters: a test you never saw fail might not be able to fail.

Below is the driver, three tests, and three bugs you can plant. Each bug is a real, common slip. Turn bugs on, switch tests on or off, and press Run tests. Notice what happens when a bug has no test.

Break the driver, catch it

Top row: plant a bug (pressed means the bug is in the code). Second row: which tests exist (pressed means written). Then press Run tests.

The sensor is a model of the LIS3DH from its datasheet: WHO_AM_I 0x0F = 0x33, command byte RW (0x80), MS (0x40) and address, low byte at the lower address, two’s complement, 1 mg per count at ±2 g. The driver runs in JavaScript but mirrors the C shown. This is a model, not a chip.

What each bug does to the bytes

Bug A, the read bit is missing. The command byte is 0x0F instead of 0x8F. The chip thinks you are writing to WHO_AM_I, which it ignores. You receive zeros. Symptom: expected 0x33, got 0x00. The X reading is also 0, so the positive-X test fails too.

Bug B, the auto-increment bit is missing. The command is 0xA8 instead of 0xE8. The address does not advance, so both received bytes come from 0x28. For +1000 mg you get 0xE8 twice, 0xE8E8, which is −5912. Symptom: expected 1000, got -5912. A test of a single byte read would never see it.

Bug C, the sign is lost. The driver builds the 16-bit value and returns it in a wider integer without the (int16_t) cast. A value of −1000 is 0xFC18, which stays 64536. Symptom: expected -1000, got 64536. The positive test passes. Only a negative reading shows it.

Plant bug C, turn off the negative test, and run. Everything is green and the bug is still there. Green means “the checks I wrote pass”. It never means “the code is right”. The choice of inputs is the skill. Always include the awkward ones: zero, the largest and smallest value, a negative number, and one value per byte so that a swapped byte shows.

On real hardware

Take an STM32 Nucleo board and an LIS3DH breakout wired to one of its SPI ports. Clip a logic analyzer to SCK, MOSI, MISO and CS. Send the WHO_AM_I read and check that MOSI shows 0x8F and MISO shows 0x33. Then read X with the board flat and still: you should see about 0 mg on X and Y and about 1000 mg on Z, a standing 1 g. If the real bytes differ from the fake’s, the fake is wrong, and you fix the fake first.

The driver returns 64536 for a sensor reading of −1000 mg. Your suite has only the +1000 mg test and it is green. What is the lesson?

Chapter 5

Make the Chip Misbehave on Purpose

Inject faults into the fake sensor to run the error paths that a bench almost never shows you

Your driver passes every test from Chapter 4. Six months later a customer sends back a band whose step counter froze. You open it. A wire to the sensor has a hairline crack. The chip answers sometimes and stays silent at other times. Your driver waits for a “data ready” flag that never comes, and it waits forever.

Look at your driver code. Next to each call that can fail there is an if and a branch that returns an error. On the bench those branches never ran. The wires worked. The chip answered. The code you wrote with most care for bad days was never tested on a bad day.

Fault injection is the answer: you make the fake misbehave on purpose, in a way you choose, as often as you choose, and you check what your code does. This is something a bench cannot easily give you. You can cut a wire with scissors once. You cannot cut it at call number 7, 100 times, in a CI job.

Five faults a sensor can have

Each fault below is a way the real world differs from the happy fake. Each one is a few lines in the fake.

A fault is a hook in the fake

In C, the fake gets one extra function that the test calls, and one if inside spi_xfer that obeys it.

ctypedef enum { FAULT_NONE, FAULT_DEAD_BUS, FAULT_NO_DRDY, FAULT_OVERRUN, FAULT_GLITCH } fault_t;

static fault_t g_fault; static int g_after;          /* fault starts at call number g_after */
void fake_inject(fault_t f, int after_calls) { g_fault = f; g_after = after_calls; }

bool spi_xfer(const uint8_t *tx, uint8_t *rx, size_t n) {
    normal_transfer(tx, rx, n);
    if (g_fault == FAULT_DEAD_BUS && g_calls >= g_after) memset(rx, 0xFF, n);
    if (g_fault == FAULT_NO_DRDY && tx[0] == (0x80 | 0x27)) rx[1] &= ~0x08;   /* hide ZYXDA */
    g_calls++;
    return true;
}

The test says: “Make data never ready. Call lis3dh_read_x_mg. It must return an error within five polls.” Before the fix, that test hangs, and the test runner’s own timeout turns the hang into a failure. That is red. After the fix, it passes. You have reproduced the frozen band in one second, on your laptop, without the band.

Three drivers meet the faults

The device below plays 20 reads against the fake. It lets you pick the fault, how often it strikes, and one of three driver styles.

Inject a fault, read twenty times

Each square is one read. Green: right value. Teal: the driver reported a problem. Red: wrong value passed on as good, or the driver stuck. Grey: never happened because the driver hung.

40%

Illustrative model of Chapter 4’s fake: true reading 500 mg plus 10 mg per read; faults strike by a repeatable pseudo-random draw. Fault behaviour (STATUS bits ZYXDA 0x08 and ZYXOR 0x80, the CTRL_REG1 reset value 0x07) follows the LIS3DH datasheet; the dead-bus level depends on your board’s pull resistors.

What the device shows

Set No data ready at 40% with Polls forever. The first read that meets the fault never returns, and every later read is grey. In the real device this is a frozen band, and the only thing that saves it is a watchdog reset. With No checks the driver does not hang but hands back stale numbers as if they were new: red squares, no error anywhere.

Now switch to Defensive. Most of the same squares turn teal. The driver did not make the fault go away. It made the fault visible, and a visible fault can be handled: retry, mark the sample bad, or tell the user. Look at Glitch with Defensive. A few red squares remain. A flipped bit that lands inside the legal range cannot be seen by a range check alone. For those, you need a checksum, or a redundant reading, or a plausibility test against the last value.

That last point is honest and important. Fault injection tells you what your code does. It does not make the code catch everything. It tells you what you still miss, and the red squares are your to-do list.

How to know the error paths ran

Symptom: the code has a branch you believe is safe and no test touches it. Measurement: run the host tests with the coverage report (the Interrupt post builds it with lcov). The lines that never ran are the error branches. Fix: write a fault-injection test per branch, then check the coverage turns green. Remember that coverage shows a line ran, not that the test judged the result, so read each test’s assertion too.

A last rule collects the chapter: every wait has a bound. Any loop that waits for hardware needs a count or a time limit, and a test that proves it gives up. A watchdog (see the safety lesson) is the last net. It should not be the first.

On real hardware

On a Nucleo with a LIS3DH breakout, run the driver while you gently unplug the MISO jumper wire. Log, with a timer, how long lis3dh_read_x_mg takes to return. A good driver returns an error within the poll limit times the poll interval. A bad one never returns, and the board resets only if a watchdog is on.

A driver waits for the data-ready bit with no limit. How do you test that it can hang, without a broken sensor?

Chapter 6

Control Time and Interrupts on the Host

Use a fake clock and a forced interrupt to reproduce a bug that strikes once in 49.7 days

A smart lock works perfectly in the lab for months. Then, on one morning, 49 days and 17 hours after a power-up, it forgets what time it is and unlocks late. A day later it is fine again. Nobody can reproduce it. Your lab never ran a lock that long without a reset, and when it did, the failure lasted a few microseconds.

Time is the hardest thing to test on a board, because you cannot slow it down, rewind it, or jump ahead. Interrupts make it worse. An interrupt is a signal that makes the processor stop what it is doing, run a small function called an interrupt service routine (ISR), and then carry on. It can arrive between any two machine instructions.

A counter that two hands touch

Most firmware keeps a tick counter. A timer interrupt fires every millisecond, and its ISR adds one to a variable. Here it is as a 64-bit number, so that it never wraps in practice.

cvolatile uint64_t ticks;                       /* 1 tick = 1 ms */
void tick_isr(void) { ticks++; }               /* the ISR: runs every millisecond */

uint64_t now_ms(void) { return ticks; }          /* main code reads it */

On a 32-bit core, a 64-bit variable lives in two 32-bit halves. Reading it takes two steps: read the low half, read the high half. An ISR can fire between the two steps. This is a race: the result depends on the exact order in which two things happen.

The torn read, worked step by step

Let the counter stand at 0x0000 0000 FFFF FFFF. The low half is full. The next tick carries into the high half and gives 0x0000 0001 0000 0000.

  1. Main reads the low half: it gets 0xFFFFFFFF.
  2. The ISR fires. The counter becomes 0x00000001_00000000.
  3. Main reads the high half: it gets 0x00000001.
  4. Main glues them: 0x00000001_FFFFFFFF = 8,589,934,591.

The true time was about 4,294,967,296 ms. The value main computed is 4,294,967,295 ms too large, which is 49.7 days. A torn read is a value made from halves of two different moments. It never appears on a normal day, because the low half is rarely full. It appears at the rollover, and only if the ISR lands in a window a few instructions wide.

The fake clock, and the forced interrupt

Two tools make this testable. The first is a fake clock. The code reads time only through a seam such as get_ticks(). In the test, you set the counter to any value you like, so 49.7 days of uptime cost nothing: set it one tick before the rollover. The second is a test hook, a callback placed between the two reads that your test fills in with a call to the ISR.

c/* firmware build: the hook compiles to nothing */
/* test build: it calls whatever the test registered */
#ifdef UNIT_TEST
  extern void (*test_hook)(int point);
  #define HOOK(n) do { if (test_hook) test_hook(n); } while (0)
#else
  #define HOOK(n) ((void)0)
#endif

uint64_t now_ms_racy(void) {
    uint32_t lo = ticks_lo();
    HOOK(1);                       /* a test can fire tick_isr() right here */
    uint32_t hi = ticks_hi();
    return ((uint64_t)hi << 32) | lo;
}

void test_now_is_never_torn(void) {
    fake_ticks_set(0x00000000FFFFFFFFULL);
    test_hook = fire_tick_isr_once;                 /* runs at HOOK(1) */
    uint64_t t = now_ms_racy();
    TEST_ASSERT_TRUE(t == 0xFFFFFFFFULL || t == 0x100000000ULL);   /* before or after, never between */
}

The device below runs the same story for you. Pick the start value, the way main reads the counter, and the instant the interrupt arrives. A slot is the instruction before which the ISR fires. Then use Try every slot to run all five.

Fire the interrupt at the worst moment

Pick a start value and a read method. Drag the slot to move the interrupt along the instructions. The last line shows what main computed.

1

A model of a 32-bit core reading a 64-bit counter in 32-bit steps; one ISR adds one tick. A value counts as right if it equals the counter before or after that tick. On real parts, check your core’s documentation for which accesses are single steps. Interrupt masking is shown as CMSIS-style disable and enable calls.

Reading the result

With Fresh boot every slot is right. The low half is far from full, so a tick never carries. This is why the bench is happy for months. With Near rollover and Plain, exactly one slot is wrong: the one between the two reads. That is one of five. On a real board the window is a few instructions in a millisecond, and the low half is full for one tick in 4,294,967,296.

Retry reads the high half, then the low half, then the high half again, and starts over if the two high reads differ. An ISR can change the counter at most once per attempt, so the second attempt succeeds. Mask turns interrupts off for the two reads. The tick waits and fires after. Masking is simple, and it adds delay to every interrupt, so keep the masked part to two instructions.

A third fix is to avoid the problem. Keep time in a 32-bit counter and compare intervals with unsigned subtraction. If start = 0xFFFFFFF0 and now has wrapped to 5, then (uint32_t)(now - start) is 21, the true elapsed time, even though now is smaller than start. A single 32-bit read is one instruction and cannot tear.

What the host test does not prove

This test explores the orders of instructions in C. It cannot see effects below that level: cache lines, write buffers, a second core, or DMA writing memory behind your back. On a single-core Cortex-M, instruction order is the main hazard, so the test is strong there. It is weaker once a second bus master exists.

On real hardware

On a Nucleo, set the tick counter to 0xFFFFFFFFFFFF0000 at boot by writing it in a debug build, then run the plain read in a tight loop and count torn values. You will see a few per rollover, not one per read. Then switch to retry and confirm the count drops to zero over the same run.

See interrupts and DMA for how the processor takes an interrupt, and embedded real-time systems for more on timers.

Your bench ran a device for a month with no timing bug, but the code reads a 64-bit tick counter in two 32-bit steps. How do you test for a torn read in one second?

Chapter 7

Run the Real Firmware on a Pretend Chip

Use the Renode emulator to boot the exact file you flash, and write a test that waits for a line on a virtual UART

Host tests run your C on your laptop’s processor. That leaves a gap. The file that goes on the chip is built by another compiler, for another instruction set, with a startup file, a linker script and interrupt vectors that your host tests never touch. A bug in any of them survives every host test.

An emulator closes the gap by pretending to be the chip. It reads the firmware file (an ELF file, the program as the linker wrote it), translates the Arm instructions it finds into instructions your laptop can run, and keeps a model of the processor state. Around the processor it keeps models of the memory, the clock block, the UART, the GPIO pins. Your firmware runs unchanged.

What Renode is

Renode, from Antmicro, is an open-source emulation framework. It supports Cortex-M, Cortex-A, RISC-V, x86 and SPARC cores. It is built to be scripted, so it can run unattended on a CI server, and it has a test layer built on Robot Framework, a keyword-driven test tool where a test reads like a list of steps.

Three kinds of file matter. A platform description (.repl) lists the peripherals of a board in a short YAML-like text: each with a type, an address and a size. These files compose, so you load a board file and then add a small one. A script (.resc) is a list of Renode commands. A robot file (.robot) is the test.

The six commands

These monitor commands come from the Interrupt walkthrough of Renode with an STM32F4 Discovery board. You type them into Renode’s console, or put them in a .resc file.

  1. mach create "band" makes an empty machine.
  2. machine LoadPlatformDescription @board.repl adds the processor, memory and peripherals.
  3. sysbus LoadELF @build/firmware.elf puts your firmware in the flash model.
  4. showAnalyzer sysbus.uart2 opens a window that shows what the firmware writes to the UART.
  5. start runs it. (pause and machine RequestReset stop and reset it. machine StartGdbServer 3333 lets a debugger attach.)
  6. A Robot test waits for text on that UART and gives a verdict.

Step through them below. The board on the left is empty until you load the platform. Two switches change the story: one removes a memory block that the firmware uses, and one plants the byte-order bug from the hero.

Boot the firmware in Renode

Press Next command to run the session one command at a time. The board model fills in. The console shows what Renode prints.

The commands follow the Interrupt Renode post and the Renode testing docs. The warning text is paraphrased. “board.repl” and “firmware.elf” are placeholder names. The UART lines are our firmware’s, not a real board’s.

Virtual time

Renode keeps its own clock. The docs call it virtual time: it is measured in virtual seconds, with a resolution of one virtual nanosecond, and it advances in small slices that all parts of the machine share, so they stay in step. By default Renode slows the run down if virtual time would pass faster than real time. That gives you a firmware that sees its timers behave as it expects, and no dependence on how busy your laptop is.

The same idea is why a test can say “wait up to five seconds for this line”. Those five seconds are virtual seconds, so a busy laptop does not make the firmware miss its deadline. The pages we read explain virtual time but do not promise bit-for-bit repeatability, so check reproducibility on your own project by running a test twice.

A Robot test, line by line

robot*** Settings ***
Resource        ${RENODEKEYWORDS}
Suite Setup     Setup
Suite Teardown  Teardown

*** Test Cases ***
Band Reports 1000 Milli-g
    Execute Command            mach create "band"
    Execute Command            machine LoadPlatformDescription @board.repl
    Execute Command            sysbus LoadELF @${CURDIR}/build/firmware.elf
    Create Terminal Tester     sysbus.uart2
    Start Emulation
    Wait For Line On Uart      x=1000 mg    timeout=5

The first line loads the keyword library that connects the test to Renode. Execute Command sends a monitor command. The terminal tester watches a UART. Wait For Line On Uart passes when the firmware prints that line and fails at the timeout. The test is a user of your firmware, as a person at a serial terminal would be. The Renode docs also list Write Line To Uart, to type a command into the firmware, and keywords to check outgoing network packets.

Run it in CI with renode-test. Set RENODE_CI_MODE=YES and Renode saves a snapshot of every failed test to output/tests/snapshots, so you can load the machine in the state it died in. Results go to robot_output.xml, log.html and report.html. The option -j runs tests in parallel. Antmicro also publishes a GitHub Action, antmicro/renode-test-action, that installs Renode and runs your robot files.

When the model is missing a piece

Symptom: the console fills with “non existing peripheral” warnings. Measurement: the address in the warning, 0x10000000, is the start of CCM RAM, a block of fast memory on the STM32F4 that the firmware’s linker script uses. The stock board file in the Interrupt post did not have it. Fix: add a small .repl file that declares it, ccm: Memory.MappedMemory @ sysbus 0x10000000 with size: 0x10000, and load it after the board file.

This is the real limit of emulation. A model is only as good as its authors made it. It runs the code you wrote and the peripherals someone modelled. It does not run the analog parts, and it does not know how long a real flash erase takes. Treat it as strong evidence for logic and wiring of the software, and weak evidence for electrical and timing questions.

On real hardware

Flash the same firmware.elf to an STM32 Nucleo or a Discovery board and open its serial port. The line your Robot test waits for should appear there too. If the emulator passes and the board does not, you have found a gap between the model and the chip. Write down the difference: it is a test you owe the emulator.

What does a Renode test give you that a host unit test does not?

Chapter 8

Put the Board on a Shelf, Then Put It in a Pipeline

Wire real boards to a computer, then order every test rung in a CI pipeline so the cheapest answer arrives first

On Friday evening a teammate merges a small change. Every host test passes. On Monday the board will not boot, and nobody knows which of the 14 commits since Thursday broke it. The tests were good. They were not run on every change, and the one that matters, the board, was not in the loop at all.

Two ideas fix that. The first brings the real board into automatic testing. The second runs every rung of the ladder from Chapter 1 on every change, in an order that wastes the least time.

Hardware in the loop

Hardware in the loop (HIL) means a real board sits on a shelf, connected to a computer that can flash it, reset it, feed it inputs and read its outputs, with no human. The computer is part of a loop: it sends a stimulus, the board reacts, the computer judges.

A small rig has a few pieces. A debug probe (J-Link, ST-Link, CMSIS-DAP) lets the computer flash and reset the board over its debug port. A serial cable carries the firmware’s log lines. Optionally there is a switchable power supply, to cut power on purpose, and a signal source to stand in for the sensor.

The best public example is the TinyUSB project, a USB software stack. Its page describes two rigs, with 30 and 3 boards, 33 in all. Every pull request that touches code builds the examples and runs them on real silicon before it can merge. The debug probes include J-Link, ST-Link, the RP2040 debug probe, WCH-Link, TI ICDI and ESP USB-JTAG, one per board. The boards sit behind 7-port USB hubs on dedicated USB controllers.

Look at how the TinyUSB flow is split, because it is a good template.

  1. Build the examples on GitHub-hosted runners, the cloud machines GitHub provides. Upload the binaries.
  2. On self-hosted runners (machines you own, with the boards plugged in) download the binaries, flash each board, and run its tests.
  3. A script limits a pull request’s run to the boards and examples the change can affect. If it cannot tell, it runs everything.
  4. Each board is locked while a test uses it, so a person and CI cannot fight over the same board.
  5. Reports are uploaded and one comment is posted on the pull request.

Three lessons follow. Build in the cloud and test on the bench. Skip what the change cannot touch. Treat each board as a shared resource with a lock. A fourth is about safety: a self-hosted runner executes code from pull requests on a machine wired to your bench, so give it the same care as any machine that holds credentials.

A pipeline orders the rungs

A CI pipeline (continuous integration) is a list of stages that run automatically when someone pushes a change. Each stage either passes or fails the change. In GitHub Actions a workflow has jobs; jobs run in parallel unless one names another in needs, which makes it wait. Each job names where it runs with runs-on.

The ordering rule is simple. Put the cheapest, most informative stage first, and stop at the first failure. Then a typo costs 40 seconds, not 40 minutes. Here is a sketch for our driver.

yamlname: firmware-ci
on: [pull_request]
jobs:
  host-tests:                                   # Chapters 2 to 6: seconds
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: make test        # host build, -fsanitize=address, one binary per test file
  firmware-build:
    needs: host-tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: make firmware    # arm-none-eabi-gcc; also check the size budget
  renode:                                       # Chapter 7: tens of seconds to minutes
    needs: firmware-build
    runs-on: ubuntu-latest
    steps:
      - uses: antmicro/renode-test-action@v5
        with: { renode-revision: 'master', tests-to-run: 'tests/**/*.robot' }
  hil:                                          # the bench: minutes, scarce
    needs: renode
    runs-on: [self-hosted, hardware-in-the-loop]
    steps:
      - run: python3 test/hil/run.py --board nucleo-1

The device lets you design the same pipeline. Turn stages on and off. For each of the eight bugs from Chapter 1, the bars show how long it takes for the pipeline to turn red. The scale is logarithmic, so a 10 second stage and a 10 minute stage both fit.

Build the pipeline

Switch stages on. Choose the order and when the bench runs. A solid bar is a bug the pipeline surely catches; a hollow bar is a maybe.

Stage times are illustrative: build 40 s, host unit tests 10 s, host with fakes 30 s, Renode 120 s, bench 600 s, nightly bench 12 h. Which stage catches which bug is the matrix of Chapter 1, our judgment. Real rigs differ.

What the bars teach

Start with only Host unit on. Most bars say the bug escapes. Add Host + fakes and several turn solid within a minute. Add the Bench and the last ones turn solid, but a 10 minute stage is now the slowest link. Switch to Bench nightly. The bench-only bugs now take 12 hours to turn red. That is a trade you may choose: a rare bug is found tomorrow, and every pull request stays fast.

Now flip the order to Slowest first. The same bugs are found, but a bug the host would catch in seconds now waits behind the bench. Order does not change what is found. It changes how long you wait to hear.

When the pipeline lies

Symptom: the pipeline goes red about one run in ten, and a re-run turns it green. Measurement: run the same commit many times. Renode’s test runner has a repeat option, -n 10 in its docs, for exactly this. Count the failures and find which test fails. Fix: find the shared state or the timing assumption. Quarantine the flaky test in a visible list. Never delete it, and never let people learn to ignore red.

A bench has its own failure: a loose cable, a hung board, a probe that needs a power cycle. Give the rig a health check that runs first, and report “rig unhealthy” as different from “firmware failed”.

On real hardware

Take one spare Nucleo, a USB cable and a Raspberry Pi or old laptop. Install a self-hosted runner on it, label it, and wire a job that flashes the board and waits for the line boot ok on its serial port. Time it from push to verdict. That number, not any number in this lesson, is the one that tells you how often your team will wait.

The safety lesson has a short HIL and CI section; this chapter is the full treatment. For the role of a test engineer on a robot team, see the robotics test engineer lesson.

A one-line typo should not cost you a 10 minute bench run. What ordering rule prevents that?

Chapter 9

Field Guide: Testing Firmware Without the Board

Review the ladder, the numbers, the checklist and the core code, then see where to go next

You can now say where each firmware bug should be found and why. Pure logic is found on the host in seconds. Driver code is found against a fake chip, with faults injected on purpose and a fake clock under your control. The software stack as a whole is found in an emulator, as the exact file you flash. Wires, clocks and real timing are found on a bench. A pipeline orders all of them, cheapest first.

The one-paragraph summary

A seam lets one driver run against real or fake hardware. A stub ignores, a fake behaves, a mock is scripted and checked. A test goes red before it goes green, and a green suite proves only the cases written. Fault injection runs the error paths, and every wait needs a bound. A fake clock and a test hook force a race on purpose. Renode runs the real ELF on a model with virtual time. Hardware in the loop checks what only silicon knows. CI runs it all on every change.

The numbers and terms

WhatNumber or termSource and note
Iteration cycle, one authorabout 10 min to about 2 sInterrupt unit-testing post; one team, not a law
Time to write that unit test2 daysSame post
Good test speeda few ms ideal, 1 s worst acceptableSame post
Time on debugging and testing60% or moreA 2017 Embedded market study, as cited by that post
LIS3DH WHO_AM_Iregister 0x0F = 0x33ST datasheet, Doc ID 17530 Rev 1
LIS3DH command byteRW 0x80, MS 0x40, address in bits 5 to 0; X burst read = 0xE8Datasheet section 6.2
LIS3DH CTRL_REG1reset 0x07 (power-down); 0x57 = 100 Hz, XYZ onDatasheet registers 8.8 and Table 26
LIS3DH SPI clock, scale10 MHz max; 1 mg per count at ±2 gDatasheet electrical and mechanical tables
STATUS bitsZYXDA = data ready (0x08), ZYXOR = overrun (0x80)Datasheet register 8.15
32-bit tick wrap232 ms = 49.7 daysArithmetic
Torn read example0x1FFFFFFFF = 8,589,934,591 instead of 4,294,967,296Chapter 6 worked example
Renode test length8.35 s and 8.10 s in two examplesInterrupt Renode post; Renode docs
Renode virtual time1 virtual ns resolutionRenode time framework docs
TinyUSB bench33 boards in 2 rigs (30 and 3)TinyUSB HIL page

The checklist

The core, as code

This is the smallest complete host test for our driver. It is a sketch: fake_sensor_* are the helpers from Chapter 4, and the Unity macros are the ones named in Unity’s documentation.

c/* test_lis3dh.c : build for the host, run in milliseconds */
#include "unity.h"
#include "lis3dh.h"
#include "fake_spi_lis3dh.h"

void setUp(void)    { fake_sensor_reset(); }       /* fresh chip for every test (Ch 3, 4) */
void tearDown(void) { }

void test_whoami_is_0x33(void)    { TEST_ASSERT_TRUE(lis3dh_whoami_ok()); }
void test_read_x_positive(void) { fake_sensor_set_x( 1000); TEST_ASSERT_EQUAL_INT( 1000, lis3dh_read_x_mg()); }
void test_read_x_negative(void) { fake_sensor_set_x(-1000); TEST_ASSERT_EQUAL_INT(-1000, lis3dh_read_x_mg()); }
void test_no_data_ready_times_out(void) {          /* fault injection (Ch 5) */
    fake_inject(FAULT_NO_DRDY, 0);
    int v;
    TEST_ASSERT_EQUAL_INT(LIS3DH_ERR_TIMEOUT, lis3dh_try_read_x_mg(&v));
    TEST_ASSERT_LESS_OR_EQUAL_UINT32(5, fake_sensor_status_polls());   /* the wait is bounded */
}

int main(void) {
    UNITY_BEGIN();
    RUN_TEST(test_whoami_is_0x33);
    RUN_TEST(test_read_x_positive);
    RUN_TEST(test_read_x_negative);
    RUN_TEST(test_no_data_ready_times_out);
    return UNITY_END();
}
/* build: gcc -Wall -Werror -fsanitize=address lis3dh.c fake_spi_lis3dh.c test_lis3dh.c unity.c -o test_lis3dh */

Where this sits

This lesson stands on drivers, HALs and state machines: a clean driver layer is what makes a seam cheap. It leans on interrupts and DMA for the race in Chapter 6 and on buses on the wire for SPI itself. Its limits point onward to debugging and tracing a running chip, where the bench finds what the tests could not, and to fail-safe design, where a watchdog is the net under your bounded waits. Zephyr in practice covers the RTOS side; Antmicro has described running Zephyr samples in Renode through Zephyr’s Twister test runner.

Keep going

The takeaway. A test is a question you can afford to ask again. Ask each question at the cheapest place that can answer it honestly: the laptop for logic, a fake for drivers and faults, an emulator for the software stack, and a bench for what only silicon knows. Write down what your fake believes, and check it once against a real chip.

Sources

No course or slides sit behind this lesson. It is built from primary sources we opened, and every number above is traced to one of them or marked as illustrative.

Your host tests are green, your Renode test is green, and the board returns garbage from the sensor. What is the most likely cause?

Now press Present or Teach and explain from memory why the same bug costs 2 seconds in one place and 10 minutes in another, what a fake can and cannot prove, and how you would order a pipeline for a new sensor driver. Then go back to the bug hunt at the top, set the board against the host, and say what the bars now mean.

Testing Firmware: Test Firmware Without the Board
Back to the Firmware series start · Drivers and state machines · Interrupt: unit testing basics · Renode testing docs