Failed to launch GDB while debugging Hifive1 with PlatformIO

VSCode_hifive1_Fail_Launch

Please refer to the above picture?
Should I modify anything in the default launch.json or c_cpp_properties.json?

No, these are automatically generated.

Looks like the debugger cannot connect to your board. Can you post the result of

lsusb

and a manual openocd invocation

~/.platformio/packages/tool-openocd-riscv/bin/openocd -s ~/.platformio/packages/tool-openocd-riscv/share/openocd/scripts -f ~/.platformio/packages/framework-freedom-e-sdk/bsp/sifive-hifive1/openocd.cfg

Also, do you have a Hifive1 or a Hifive1 Rev B?

Hi, @maxgerhardt
Thank you for your reply.

I have a Hifive 1 Rev B.

 ✔  lsusb  
Bus 001 Device 008: ID 1366:1051 SEGGER 

 ✔  ~/.platformio/packages/tool-openocd-riscv/bin/openocd -s ~/.platformio/packages/tool-openocd-riscv/share/openocd/scripts -f ~/.platformio/packages/framework-freedom-e-sdk/bsp/sifive-hifive1/openocd.cfg
Open On-Chip Debugger 0.10.0+dev (SiFive OpenOCD 0.10.0-2019.08.2)
Licensed under GNU GPL v2
For bug reports:
	https://github.com/sifive/freedom-tools/issues
adapter speed: 10000 kHz
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6010, description 'Dual RS232-HS', serial '*' at bus location '*'

You are right. no device found. How to solve this issue?

Cheers
Pei

If you use revision B you must change your board = in the platofrmio.ini to hifive1-revb. (HiFive1 Rev B — PlatformIO latest documentation).

If that still doesn’t work I need to see the output of

~/.platformio/packages/tool-openocd-riscv/bin/openocd -s ~/.platformio/packages/tool-openocd-riscv/share/openocd/scripts -f ~/.platformio/packages/framework-freedom-e-sdk/bsp/sifive-hifive1-revb/openocd.cfg

There is such a folder ~/.platformio/packages/framework-freedom-e-sdk/bsp/sifive-hifive1-revb, but NO such a file ~/.platformio/packages/framework-freedom-e-sdk/bsp/sifive-hifive1-revb/openocd.cfg.

And, if I copy openocd.cfg from folder ~/.platformio/packages/framework-freedom-e-sdk/bsp/sifive-hifive1 to ~/.platformio/packages/framework-freedom-e-sdk/bsp/sifive-hifive1-revb, I got the following ERROR message:

 ✘  ~/.platformio/packages/tool-openocd-riscv/bin/openocd -s ~/.platformio/packages/tool-openocd-riscv/share/openocd/scripts -f ~/.platformio/packages/framework-freedom-e-sdk/bsp/sifive-hifive1-revb/openocd.cfg
Open On-Chip Debugger 0.10.0+dev (SiFive OpenOCD 0.10.0-2019.08.2)
Licensed under GNU GPL v2
For bug reports:
	https://github.com/sifive/freedom-tools/issues
adapter speed: 10000 kHz
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6010, description 'Dual RS232-HS', serial '*' at bus location '*'

Oh, that’s right, seems to be a bug… Hm I noticed also that the openocd config says

interface ftdi
ftdi_device_desc "Dual RS232-HS"
ftdi_vid_pid 0x0403 0x6010

so it’s seraching for an FTDI USB device with VID and PID 0x0403, 0x6010, but your lsusb shows a…

SEGGER device with VID/PID 0x1366/0x1051? How does a Segger (Jlink?) get on that board?

Can you show a link where you bought the board?

The config expects an FTDI chips, not a SEGGER something.

I purchased it from CrowdSupply
https://www.crowdsupply.com/sifive/hifive1-rev-b

I actually installed https://www.segger.com/downloads/jlink/. If I didn’t install this SDK, I wouldn’t even ben able to start debug in VSCode.

Ah sorry that’s actually correct that there’s a JLink on the board.

The board has a default uplaod method of jlink. You shouldn’t need the openocd config at all. The debugging should start as normal when you select board = hifive1-revb without any special options.

Are there any error messages when you go Run -> Start debugging?

Did this get resolved?

I’m running into the same problem. Trying to use CLI platformio and getting the same error as above.

sifive hifive1 revb

Configuring upload protocol…
AVAILABLE: jlink
CURRENT: upload_protocol = jlink
Uploading .pio\build\sifive-hifive1-revb\firmware.hex
SEGGER J-Link Commander V6.88b (Compiled Nov 27 2020 15:45:43)
DLL version V6.88b, compiled Nov 27 2020 15:44:11

J-Link Command File read successfully.
Processing script file…

J-Link connection not established yet but required for command.
Connecting to J-Link via USB…FAILED: Cannot connect to J-Link.

J-Link connection not established yet but required for command.
Connecting to J-Link via USB…FAILED: Failed to open DLL

