feat(extensions): sysrq-serial-trigger + kernel-debug-tiers (on-device kernel debugging via serial console)#9776
feat(extensions): sysrq-serial-trigger + kernel-debug-tiers (on-device kernel debugging via serial console)#9776
Conversation
Enable Magic SysRq through the serial console for headless ARM boards (Helios64, etc.). Mainline ships MAGIC_SYSRQ_SERIAL_SEQUENCE empty, disabling BREAK-triggered SysRq; this extension fills it with a deliberate sequence after BREAK so the operator on the serial console can sync/remount-RO/reboot from any kernel state where interrupts flow. Also overrides distro kernel.sysrq=176 to 1 (full command set) and extends u-boot autoboot delay so the prompt is actually catchable. Pair with the companion `kernel-debug-tiers` extension to make the tracebacks reachable via SysRq actually informative (BTF, hung-task, KGDB symbol resolution). Signed-off-by: Igor Velkov <325961+iav@users.noreply.github.com>
Cumulative kernel debug-information tiers for headless boards that need
on-device debugging through the serial console:
KERNEL_DEBUG_TIER=0 no-op (extension loaded but kernel-side disabled)
KERNEL_DEBUG_TIER=1 printk timestamps + lockup/hung-task detection
(default — cheap, no board prerequisites)
KERNEL_DEBUG_TIER=2 + pstore/ramoops (needs DT or bootarg reservation)
KERNEL_DEBUG_TIER=3 + KGDB/KDB over serial (needs kgdboc= bootarg)
By itself the extension does nothing visible at runtime; it bakes enough
information into the kernel image that operator-console facilities like
SysRq tracebacks and KGDB sessions are actually useful instead of streams
of hex addresses. Pair with `sysrq-serial-trigger` (separate extension)
to also enable the operator-control surface itself.
extension_prepare_config validates the tier value, hard-fails with a
helpful message on KERNEL_BTF=no + KERNEL_DEBUG_TIER>=1 (BTF is required
for hung-task tracebacks and KGDB symbol resolution; either set
KERNEL_BTF=yes or KERNEL_DEBUG_TIER=0 to opt out of the kernel side),
and forces KERNEL_BTF=yes for tier>=1 when not explicitly set.
Signed-off-by: Igor Velkov <325961+iav@users.noreply.github.com>
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughTwo new Bash extensions: kernel-debug-tiers adds tiered kernel debug validation and tiered kernel config (tiers 0–2 in these diffs), and sysrq-serial-trigger enables Magic SysRq over serial with U-Boot autoboot tweaks and an image sysctl to enable SysRq. ChangesKernel Debug Tiers
SysRq Serial Trigger
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@extensions/sysrq-serial-trigger.sh`:
- Around line 48-65: The code accepts an empty SYSRQ_SERIAL_SEQUENCE which, when
set to "", will silently disable serial SysRq; change the logic around seq
(declared from SYSRQ_SERIAL_SEQUENCE) to guard against empty values: if seq is
empty or only whitespace, treat it as unset and skip calling
kernel_config_set_string and avoid appending to kernel_config_modifying_hashes
(or set a safe default sequence), and ensure opts_y/opts_val still reflect
enabling only when a non-empty sequence is provided; update the conditional that
writes MAGIC_SYSRQ_SERIAL_SEQUENCE so kernel_config_set_string and
kernel_config_modifying_hashes are only invoked when seq is non-empty (use the
existing seq variable and the functions kernel_config_set_string and
kernel_config_modifying_hashes).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9620094e-8b87-4446-aa9a-1a0ea730da92
📒 Files selected for processing (2)
extensions/kernel-debug-tiers.shextensions/sysrq-serial-trigger.sh
…_SEQUENCE
CR: ${SYSRQ_SERIAL_SEQUENCE:-sysrq} substitutes only when the variable
is unset, not when explicitly empty. An empty override silently writes
MAGIC_SYSRQ_SERIAL_SEQUENCE="" — which the kernel itself documents as
disabling BREAK-triggered SysRq entirely (see lib/Kconfig.debug). The
extension would then look enabled while doing nothing on the wire.
Treat empty the same way kconfig does: refuse it loudly so the operator
fixes their config instead of getting a silently-disabled SysRq path.
Signed-off-by: Igor Velkov <325961+iav@users.noreply.github.com>
Description
Two extensions that, together with the kernel patches already merged as PR #9750 (rk3399 8250_dw) and PR #9760 (mvebu-6.18 8250_dw), form a coherent system for on-device kernel debugging through the serial console on headless ARM boards (NAS-style: helios4, helios64, similar).
Each piece is necessary, none is sufficient on its own:
kernel-debug-tiersturns on the kernel-side information without which there is nothing to debug — BTF for hung-task tracebacks, printk timestamps and PRINTK_CALLER, lockup/hung-task detection, pstore/ramoops for post-reboot dmesg, KGDB symbol resolution. Three cumulative tiers (KERNEL_DEBUG_TIER=1|2|3, default 1) so the operator picks the cost they're willing to pay; tier 0 is a deliberate no-op.sysrq-serial-triggerturns on the serial console as a debug surface —MAGIC_SYSRQ+MAGIC_SYSRQ_SERIAL_SEQUENCEin kconfig,kernel.sysrq=1sysctl, and a long enough u-bootBOOTDELAYfor the operator to actually catch the prompt. Without this, even a kernel full of debug info can only be examined post-mortem; nothing can be done about a live hang.The
8250_dwdriver patches (PR fix(kernel/rockchip64-7.0): restore SysRq-via-BREAK on dw-apb-uart (8250_dw) #9750/fix(kernel/mvebu-6.18): restore SysRq-via-BREAK on dw-apb-uart (8250_dw) #9760, already merged) close the last gap on rk3399 and mvebu: the BREAK condition on a dw-apb-uart goes throughdw8250_handle_irq(), which used to swallowLSR.BIwithout invokinguart_handle_break()→handle_sysrq_from_serial(). Before those patches, even a fully configured SysRq-over-serial setup on these SoCs only appeared to work; the operator's BREAK never reached the SysRq dispatcher.Together these three changes make the well-documented "send BREAK, type the magic sequence, then press a SysRq command" workflow actually functional on rk3399 and mvebu boards, with enough kernel debug info behind it that the resulting tracebacks and KGDB sessions are informative rather than just hex addresses.
Tier guarantees
KERNEL_BTF=no+KERNEL_DEBUG_TIER>=1exits early inextension_prepare_configwith a helpful message (setKERNEL_BTF=yes/leave unset, orKERNEL_DEBUG_TIER=0).KERNEL_BTF=nofor RAM reasons.sysrq-serial-triggeris independent of the debug tiers; either can be enabled standalone.Tests performed
End-to-end on helios64 (rockchip64-edge, kernel 7.0.3-rockchip64):
KERNEL_DEBUG_TIER=1(default)KERNEL_DEBUG_TIER=0KERNEL_DEBUG_TIER=2KERNEL_DEBUG_TIER=3KERNEL_BTF=no(default tier 1)extension_prepare_configKERNEL_BTF=no KERNEL_DEBUG_TIER=0Checklist
Assisted-by: Claude:claude-opus-4.7
Summary by CodeRabbit