ワンクリックで
cortex-m-debug
Use when debugging Cortex-M microcontrollers, firmware bring-up, SWD/JTAG sessions, faults, startup code, or flashing failures
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Use when debugging Cortex-M microcontrollers, firmware bring-up, SWD/JTAG sessions, faults, startup code, or flashing failures
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use when debugging Cortex-R5 or Cortex-R firmware — TCM, MPU, caches, DFSR/DFAR aborts, exceptions, GIC/VIC interrupts, lockstep or split mode, ECC, or JTAG bring-up
Use when integrating or debugging heatshrink embedded compression — encoder/decoder sink/poll/finish loops, window/lookahead sz2, HSER/HSDR codes, or static vs dynamic alloc
Use when integrating, porting, or debugging micro-ecc (uECC) ECDH, ECDSA, key generation, uECC_set_rng, signatures, curve selection, or key/signature byte formats on an MCU
Use when debugging OpenOCD, J-Link, ST-Link, CMSIS-DAP, probe connection, reset scripts, flash algorithms, GDB attach, semihosting, RTT, or SWD/JTAG failures
Use when integrating, refactoring, or debugging PLOOC object-oriented C - def_class encapsulation, private_member protection, vtable dispatch, or inheritance-style structs
Use when integrating or debugging Li-ion charger/fuel gauge ICs (BQ24295, BQ27441, MAX17048) over I2C, covering charge start, watchdog host mode, NTC/JEITA faults, and SOC jumps
| name | cortex-m-debug |
| description | Use when debugging Cortex-M microcontrollers, firmware bring-up, SWD/JTAG sessions, faults, startup code, or flashing failures |
Use this skill to debug ARM Cortex-M firmware systematically. Start by identifying the exact MCU, board state, debug probe, toolchain, and failure phase, then choose the safest inspection path before changing flash, option bytes, clocks, or startup code.
Use this skill when:
Reset_Handler, hits HardFault, or has no UART/log output.Do not use this skill when:
cortex-r5-debug), embedded Linux, RISC-V, AVR, ESP8266, ESP32 Xtensa, or another non-Cortex-M architecture.Ask for the minimum context needed:
Classify the failure phase. Use these buckets: probe cannot connect, flash/download fails, reset/startup fails, runtime fault, peripheral bring-up fails, or low-power/wakeup fails.
Establish a non-destructive debug connection. Prefer connect-under-reset when firmware may reconfigure SWD pins, enter low power, or crash immediately.
Confirm target identity. Read the MCU ID, core type, flash size, RAM size, and debug probe target report before trusting assumptions.
Load symbols before changing target state. In GDB, load the ELF symbols first so addresses, functions, and sections are meaningful.
Collect baseline evidence. Record reset PC, SP, vector table address, fault registers if applicable, and whether the image in flash matches the expected build.
Pick the narrowest next check. Do not jump from "no boot" directly to rewriting startup code. Verify reset vector, memory map, clock assumptions, and fault state first.
Ask before destructive actions. Chip erase, option byte changes, mass erase, readout protection changes, boot mode changes, and flash loader changes require explicit user approval.
For SWD/JTAG connection issues, check:
Useful command patterns:
openocd -f interface/stlink.cfg -f target/stm32f4x.cfg
arm-none-eabi-gdb build/firmware.elf
JLinkGDBServer -device <device> -if SWD -speed 4000
pyocd list
pyocd gdbserver --target <target>
After GDB connects, collect evidence before editing code:
target extended-remote :3333
monitor reset halt
info registers
x/8wx 0x00000000
x/8wx 0x08000000
info files
bt
For Cortex-M, pay special attention to:
sp: should point into valid RAM after reset.pc: should point to Reset_Handler or a valid flash/RAM execution address.xpsr: Thumb state and exception state.VTOR: vector table location on cores that implement it.When the target hits HardFault, BusFault, UsageFault, or MemManage:
Stop and preserve the fault state. Do not reset before reading fault registers.
Read core fault registers. Common System Control Block addresses:
SCB_CFSR = 0xE000ED28
SCB_HFSR = 0xE000ED2C
SCB_DFSR = 0xE000ED30
SCB_MMFAR = 0xE000ED34
SCB_BFAR = 0xE000ED38
SCB_AFSR = 0xE000ED3C
SCB_SHCSR = 0xE000ED24
x/wx 0xE000ED28
x/wx 0xE000ED2C
x/wx 0xE000ED34
x/wx 0xE000ED38
info registers
bt
Decode the stacked frame.
Determine whether MSP or PSP was active, then inspect stacked r0-r3, r12, lr, pc, and xpsr.
Map the faulting PC.
info symbol <pc>
list *<pc>
disassemble /m <function>
Common causes:
If the target fails before main():
.isr_vector is placed at the boot address expected by the boot mode.Reset_Handler copies .data, zeros .bss, initializes clocks only after safe reset defaults, and calls SystemInit/main in the intended order.If flashing fails:
If flashing succeeds but the board does not run:
For UART, GPIO, SPI, I2C, PWM, ADC, or timers:
Before claiming progress:
sp, reset pc, and whether they are in valid memory ranges.User:
STM32 Cortex-M4 固件下载后没日志,怀疑没启动。
Agent:
Reset_Handler is reached.