Diagnose why a SoC's firmware/OS stops booting under QEMU and decide the smallest model change that gets it further - reads bringup-run.py summaries (milestones, PC hotspots, unimplemented accesses, guest errors) and traces each blocker to a register and a source. Use during the bring-up phase or whenever a run stalls, crashes, or loops.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Qemu Bringup Debug?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/oscardagrach-qemu-bringup-debug)
---
name: qemu-bringup-debug
description: Diagnose why a SoC's firmware/OS stops booting under QEMU and decide the smallest model change that gets it further - reads bringup-run.py summaries (milestones, PC hotspots, unimplemented accesses, guest errors) and traces each blocker to a register and a source. Use during the bring-up phase or whenever a run stalls, crashes, or loops.
---
# Bring-up diagnosis
One iteration = run, diagnose, fix, rerun. `scripts/bringup-run.py <soc> --label <why>`
writes `socs/<soc>/bringup/runs/NNN/summary.json` (+ `summary.md`, `serial*.log`,
`qemu.log`, `cmdline.txt`). Progress is `summary.progress` = [milestones reached, serial
bytes]; compare with the previous run. Log each iteration in `socs/<soc>/bringup/LOG.md`.
## Read the summary in this order
1. `outcome`: `success` (done), `stall` (serial went quiet), `timeout`, `qemu-exited`
(look at `stdout_tail`: abort/assert = a model or machine bug, fix that first), `log-flood`
(qemu.log passed `max_log_mb` with thousands of distinct addresses: usually a runaway guest, e.g. a bad sp pushing through a stub
window; `unimp_last` and `pc_hotspots` show where, `log_truncated` counts what was not itemized).
2. `pc_hotspots`: `spinning: true` with a small `hot_range` is a polling loop.
`hot_disasm` shows the loop: find the load (`ldr`; RISC-V `lw`) whose address the loop compares -
that MMIO register + bit is the blocker. If the address comes from a literal pool or a
base register, compute it from the disassembly or use `qemu-firmware-re`.
PC at a `wfi`/`wfe` = waiting for an interrupt (timer or device IRQ not wired/firing).
PC in an exception vector or a `b .` = crashed: rerun with `log_flags: unimp,guest_errors,int`
to get the exception class, faulting address (FAR) and PC.
3. `unimp_unlisted`: accesses to a catch-all window or a region no spec peripheral covers. The
firmware uses a block intake missed: add it to the spec (with provenance) and model or stub it.
`unimp_last`: the most recent distinct unimplemented accesses, usually the blocker
when the PC is spinning nearby. `unimp_by_device`: what to model next by volume.
4. `log_messages`: guest errors (bad access sizes, writes to RO, unassigned accesses).
5. `serial_tail`: the last message often names the subsystem (DDR, clock, MMC, PMIC...).
## Before calling bring-up done
Reaching the last milestone is not enough. In the final run, `unimp_unlisted` must be empty, and
every distinct read from a stub (`unimp_accesses` with `rw: read`) needs a reason the value 0 is
correct, from the code that reads it: read-modify-write whose result doesn't depend on it, an
error/status check where 0 means OK, or a register only logged. A read whose value feeds a
decision (poll, branch, computed delay or frequency) needs a model, even if boot got through.
## Common blockers and smallest fixes
| Symptom | Usual cause | Smallest fix |
|---|---|---|
| Spin reading a clock/PLL/sysctl register | lock / ready bit never sets | sysctl model: bit reads as 1 (source: TRM/BSP poll loop) |
| Spin in DDR init (SPL) | DDR PHY training status bits | DDR controller stub returning "done/pass" for polled bits; DRAM is plain RAM |
| Spin on UART status before printing | TX-ready / FIFO-not-full bit | reuse correct UART model or add the status bit (DW UART: USR @0x7c) |
| Silent: no serial at all | wrong reset vector/entry, console UART base/regshift, chardev not attached | check `cmdline.txt`, CPU rvbar/init-svtor (RISC-V: `resetvec`), `serial_hd()` index |
| Stuck at `wfi` early | timer IRQ not wired, CNTFRQ 0, wrong PPI | wire generic timer PPIs, set `cntfrq` |
| RISC-V: trap loop / hot PC at the trap vector | illegal instruction (vendor CSR or custom instruction the CPU model lacks), access fault on an unmapped address | add `int` to `log_flags`: each trap logs its cause; `mcause` 2 = illegal instruction (`mtval` holds the instruction), 1/5/7 = access fault (`mtval` = address). Add the CSR/extension to the CPU model or a stub for the address |
| Crash or not depending on the run; first timer IRQ lands during early init (e.g. before the RTOS sets up its IRQ stack) | timer counts CPU cycles on hardware, but QEMU's virtual clock follows host time, so TCG translation makes init look slow | add `-icount shift=N` to run.yaml so virtual time follows instructions (shift=3 is 8 ns/insn, about 125 MHz; pick N near the core clock). Confirm with `-d int` that the trap is a timer IRQ, not a model bug |
| RISC-V: stuck at `wfi`, timer never fires | machine timer not wired, wrong `timebase-frequency`, external interrupt not reaching `mip.MEIP` | ACLINT mtimer at the spec address and frequency; PLIC context (or vendor controller) wired to the hart's M external interrupt |
| RISC-V: silent after OpenSBI banner | wrong next-stage address/DTB in `a1`, console mismatch between OpenSBI and kernel | check `fw_dynamic` info / `-kernel` address, DTB `stdout-path` |
| Hang after "Starting kernel" | earlycon base wrong, DTB mismatch, PSCI conduit, secondary CPUs | check DTB passed, PSCI mode vs firmware, `start-powered-off` |
| Linux probe errors/timeouts | device modeled partially | model the next registers that driver touches (`unimp_accesses` for that device) |
| Reset loop | watchdog firing or SoC reset register | model watchdog as disabled or implement reset correctly |
| Boot ROM gives up on media | boot-media controller or image header/signature | prefer entry_mode `firmware` (skip the ROM) unless the ROM is the target |
| Crypto/signature check fails | secure boot in ROM/SPL | model the fuse/OTP as "secure boot disabled", or skip the stage |
## Rules
- Every fix cites its source: TRM page, BSP file:line, or firmware address showing the
poll. A guess is allowed only when nothing else exists; mark it `guess:` in a code
comment and in LOG.md so it can be revisited.
- Prefer the smallest model change that matches real hardware semantics. Don't hack the
firmware image, don't skip instructions with gdb, don't special-case PCs in QEMU.
- One blocker per fix batch when blockers are related; independent devices can be fixed
in parallel (different files).
- If two consecutive iterations make no progress on the same blocker, change approach:
go to `qemu-firmware-re` for the exact expected value, read the BSP driver for that
register, or switch `boot.entry_mode` to bypass the stage. After three, record it in
STATUS.md "blocked on a human" with everything tried.
## Deeper tools
- `-d unimp,guest_errors,int,cpu_reset` via `log_flags` in run.yaml.
- Trace a model: `-trace '<soc>_*'` in run.yaml args (needs trace events in the model).
- GDB: add `-s -S` to args, run QEMU yourself in tmux, `gdb -ex 'target remote :1234'`
(check `gdb --configuration` lists arm/aarch64/riscv support), break at the hot PC, inspect registers.
- `info mtree -f` through QMP `human-monitor-command` to confirm the memory map.