Module 5 · Lesson 112 of 129

The dev loop and risk list

Set up a QEMU-first SensorNode development loop, automate driver checks, and map M5 lessons to project components, risks, and fallbacks.

  • Beginner to advanced
  • 9 min read
  • 60 min lab
What you will need

Ubuntu 24.04 in WSL2 or a VM; Git, GCC, Make, Python 3 and sparse; Linux 6.8 source and a prepared module build tree; the course QEMU guest; a SensorNode board and serial console for hardware validation

Your place in the module
By the end you can 4 objectives
  • Run driver checks against a pinned Linux build and identify what must be tested on the board
  • Map each M5 lesson to a SensorNode component, artifact, or scope decision
  • Record a trigger, fallback, and closure condition for each project risk
  • Configure CI to check patches, analyze driver code with sparse, and run KUnit
Video coming soonThe dev loop and risk list
The video for this lesson is being recorded. Read the lesson below in the meantime.
Recall first from Decomposing the driver stack and milestones
  • IIO owns sensor readings, the input subsystem owns button events, and the LED class owns brightness control.
  • The sensor driver owns its runtime power transitions, while resource providers manage shared resources.
  • Milestone 1 requires a real IIO read on the board and a KUnit result for logic used by the driver.
01

Build in Ubuntu, test in QEMU, verify on the board

3 min read

The last lesson set the milestones. This lesson answers the day-to-day loop, from QEMU to the board with CI, and maps every M5 lesson to a project component with a risk list and fallbacks.

A module can compile on Ubuntu and still fail to load in the guest. For example, when CONFIG_MODVERSIONS is enabled, the kernel checks version information for imported symbols. The kernel's external module guide explains why modules_prepare alone cannot supply the Module.symvers needed in that case. Record which kernel build produced the module before treating a load failure as a SensorNode bug. Building External Modules

SensorNode development loopChangesourceBuild forQEMUTest fakesensorBuild forboardVerify realsensor↻ Repeat from step 1ChangesourceBuild forQEMUTest fakesensorBuild forboardVerify realsensor↻ Repeat from step 1
Build and test the guest first, then build the same revision for the board

Keep the driver sources, test inputs, kernel configuration fragments, and test scripts in Git. Record the kernel source revision, toolchain, and guest image identifier in the project README. Keep separate build outputs for QEMU and the board. Even when both targets use the same processor architecture, their kernel configurations and build products can differ.

  1. Change one observable behavior. Write down what the test should see. For example, a failed fake sensor read should report an error, and the next successful read should return a fresh sample.
  2. Build against the prepared kernel build directory for the QEMU guest. Boot the course guest with its matching kernel and transfer the resulting module. Use the guest's serial console to capture kernel messages and the smoke test result. Select the fake backend and run the same test inputs after each change. Bound the test runtime so a blocked read fails the run instead of leaving it waiting indefinitely.
  3. When the guest passes, build the same Git revision using the board kernel's build tree and toolchain. Run the applicable smoke checks with the real backend, then verify probe, sample acquisition, and any wired interrupt or power transition required by the milestone. Save the board model, kernel release, source revision, backend, and logs. Keep the known-good boot image available for recovery.

The fake backend gives you repeatable input and error cases. A guest pass supports claims about the paths those cases exercised. Board evidence is needed for pin configuration, sensor communication, interrupt delivery, and timing on the hardware. If a failure appears only on the board, preserve that run and use the smallest reproducing case before changing the shared driver logic.

02

Make the driver checks repeatable

2 min read

Use for every proposed driver change. Put the commands in a tracked Bash script so a learner can run the same checks locally. Configure the CI runner to fetch the comparison branch, check out the proposed revision, install the build dependencies, and prepare the pinned kernel inputs. Use a named commit from the target branch as the comparison base. The patch check should receive the commits proposed for review, including their commit messages.

Evidence from CICheckpatchSparseKUnitInputProposedpatchesDriversourcesConfiguredtest kernelEvidencePatchdiagnosticsAnalysisdiagnosticsSuite resultsRetainPatch reportBuild logTest log
Each CI check has a distinct input and result

