Search code examples
linuxembeddedstm32openocd

OpenOCD cannot open connection to STM32L4 board (STEVAL STWINCSV1)


I have a STEVAL STWINCSV1 board with an STM32L4R9 chip connected to my computer via USB. I am trying to use OpenOCD to flash a new image. I am using the command openocd -d -f board/stm32l4discovery.cfg to try to open a connection to the board. Here are the contents of the cfg file

# Explicitly for the STM32L476 discovery board:
# http://www.st.com/web/en/catalog/tools/PF261635
# but perfectly functional for any other STM32L4 board connected via
# an stlink-v2-1 interface.
# This is for STM32L4 boards that are connected via stlink-v2-1.
 
source [find interface/stlink.cfg]
 
transport select hla_swd
 
source [find target/stm32l4x.cfg]
 
reset_config srst_only

When I plug in the board via USB and check the output of dmesg | grep usb, here is what I get (I plugged the board in multiple times):

[15316.981696] usb 1-1.3: new full-speed USB device number 7 using xhci_hcd
[15317.119120] usb 1-1.3: New USB device found, idVendor=0483, idProduct=5740, bcdDevice= 2.00
[15317.119121] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[15317.119122] usb 1-1.3: Product: STM32 Virtual ComPort in FS Mode
[15317.119123] usb 1-1.3: Manufacturer: STMicroelectronics
[15317.119123] usb 1-1.3: SerialNumber: FFFFFFFEFFFF
[15317.169176] usbcore: registered new interface driver cdc_acm
[15726.366247] usb 1-1.3: USB disconnect, device number 7
[15733.238286] usb 1-1.3: new full-speed USB device number 8 using xhci_hcd
[15733.363181] usb 1-1.3: New USB device found, idVendor=0483, idProduct=5740, bcdDevice= 2.00
[15733.363182] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[15733.363183] usb 1-1.3: Product: STM32 Virtual ComPort in FS Mode
[15733.363184] usb 1-1.3: Manufacturer: STMicroelectronics
[15733.363184] usb 1-1.3: SerialNumber: FFFFFFFEFFFF
[15822.875489] usb 1-1.3: USB disconnect, device number 8
[15861.278256] usb 1-3.4: new full-speed USB device number 9 using xhci_hcd
[15861.400511] usb 1-3.4: New USB device found, idVendor=0483, idProduct=5740, bcdDevice= 2.00
[15861.400512] usb 1-3.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[15861.400513] usb 1-3.4: Product: STM32 Virtual ComPort in FS Mode
[15861.400514] usb 1-3.4: Manufacturer: STMicroelectronics
[15861.400514] usb 1-3.4: SerialNumber: FFFFFFFEFFFF
[16196.113834] usb 1-3.4: USB disconnect, device number 9
[16251.868195] usb 1-1.3: new full-speed USB device number 10 using xhci_hcd
[16252.006377] usb 1-1.3: New USB device found, idVendor=0483, idProduct=5740, bcdDevice= 2.00
[16252.006378] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[16252.006379] usb 1-1.3: Product: STM32 Virtual ComPort in FS Mode
[16252.006380] usb 1-1.3: Manufacturer: STMicroelectronics
[16252.006380] usb 1-1.3: SerialNumber: FFFFFFFEFFFF

When I run openocd -d -f board/stm32l4discovery.cfg, here is the output (pastebinned since it was a bit long): https://pastebin.com/biVLuf7U

Does anyone know what might be going wrong here?


Solution

  • I figured out the issue. First of all, the eval board I was using does not support stlink over its usb port, so I had to use a stlink/v3 mini external programmer instead. Also, the latest OpenOCD release on my distro did not support stlink/v3, so I had to compile OpenOCD from source. That fixed my issue.