
Recall first from Documentation and code review
- Kernel-doc records the contract that callers and reviewers need to verify.
- Device-managed resources are released automatically, while asynchronous users still need a safe shutdown sequence.
- Lock review covers shared state, caller context, and waits for other execution paths.
Start with a boot you can identify
3 min readThe last lesson finished the driver stack and its review. This lesson answers how to present it, with a scripted boot, a demo of IIO, input and LED, and the interrupt flow in /proc/interrupts.
The kernel's LED class documentation describes how a trigger can control an LED. That creates a practical problem for the demo. If the LED is already blinking at login, the audience has seen an LED work, but you still need to establish which device it belongs to and what caused the change. Apply the same standard throughout the run. For each claim, decide what action you will take, what you expect to see, and which observation you will save.
Write down the board model, sensor and wiring, the source revision and the expected kernel release. Identify the intended boot entry and device tree configuration. Prepare a board profile with the bus device paths, expected driver names, IIO device name and channel, input device identity, LED class name, and the method for finding the button IRQ. Record the permissions required for kernel logs, event devices, and LED writes. Recheck those permissions from the account that will run the demo.
Open a serial console on the host and start logging before reboot. Show the firmware or bootloader stage if your setup exposes it, then the kernel console, then the point where user space is ready. Some setups first emit serial text from the kernel. Say where the available capture begins. Use the same image and boot entry you rehearsed, and keep the serial log running even if you use SSH to drive the tests. This gives you a record if the system never becomes reachable over the network.
Save the running identity and kernel messages on the target. Set BUS_DEV to a device directory under /sys/bus discovered during rehearsal. Set RUN_DIR to a fresh directory for the current run before executing the commands. Repeat the binding check for each bus device in your board profile.
uname -r
cat /proc/cmdline
cat /proc/sys/kernel/random/boot_id
sudo dmesg > "$RUN_DIR/kernel.log"
readlink -e "$BUS_DEV/driver"
Compare the resolved driver link with the expected driver and show the subsystem devices associated with that binding. A single driver may register several interfaces, so record each expected interface even when two of them share a parent. If your driver logs a successful probe, point to the message and the device it names. A loaded module alone is weak evidence because it can be present without binding. A missing link at the deadline is a failed binding check. If available on the kernel you prepared, /sys/kernel/debug/devices_deferred can help identify a device waiting for a dependency. Keep the boot log even if a deferred device later binds successfully.
Demonstrate one controlled change at a time
4 min readUse two terminals or a split console. Put the test runner in one and the event monitor in the other. Tell the audience what to watch before you change the sensor stimulus or press the button. Save complete readings and event records while displaying only the lines needed to explain the result. Use the same order in rehearsal and in the review so you can find the evidence quickly.
For IIO, locate the sensor under /sys/bus/iio/devices/. Read the name attributes and, if two devices have the same name, confirm the parent device using the resolved sysfs path. Read the channel your driver exposes. For a raw voltage channel, for example, this can be in_voltage0_raw on a device that exports it. Take a baseline, apply a known change suited to your sensor, wait for the settling time you established in rehearsal, and read again. A repeatable test could cover and uncover a light sensor. Write down the expected direction or acceptable range for your hardware. If you present converted values, use the scale, offset where applicable, and units defined for that channel's ABI. Save the raw readings too. If the value stays constant, verify the stimulus and device identity before claiming the sensor check passed.
For input, resolve the current /dev/input/event* node using the device identity from your profile. The sysfs device/name under the corresponding /sys/class/input/event* entry helps identify it. Verify its parent if the name is ambiguous. Start sudo evtest "$EVENT_DEV" and wait until it is monitoring before touching the button. Press and release once. For the momentary key in this demo, look for EV_KEY with the configured key code and values 1 for press and 0 for release. Stop the capture after the release. Save the event log with the chosen node and device identity so a reviewer can tell which physical control generated the event.
Capture /proc/interrupts before and after that same action. Take the first snapshot with the button idle. Find the registered button IRQ in the current boot using the action name and controller information from rehearsal. Save the full table on both sides of the action, then compare the row with the same IRQ number in the two snapshots. Add the changes across the CPU columns. Explain the flow as you show the data. The button changes the GPIO input, the interrupt controller delivers an IRQ, and the driver handles the signal and reports input events. The before-and-after count covers the observation window. Both edges, contact bounce, or activity from another device on a shared IRQ can affect the count. A positive delta and the expected key events together support the demonstration. The count alone cannot identify the reported key code or the number of presses.
For the LED, show the intended entry under /sys/class/leds/, read max_brightness and brightness, and inspect trigger if it exists. Rehearse with an LED you can safely control and record its initial state. If a trigger is active, save the selected trigger, shown in brackets, and any settings you need to restore. Set the trigger to none before manual control. With LED_DIR set to the selected LED's sysfs directory, write 0 and then a supported nonzero value to brightness. Show the physical LED after each write and log the readback. Restore the prior brightness and, if applicable, the trigger and its settings. If your project routes button events to the LED, test that interaction after the manual checks and record what implements the link, such as the project program consuming the input events.
Use sysfs for these subsystem interfaces. Use debugfs for targeted diagnostics when your image exposes them, such as the deferred-device list or a diagnostic entry your driver provides. Check that debugfs is mounted at /sys/kernel/debug before relying on that path. Record a missing optional view as unavailable. Debugfs has no stable userspace ABI, so keep its output as extra evidence and base the functional checks on the interfaces the project exposes for normal use.
Run the script and present the results
4 min readMake the host runner responsible for the capture and the boot transition. Start with the target reachable. Start serial capture, read the current boot ID over SSH, and request a reboot. Expect the reboot request to interrupt the SSH connection. Retry a short SSH command until it returns a different boot ID or the deadline expires. A returned shell alone can be from the old boot if it answers before shutdown. After the new ID appears, check the kernel release and wait for the expected bindings with their own deadline. Run the target test script only after those gates pass. On a timeout, save the evidence collected so far and record which gate failed.
Put physical actions at explicit prompts. For the sensor, log the baseline before prompting for the changed stimulus. For the button, confirm the event monitor is ready and save the first IRQ snapshot before prompting for the press and release. Give each capture a deadline and end the monitor when the capture finishes. For the LED, log the requested state and readback and ask the operator to confirm the physical state. Have the script attempt restoration even when a check fails and record any restoration failure. Save the exit status and a short result summary alongside the serial log, kernel log, readings, input events, and both IRQ snapshots. Give each check an expected observation, an actual observation and a status. Mark any check the runner could not reach as skipped and include the reason.
Going deeperPackage a run the reviewer can repeat
Use one host entry script with a board profile and separate commands for building and running. The build command should select the pinned source revision and kernel configuration, invoke the project's existing build with the recorded compiler, and stage the kernel image, device trees and modules that belong together. Save the build log and a manifest with the kernel release and artifact hashes. The run command should take that manifest and the target profile, then associate the logs with the selected artifacts and the boot identity. Test the entry script from a fresh checkout to catch missing dependencies and hard-coded paths.
For a reviewer without your board, prepare a QEMU guest with the test dependencies and a clean snapshot taken before the demo. Record the QEMU machine type, disk image and snapshot restore procedure, and rehearse restoring it. State which interfaces the guest actually exercises. Use the captured board run for physical sensor, GPIO and LED evidence when the guest lacks equivalent hardware. Label both run environments in the results.
Going deeperDecode an intentional oops live
Do this after the successful demo in a disposable QEMU guest. Prepare a kernel with LKDTM, debugfs and debug information. Start the host serial capture, load LKDTM if it was built as a module, and verify that the DIRECT entry under /sys/kernel/debug/provoke-crash/ lists BUG. Keep an unstripped vmlinux and the build tree for that running kernel available on the host. Trigger the deliberate fault in the guest:
printf '%s\n' BUG | sudo tee /sys/kernel/debug/provoke-crash/DIRECT
Use the captured oops to locate the faulting function and its +offset/size annotation. From the matching kernel source tree on the host, run scripts/faddr2line "$VMLINUX" "$FAULT_FRAME" with VMLINUX pointing to the matching image and FAULT_FRAME set to the actual annotated function. Open the reported source location and show the deliberate fault. Explain the finding with the observed frame and source line, then restore the clean snapshot. The guest may stop or panic, so keep the serial log on the host throughout.
Present the result in boot order. Show the new boot ID and expected bindings, then one piece of evidence for each subsystem and the IRQ comparison. If a live check fails, show its recorded status. You can use a saved rehearsal log to explain the expected result if you identify it as a separate run. The next lesson, The code review checklist, turns from the behavior you observed to the questions a reviewer asks of the implementation.
Key takeaways
- A driver link in a bus device's sysfs directory identifies the driver bound to that device
- A controlled stimulus gives an IIO sample more evidentiary value than a single successful read
- An IRQ counter counts interrupt activity while evtest shows the input events delivered to user space
- A new boot ID identifies a fresh kernel boot before the test runner starts
Reflect
- Explain to a colleague, in two sentences: capture the boot of the intended kernel and verify each expected driver binding
- Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
- 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
- Kernel documentationIndustrial I/O core: devices and channels
- Kernel documentationInput event codes: event types and values
- Kernel documentationLED class: brightness and triggers
- Kernel documentationProvoking crashes: Linux Kernel Dump Test Module
- Kernel documentationBug hunting: decoding an oops
Official documentation first. Links checked when the lesson was published.