Logotipo de Cortex M Debug

Cortex M Debug

Comunidad
easyzoom
cortex-m-debug

Use when debugging Cortex-M microcontrollers, firmware bring-up, SWD/JTAG sessions, faults, startup code, or flashing failures

Descripción general

Editoreasyzoom
Repositorioaix-skills
Nombre de la habilidadcortex-m-debug
Estrellas
39
Forks
5
Archivos incluidos
Solo instrucciones
LicenciaMIT
Enlaces
  • Instrucciones en Markdown

    Un archivo SKILL.md que el modelo carga cuando lo necesita, de modo que solo consume tokens cuando una petición es realmente relevante.

  • Funciona con cualquier LLM

    Las habilidades de IA están en Markdown, no en código específico de un proveedor, por lo que funcionan con GPT, Claude, Gemini, Grok o un modelo local.

  • Todo en las instrucciones

    Todo lo que necesita el modelo está en las instrucciones: no hay archivos adicionales que sincronizar.

  • Código abierto

    Publicada por easyzoom en GitHub. Revisa el contenido original antes de instalarla.

Instalación

Instala la habilidad de IA Cortex M Debug en TypingMind para usarla con cualquier LLM, o añádela a otro agente que lea SKILL.md.

1

Instalar en TypingMind

TypingMind instala una habilidad directamente desde su carpeta de GitHub: lee SKILL.md, empaqueta los archivos de recursos y guarda el resultado localmente.

  1. Abre la aplicación y ve a Plugins → Habilidades.
  2. Elige «Instalar desde GitHub».
  3. Pega la URL de la carpeta de la habilidad que se muestra a continuación y confirma.
    https://github.com/easyzoom/aix-skills/tree/main/skills/cortex-m-debug
  4. Activa la habilidad en cada chat en el que quieras tenerla disponible.
Plugins → Habilidades → Añadir habilidad → Desde URL de GitHub; después, pega la URL de la carpeta y pulsa Continuar.
2

Instalar en otro agente

Cualquier agente que lea el formato Agent Skills puede usar esta habilidad: copia la carpeta en el directorio de habilidades de ese agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/easyzoom/aix-skills.git /tmp/aix-skills
mkdir -p .claude/skills
cp -r /tmp/aix-skills/skills/cortex-m-debug .claude/skills/cortex-m-debug
Reinicia Claude Code después de copiarla para que detecte la nueva habilidad.

Úsala en TypingMind

Activa Cortex M Debug en cualquier chat de TypingMind y el modelo se encargará del resto. Su nombre y descripción se incluyen en el prompt del sistema y, en cuanto una petición es relevante, el modelo carga las instrucciones completas por sí solo. No tienes que invocarla manualmente y no consume tokens hasta que se utiliza.

El modelo carga Cortex M Debug automáticamente en cuanto una petición es relevante para esa habilidad.

Funciona con cualquier modelo de IA

Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que Cortex M Debug no está vinculada al modelo para el que se creó. Instálala una sola vez en TypingMind y úsala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modelo local que ejecutes tú, todo con tus propias claves API.

  • Se carga solo cuando se necesita

    El prompt del sistema solo incluye el nombre y la descripción. Las instrucciones se cargan con la primera petición relevante, por lo que una habilidad que no se usa no supone ningún coste.

  • Cambia de modelo durante el chat

    Como la habilidad contiene instrucciones y no código, cambiar de modelo no impide que funcione: el nuevo modelo lee el mismo archivo SKILL.md.

Instrucciones de la habilidad

Este es el contenido de SKILL.md que carga el modelo. Léelo antes de instalar la habilidad: contiene instrucciones que tu modelo seguirá.

Cortex-M Debug

Overview

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.

When To Use

Use this skill when:

  • The target is a Cortex-M MCU, such as Cortex-M0/M0+/M3/M4/M7/M23/M33/M55/M85.
  • The user mentions SWD, JTAG, J-Link, ST-Link, CMSIS-DAP, OpenOCD, pyOCD, GDB, or vendor IDE debug.
  • Firmware does not boot, cannot be flashed, stops in Reset_Handler, hits HardFault, or has no UART/log output.
  • The task involves vector tables, startup files, linker scripts, clocks, reset behavior, or fault registers.

Do not use this skill when:

  • The target is Cortex-R (use cortex-r5-debug), embedded Linux, RISC-V, AVR, ESP8266, ESP32 Xtensa, or another non-Cortex-M architecture.
  • The user only needs application-level C code review with no target-specific debug context.
  • The request is to modify production firmware or security configuration before collecting baseline evidence.

First Questions