J-Link connection not established yet but required for command.
Connecting to J-Link via USB…FAILED: Failed to open DLL

Well but that is a different error. Are you on Windows? Have you installed the JLink drivers?

Hi,

On windows 10 with jlink installed.
After installing, I get a popup window titled “j-link V6.88b emulator” with text
No emulators connected to USB with connection method ip as the option or an identifier as a separate input box

In the Windows device manager, do you see JLink as a listed USB device? Can you show a screenshot if yes? Are there any unknown devices in the device manager?

It shows as JLink CDC Uart. two devices.

Output from windows usb device viewer

[Port6]  :  USB Composite Device


Is Port User Connectable:         yes
Is Port Debug Capable:            no
Companion Port Number:            0
Companion Hub Symbolic Link Name: 
Protocols Supported:
 USB 1.1:                         yes
 USB 2.0:                         yes
 USB 3.0:                         no

Device Power State:               PowerDeviceD0

       ---===>Device Information<===---
English product name: "J-Link"

ConnectionStatus:                  
Current Config Value:              0x01  -> Device Bus Speed: Full (is not SuperSpeed or higher capable)
Device Address:                    0x05
Open Pipes:                          10

          ===>Device Descriptor<===
bLength:                           0x12
bDescriptorType:                   0x01
bcdUSB:                          0x0200
bDeviceClass:                      0xEF  -> This is a Multi-interface Function Code Device
bDeviceSubClass:                   0x02  -> This is the Common Class Sub Class
bDeviceProtocol:                   0x01  -> This is the Interface Association Descriptor protocol
bMaxPacketSize0:                   0x40 = (64) Bytes
idVendor:                        0x1366 = SEGGER Microcontroller Systems GmbH
idProduct:                       0x1051
bcdDevice:                       0x0100
iManufacturer:                     0x01
     English (United States)  "SEGGER"
iProduct:                          0x02
     English (United States)  "J-Link"
iSerialNumber:                     0x03
     English (United States)  "000979000982"
bNumConfigurations:                0x01

          ---===>Open Pipes<===---

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x83  -> Direction: IN - EndpointID: 3
bmAttributes:                      0x03  -> Interrupt Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x87  -> Direction: IN - EndpointID: 7
bmAttributes:                      0x03  -> Interrupt Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x89  -> Direction: IN - EndpointID: 9
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x06  -> Direction: OUT - EndpointID: 6
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x81  -> Direction: IN - EndpointID: 1
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x02  -> Direction: OUT - EndpointID: 2
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x85  -> Direction: IN - EndpointID: 5
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x04  -> Direction: OUT - EndpointID: 4
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x8B  -> Direction: IN - EndpointID: 11
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x08  -> Direction: OUT - EndpointID: 8
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

       ---===>Full Configuration Descriptor<===---

          ===>Configuration Descriptor<===
bLength:                           0x09
bDescriptorType:                   0x02
wTotalLength:                    0x00BB  -> Validated
bNumInterfaces:                    0x06
bConfigurationValue:               0x01
iConfiguration:                    0x04
     English (United States)  "Configuration"
bmAttributes:                      0x80  -> Bus Powered
MaxPower:                          0x32 = 100 mA

          ===>IAD Descriptor<===
bLength:                           0x08
bDescriptorType:                   0x0B
bFirstInterface:                   0x00
bInterfaceCount:                   0x02
bFunctionClass:                    0x02  -> This is Communications (CDC Control) USB Device Interface Class
bFunctionSubClass:                 0x02
bFunctionProtocol:                 0x00
iFunction:                         0x05
     English (United States)  "CDC"

          ===>Interface Descriptor<===
bLength:                           0x09
bDescriptorType:                   0x04
bInterfaceNumber:                  0x00
bAlternateSetting:                 0x00
bNumEndpoints:                     0x01
bInterfaceClass:                   0x02  -> This is Communications (CDC Control) USB Device Interface Class
bInterfaceSubClass:                0x02
bInterfaceProtocol:                0x01
iInterface:                        0x05
     English (United States)  "CDC"
  -> This is a Communications (CDC Control) USB Device Interface Class

          ===>Descriptor Hex Dump<===
bLength:                           0x05
bDescriptorType:                   0x24
05 24 00 10 01 
  -> This is a Communications (CDC Control) USB Device Interface Class

          ===>Descriptor Hex Dump<===
bLength:                           0x05
bDescriptorType:                   0x24
05 24 01 03 01 
  -> This is a Communications (CDC Control) USB Device Interface Class

          ===>Descriptor Hex Dump<===
bLength:                           0x04
bDescriptorType:                   0x24
04 24 02 06 
  -> This is a Communications (CDC Control) USB Device Interface Class

          ===>Descriptor Hex Dump<===
bLength:                           0x05
bDescriptorType:                   0x24
05 24 06 00 01 

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x83  -> Direction: IN - EndpointID: 3
bmAttributes:                      0x03  -> Interrupt Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>Interface Descriptor<===
bLength:                           0x09
bDescriptorType:                   0x04
bInterfaceNumber:                  0x01
bAlternateSetting:                 0x00
bNumEndpoints:                     0x02
bInterfaceClass:                   0x0A  -> This is a CDC Data USB Device Interface Class
bInterfaceSubClass:                0x00
bInterfaceProtocol:                0x00
iInterface:                        0x06
     English (United States)  "CDC DATA interface"

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x81  -> Direction: IN - EndpointID: 1
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x02  -> Direction: OUT - EndpointID: 2
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>IAD Descriptor<===
bLength:                           0x08
bDescriptorType:                   0x0B
bFirstInterface:                   0x02
bInterfaceCount:                   0x02
bFunctionClass:                    0x02  -> This is Communications (CDC Control) USB Device Interface Class
bFunctionSubClass:                 0x02
bFunctionProtocol:                 0x00
iFunction:                         0x07
     English (United States)  "CDC"

          ===>Interface Descriptor<===
bLength:                           0x09
bDescriptorType:                   0x04
bInterfaceNumber:                  0x02
bAlternateSetting:                 0x00
bNumEndpoints:                     0x01
bInterfaceClass:                   0x02  -> This is Communications (CDC Control) USB Device Interface Class
bInterfaceSubClass:                0x02
bInterfaceProtocol:                0x01
iInterface:                        0x07
     English (United States)  "CDC"
  -> This is a Communications (CDC Control) USB Device Interface Class

          ===>Descriptor Hex Dump<===
bLength:                           0x05
bDescriptorType:                   0x24
05 24 00 10 01 
  -> This is a Communications (CDC Control) USB Device Interface Class

          ===>Descriptor Hex Dump<===
bLength:                           0x05
bDescriptorType:                   0x24
05 24 01 03 03 
  -> This is a Communications (CDC Control) USB Device Interface Class

          ===>Descriptor Hex Dump<===
bLength:                           0x04
bDescriptorType:                   0x24
04 24 02 06 
  -> This is a Communications (CDC Control) USB Device Interface Class

          ===>Descriptor Hex Dump<===
bLength:                           0x05
bDescriptorType:                   0x24
05 24 06 02 03 

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x87  -> Direction: IN - EndpointID: 7
bmAttributes:                      0x03  -> Interrupt Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>Interface Descriptor<===
bLength:                           0x09
bDescriptorType:                   0x04
bInterfaceNumber:                  0x03
bAlternateSetting:                 0x00
bNumEndpoints:                     0x02
bInterfaceClass:                   0x0A  -> This is a CDC Data USB Device Interface Class
bInterfaceSubClass:                0x00
bInterfaceProtocol:                0x00
iInterface:                        0x08
     English (United States)  "CDC DATA interface"

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x85  -> Direction: IN - EndpointID: 5
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x04  -> Direction: OUT - EndpointID: 4
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>Interface Descriptor<===
bLength:                           0x09
bDescriptorType:                   0x04
bInterfaceNumber:                  0x04
bAlternateSetting:                 0x00
bNumEndpoints:                     0x02
bInterfaceClass:                   0xFF  -> Interface Class Unknown to USBView
bInterfaceSubClass:                0xFF
bInterfaceProtocol:                0xFF
iInterface:                        0x09
     English (United States)  "BULK interface"

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x89  -> Direction: IN - EndpointID: 9
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x06  -> Direction: OUT - EndpointID: 6
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>Interface Descriptor<===
bLength:                           0x09
bDescriptorType:                   0x04
bInterfaceNumber:                  0x05
bAlternateSetting:                 0x00
bNumEndpoints:                     0x02
bInterfaceClass:                   0x08  -> This is a Mass Storage USB Device Interface Class
bInterfaceSubClass:                0x06
bInterfaceProtocol:                0x50
iInterface:                        0x0A
     English (United States)  "MSD interface"

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x8B  -> Direction: IN - EndpointID: 11
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

          ===>Endpoint Descriptor<===
bLength:                           0x07
bDescriptorType:                   0x05
bEndpointAddress:                  0x08  -> Direction: OUT - EndpointID: 8
bmAttributes:                      0x02  -> Bulk Transfer Type
wMaxPacketSize:                  0x0040 = 0x40 bytes
bInterval:                         0x01

Hmm the BULK interface has still uninstalled drivers though and I think that’s where the problem is. Can you download the latest official JLink package from SEGGER - The Embedded Experts - Downloads and install it, (while making sure the default “Install USB Driver for JLink” is ticked).

Then unplug and replug the HiFive board. Then open the program “C:\Program Files (x86)\SEGGER\JLink\JLinkConfig.exe”. Does it report any connected JLinks connected via USB?

Oh actually maybe directly look at J-Link shown as generic BULK device in Windows - SEGGER Wiki, seems to be a known problem

Reinstalling jlink fixed it. I was able to load firmware.
Thanks for the help!