Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


Unable to debug with ST-LinkV2-1

I am able to build a project for a custom board with a STM32F407, imported from STCubeMX. When I try to debug how ever I get this error message:

Error in final launch sequence
Failed to execute MI command:
-target-select remote localhost:3333

Error message from debugger back end:
localhost:3333: The system tried to join a drive to a directory on a joined drive.

I know that the ST-Link is working because I can communicate and flash the unit with STM32 ST_LINK Utility.

OS is Win7, CPU is x64.

I don’t know what other information to provide.

TIA
Corky

Hi,

I have the same problem few days ago. But finally I was able to connect and debug on two boards, one of them was with STM32F303 (stm32f3discovery board) and NUCLEO-L152RE (on board ST-LINK/V2-1). I have also imported projects from STCube. For me it works on Win 7 and Win 8 64 bits.

What I can suggest you is to activate debug level 3 in System Workbench. This will print on Eclipse console a lot of information and maybe you can figure out what is happen. If you can’t see first messages just increase the buffer of the Eclipse console until will fit. On Debug Configuration window just add ‘-d3’ to ‘OpenOCD Setup’ field. See attached screen shoot.

If you did not already do, check the documentation: http://www.openstm32.org/Importing+a+STCubeMX+generated+projectQuestion
(OpenSTM32 Community Site » Documentation » System Workbench for STM32 » User Guide » Importing a STCubeMX generated project)
There is a section how to manually set the debug configuration.


Alternatively, you can start OpenOCD from command line.
Example:
c:\openocd-0.9.0_fc\bin>openocd.exe -f c:\openocd-0.9.0_fc\scripts\board\stm32f429discovery.cfg -d 3 -l d:\openocd_stm32f429_log.txt

you will see something like this on console:

‘’Open On-Chip Debugger 0.9.0 (2015-05-19-12:06)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.htmlQuestion
User : 13 0 command.c:546 command_print(): debug_level: 3
Debug: 14 15 command.c:145 script_debug(): command - ocd_command ocd_command type ocd_log_output d:openocd_stm32f429_log.txt
Debug: 15 15 command.c:145 script_debug(): command - log_output ocd_log_output d:openocd_stm32f429_log.txt’’

Check the file specified with -l command (-l = log)

But before to do that you have to:
1) Download and install OpenOCD compiled for Win from Freddie Chopin web site (google ‘freddie chopin openocd’). System Workbench has the OpenOCD but you have to issue some commands first to add necessary path else will not work. See more in this post “openocd - wrong paths on win x64” (search in this forum)

2) Check what script System Workbench is using for your board/microcontroller and use the same script in command line. If you board does’t have a ‘board’ script you can specify the mcu script and the interface script (check one board script close to your micro)



For a successful connection you have to see something like this (note that this is without -d3):

‘’c:\openocd-0.9.0_fc\bin>openocd.exe -f c:\openocd-0.9.0_fc\scripts\board\stm32f429discovery.cfg
Open On-Chip Debugger 0.9.0 (2015-05-19-12:06)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.htmlQuestion
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Info : STLINK v2 JTAG v17 API v2 SWIM v0 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 2.864877
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints’’

and here the On-Chip Debugger wait for commands from GDB Server. Press CTRL+C to stop to OpenOCD application.

Please note that for STLINK V2.1 PID is 0x374B (not 0x3748)


Thank you, cipriansalageanu.
Your sugestion of setting the d3 option is helpful. I was able to capture a log file of the details, however I still do not understand the cause of the problem. I will attach the log, hoping that someone will recognize the issue.
Regards

Hi,

My guess is that (as farlane pointed out below - sorry for jump) is a USB HW / WinUSB library problem. In your log, function stlink_usb_open() fails.

‘’Debug: 258 156 stlink_usb.c:1602 stlink_usb_open(): stlink_usb_open
‘’Debug: 259 156 stlink_usb.c:1619 stlink_usb_open(): transport: 1 vid: 0x0483 pid: 0x374b serial:
Error: 260 343 stlink_usb.c:1632 stlink_usb_open(): open failed

My understanding is that OpenOCD application try to connect using USB to the SWD debug probe but the application has no response from HW side.

What you can do:
Check again to have a good USB cable - I can see the same error when there is no target board attached.
Check jumpers on target board, if you have any, to be in correct position.