The commands below assume you run from the SensorNode repository root. BASE is the comparison commit, KERNEL_SRC is the absolute path to the pinned kernel source, and KBUILD_DIR is the absolute path to the prepared build directory for the guest kernel. The proposed repository layout uses drivers/ for the external module and tests/.kunitconfig for the KUnit configuration.

bash
set -euo pipefail

git format-patch --stdout "$BASE"..HEAD |
    perl "$KERNEL_SRC/scripts/checkpatch.pl" -

make -C "$KBUILD_DIR" M="$PWD/drivers" C=2 modules

kunit_config="$PWD/tests/.kunitconfig"
(
    cd "$KERNEL_SRC"
    python3 tools/testing/kunit/kunit.py run --kunitconfig="$kunit_config"
)

checkpatch.pl examines patch conventions. The sparse check uses Kbuild, and C=2 examines relevant source files even when their objects are already up to date. Sparse diagnostics can appear in an otherwise successful build. For this small project, require a clean sparse run for the driver files and configure the CI job to fail when it finds a sparse warning in those files. Test that policy by observing the job reject a temporary change that produces a diagnostic. Checkpatch · Sparse

The KUnit command uses the runner's default User Mode Linux target. Its kernel tree must already include the SensorNode suite and its Kconfig and Kbuild wiring. The configuration file selects KUnit and the suite. A configuration file alone cannot discover tests in the external module directory. If implementation is still at kick-off, use an in-tree sample suite to verify the runner setup and label that result as infrastructure evidence. Once the project suite is present, require its name in the results, fail on a missing suite or failed test, and retain the log. A small deterministic conversion or error-handling test is enough to prove that SensorNode code actually ran. Getting Started with KUnit

The command sequence stops on an error. In CI, use separate jobs or steps that report each check independently, and upload their logs on failure. Also keep the QEMU smoke test result distinct from the KUnit result. One tests a booted guest and its driver integration. The other reports the assertions selected in the KUnit kernel.

03

Map lessons to components and record fallbacks

5 min read

Put the map in a tracked project document. Use it to decide which file, test, or review question belongs to a change. In the table, each short ID starts with M5- in the course. Pairings within a row follow lesson order. Use an entry as a scope decision when the corresponding subsystem is absent from your design.

