From rkit
Systematic investigation protocol for MCU HardFault, MPU boot/kernel issues, and WPF crashes. Triggers: investigate, 조사, 調査, 调查, investigar, enquêter, untersuchen, indagare, HardFault, crash, 크래시
npx claudepluginhub solitasroh/rkit --plugin rkitThis skill is limited to using the following tools:
Detect the project domain to select the correct investigation protocol:
Creates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Executes implementation plans in current session by dispatching fresh subagents per independent task, with two-stage reviews: spec compliance then code quality.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
Detect the project domain to select the correct investigation protocol:
.ioc, .ld, startup_*.s, stm32*.h, fsl_*.h.dts, .dtsi, bblayers.conf, *.bb.csproj with <UseWPF>true</UseWPF>If detection fails, ask the user which domain applies.
Gather fault register values from the user or debug session:
| Register | Address | Purpose |
|---|---|---|
| CFSR | 0xE000ED28 | Configurable Fault Status |
| HFSR | 0xE000ED2C | HardFault Status |
| MMFAR | 0xE000ED34 | MemManage Fault Address |
| BFAR | 0xE000ED38 | BusFault Address |
| LR | (stacked) | Link Register at fault |
| PC | (stacked) | Program Counter at fault |
Ask the user:
# Resolve PC to source file and line
arm-none-eabi-addr2line -e build/*.elf -f -C <PC_value>
# Resolve LR (caller)
arm-none-eabi-addr2line -e build/*.elf -f -C <LR_value>
# Disassemble around fault address
arm-none-eabi-objdump -d -S build/*.elf | grep -A 10 -B 5 "<PC_value>"
# Check stack boundaries
arm-none-eabi-nm build/*.elf | grep -E "_estack|_sstack|__stack"
# Check MSP value vs _estack
# If MSP < _sstack or MSP > _estack => Stack Overflow
# Heap usage (if using malloc)
arm-none-eabi-nm --size-sort build/*.elf | grep -i heap
Stack overflow detection:
_estack (stack top) defined in linker scriptuxTaskGetStackHighWaterMark()| CFSR Bit | Cause | Typical Root Cause |
|---|---|---|
| IACCVIOL | Instruction access | Jump to invalid address |
| DACCVIOL | Data access violation | NULL pointer dereference |
| MUNSTKERR | Unstacking error | Corrupted stack |
| MSTKERR | Stacking error | Stack overflow |
| IBUSERR | Instruction bus error | Flash read error |
| PRECISERR | Precise data bus error | Invalid memory access |
| IMPRECISERR | Imprecise bus error | Buffered write to invalid addr |
| UNDEFINSTR | Undefined instruction | Corrupted code / wrong thumb |
| INVSTATE | Invalid state | BX to non-thumb address |
| INVPC | Invalid PC load | Corrupted exception return |
| UNALIGNED | Unaligned access | Struct packing / cast issue |
| DIVBYZERO | Division by zero | Missing zero-check |
| Root Cause | Fix |
|---|---|
| NULL pointer | Add NULL check before dereference; trace allocation |
| Stack overflow | Increase stack size in linker script or FreeRTOS config |
| Alignment error | Use __attribute__((packed)) or __PACKED with care |
| MPU violation | Review MPU region config; check access permissions |
| Division by zero | Add denominator validation before division |
| Invalid function ptr | Verify callback registration; check vtable integrity |
Ask the user:
# Collect kernel messages
dmesg | tail -100
# Check for kernel panic
dmesg | grep -i -E "panic|oops|bug|error|fail"
# Boot log
cat /var/log/boot.log 2>/dev/null || journalctl -b -p err
# Compile DTS to check for syntax errors
dtc -I dts -O dtb -o /dev/null -W no-unit_address_vs_reg <file>.dts 2>&1
# Decompile running DTB for comparison
dtc -I dtb -O dts /sys/firmware/devicetree/base > running.dts 2>/dev/null
# Check for DTS warnings
dtc -I dts -O dtb <file>.dts 2>&1 | grep -i -E "warning|error"
# Search for duplicate GPIO usage across DTS includes
grep -rn "pinctrl-0\|MX6UL_PAD\|MX6Q_PAD\|MX28_PAD" *.dts *.dtsi 2>/dev/null
# Check pinctrl groups for conflicts
grep -A 5 "pinctrl_" *.dts *.dtsi | grep "fsl,pins"
Look for:
# Loaded modules
lsmod
# Platform driver binding status
ls /sys/bus/platform/drivers/
# Check if driver probed successfully
dmesg | grep -E "probe|bound|failed"
# Device presence
ls /sys/bus/i2c/devices/ 2>/dev/null
ls /sys/bus/spi/devices/ 2>/dev/null
| Category | Symptoms | Investigation Path |
|---|---|---|
| DTS syntax error | dtc compilation fails | Fix DTS syntax |
| Pin conflict | Peripheral not responding | Resolve pad mux conflicts |
| Driver not loaded | No /dev entry, probe fail in dmesg | Check defconfig, compatible |
| Kernel config missing | Feature absent | Enable in defconfig, rebuild |
| Clock/power | Peripheral timeout | Check clock tree, regulator |
| Memory map | Bus error on access | Verify reg property in DTS |
Ask the user:
Key exception types to look for:
NullReferenceException -- Missing binding or uninitialized objectXamlParseException -- XAML syntax/resource errorInvalidOperationException -- Cross-thread UI accessBindingExpression errors in Output window# Search for common binding issues in XAML
grep -rn "Binding\|{Binding" --include="*.xaml" .
# Check DataContext assignments
grep -rn "DataContext" --include="*.xaml" --include="*.cs" .
# Look for x:Bind (WPF does NOT support this)
grep -rn "x:Bind" --include="*.xaml" .
Common binding errors:
BindingExpression path error: Property name mismatch between XAML and ViewModelCannot find governing FrameworkElement: DataContext not set or wrong scopeValue produced by BindingExpression is not valid: Type converter missing# Check ViewModel inherits ObservableObject
grep -rn "ObservableObject\|INotifyPropertyChanged" --include="*.cs" .
# Check [ObservableProperty] usage
grep -rn "\[ObservableProperty\]" --include="*.cs" .
# Check [RelayCommand] usage
grep -rn "\[RelayCommand\]" --include="*.cs" .
# Verify partial class (required for source generators)
grep -rn "partial class" --include="*.cs" .
Violations to detect:
System.Windows.Controls (breaks MVVM separation)partial keyword on ViewModel class (CommunityToolkit source generators require it){x:Bind} instead of {Binding} (UWP/WinUI only, not WPF)# List all packages with versions
dotnet list package
# Check for vulnerable packages
dotnet list package --vulnerable 2>/dev/null
# Check for deprecated packages
dotnet list package --deprecated 2>/dev/null
# Restore and check for version conflicts
dotnet restore --verbosity detailed 2>&1 | grep -i -E "conflict|downgrade|warning"
| Category | Symptoms | Fix |
|---|---|---|
| Binding error | BindingExpression in Output | Fix property path, set DataContext |
| Threading | InvalidOperationException on UI access | Use Dispatcher.Invoke |
| NuGet conflict | FileLoadException, MissingMethodException | Align package versions |
| Data conversion | FormatException, InvalidCastException | Add IValueConverter |
| XAML parse | XamlParseException at startup | Fix XAML syntax, check resource URIs |
| Missing resource | IOException, resource not found | Check Build Action, pack URI |
After completing investigation, present findings in this structure:
## Investigation Report
Feature: {feature_name}
Date: {timestamp}
Domain: {mcu|mpu|wpf}
### Symptom
{What was observed}
### Root Cause
{Classification from Phase 4}
{Detailed technical explanation}
### Evidence
{Register values / error messages / stack traces}
### Fix Applied
{What was changed and why}
### Prevention
{How to prevent recurrence}
Record significant investigation findings as Architecture Decision Records:
Save to .rkit/decisions/ADR-{NNN}-{slug}.md:
# ADR-{NNN}: {Title}
## Status: Accepted
## Date: {date}
## Context
{What led to the investigation}
## Decision
{Root cause and chosen fix}
## Consequences
{Impact of the fix, what to watch for}