Ask for the minimum context needed:

  • MCU part number and board name.
  • Core family if known, such as Cortex-M0+, M4F, M7, or M33.
  • Current symptom: cannot connect, cannot flash, no boot, crash, hang, wrong peripheral behavior, or no logs.
  • Debug probe: J-Link, ST-Link, CMSIS-DAP, DAPLink, ULINK, or onboard probe.
  • Debug transport: SWD or JTAG.
  • Toolchain and workflow: OpenOCD, pyOCD, J-Link GDB Server, STM32CubeIDE, Keil, IAR, PlatformIO, Zephyr, RTOS, or bare metal.
  • Available artifacts: ELF, MAP file, linker script, startup file, OpenOCD config, boot log, fault dump, or GDB transcript.

Workflow

  1. 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.

  2. Establish a non-destructive debug connection. Prefer connect-under-reset when firmware may reconfigure SWD pins, enter low power, or crash immediately.

  3. Confirm target identity. Read the MCU ID, core type, flash size, RAM size, and debug probe target report before trusting assumptions.

  4. Load symbols before changing target state. In GDB, load the ELF symbols first so addresses, functions, and sections are meaningful.

  5. Collect baseline evidence. Record reset PC, SP, vector table address, fault registers if applicable, and whether the image in flash matches the expected build.

  6. 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.

  7. 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.

Debug Connection Checklist

For SWD/JTAG connection issues, check:

  • Probe driver and permissions.
  • Correct target voltage and common ground.
  • SWDIO, SWCLK, RESET, GND, and VTref wiring.
  • Probe speed. Lower the clock for unstable boards, for example 100 kHz to 1 MHz.
  • Reset strategy: normal reset, hardware reset, connect-under-reset, or halt-after-reset.
  • Whether firmware disables debug pins, changes clocks too early, enters sleep, or locks the chip.
  • Whether readout protection, secure debug, TrustZone, or option bytes block access.

Useful command patterns:

bash
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>

GDB Baseline

After GDB connects, collect evidence before editing code:

gdb
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.
  • Vector table word 0: initial stack pointer.
  • Vector table word 1: reset handler address with Thumb bit set.
  • xpsr: Thumb state and exception state.
  • VTOR: vector table location on cores that implement it.

Fault Debugging

When the target hits HardFault, BusFault, UsageFault, or MemManage:

  1. Stop and preserve the fault state. Do not reset before reading fault registers.

  2. Read core fault registers. Common System Control Block addresses:

text
SCB_CFSR  = 0xE000ED28
SCB_HFSR  = 0xE000ED2C
SCB_DFSR  = 0xE000ED30
SCB_MMFAR = 0xE000ED34
SCB_BFAR  = 0xE000ED38
SCB_AFSR  = 0xE000ED3C
SCB_SHCSR = 0xE000ED24
  1. In GDB, read them:
gdb
x/wx 0xE000ED28
x/wx 0xE000ED2C
x/wx 0xE000ED34
x/wx 0xE000ED38
info registers
bt
  1. Decode the stacked frame. Determine whether MSP or PSP was active, then inspect stacked r0-r3, r12, lr, pc, and xpsr.

  2. Map the faulting PC.

gdb
info symbol <pc>
list *<pc>
disassemble /m <function>

Common causes:

  • Invalid vector table or wrong linker script origin.
  • Stack pointer outside RAM or stack overflow.
  • Calling through a null or corrupted function pointer.
  • Unaligned access on cores/configurations that fault.
  • Executing from erased flash or invalid memory.
  • FPU enabled in compiler flags but not initialized, or ABI mismatch.
  • Interrupt handler missing, weak default handler hit, or wrong IRQ name.

Startup And Linker Checks

If the target fails before main():

  • Confirm the linker script Flash and RAM origins match the exact MCU.
  • Confirm .isr_vector is placed at the boot address expected by the boot mode.
  • Confirm initial SP is within RAM and properly aligned.
  • Confirm Reset_Handler copies .data, zeros .bss, initializes clocks only after safe reset defaults, and calls SystemInit/main in the intended order.
  • Confirm C library initialization is included if C++ constructors or libc startup are required.
  • Confirm vector table relocation, bootloader offset, and application offset agree.

Flashing And Reset Checks

If flashing fails:

  • Identify whether the failure is connect, erase, program, verify, or reset.
  • Confirm the target config matches the MCU family and flash bank.
  • Lower SWD speed and try connect-under-reset.
  • Check target voltage and reset line behavior.
  • Ask before mass erase or option byte changes.
  • Preserve readout protection and security state unless the user explicitly approves changing it.

If flashing succeeds but the board does not run:

  • Compare the programmed address with the linker script origin.
  • Confirm boot pins or option bytes select the expected boot source.
  • Halt immediately after reset and inspect SP/PC.
  • Check whether watchdog, clock setup, or early peripheral init resets the chip.

Peripheral Bring-Up Checks

For UART, GPIO, SPI, I2C, PWM, ADC, or timers:

  1. Confirm the peripheral clock is enabled.
  2. Confirm pin mux/alternate function and electrical mode.
  3. Confirm reset state and initialization order.
  4. Confirm board schematic pin mapping and package pinout.
  5. Confirm interrupt enable, priority, vector name, and handler symbol.
  6. Confirm DMA channel, request mapping, cache, and alignment on cores where relevant.