Responding to a riskObservetriggerUsefallbackGathermissingevidenceClose riskObservetriggerUsefallbackGathermissingevidenceClose risk
When a risk appears, use the fallback and keep the original verification open
Lessons SensorNode component or project evidence, in order
S01A, S01A2, S01A3, S01A4 Driver and reader boundary, reader scheduling, buffer memory, device-file calls
S01B, S01B2, S01B3, S01B4 Pinned kernel build, guest module load, serial logs, debug procedure
S02A, S02A2, S02A3 Module entry, build and unwind, symbol dependencies
S02B, S02B2, S02B3, S02B4 Character endpoint, sample I/O, node discovery, error and compat tests
S03A, S03A2, S03A3 Control ABI, misc device and attributes, debug counters and cleanup
S03B, S03B2, S03B3, S03B4, S03B5 Shared state, queue protection, configuration and completion, read-mostly decision, lock order
S04A, S04A2, S04A3, S04A4, S04A5 Idle reader, sample notification, interrupted read, empty nonblocking read, event readiness
S04B, S04B2, S04B3, S04B4, S04B5 Timestamps, polling interval, precision requirement, deferred acquisition, worker choice
S05A, S05A2, S05A3, S05A4, S05A5 Sample storage, probe resources, register mapping, mapping ABI, zero-copy decision
S05B, S05B2, S05B3, S05B4 Device topology, platform binding, probe dependencies, attribute lifetime
S06A, S06A2, S06A3, S06A4, S06A5 Board description, property parsing, device links, binding schema, pin configuration
S06B, S06B2, S06B3, S06B4, S06B5 GPIO descriptors, IRQ setup, threaded acquisition, IRQ routing, controller scope
S07A, S07A2, S07A3, S07A4 Button device, key codes, status LED, userspace peripheral checks
S07B, S07B2, S07B3, S07B4, S07B5 I2C binding, sensor transactions, bus diagnostics, register access, IRQ and mux scope
S08A, S08A2, S08A3, S08A4 Monitoring interface, channel interface, buffered acquisition, units and subsystem choice
S08B, S08B2, S08B3, S08B4, S08B5 SPI backend option, board and transfers, chip select and mode, userspace diagnostic, controller DMA scope
S09A, S09A2, S09A3, S09A4 MMIO scope, clock consumer, clock provider scope, reset dependencies
S09B, S09B2, S09B3, S09B4 Runtime PM, supply dependencies, sampling cost, board measurements
S10A, S10A2, S10A3, S10A4 PCI scope, lifecycle comparison, MSI scope, separate QEMU edu fixture
S10B, S10B2, S10B3, S10B4 DMA need, transfer mapping, DMA engine scope, coherency evidence from edu
S11A, S11A2, S11A3, S11A4, S11A5 Crash log, buffer lifetime, locks and traces, console recovery, regression investigation
S11B, S11B2, S11B3, S11B4 Core assertions, userspace smoke test, fake backend, CI jobs
S12A, S12A2, S12A3, S12A4, S12A5 Serial option, network scope, storage scope, display scope, USB scope
S12B, S12B2, S12B3, S12B4 Rust build feasibility, safety review, endpoint comparison, implementation choice
S13A, S13A2, S13A3, S13A4, S13A5 Contribution process, patch series, review checks, driver docs, source licensing
S13B, S13B2, S13B3 Project brief, milestone plan, development loop and risk register
S14A, S14A2, S14A3, S14A4 Stack implementation, blocking behavior, test evidence, review documentation
S14B, S14B2, S14B3, S14B4 Demo, review checklist, delivery series, measurement record
S15A, S15A2, S15A3, S15A4, S15A5 Evidence index, design sketch, sensor design, incident cases, project decisions
S15B, S15B2, S15B3, S15B4 Written exam notes, further exam notes, practical review, portfolio retrospective

Record each risk with an owner and milestone. Give it an observable trigger, an action that keeps work moving, and evidence that would let you close it. Use the current project requirements to decide whether a fallback may appear in the demo. For example, polling can let the application team continue while the IRQ issue is open, but a milestone that requires interrupt-driven acquisition still needs a board run showing an interrupt and the corresponding sample.

Risk and trigger Fallback Evidence needed to close
Board or sensor unavailable at integration Run the QEMU guest with scripted samples and injected errors Capture real samples through the intended board interface
Guest rejects a rebuilt module Restore the known-good guest and rebuild from its recorded kernel inputs Load the rebuilt driver and rerun the guest smoke test
Board probe or transfers fail Keep testing shared paths with the fake backend and capture the board probe and transfer logs Verify probe and repeated transfers on the target wiring
Samples arrive when polled but IRQ mode stalls Use polling for integration and mark IRQ validation pending Observe the wired interrupt followed by sample delivery
CI runs KUnit without the SensorNode suite Keep the sample suite as a runner check and leave project KUnit coverage pending Capture a result naming the SensorNode suite and its cases

Review the risk row when you promote a revision from QEMU to the board. A commit and a serial log make the result reproducible by someone who was absent from the run. When a fallback is active, put it in the run record beside the backend and test result, so a passing demo can be traced to the behavior it actually exercised.

Implementing the driver stack begins with the planned components. Bring the pinned build inputs, a repeatable test command, and the risk register so the first driver change has a recorded acceptance case.

Key takeaways

  • QEMU can exercise driver behavior with a fake sensor backend
  • A board build needs the matching target kernel build tree and toolchain
  • Checkpatch, sparse, and KUnit provide different evidence
  • A fallback keeps development moving while the original risk remains open
Reflect
  1. Explain to a colleague, in two sentences: run driver checks against a pinned Linux build and identify what must be tested on the board
  2. Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
  3. What surprised you when you ran the commands yourself?
On a real board

Repeat the key commands on your Raspberry Pi or lab board over SSH or the serial console. Note anything that behaves differently from your PC, such as missing tools, a BusyBox shell or a read-only filesystem.

References and further reading

Find your next step

↑ ↓ to move · Enter to open · Esc to close