OpenOCD fails to connect to STM32F4Discovery using STLINK-V2

Hi!

I have been using OpenOCD previously to connect and debug my STM32F4Discovery but after a reinstall of the computer I cannot get it to work and I have no idea what is wrong.

Usually I just install the driver via the ST-LINK Utility and OpenOCD works, but not this time.

I am using Windows 7 x64 and OpenOCD 0.7.0.

When I run the command openocd-0.7.0.exe -f …\scripts\board\stm32f4discovery.cfg I get the cryptic error:

Open On-Chip Debugger 0.7.0 (2013-05-05-10:41)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.sourceforge.net/doc/doxygen/bugs.html
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : This adapter doesn't support configurable speed
Error: open failed
in procedure 'transport'
in procedure 'init'

And if I use the debug command:

Open On-Chip Debugger 0.7.0 (2013-05-05-10:41)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.sourceforge.net/doc/doxygen/bugs.html
User : 13 8 command.c:549 command_print(): debug_level: 3
Debug: 14 18 configuration.c:45 add_script_search_dir(): adding C:/Users/Korken/Desktop/openocd-0.7.0/bin/..
Debug: 15 29 configuration.c:45 add_script_search_dir(): adding C:/Users/Korken/Desktop/openocd-0.7.0/bin/../share/openocd/scripts
Debug: 16 42 configuration.c:45 add_script_search_dir(): adding C:/Users/Korken/Desktop/openocd-0.7.0/bin/../scripts
Debug: 17 53 configuration.c:86 find_file(): found ..\scripts\board\stm32f4discovery.cfg
Debug: 18 61 configuration.c:86 find_file(): found C:/Users/Korken/Desktop/openocd-0.7.0/bin/../scripts/interface/stlink-v2.cfg
Debug: 19 72 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_interface hla
Debug: 20 79 command.c:145 script_debug(): command - interface ocd_interface hla
Debug: 22 86 command.c:369 register_command_handler(): registering 'ocd_hla_device_desc'...
Debug: 23 94 command.c:369 register_command_handler(): registering 'ocd_hla_serial'...
Debug: 24 101 command.c:369 register_command_handler(): registering 'ocd_hla_layout'...
Debug: 25 108 command.c:369 register_command_handler(): registering 'ocd_hla_vid_pid'...
Debug: 26 114 command.c:369 register_command_handler(): registering 'ocd_stlink_api'...
Debug: 27 121 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_hla_layout stlink
Debug: 28 129 command.c:145 script_debug(): command - hla_layout ocd_hla_layout stlink
Debug: 30 136 hla_interface.c:167 hl_interface_handle_layout_command(): hl_interface_handle_layout_command
Debug: 31 145 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_hla_device_desc ST-LINK/V2
Debug: 32 156 command.c:145 script_debug(): command - hla_device_desc ocd_hla_device_desc ST-LINK/V2
Debug: 34 164 hla_interface.c:141 hl_interface_handle_device_desc_command(): hl_interface_handle_device_desc_command
Debug: 35 174 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_hla_vid_pid 0x0483 0x3748
Debug: 36 183 command.c:145 script_debug(): command - hla_vid_pid ocd_hla_vid_pid 0x0483 0x3748
Debug: 38 191 hla_interface.c:195 hl_interface_handle_vid_pid_command(): hl_interface_handle_vid_pid_command
Debug: 39 200 configuration.c:86 find_file(): found C:/Users/Korken/Desktop/openocd-0.7.0/bin/../scripts/target/stm32f4x_stlink.cfg
Debug: 40 210 configuration.c:86 find_file(): found C:/Users/Korken/Desktop/openocd-0.7.0/bin/../scripts/target/stm32_stlink.cfg
Debug: 41 221 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_transport select hla_swd
Debug: 42 229 command.c:145 script_debug(): command - ocd_transport ocd_transport select hla_swd
Debug: 43 237 hla_transport.c:187 hl_transport_select(): hl_transport_select
Debug: 44 243 command.c:369 register_command_handler(): registering 'ocd_hla'...
Debug: 45 249 command.c:369 register_command_handler(): registering 'ocd_jtag'...
Debug: 46 256 command.c:369 register_command_handler(): registering 'ocd_jtag'...
Debug: 47 261 command.c:369 register_command_handler(): registering 'ocd_jtag'...
Debug: 48 268 command.c:369 register_command_handler(): registering 'ocd_jtag'...
Debug: 49 274 command.c:369 register_command_handler(): registering 'ocd_jtag'...
Debug: 50 280 command.c:369 register_command_handler(): registering 'ocd_jtag'...
Debug: 51 287 command.c:369 register_command_handler(): registering 'ocd_jtag'...
Debug: 52 293 command.c:369 register_command_handler(): registering 'ocd_jtag'...
Debug: 53 299 command.c:369 register_command_handler(): registering 'ocd_jtag'...
Debug: 54 306 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_hla newtap stm32f4x cpu -expected-id 0x2ba01477
Debug: 55 316 command.c:145 script_debug(): command - ocd_hla ocd_hla newtap stm32f4x cpu -expected-id 0x2ba01477
Debug: 56 325 hla_tcl.c:104 jim_hl_newtap_cmd(): Creating New Tap, Chip: stm32f4x, Tap: cpu, Dotted: stm32f4x.cpu, 2 params
Debug: 57 334 hla_tcl.c:114 jim_hl_newtap_cmd(): Processing option: -expected-id
Debug: 58 341 core.c:1323 jtag_tap_init(): Created Tap: stm32f4x.cpu @ abs position 0, irlen 0, capture: 0x0 mask: 0x0
Debug: 59 350 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_target create stm32f4x.cpu hla_target -chain-position stm32f4x.cpu
Debug: 60 362 command.c:145 script_debug(): command - ocd_target ocd_target create stm32f4x.cpu hla_target -chain-position stm32f4x.cpu
Debug: 61 374 target.c:1615 target_free_all_working_areas_restore(): freeing all working areas
Debug: 62 381 command.c:369 register_command_handler(): registering 'ocd_arm'...
Debug: 63 388 command.c:369 register_command_handler(): registering 'ocd_arm'...
Debug: 64 394 command.c:369 register_command_handler(): registering 'ocd_arm'...
Debug: 65 400 command.c:369 register_command_handler(): registering 'ocd_arm'...
Debug: 66 406 command.c:369 register_command_handler(): registering 'ocd_arm'...
Debug: 67 412 command.c:369 register_command_handler(): registering 'ocd_arm'...
Debug: 68 419 hla_target.c:299 adapter_target_create(): adapter_target_create
Debug: 69 425 hla_target.c:272 adapter_init_arch_info(): adapter_init_arch_info
Debug: 70 430 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 71 438 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 72 445 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 73 452 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 74 459 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 75 466 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 76 473 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 77 480 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 78 487 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 79 494 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 80 501 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 81 508 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 82 515 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 83 522 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 84 529 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 85 536 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 86 543 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 87 550 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 88 557 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 89 564 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 90 572 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 91 578 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 92 585 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 93 592 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 94 599 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 95 607 command.c:369 register_command_handler(): registering 'ocd_stm32f4x.cpu'...
Debug: 96 613 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_stm32f4x.cpu configure -work-area-phys 0x20000000 -work-area-size 0x1
Debug: 97 628 command.c:145 script_debug(): command - ocd_stm32f4x.cpu ocd_stm32f4x.cpu configure -work-area-phys 0x20000000 -work-area-size 0x10000 -work-a
Debug: 98 642 target.c:1615 target_free_all_working_areas_restore(): freeing all working areas
Debug: 99 650 target.c:1615 target_free_all_working_areas_restore(): freeing all working areas
Debug: 100 657 target.c:1615 target_free_all_working_areas_restore(): freeing all working areas
Debug: 101 664 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_flash bank stm32f4x.flash stm32f2x 0 0 0 0 stm32f4x.cpu
Debug: 102 676 command.c:145 script_debug(): command - ocd_flash ocd_flash bank stm32f4x.flash stm32f2x 0 0 0 0 stm32f4x.cpu
Debug: 105 686 command.c:369 register_command_handler(): registering 'ocd_stm32f2x'...
Debug: 106 693 command.c:369 register_command_handler(): registering 'ocd_stm32f2x'...
Debug: 107 700 command.c:369 register_command_handler(): registering 'ocd_stm32f2x'...
Debug: 108 707 tcl.c:781 handle_flash_bank_command(): 'stm32f2x' driver usage field missing
Debug: 109 713 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_reset_config srst_only srst_nogate
Debug: 110 723 command.c:145 script_debug(): command - reset_config ocd_reset_config srst_only srst_nogate
User : 112 731 command.c:549 command_print(): srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Debug: 113 742 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_init
Debug: 114 748 command.c:145 script_debug(): command - init ocd_init
Debug: 116 754 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_target init
Debug: 117 763 command.c:145 script_debug(): command - ocd_target ocd_target init
Debug: 119 769 target.c:1178 handle_target_init_command(): Initializing targets...
Debug: 120 775 hla_target.c:289 adapter_init_target(): adapter_init_target
Debug: 121 781 command.c:369 register_command_handler(): registering 'ocd_target_request'...
Debug: 122 789 command.c:369 register_command_handler(): registering 'ocd_trace'...
Debug: 123 795 command.c:369 register_command_handler(): registering 'ocd_trace'...
Debug: 124 802 command.c:369 register_command_handler(): registering 'ocd_fast_load_image'...
Debug: 125 809 command.c:369 register_command_handler(): registering 'ocd_fast_load'...
Debug: 126 815 command.c:369 register_command_handler(): registering 'ocd_profile'...
Debug: 127 822 command.c:369 register_command_handler(): registering 'ocd_virt2phys'...
Debug: 128 828 command.c:369 register_command_handler(): registering 'ocd_reg'...
Debug: 129 835 command.c:369 register_command_handler(): registering 'ocd_poll'...
Debug: 130 842 command.c:369 register_command_handler(): registering 'ocd_wait_halt'...
Debug: 131 848 command.c:369 register_command_handler(): registering 'ocd_halt'...
Debug: 132 855 command.c:369 register_command_handler(): registering 'ocd_resume'...
Debug: 133 861 command.c:369 register_command_handler(): registering 'ocd_reset'...
Debug: 134 868 command.c:369 register_command_handler(): registering 'ocd_soft_reset_halt'...
Debug: 135 875 command.c:369 register_command_handler(): registering 'ocd_step'...
Debug: 136 881 command.c:369 register_command_handler(): registering 'ocd_mdw'...
Debug: 137 888 command.c:369 register_command_handler(): registering 'ocd_mdh'...
Debug: 138 894 command.c:369 register_command_handler(): registering 'ocd_mdb'...
Debug: 139 900 command.c:369 register_command_handler(): registering 'ocd_mww'...
Debug: 140 907 command.c:369 register_command_handler(): registering 'ocd_mwh'...
Debug: 141 913 command.c:369 register_command_handler(): registering 'ocd_mwb'...
Debug: 142 919 command.c:369 register_command_handler(): registering 'ocd_bp'...
Debug: 143 925 command.c:369 register_command_handler(): registering 'ocd_rbp'...
Debug: 144 931 command.c:369 register_command_handler(): registering 'ocd_wp'...
Debug: 145 938 command.c:369 register_command_handler(): registering 'ocd_rwp'...
Debug: 146 944 command.c:369 register_command_handler(): registering 'ocd_load_image'...
Debug: 147 951 command.c:369 register_command_handler(): registering 'ocd_dump_image'...
Debug: 148 958 command.c:369 register_command_handler(): registering 'ocd_verify_image'...
Debug: 149 965 command.c:369 register_command_handler(): registering 'ocd_test_image'...
Debug: 150 973 command.c:369 register_command_handler(): registering 'ocd_reset_nag'...
Debug: 151 979 command.c:369 register_command_handler(): registering 'ocd_ps'...
Debug: 152 985 hla_interface.c:107 hl_interface_init(): hl_interface_init
Debug: 153 991 hla_layout.c:91 hl_layout_init(): hl_layout_init
Info : 154 995 core.c:1375 adapter_init(): This adapter doesn't support configurable speed
Debug: 155 1003 openocd.c:132 handle_init_command(): Debug Adapter init complete
Debug: 156 1009 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_transport init
Debug: 157 1017 command.c:145 script_debug(): command - ocd_transport ocd_transport init
Debug: 159 1023 transport.c:240 handle_transport_init(): handle_transport_init
Debug: 160 1029 hla_transport.c:148 hl_transport_init(): hl_transport_init
Debug: 161 1035 hla_transport.c:165 hl_transport_init(): current transport hla_swd
Debug: 162 1042 hla_interface.c:44 hl_interface_open(): hl_interface_open
Debug: 163 1047 hla_layout.c:42 hl_layout_open(): hl_layout_open
Debug: 164 1052 stlink_usb.c:1233 stlink_usb_open(): stlink_usb_open
Debug: 165 1056 stlink_usb.c:1251 stlink_usb_open(): transport: 1 vid: 0x0483 pid: 0x3748
Error: 166 1087 stlink_usb.c:1254 stlink_usb_open(): open failed
Debug: 167 1091 hla_layout.c:49 hl_layout_open(): failed
Debug: 168 1095 command.c:631 run_command(): Command failed with error code -4
User : 169 1100 command.c:669 command_run_line(): in procedure 'transport'
Debug: 170 1107 command.c:631 run_command(): Command failed with error code -4
User : 171 1112 command.c:669 command_run_line(): in procedure 'init'
Debug: 172 1118 hla_interface.c:115 hl_interface_quit(): hl_interface_quit

