I’m experiencing difficulties while using an ST-Link V2 (clone) to debug an STM32 Blue Pill in PlatformIO. I’ve managed to upload programs successfully, but debugging is presenting challenges.
GDB Launch Error: “Remote communication error. Target disconnected.”
ID Mismatch: “Error: expected 1 of 1: 0x1ba01477”
Steps We Have Already Tried:
Ensured all physical connections between the ST-Link and the Blue Pill are correct.
Updated ST-Link drivers and verified functionality on another machine.
Attempted manual setting of CPUTAPID due to using a clone ST-Link.
Checked that PlatformIO and related tools are up-to-date.
Request for Assistance: I’m looking for insights or solutions from anyone who has encountered similar debugging issues with the Blue Pill and ST-Link. Any tips on configuration or other tests to try would be immensely helpful.
I’m excited to share that I found a solution to my debugging issues with the STM32 Blue Pill using the ST-Link debugger!
The problem I encountered was related to the warning message I received: “UNEXPECTED idcode: 0x2ba01477.” This makes sense, given that I was using a clone Blue Pill, which has a different ID code. Initially, I modified the platformio.ini file to address this issue, but I was puzzled about how the expected value, 0x1ba01477, could be changed properly if I had specified a different one.
After some digging, I discovered that the target configuration in the OpenOCD framework can also influence this. The configuration file is located at:
if { [info exists CPUTAPID] } {
set _CPUTAPID $CPUTAPID
} else {
if { [using_jtag] } {
set _CPUTAPID 0x3ba00477
} {
set _CPUTAPID 0x2ba01477 # Alternate ID for clone Blue Pill
}
}
Manually changing the _CPUTAPID to 0x2ba01477 resolved all my issues, and I can now debug seamlessly!
It’s amazing how sometimes the solution lies in a simple tweak. Now I’m debugging like a boss!
Thank you, everyone, for your support and insights during my troubleshooting process!
You don’t need to make local modifications to your OpenOCD package if you define a debug_server in the platformio.ini which also sets the right CPUTAPID to work with the chinese clones.