embedded
debugger_error
ai_generated
true
Error: init mode failed (unable to connect to the target)
ID: embedded/stlink-connection-failed
85%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 32 | active | — | — | — |
Root Cause
ST-LINK cannot connect to STM32 via SWD/JTAG. Wiring, BOOT pins, sleep mode, or flash protection.
genericWorkarounds
-
90% success Use connect under reset mode
openocd -f interface/stlink.cfg -c 'reset_config srst_only' -f target/stm32f4x.cfg
-
88% success Check SWD wiring: SWDIO, SWCLK, GND, and NRST
Minimum: GND, SWDIO (PA13), SWCLK (PA14). Keep wires under 10cm.
-
85% success Erase flash via BOOT0 pin to recover bricked chips
Set BOOT0=HIGH, power cycle, erase via STM32CubeProgrammer UART, then BOOT0=LOW
Dead Ends
Common approaches that don't work:
-
Increase SWD clock frequency for stable connection
80% fail
Higher frequency makes marginal connections WORSE; long wires need LOWER frequencies
-
Replace the ST-LINK adapter assuming it is broken
70% fail
Usually the target chip or wiring is the problem. Verify with a second target board first.
-
Flash via serial bootloader to fix debug port
72% fail
Serial flash may work but does not re-enable SWD if firmware disabled the SWD pins