which says that it fail at:

Debug: 164 1052 stlink_usb.c:1233 stlink_usb_open(): stlink_usb_open
Debug: 165 1056 stlink_usb.c:1251 stlink_usb_open(): transport: 1 vid: 0x0483 pid: 0x3748
Error: 166 1087 stlink_usb.c:1254 stlink_usb_open(): open failed

However this is the correct VID and PID. And I have no idea of what goes wrong.

Does anyone know how to fix this?

Best Regards

Emil, Sweden

Looks like a driver issue or (silly thought) usb cable in the wrong connector …

Check vid/pid’s of all attached devices

I have double checked all USB devices and no collisions in VID/PID and OpenOCD tries to connect to the correct VID/PID.

Also I have tried uninstalling and reinstalling drivers a few times, still no change.

The funny thing is that the ST-LINK Utility can talk to the programmer without a problem… :think:

Any more ideas?

Never had any success using a stlink v2 to talk to the stm32f1x target.

using openocd-0.x.x.exe -f interface/stlink-v2.cfg -f target/stm32f1x_stlink.cfg

version 0.6.1 error:

libusbx: warning [init_device] could not get node connection information for device ‘\.\USB#VID_0483&PID_3748#6&1505871C&0&4’: [87] The parameter is incorrect.

version 0.7.0 error:

Info : This adapter doesn’t support configurable speed

hundred other combinations of openocd config files and online-forum suggestions yielded no result.

Tried ST-Utility driver as well as winusb and libusb drivers.

atollic gdbserver seems to be only thing that works with stlink v2. But unfortunately they pulled out free gdbserver support. You’d need to use their GUI to make it work.

sharifs