Zephyr Debug
Audit workflow
For every non-trivial task that writes to the workspace, choose a stable task
slug and keep agent-only records under:
.zephyr-skills/<agent-task>/
├── audit.md # Baseline, decisions, evidence, verification, and gaps
├── commands.md # Redacted commands, working directories, and results
├── scripts/ # Intermediate debug documents, scripts, and harnesses
├── output/ # Non-Zephyr dependencies and temporary binaries
└── logs/ # Decisive build, test, runtime, or diagnostic logs
Put every generated intermediate debugging document, debug script, and
scaffolding or harness script, including Bash and Python scripts, under
scripts/, never in a build directory. Put non-Zephyr third-party source or
libraries acquired solely for the agent's task, and temporary binaries produced
by agent-only probes or tools, under output/. Do not copy normal Zephyr build
artifacts there. Keep other agent plans and temporary evidence in the same task
directory. In a Git worktree, add
/.zephyr-skills/ to the repository-local exclude file returned by
git rev-parse --git-path info/exclude before writing audit artifacts. Preserve
existing entries, avoid duplicates, and verify before handoff that
git status --short contains no .zephyr-skills/ paths. Keep Zephyr-native
build trees, binaries, and test outputs separate: honor a user-specified path,
otherwise use defaults such as configured build.dir-fmt, build/, or
twister-out/. Record the effective paths, do not stage .zephyr-skills/
unless requested, and report the task directory and unresolved gaps at handoff.
Diagnose
- Capture expected and observed behavior, the narrowest reproducer, and the
first decisive log.
- Exclude wrong revisions, boards, configuration, stale output, and generated
artifact or toolchain mismatches before changing source.
- Locate the first broken invariant across Kconfig, CMake, devicetree,
generated files, runner commands, boot flow, and runtime state.
- Test each hypothesis with the smallest reversible probe and distinguish
observations from inferences.
- For diagnosis-only requests, stop at the supported cause and remaining
uncertainty. Implement a fix and regression gate only when requested.
Choose a debugging path
- Use Zephyr logging and targeted instrumentation when the failure remains
observable without stopping the system.
- Use a QEMU GDB stub for reproducible emulated failures, early boot, exception
state, memory inspection, breakpoints, and instruction-level stepping.
- Use the board's configured debug runner with OpenOCD or J-Link for hardware
failures. Select the runner from the board, probe, and user environment; do
not assume that one backend is universally available.
- Combine logs with GDB when console history or timing explains state that a
stopped target cannot.
Run a remote GDB session
- Preserve the exact ELF and build configuration that reproduce the failure.
Use the matching toolchain GDB and keep symbols in the Zephyr build tree.
- Start the remote endpoint with the configured Zephyr runner: a QEMU GDB
stub for emulation, or a debug server backed by OpenOCD or J-Link for
hardware. Prefer runner-generated arguments over guessed probe, transport,
reset, or device settings.
- If installed, use Tmux for concurrent panes; otherwise use Zellij, then
separate terminals. Keep the debug server or QEMU in one pane, GDB in a
second, and optional console or log monitoring in a third.
- Generate a task-specific GDB command file under
.zephyr-skills/<agent-task>/scripts/, including the symbol file, remote
endpoint, breakpoints or watchpoints, thread inspection, and
evidence-producing commands. Avoid changing global GDB configuration.
- Connect with
target remote or target extended-remote as required by the
server. Capture the server command, GDB command file, decisive backtraces,
register or memory state, and target logs in the audit directory.
- For a live hardware target, prefer attach semantics when flashing or reset
is not requested. Record any operation that changes target state.
Use Zephyr logging and instrumentation
- Enable the Zephyr logging subsystem and the narrowest useful module or
subsystem log level through task-specific configuration or overlays.
- Add
LOG_DBG, LOG_INF, LOG_WRN, LOG_ERR, or hexdump probes at state
transitions, error paths, ownership changes, and relevant interrupt or
scheduling boundaries.
- Include stable identifiers and state in messages, but never log secrets or
unbounded data. Keep probes minimal and easy to remove or gate.
- Account for timing changes from added logging, synchronous output, transport
buffering, and log overflow. Recheck the failure with reduced instrumentation
before treating the result as causal.
- Save decisive console output under
.zephyr-skills/<agent-task>/logs/ and
state which logging configuration and probes produced it.
Guardrails
- Do not hide a failure by weakening assertions or tests.
- Stop only QEMU processes started for the task; never kill broad process
groups.
- Stop only debug servers and multiplexer sessions started for the task.
1---2name: zephyr-debug3description: Use when reproducing or isolating the root cause of a Zephyr build, toolchain, QEMU, boot, board, or runtime failure.4---56# Zephyr Debug78## Audit workflow910For every non-trivial task that writes to the workspace, choose a stable task11slug and keep agent-only records under:1213```text14.zephyr-skills/<agent-task>/15├── audit.md # Baseline, decisions, evidence, verification, and gaps16├── commands.md # Redacted commands, working directories, and results17├── scripts/ # Intermediate debug documents, scripts, and harnesses18├── output/ # Non-Zephyr dependencies and temporary binaries19└── logs/ # Decisive build, test, runtime, or diagnostic logs20```2122Put every generated intermediate debugging document, debug script, and23scaffolding or harness script, including Bash and Python scripts, under24`scripts/`, never in a build directory. Put non-Zephyr third-party source or25libraries acquired solely for the agent's task, and temporary binaries produced26by agent-only probes or tools, under `output/`. Do not copy normal Zephyr build27artifacts there. Keep other agent plans and temporary evidence in the same task28directory. In a Git worktree, add29`/.zephyr-skills/` to the repository-local exclude file returned by30`git rev-parse --git-path info/exclude` before writing audit artifacts. Preserve31existing entries, avoid duplicates, and verify before handoff that32`git status --short` contains no `.zephyr-skills/` paths. Keep Zephyr-native33build trees, binaries, and test outputs separate: honor a user-specified path,34otherwise use defaults such as configured `build.dir-fmt`, `build/`, or35`twister-out/`. Record the effective paths, do not stage `.zephyr-skills/`36unless requested, and report the task directory and unresolved gaps at handoff.3738## Diagnose39401. Capture expected and observed behavior, the narrowest reproducer, and the41 first decisive log.422. Exclude wrong revisions, boards, configuration, stale output, and generated43 artifact or toolchain mismatches before changing source.443. Locate the first broken invariant across Kconfig, CMake, devicetree,45 generated files, runner commands, boot flow, and runtime state.464. Test each hypothesis with the smallest reversible probe and distinguish47 observations from inferences.485. For diagnosis-only requests, stop at the supported cause and remaining49 uncertainty. Implement a fix and regression gate only when requested.5051## Choose a debugging path5253- Use Zephyr logging and targeted instrumentation when the failure remains54 observable without stopping the system.55- Use a QEMU GDB stub for reproducible emulated failures, early boot, exception56 state, memory inspection, breakpoints, and instruction-level stepping.57- Use the board's configured debug runner with OpenOCD or J-Link for hardware58 failures. Select the runner from the board, probe, and user environment; do59 not assume that one backend is universally available.60- Combine logs with GDB when console history or timing explains state that a61 stopped target cannot.6263## Run a remote GDB session64651. Preserve the exact ELF and build configuration that reproduce the failure.66 Use the matching toolchain GDB and keep symbols in the Zephyr build tree.672. Start the remote endpoint with the configured Zephyr runner: a QEMU GDB68 stub for emulation, or a debug server backed by OpenOCD or J-Link for69 hardware. Prefer runner-generated arguments over guessed probe, transport,70 reset, or device settings.713. If installed, use Tmux for concurrent panes; otherwise use Zellij, then72 separate terminals. Keep the debug server or QEMU in one pane, GDB in a73 second, and optional console or log monitoring in a third.744. Generate a task-specific GDB command file under75 `.zephyr-skills/<agent-task>/scripts/`, including the symbol file, remote76 endpoint, breakpoints or watchpoints, thread inspection, and77 evidence-producing commands. Avoid changing global GDB configuration.785. Connect with `target remote` or `target extended-remote` as required by the79 server. Capture the server command, GDB command file, decisive backtraces,80 register or memory state, and target logs in the audit directory.816. For a live hardware target, prefer attach semantics when flashing or reset82 is not requested. Record any operation that changes target state.8384## Use Zephyr logging and instrumentation8586- Enable the Zephyr logging subsystem and the narrowest useful module or87 subsystem log level through task-specific configuration or overlays.88- Add `LOG_DBG`, `LOG_INF`, `LOG_WRN`, `LOG_ERR`, or hexdump probes at state89 transitions, error paths, ownership changes, and relevant interrupt or90 scheduling boundaries.91- Include stable identifiers and state in messages, but never log secrets or92 unbounded data. Keep probes minimal and easy to remove or gate.93- Account for timing changes from added logging, synchronous output, transport94 buffering, and log overflow. Recheck the failure with reduced instrumentation95 before treating the result as causal.96- Save decisive console output under `.zephyr-skills/<agent-task>/logs/` and97 state which logging configuration and probes produced it.9899## Guardrails100101- Do not hide a failure by weakening assertions or tests.102- Stop only QEMU processes started for the task; never kill broad process103 groups.104- Stop only debug servers and multiplexer sessions started for the task.