STM32 Programming with FT2232H via SWD - Encounter "Error connecting DP: cannot read IDR"

Hello everyone,

I am reaching out in hopes of finding a solution to a persistent issue I’ve been encountering. I am attempting to program an STM32L412KB microcontroller using SWD (Serial Wire Debug) with an FT2232 module. While I’ve had success with the JTAG interface, transitioning to SWD has been problematic.

The specific issue I am facing is an error message: “Error: Error connecting DP: cannot read IDR”. This occurs when I try to establish a connection using my programming and debugging tools. I have tried various settings and configurations, but to no avail.

I’m wondering if anyone here has had similar experiences or if there are known issues or limitations with this particular hardware and microcontroller combination. Any advice or suggestions on what I might try would be greatly appreciated.

FT2232H.cfg file for SWD

# OpenOCD configuration file for the FTDI FT2232HL

# Include the configuration for the JTAG adapter.
# If you have a different interface, please edit this to include the
# configuration file of yours.
adapter driver ftdi
ftdi vid_pid 0x0403 0x6010
ftdi channel 0
ftdi layout_init 0x0008 0x000b
transport select swd
adapter speed 20
telnet_port 4444

ftdi layout_init 0x0018 0x05fb
ftdi layout_signal SWD_EN -data 0
ftdi layout_signal nSRST -data 0x0010

Try using an existing configuration like with the pins that are written there. Specifically both ADBUS1 and 2 have to be connected to SWDIO, I think (one for output one for input).

I used the ft232h-module-swd.cfg file and changed the pid to 6010. But the error code has remained the same.

According to the data sheet, I only need one data line and one clock.

Yeah that’s on the microcontroller side. It indeed only has SWDIO that is a combination of TDO and TDI (testdata in / out). But on the FTDI I imagine it manually needs to connect TDO and TDI together by the user. Otherwise, why would it be written in all these configs.

Actually, per

there should even by a protecting resistor on TDI to prevent TDO driving into TDI when it doesn’t want to.

Though if the tristating is working properly

you should not need that.

I have this resistor on my board. I have also looked at this page and taken the configuration from there. Unfortunately, the configuration is very outdated. Maybe that’s why it has an error.

Do you have any other ideas?

But your FTDI pin layout (aka pin config is different)? And it’s also appearing twice? The

ftdi layout_init 0x0030 0x003b

does not appear.

Ah my fault. I have changed it and tried it, but the error code remains the same.

adapter driver ftdi
ftdi vid_pid 0x0403 0x6010
# data MSB..LSB       direction (1:out) MSB..LSB
# 0000'0000'0011'0000 0000'0000'0011'1011
ftdi layout_init 0x0030 0x003b
# 0xfff8 0xfffb
# Those signal are only required on some platforms or may required to be
# enabled explicitly (e.g. nrf5x chips).
ftdi layout_signal nSRST -data 0x0010 -oe 0x0010
ftdi layout_signal nTRST -data 0x0020 -oe 0x0020

# swd enable
ftdi layout_signal SWD_EN -data 0
# tri-state (configure as input) TDO/TIO when reading
#ftdi layout_signal SWDIO_OE -data 0

transport select swd

# re-configure TDO as tri-state
#ftdi layout_signal TDO -data 0x0002 -oe 0x0002
#ftdi layout_signal TDI -data 0x0004