Safety Rules

  • Do not mass erase, change option bytes, disable protections, alter boot configuration, or flash unknown binaries without explicit approval.
  • Do not assume the MCU family from board branding. Ask for the exact part number or read it from the probe.
  • Do not treat Cortex-M0/M0+ like Cortex-M3/M4/M7 for fault decoding. Some registers and features differ.
  • Do not trust source-level debugging until the ELF, flash image, and running target are confirmed to match.
  • Do not keep retrying at high SWD speed when the target connection is unstable.

Verification

Before claiming progress:

  • State the MCU, core family, probe, transport, and toolchain used.
  • Confirm whether the probe can connect and halt the core.
  • Report reset sp, reset pc, and whether they are in valid memory ranges.
  • If a fault occurred, report fault registers and the mapped faulting symbol/address.
  • If flashing was attempted, report erase/program/verify status separately.
  • List any destructive action skipped or waiting for user approval.

Common Failures

  • Debugging the wrong MCU target config.
  • Forgetting connect-under-reset when firmware disables SWD pins.
  • Fixing startup code before checking reset SP/PC and linker origins.
  • Resetting immediately after a fault and losing the fault state.
  • Ignoring bootloader offsets when the vector table is not at flash base.
  • Assuming all Cortex-M cores expose the same debug and fault registers.

Example

User:

text
STM32 Cortex-M4 固件下载后没日志,怀疑没启动。

Agent:

  1. Asks for MCU part number, board, probe, toolchain, firmware ELF, and whether SWD can connect.
  2. Connects with reset halt and loads symbols.
  3. Checks initial SP/PC, vector table, linker origin, and whether Reset_Handler is reached.
  4. If it faults, reads SCB fault registers before resetting.
  5. Summarizes evidence and asks before erase, option byte changes, or code modifications.

Preguntas frecuentes

¿Qué hace la habilidad de IA Cortex M Debug?

Use when debugging Cortex-M microcontrollers, firmware bring-up, SWD/JTAG sessions, faults, startup code, or flashing failures

¿Por qué usar Cortex M Debug en TypingMind?

Porque la instalas una vez y la usas con cualquier modelo. Cortex M Debug está escrita en Markdown, no en código específico de un proveedor, por lo que la misma habilidad funciona con GPT-5, Claude, Gemini, Grok o un modelo local, y puedes cambiar de modelo en mitad del chat sin que deje de funcionar. TypingMind utiliza tus propias claves API, de modo que pagas directamente a los proveedores en lugar de pagar una suscripción por puesto, y tus habilidades y chats permanecen en tu propio almacenamiento.

¿Cómo instalo Cortex M Debug en TypingMind?

Abre Plugins → Habilidades → Instalar desde GitHub en TypingMind y pega https://github.com/easyzoom/aix-skills/tree/main/skills/cortex-m-debug. TypingMind lee su archivo SKILL.md y la instala como una habilidad que puedes activar en cada chat.

¿Qué modelos de IA pueden usar Cortex M Debug?

Cualquier modelo que conectes en TypingMind. Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que GPT, Claude, Gemini, Grok y los modelos locales pueden cargar esta habilidad cuando una solicitud se corresponda con ella.

¿Con cuántos modelos de IA puedo usar Cortex M Debug?

Con tantos como quieras. Siempre que un modelo admita habilidades, puedes usar Cortex M Debug con él: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama y muchos más, todos en TypingMind con tus propias claves API.

¿Es gratuita la habilidad de IA Cortex M Debug?

Sí. easyzoom la ha publicado en GitHub bajo la licencia MIT. Solo pagas a tu proveedor de IA por los tokens que utilizas.

¿Qué son las habilidades de IA?

Una habilidad de IA es un conjunto de instrucciones reutilizables que enseña a un modelo de IA a realizar una tarea concreta. Sigue el formato abierto Agent Skills: un archivo SKILL.md con un nombre y una descripción, además de los scripts, plantillas o archivos de referencia que pueda necesitar el modelo. El modelo solo lee las instrucciones cuando tu solicitud se corresponde con la habilidad, por lo que una habilidad instalada no supone ningún coste hasta que se utiliza.

¿En qué se diferencian las habilidades de IA de los plugins o los servidores MCP?

Un plugin o un servidor MCP proporciona al modelo nuevas herramientas que puede invocar: código que se ejecuta en algún lugar y devuelve un resultado. En cambio, una habilidad de IA aporta conocimientos y procedimientos al modelo: cómo abordar una tarea, qué pasos seguir y qué se considera un buen resultado. Las habilidades son instrucciones en Markdown, por lo que no necesitan servidor, clave API ni entorno de ejecución, y funcionan con cualquier modelo.

Ver todos

Crea ya tu propio espacio de trabajo IA

Suscríbete a nuestro boletín para recibir avisos sobre nuevas funciones y próximos sorteos 👇