$npx -y skills add easyzoom/aix-skills --skill mcu-flashing-debugUse when MCU firmware download, flashing, erase, verify, probe connection, boot mode, read protection, or programmer tool operations fail
| 1 | # MCU Flashing Debug |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Use this skill to debug MCU programming failures safely. Separate connection, erase, program, verify, and reset problems before recommending mass erase, option byte changes, security unlock, or boot configuration changes. |
| 6 | |
| 7 | ## When To Use |
| 8 | |
| 9 | Use this skill when: |
| 10 | |
| 11 | - Firmware cannot be downloaded or flashed to an MCU. |
| 12 | - The programmer reports connect, erase, program, verify, timeout, locked, protected, or target voltage errors. |
| 13 | - The user mentions ST-Link, J-Link, CMSIS-DAP, OpenOCD, pyOCD, STC-ISP, WCH-Link, Nu-Link, vendor programmers, boot pins, ISP, IAP, DFU, or UART bootloader. |
| 14 | |
| 15 | Do not use this skill for application-level bugs after a confirmed successful program/verify/run cycle. For probe-specific debugging (OpenOCD scripts, J-Link config, adapter speed), use `openocd-jlink-stlink-debug`. |
| 16 | |
| 17 | ## First Questions |
| 18 | |
| 19 | Ask for: |
| 20 | |
| 21 | - MCU part number and board. |
| 22 | - Programmer/probe and connection method. |
| 23 | - Tool name and exact error output. |
| 24 | - Firmware artifact path/type: ELF, HEX, BIN, IHX, UF2, or vendor package. |
| 25 | - Whether erase, program, verify, and reset are separate steps in the tool output. |
| 26 | - Target voltage, reset wiring, boot pins, and whether the board is externally powered. |
| 27 | |
| 28 | ## Workflow |
| 29 | |
| 30 | 1. Classify the failing step. |
| 31 | Do not treat "download failed" as one problem. Identify connect, erase, program, verify, reset, or run failure. |
| 32 | |
| 33 | 1. Confirm physical and electrical basics. |
| 34 | Check power, ground, target voltage sense, reset line, boot pins, and signal wiring before changing software. |
| 35 | |
| 36 | 1. Confirm tool-target match. |
| 37 | Verify exact chip model, flash algorithm, probe interface, target config, and firmware address. |
| 38 | |
| 39 | 1. Lower risk before increasing force. |
| 40 | Try lower adapter speed, connect-under-reset, separate erase/program/verify, and fresh rebuild before mass erase. |
| 41 | |
| 42 | 1. Preserve logs. |
| 43 | Capture programmer output and avoid repeated blind retries. |
| 44 | |
| 45 | 1. Ask before destructive operations. |
| 46 | Mass erase, security unlock, option byte writes, readout protection changes, bootloader erase, and config fuse changes require explicit approval. |
| 47 | |
| 48 | ## Method Checks |
| 49 | |
| 50 | ### SWD/JTAG |
| 51 | |
| 52 | - Confirm SWDIO/TMS, SWCLK/TCK, RESET, GND, and VTref. |
| 53 | - Lower adapter clock for long wires or unstable power. |
| 54 | - Try connect-under-reset when firmware disables debug pins or enters low power. |
| 55 | - Confirm the debug probe can see target voltage. |
| 56 | - Confirm readout protection or secure debug is not blocking access. |
| 57 | |
| 58 | ### UART/ISP/IAP |
| 59 | |
| 60 | - Confirm TX/RX cross, common ground, boot pin state, reset/power-cycle sequence, and baud behavior. |
| 61 | - Confirm the chip actually contains a ROM bootloader or vendor ISP mode. |
| 62 | - Confirm USB-to-UART voltage level matches target IO voltage. |
| 63 | - Confirm selected chip model and serial port. |
| 64 | |
| 65 | ### USB DFU/Bootloader |
| 66 | |
| 67 | - Confirm boot mode entry sequence. |
| 68 | - Confirm USB enumeration and permissions. |
| 69 | - Confirm package format and target address. |
| 70 | - Preserve existing bootloader or calibration regions unless explicitly approved. |
| 71 | |
| 72 | ## Verification |
| 73 | |
| 74 | Before claiming flashing is fixed: |
| 75 | |
| 76 | - Report connect, erase, program, verify, and reset/run status separately. |
| 77 | - State the programmer, target chip, interface, adapter speed, firmware artifact, and programmed address. |
| 78 | - Confirm whether destructive actions were avoided, skipped, or explicitly approved. |
| 79 | - If verify fails, report the first failing address or range if the tool provides it. |
| 80 | |
| 81 | ## Common Failures |
| 82 | |
| 83 | - Recommending mass erase before confirming wiring and target voltage. |
| 84 | - Selecting a similar but wrong MCU in the programmer. |
| 85 | - Flashing a binary to the wrong base address. |
| 86 | - Ignoring verify failures because program appeared to succeed. |
| 87 | - Forgetting boot pin or reset timing for UART bootloaders. |
| 88 | |
| 89 | ## Example |
| 90 | |
| 91 | User: |
| 92 | |
| 93 | ```text |
| 94 | OpenOCD 连接 STM32 总是 timeout,下载不了。 |
| 95 | ``` |
| 96 | |
| 97 | Agent: |
| 98 | |
| 99 | 1. Asks for exact chip, probe, OpenOCD configs, wiring, target voltage, and error log. |
| 100 | 1. Separates connect failure from flash failure. |
| 101 | 1. Suggests lower SWD speed and connect-under-reset before erase. |
| 102 | 1. Asks before readout protection or mass erase operations. |