Hi,
I am running into some issues to connect with a target using an ST-LINK V3SET.
The setup is :
The issue seems to be related to USB problems.
The error is stlink_usb_error_check(): STLINK_JTAG_GET_IDCODE_ERROR when running :
openocd -d -f /usr/local/share/openocd/scripts/interface/stlink-dap.cfg -f /usr/local/share/openocd/scripts/target/stm32f7x.cfg
Output is:
Info : 88 3 server.c:297 add_service(): Listening on port 6666 for tcl connections
Info : 89 3 server.c:297 add_service(): Listening on port 4444 for telnet connections
Debug: 90 3 command.c:155 script_debug(): command - init
Debug: 91 3 command.c:155 script_debug(): command - target init
Debug: 92 3 command.c:155 script_debug(): command - target names
Debug: 93 3 command.c:155 script_debug(): command - stm32f7x.cpu cget -event gdb-flash-erase-start
Debug: 94 3 command.c:155 script_debug(): command - stm32f7x.cpu configure -event gdb-flash-erase-start reset init
Debug: 95 3 command.c:155 script_debug(): command - stm32f7x.cpu cget -event gdb-flash-write-end
Debug: 96 3 command.c:155 script_debug(): command - stm32f7x.cpu configure -event gdb-flash-write-end reset halt
Debug: 97 3 command.c:155 script_debug(): command - stm32f7x.cpu cget -event gdb-attach
Debug: 98 3 command.c:155 script_debug(): command - stm32f7x.cpu configure -event gdb-attach halt 1000
Debug: 99 3 target.c:1657 handle_target_init_command(): Initializing targets...
Debug: 100 3 semihosting_common.c:109 semihosting_common_init():
Debug: 101 3 stlink_usb.c:5081 stlink_dap_init(): stlink_dap_init()
Debug: 102 3 stlink_usb.c:3693 stlink_open(): stlink_open
Debug: 103 3 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x3744 serial:
Debug: 104 3 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x3748 serial:
Debug: 105 3 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x374b serial:
Debug: 106 3 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x374d serial:
Debug: 107 3 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x374e serial:
Debug: 108 3 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x374f serial:
Debug: 109 3 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x3752 serial:
Debug: 110 3 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x3753 serial:
Debug: 111 3 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x3754 serial:
Info : 112 7 stlink_usb.c:1434 stlink_usb_version(): STLINK V3J10M3B5S1 (API v3) VID:PID 0483:3753
Debug: 113 7 stlink_usb.c:1659 stlink_usb_exit_mode(): MODE: 0x01
Info : 114 7 stlink_usb.c:1470 stlink_usb_check_voltage(): Target voltage: 3.347832
Debug: 115 7 stlink_usb.c:1727 stlink_usb_init_mode(): MODE: 0x01
Debug: 116 7 stlink_usb.c:3093 stlink_dump_speed_map(): Supported clock speeds are:
Debug: 117 7 stlink_usb.c:3096 stlink_dump_speed_map(): 24000 kHz
Debug: 118 7 stlink_usb.c:3096 stlink_dump_speed_map(): 8000 kHz
Debug: 119 7 stlink_usb.c:3096 stlink_dump_speed_map(): 3300 kHz
Debug: 120 7 stlink_usb.c:3096 stlink_dump_speed_map(): 1000 kHz
Debug: 121 7 stlink_usb.c:3096 stlink_dump_speed_map(): 200 kHz
Debug: 122 7 stlink_usb.c:3096 stlink_dump_speed_map(): 50 kHz
Debug: 123 7 stlink_usb.c:3096 stlink_dump_speed_map(): 5 kHz
Debug: 124 37 stlink_usb.c:1086 stlink_usb_error_check(): STLINK_JTAG_GET_IDCODE_ERROR
Error: 125 37 stlink_usb.c:3748 stlink_open(): init mode failed (unable to connect to the target)
Debug: 126 37 stlink_usb.c:1659 stlink_usb_exit_mode(): MODE: 0x01
Debug: 127 37 command.c:544 run_command(): Command 'init' failed with error code -4
User : 128 37 command.c:608 command_run_line():
Debug: 129 37 target.c:2199 target_free_all_working_areas_restore(): freeing all working areas
The usb device is enumerated in dmesg :
[171481.193449] usb 1-4.2: New USB device found, idVendor=0483, idProduct=3753, bcdDevice= 1.00
[171481.193461] usb 1-4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[171481.193467] usb 1-4.2: Product: STLINK-V3
[171481.193471] usb 1-4.2: Manufacturer: STMicroelectronics
[171481.193475] usb 1-4.2: SerialNumber: 0019001C3656501420363341
[171481.198570] cdc_acm 1-4.2:1.1: ttyACM0: USB ACM device
[171481.199678] cdc_acm 1-4.2:1.4: ttyACM1: USB ACM device
Running stlink command st-trace -v:
Failed to parse flash type or unrecognized flash type
2022-12-07T09:08:55 DEBUG trace.c: show_help = false
2022-12-07T09:08:55 DEBUG trace.c: show_version = false
2022-12-07T09:08:55 DEBUG trace.c: logging_level = 100
2022-12-07T09:08:55 DEBUG trace.c: core_frequency = 0 Hz
2022-12-07T09:08:55 DEBUG trace.c: trace_frequency = 0 Hz
2022-12-07T09:08:55 DEBUG trace.c: reset_board = true
2022-12-07T09:08:55 DEBUG trace.c: force = false
2022-12-07T09:08:55 DEBUG trace.c: serial_number = any
2022-12-07T09:08:55 DEBUG common.c: *** looking up stlink version
2022-12-07T09:08:55 DEBUG common.c: st vid = 0x0483 (expect 0x0483)
2022-12-07T09:08:55 DEBUG common.c: stlink pid = 0x3753
2022-12-07T09:08:55 DEBUG common.c: stlink version = 0x3
2022-12-07T09:08:55 DEBUG common.c: jtag version = 0xa
2022-12-07T09:08:55 DEBUG common.c: swim version = 0x1
2022-12-07T09:08:55 DEBUG common.c: stlink current mode: mass
2022-12-07T09:08:55 DEBUG usb.c: JTAG/SWD freq set to 0
2022-12-07T09:08:55 DEBUG common.c: stlink current mode: mass
2022-12-07T09:08:55 DEBUG common.c: *** stlink_enter_swd_mode ***
2022-12-07T09:08:55 DEBUG usb.c: ENTER_SWD error (0x09)
Failed to enter SWD mode
2022-12-07T09:08:55 ERROR trace.c: Your stlink is not connected to a device
This seems to be somehow related to #325 #308 .
Thank you for your help.
Hi, no it's not related with #325 and #308.
I can get the same error STLINK_JTAG_GET_IDCODE_ERROR (code 0x09) with an STLink V3 stand-alone not connected to any target.
Are you sure the SWD connection is ok? The target board is powered on?
Hi Antonio,
To give a little more context:
We have a board with an F446RE as application target and a F723 programmed as an STLINK-V3.
(thanks to the great work here ).
We've been able to program the F723 with an unprotected STLINK-V3 firmware. But I get
STLINK_JTAG_GET_IDCODE_ERROR when trying to program the F446RE.
To debug, we :
1) Tried to program directly the F446RE with an STLINKV2 from a Nucleo. This works. Meaning that the F446RE is properly powered on the main board.
With touch pins we cabled SWCLK, SWDIO, GND, SWO, NRST (the 3 first were sufficient to flash).
2) Tried to program directly the F446RE with an external STLINK-V3SET. No luck.
When checking on our analyzer. The IDCODE is properly returned and everything works with STLINKV2. However, with STLINKV3, the IDCODE is not even requested after the reset sequence (which is also a little different from the V2).
I have attached the screen captures of the SWDIO/SWCLK frames.
Thank you for your help
Last edit: Tanguy Serrat 2022-12-07
reverse engineered STLink V3! Interesting!
Did someone already succeed to make it working? Or this is the first tentative to use the cloned FW?
The signals you sent from logic analyzer cannot show if there is any signal integrity issue. Do you have an oscilloscope to check them?
But looks like the target F4 does not ACK the SWD request and does not return the IDCODE.
Try to use some extremely low frequency adding to OpenOCD command line
-c 'adapter speed 5'
and eventually add series resistors on SWDCK and SWDIO wires, between 22 to 100 ohm
I guess some people did manage to get V3 working according to this thread.
Although, I am quite surprised that I can't program anymore targets using the official V3SET.
This one has only been updated using the CubeProgrammer.
I will check using an oscilloscope and with very low speeds.
On the V3 signals from the target, would you say that the request for IDCODE is the part I've outlined in red ?
Thank you
Last edit: Tanguy Serrat 2022-12-07
I think that the part before the highlighted is the switch from JTAG to SWD.
The part highlighted looks like the read of DAP register DPIDR.
On STLink V2 you get the ACK reply and the value
On STLink V3 clone looks like the ACK is missing. But it would require zooming in the picture and analyze the bits to confirm it
Hi Antonio,
Thank you for your answer.
Indeed, using lower speed or adding an 150Ohm resistor on SWDIO/TCK allowed to flash properly the target, good catch !
Now, through the STLINKV3 clone (on the board), I am able to go further away but both CubeProgrammer and OpenOcd can't connect to the target.
Here is the log:
The first error is :
Debug: 147 121 stlink_usb.c:1130 stlink_usb_error_check(): unknown/unexpected STLINK status code 0x5The
BUG: can't assert SRSTis also a log I get using the V3SET.I have tried the F446RE with V3SET through the copper traces on the PCB, and it works (without resistors). So the signal between V3clone and F446 should be fine.
Comparing signals on logic analyzer, I see that on there are sometimes where the target response to e.g. Request DebugPort Read RDBUFF, the timings are quite different between V3SET and V3Clone.
V3Clone also gets 0x0 replies and triggers a line reset afterwards.
V3Clone and V3SET have different fw versions. I could update V3Clone, but I am afraid that the upragder uploads an FW with protected bootloader.
Testing with
st-trace -vgives:2022-12-09T17:04:28 DEBUG usb.c: READDEBUGREG error (0x05)Do you see what I would be missing ?
Thanks again for your help.
Last edit: Tanguy Serrat 2022-12-09
Ok, so I finally upgraded the clone using the CubeProgrammer.
From version V3J7M2B4S1 (with unprotected bootloader) to V3J10M3B5S1 and it works like a charm !
Thanks again for your precious help !