Author Topic: OpenOCD fail to open STM32 Nucleo board  (Read 16123 times)

0 Members and 1 Guest are viewing this topic.

Offline BudTopic starter

  • Super Contributor
  • ***
  • Posts: 6802
  • Country: ca
OpenOCD fail to open STM32 Nucleo board
« on: January 09, 2017, 03:16:20 am »
I have a STM32F302R8 Nucleo board as the hardware, with a built-in programmer with SWD interface, Windows 7 and the software setup is Eclipse Oxygen IDE with OpenSTM32 plugin, the project files created using STM32CubeMX. I created a debug configuration in Eclipse and the project compiles and creates debug binaries and all is hunky-dory until I am trying to run a debug session using OpenOCD. The damn thing cant connect to the board no matter what - I have attached a full log from OpenOCD, the meat is in the last few lines where it fails. The problem is I cant figure out why. Here is the related part from the log:

Code: [Select]
Debug: 258 166 hla_layout.c:42 hl_layout_open(): hl_layout_open
Debug: 259 169 stlink_usb.c:1698 stlink_usb_open(): stlink_usb_open
Debug: 260 169 stlink_usb.c:1716 stlink_usb_open(): transport: 1 vid: 0x0483 pid: 0x374b serial:
Error: 261 207 stlink_usb.c:1729 stlink_usb_open(): open failed
Debug: 262 207 hla_layout.c:49 hl_layout_open(): failed
Debug: 263 208 command.c:628 run_command(): Command failed with error code -4
User : 264 208 command.c:689 command_run_line(): in procedure 'init'
in procedure 'ocd_bouncer'

Now, I also downloaded the ST-Link programming utility from ST and when I run it, it is working, it finds the board no problem. So the board and the USB link is operational. I checked and made sure the board's USB PID/VID in Windows are the same as in the OpenOCD script files, and they also can be seen in the attached log, all is matching. Still, OpenOCD in Eclipse fails to see the board, while ST-Link can. I went one step farther and installed a standalone version of OpenOCD to no avail, still not working, so the problem is not with Eclipse.

I wonder if there is a secret sauce that you know about, how to get OpenOCD connect to an STM32 board that has a built-in ST-Link v2.1, or if it is known to be flaky and maybe I should not waste my time on it. Again, the vendor utility is working no problem.
Facebook-free life and Rigol-free shack.
 

Offline stj

  • Super Contributor
  • ***
  • Posts: 2153
  • Country: gb
Re: OpenOCD fail to open STM32 Nucleo board
« Reply #1 on: January 09, 2017, 04:36:17 am »
i have read about this before,
i think you will find it's a windows problem because the usb interface presents itself as multiple devices.

go look at ST's website, i think there are some drivers there.

there is a link in this article
https://dannyelectronics.wordpress.com/2016/05/01/uart-debugging-over-st-link-v2-1/
 

Offline Gixy

  • Regular Contributor
  • *
  • Posts: 232
  • Country: fr
Re: OpenOCD fail to open STM32 Nucleo board
« Reply #2 on: January 09, 2017, 06:53:18 am »
Same problem here. I've installed SW4STM32 environment (Eclipse) but even downloading the binary to the target from IDE doesn't work. I've to download with STLINK and then, after some resets openocd eventually starts. Another problem is that I have a TFT shield with a SD card reader, and when I launch debug with the SD card inserted, this one is corrupted and I have to reformat it!
(Windows 10)
« Last Edit: January 09, 2017, 06:55:13 am by Gixy »
 

Offline BudTopic starter

  • Super Contributor
  • ***
  • Posts: 6802
  • Country: ca
Re: OpenOCD fail to open STM32 Nucleo board
« Reply #3 on: January 09, 2017, 02:01:57 pm »
I already have ST drivers for both generic chips and boards. If this is a known problem why openocd developers keep quiet. How difficult is it to say "not working/may not work in Windows with STM32  evaluation boards" so people do not waste time with this crap open source product.  :rant:
Facebook-free life and Rigol-free shack.
 

Offline stj

  • Super Contributor
  • ***
  • Posts: 2153
  • Country: gb
Re: OpenOCD fail to open STM32 Nucleo board
« Reply #4 on: January 09, 2017, 06:28:17 pm »
so does windows recognise the virtual comport?

the only other thing, is the ST-link firmware up to date?
http://www.st.com/content/st_com/en/products/embedded-software/development-tool-software/stsw-link007.html
 

Offline Koen

  • Frequent Contributor
  • **
  • Posts: 502
Re: OpenOCD fail to open STM32 Nucleo board
« Reply #5 on: January 09, 2017, 09:02:22 pm »
If this is a known problem why openocd developers keep quiet. How difficult is it to say "not working/may not work in Windows with STM32  evaluation boards" so people do not waste time with this crap open source product.  :rant:
Well, use ST's ST-Link GDB server then.
 

Offline BudTopic starter

  • Super Contributor
  • ***
  • Posts: 6802
  • Country: ca
Re: OpenOCD fail to open STM32 Nucleo board
« Reply #6 on: January 10, 2017, 06:01:12 am »
OK found the culprit. The board was connected to a USB 3.0 port on the computer. Unplugged and connected to a USB 2.0 port and OpenOCD is now working. Wasted two days. The problem is reproducible, switched back and forth a few times, clearly OpenOCD is not working on USB 3.0 on Windows 7. You are welcome.
Facebook-free life and Rigol-free shack.
 

Offline gmb42

  • Frequent Contributor
  • **
  • Posts: 294
  • Country: gb
