feat(extensions): sysrq-serial-trigger + kernel-debug-tiers (on-device kernel debugging via serial console)#9775
feat(extensions): sysrq-serial-trigger + kernel-debug-tiers (on-device kernel debugging via serial console)#9775
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>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Disabled knowledge base sources:
📝 WalkthroughWalkthroughTwo new Armbian build extension scripts are added: ChangesKernel Debug Tiers
SysRq Serial Trigger
Sequence Diagram(s)sequenceDiagram
participant Builder as Build System
participant KernelCfg as Kernel .config/Kconfig
participant UBootCfg as U-Boot config
participant Image as Target Image (rootfs)
participant Boot as Bootloader/Runtime
Builder->>KernelCfg: extension_prepare_config__kernel_debug_tiers() validate tier & BTF
Builder->>KernelCfg: custom_kernel_config__kernel_debug_tier1/2/3() set kconfig flags
Builder->>KernelCfg: custom_kernel_config__sysrq_serial_trigger() set Magic SysRq flags
Builder->>UBootCfg: post_config_uboot_target__sysrq_serial_uboot_autoboot() set bootdelay/autoboot flags
Builder->>Image: post_customize_image__sysrq_serial_trigger_userland() write sysctl.d (kernel.sysrq=1)
Boot->>Boot: runtime uses bootargs (kgdboc=...) / DT reservations for pstore
Boot->>KernelCfg: kernel boots with enabled debug tiers and serial/sysrq support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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/kernel-debug-tiers.sh`:
- Around line 88-95: The opts_y list currently includes DEBUG_STACKOVERFLOW
which is x86-only and will be ignored on ARM/ARM64; remove DEBUG_STACKOVERFLOW
from the opts_y array (or wrap its addition in an architecture guard) and
instead add a brief comment near opts_y explaining that ARM/ARM64 uses
VMAP_STACK (symbol VMAP_STACK) for stack overflow protection and that VMAP_STACK
is enabled by default on ARM64 so no DEBUG_STACKOVERFLOW entry is needed; update
any code that assumes DEBUG_STACKOVERFLOW was enabled to rely on VMAP_STACK or
an arch-specific check.
🪄 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: 60785b52-ca37-4579-826a-bbc6f266c158
📒 Files selected for processing (2)
extensions/kernel-debug-tiers.shextensions/sysrq-serial-trigger.sh
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>
CR: CONFIG_DEBUG_STACKOVERFLOW is implemented for x86/mips/powerpc/etc. but not for ARM/ARM64. On rk3399 (helios64) and mvebu (helios4) the extension's target boards, `scripts/config --enable DEBUG_STACKOVERFLOW` writes the option, but `make olddefconfig` then strips it because the symbol is not selectable on those architectures. The extension thus silently does nothing for stack-overflow detection on its primary targets while creating the impression that the protection is active. Drop it from tier 1. The remaining tier 1 settings (printk timestamps + PRINTK_CALLER + DETECT_HUNG_TASK + SOFTLOCKUP_DETECTOR + SCHED_STACK_END_CHECK) all work on ARM/ARM64. Signed-off-by: Igor Velkov <325961+iav@users.noreply.github.com>
fefa5ec to
1d2eafb
Compare
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