Check to have the latest firmware on ST-LINK using STM32 ST-Link Utility

I use the latest ST-LINK drivers from ST, maybe could help to uninstall the current drivers and then install latest ST divers. On my computer I run 3 times uninstall on STLink and only then the device became unknown in Device Manager.
Now I have this drivers: STSW-LINK009 link:http://www.st.com/web/en/catalog/tools/PF251168Question
Zadig tool reports the library version: WinUSB (v1.1.0.0)

Check this forum, there are few threads related to openocd.

Anyway, after I have done all this things still I was not able to connect to target board.
On my system (Asus X200LA) OpenOCD DOES WORK ONLY IF I completely remove from Device Manager
Ralink_MT6750_Bluetooth_01.

Attached is a description of my problem (3 pages).

If you can, check on another machine with different configuration the same setup. After I have seen this problem only on my pc, I use a virtual machine - Ubuntu and I added USB devices one by one into the WM and after each one verify that openocd still works (command line) until I find which device causes the problem.

Also you can check README.Windows file from OpenOCD (openocd.org). There are some hints related to USB adapters and libraries (but I was not able to follow all instructions and some of them are to “extreme” - see IgnoreHWSerNum).

Good luck


I also had this error while testing systemworkbench for production work. It came and went at unpredictable times, what leads me to believe this is some sort of USB/hardware thing going on.
Sometimes it helped flashing firmware to the stlink, at other times it did not.Rebooting sometimes helped, sometimes it did not. Fiddling with SWD/JTAG settings sometimes helped. I also tried modifying the OpenOCD scripts, but i could not pinpoint the exact cause. It might even have been an sub-par (USB) cable or something. In any event, it’s working for the time being.


Thanks for you help. I was able to resolve the problem. It was caused by operator head space! I thought that I had an ST-Link-V2-1, but in fact it is a V2. I hope I did not waste anyone’s time but my own.
Corky

Great that you find the problem. How did you figure out what was the problem ?. Did you review the documentation/board ?

I think is not wasted time, this could be useful also for another people who will have similar issues

I was looking through the driver / device information in Windows control pannel when I noticed that the USB ID number was not the same as the number in my log file!
Regards


This problem can also be caused by removing the stlink/discovery option jumpers - breaking the connection from stlink to target... One of those face palm moments...

I also had that problem but now its working
changed ST-link-V2-1 to V2
Its working...:-)


I also had this error! None of your proposed solutions helped!
For me it worked to press the reset button on the evaluation board at the moment I started the debugger!

Hi, All,

We really need downgrade stlink firmware from v2.1(latest) to v2?

When you create sw4stm32 project for customised board, you need select correct stlink version for OpenOCD, and that selection will appear in .cfg.

Under you project tree view, that .cfg file can be modified to match correct stlink version...

Regards,
W.G.

“We really need downgrade stlink firmware from v2.1(latest) to v2?
When you create sw4stm32 project for customised board, you need select correct stlink version for OpenOCD, and that selection will appear in .cfg.
Under you project tree view, that .cfg file can be modified to match correct stlink version...”

When generating a project for nucleo, STLink V2.1 is properly set (as if putting V2.1 in custom board) but OpenOCD indicate a libusb problem and it doesn’t work.
It’s working properly with a STlink V2 but not with a STLink V2.1.I even tried the custom thing with success..
My V2 F4Discovery is working properly while my L15RE Nucleo fails.


I ran into same problem with STM32F429I-DISCO and Win 8.1 PC.

After downloading the updated driver from ST website (http://www.st.com/web/en/catalog/tools/PF260219) and setting the debug configuration manual to STLink V2-1 and SWD it worked.

There is one more thing I found out. When you connect the board, check in the device manager, if the connected board
is listed under “Universal Serial Bus Devices->STM32 STLink”.

Some older boards, e.g. I have tried old STM32F100B - MB913C, are not listed as STLink device, only as a MSD drive,
so it seems to me this could be a problem, why debugging does not work.

There is also difference, if you connect such board with STLink Utility. It will show something like

ST-LINK SN : ST-Link/V1_on_:
ST-LINK Firmware version : V1J13S0
Connected via SWD.

In the working case it shows:

ST-LINK SN :
ST-LINK Firmware version : V2J25S0
Connected via SWD.