Re: OpenOCD fail to open STM32 Nucleo board
« Reply #7 on: January 10, 2017, 01:07:56 pm »
Windows 7 doesn't support USB 3.0 out of the box, it relies on drivers from the USB port manufacturer, and these are typically lower quality than those from MS.  Certainly that was my experience with a Renesas USB 3.0 card.

If you'd taken up the free offer from MS for Windows 10 then it's likely that this wouldn't have been an issue for you.
 

Offline BudTopic starter

  • Super Contributor
  • ***
  • Posts: 6802
  • Country: ca
Re: OpenOCD fail to open STM32 Nucleo board
« Reply #8 on: January 10, 2017, 02:40:54 pm »
Not sure what you mean.... i've been using this 3.0 port with a bunch of periferials, including this Nucleo board which works with the manufacturer's (ST) software. Over the last what, 5 years or something, OpenOCD is the only thing that did not work.
Facebook-free life and Rigol-free shack.
 

Offline BudTopic starter

  • Super Contributor
  • ***
  • Posts: 6802
  • Country: ca
Re: OpenOCD fail to open STM32 Nucleo board
« Reply #9 on: January 10, 2017, 02:45:45 pm »
Well, use ST's ST-Link GDB server then.

Thanks for the hint, i will try that.
Facebook-free life and Rigol-free shack.
 

Offline ntfreak

  • Contributor
  • Posts: 12
  • Country: gb
Re: OpenOCD fail to open STM32 Nucleo board
« Reply #10 on: January 10, 2017, 10:26:49 pm »
I already have ST drivers for both generic chips and boards. If this is a known problem why openocd developers keep quiet. How difficult is it to say "not working/may not work in Windows with STM32  evaluation boards" so people do not waste time with this crap open source product.  :rant:
I am a OpenOCD dev and as far as I know this is not a known problem. You could always file a bug report?

Regards.

Sent from my XT1562 using Tapatalk

 

Offline ntfreak

  • Contributor
  • Posts: 12
  • Country: gb
Re: OpenOCD fail to open STM32 Nucleo board
« Reply #11 on: January 10, 2017, 10:30:50 pm »
If this is a known problem why openocd developers keep quiet. How difficult is it to say "not working/may not work in Windows with STM32  evaluation boards" so people do not waste time with this crap open source product.  :rant:
Well, use ST's ST-Link GDB server then.
Did not realise ST had their own gdb server - do you have a URL?
 

Offline BudTopic starter

  • Super Contributor
  • ***
  • Posts: 6802
  • Country: ca
Re: OpenOCD fail to open STM32 Nucleo board
« Reply #12 on: January 11, 2017, 04:08:38 am »

I am a OpenOCD dev and as far as I know this is not a known problem. You could always file a bug report?


Sorry I am too old to learn how submit bug reports. There is a D3 level OpenOCD log attached to my original post, it was made on a USB3.0 port, please see if it is of a value to you.

Facebook-free life and Rigol-free shack.
 


Offline ntfreak

  • Contributor
  • Posts: 12
  • Country: gb
Re: OpenOCD fail to open STM32 Nucleo board
« Reply #14 on: January 11, 2017, 02:53:46 pm »
Sorry I am too old to learn how submit bug reports. There is a D3 level OpenOCD log attached to my original post, it was made on a USB3.0 port, please see if it is of a value to you.

OpenOCD uses the USB lib "libusb" to communicate with the ST-LINK. The version of libusb used depends on who built OpenOCD that you are using - in your case this is ac6 who develop "System Workbench for STM32".

All I can suggest is to check you are running the latest version of "System Workbench", if you are then I would tell them they need to build with the latest version of libusb as this usually fixes most USB3 issues.
If they are already building with the latest then ac6 should probably report the issue to the libusb devs - in an ideal world anyway.

Regards
 

Offline that_guy

  • Contributor
  • Posts: 41
  • Country: gb
Re: OpenOCD fail to open STM32 Nucleo board
« Reply #15 on: January 16, 2017, 02:25:20 pm »
Quote
OpenOCD uses the USB lib "libusb" to communicate with the ST-LINK. The version of libusb used depends on who built OpenOCD that you are using - in your case this is ac6 who develop "System Workbench for STM32".

This is usually it. "Official" windows applications will use Microsoft WinUSB but open source programs always use the free libusb. Confusing? Yes. There's a very useful utility called "zadig" (google it) that will allow you to switch between drivers for a specific peripheral on the fly if you run into this problem.
 

Offline ntfreak

  • Contributor
  • Posts: 12
  • Country: gb
Re: OpenOCD fail to open STM32 Nucleo board
« Reply #16 on: January 16, 2017, 02:51:36 pm »
This is usually it. "Official" windows applications will use Microsoft WinUSB but open source programs always use the free libusb. Confusing? Yes. There's a very useful utility called "zadig" (google it) that will allow you to switch between drivers for a specific peripheral on the fly if you run into this problem.

OpenOCD uses libusb as a cross platform USB lib - the driver will still be winusb on windows (ST-LINK v2 and above). zadiag should not really be required when using the ST-LINK.

Regards
 

Offline BudTopic starter

  • Super Contributor
  • ***
  • Posts: 6802
  • Country: ca
Re: OpenOCD fail to open STM32 Nucleo board
« Reply #17 on: January 16, 2017, 03:31:37 pm »
I did try Zadig and it bricked the Nucleo. It stopped working with the vendor ST Link utility, and still did not work with OpenOCD. I had to reinstall both the vendor drivers and ST Link utility to return to the status quo.
As i said, i eventually figured out it was USB 3.0 causing thd problem with Open OCD.
Facebook-free life and Rigol-free shack.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf