Sipeed RV-Debugger Lite

Platformio 1.54.1 will not work with the Sipeed RV-Debugger Lite (out of the box)

Configuring projects for upload and debugging for the sipeed-rv-debugger should work with the Lite adapter available from aliexpress etc.

It fails with the error:-

Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6010, description 'Dual RS232', serial '*' at bus location '*'

*** [upload] Error 1

This can be fixed by commenting out the ftdi_device_desc parameter in the sipeed-rv-debugger.cfg file:-

.platformio/packages/tool-openocd-gd32v/share/openocd/scripts/interface/ftdi/sipeed-rv-debugger.cfg

interface ftdi
#ftdi_device_desc "Dual RS232"
ftdi_vid_pid 0x0403 0x6010

#autoexit true

#interface cmsis-dap
transport select jtag
ftdi_layout_init 0x0008 0x001b
ftdi_layout_signal nSRST -oe 0x0020 -data 0x0020

The lite adapter uses a microcontroler to emulate the FT2232 and it does not return the expected descriptor string. Rather than breaking the cfg file other stuff it was easier to comment this line out and rely on the VID/PID for identification.

What string does it report?

In any case you should open a bug report at Issues · sipeed/platform-gd32v · GitHub with this information so that the tool-openocd-gd32v can be updated with a new configuration file for that debugger, plus the needed Python logic in the platform to recongize that adapter, as it seems to be different to https://docs.platformio.org/en/latest/plus/debug-tools/sipeed-rv-debugger.html

Bus 005 Device 074: ID 0403:6010 Future Technology Devices International, Ltd FT2232C/D/H Dual UART/FIFO IC

Is what it shows up as on Debian

I agree I should report it on github, but as I moved out when M$ moved in, and will not return till they leave this is not going to happen. Next best is to record the issues here so someone can find them in a search. Neither do I reasonably expect that platformio should change the way it is doing things or where it is hosting itself.

I guess ideally rather than tweak the descriptor for the RV-Debugger so it is less specific and works with the Lite version it would perhaps be better to create another profile specifically for the lite version. But this is not my call to make.

The Description seen by platformio though under devices is:-

/dev/ttyUSB1 Sipeed-Debug USB VID:PID=0403:6010 SER=9152F256B4 LOCATION=5-2:1.1
/dev/ttyUSB0 Sipeed-Debug - Sipeed-JTAG USB VID:PID=0403:6010 SER=9152F256B4 LOCATION=5-2:1.0

Or from the logs:-
[2226047.052213] usb 5-2: new full-speed USB device number 74 using xhci_hcd
[2226047.362315] usb 5-2: New USB device found, idVendor=0403, idProduct=6010, bcdDevice= 5.00
[2226047.362321] usb 5-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[2226047.362324] usb 5-2: Product: Sipeed-Debug
[2226047.362326] usb 5-2: Manufacturer: Kongou Hikari
[2226047.362328] usb 5-2: SerialNumber: 9152F256B4
[2226047.551993] ftdi_sio 5-2:1.0: FTDI USB Serial Device converter detected
[2226047.552046] usb 5-2: Detected FT2232C
[2226047.552441] usb 5-2: FTDI USB Serial Device converter now attached to ttyUSB0
[2226047.552598] ftdi_sio 5-2:1.1: FTDI USB Serial Device converter detected
[2226047.552636] usb 5-2: Detected FT2232C
[2226047.552914] usb 5-2: FTDI USB Serial Device converter now attached to ttyUSB1
[2228390.252931] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
[2228390.252947] ftdi_sio 5-2:1.0: device disconnected
[2231841.686597] usb 5-2: USB disconnect, device number 74
[2231841.686959] ftdi_sio ttyUSB1: FTDI USB Serial Device converter now disconnected from ttyUSB1

Overall there may be some other errors yet as it does not seem to program correctly, or at least the blink code doesn’t blink. I need to dig into this a bit more though.

Info : device id = 0x19060410
Info : flash_size_in_kb = 0x00000040
Info : flash size = 64kbytes
Info : JTAG tap: riscv.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
Warn : JTAG tap: riscv.cpu       UNEXPECTED: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
Error: JTAG tap: riscv.cpu  expected 1 of 1: 0x1e200a6d (mfg: 0x536 (Nuclei System Technology Co.,Ltd.), part: 0xe200, ver: 0x1)
Info : JTAG tap: auto0.tap tap/device found: 0x790007a3 (mfg: 0x3d1 (GigaDevice Semiconductor (Beijing)), part: 0x9000, ver: 0x7)
Error: Trying to use configured scan chain anyway...
Warn : Bypassing JTAG setup events due to errors
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
Info : Hart 0 unexpectedly reset!

*** [upload] Error 1

Issue Support Sipeed RV-Debugger Lite debug probe · Issue #31 · sipeed/platform-gd32v · GitHub is opened in the platform for tracking – should be handled by the devs there.

For the sake of completeness…

lsusb -vd 0403:6010

Bus 005 Device 076: ID 0403:6010 Future Technology Devices International, Ltd FT2232C/D/H Dual UART/FIFO IC
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0403 Future Technology Devices International, Ltd
  idProduct          0x6010 FT2232C/D/H Dual UART/FIFO IC
  bcdDevice            5.00
  iManufacturer           1 Kongou Hikari
  iProduct                2 Sipeed-Debug
  iSerial                 3 9152F256B4
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0037
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              4 Sipeed-JTAG
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x04  EP 4 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
cannot read device status, Resource temporarily unavailable (11)

Awesome, thankyou, your a star.

Ok a small update

It does seem to be programming the device OK, but you need to power cycle the device for the code to run. A reset (press button on the longan nano lite) does not help. but unplugging and then plugging the device pair from the USB seems to allow it to work.

Not sure if this is the rv-debugger lite not releasing the reset correctly or similar.

Again for completeness:-

Building in release mode
Checking size .pio/build/sipeed-longan-nano-lite/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  11.3% (used 2310 bytes from 20480 bytes)
Flash: [=         ]  10.0% (used 6572 bytes from 65536 bytes)
Configuring upload protocol...
AVAILABLE: altera-usb-blaster, gd-link, jlink, rv-link, serial, sipeed-rv-debugger, um232h
CURRENT: upload_protocol = sipeed-rv-debugger
Uploading .pio/build/sipeed-longan-nano-lite/firmware.elf
Open On-Chip Debugger 0.10.0+dev-00911-gcfbca74bd (2019-09-12-09:31)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Warn : Transport "jtag" was already selected
jtag
adapter speed: 1000 kHz

Info : clock speed 1000 kHz
Info : JTAG tap: riscv.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
Warn : JTAG tap: riscv.cpu       UNEXPECTED: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
Error: JTAG tap: riscv.cpu  expected 1 of 1: 0x1e200a6d (mfg: 0x536 (Nuclei System Technology Co.,Ltd.), part: 0xe200, ver: 0x1)
Info : JTAG tap: auto0.tap tap/device found: 0x790007a3 (mfg: 0x3d1 (GigaDevice Semiconductor (Beijing)), part: 0x9000, ver: 0x7)
Error: Trying to use configured scan chain anyway...
Warn : AUTO auto0.tap - use "jtag newtap auto0 tap -irlen 5 -expected-id 0x790007a3"
Warn : Bypassing JTAG setup events due to errors
Info : datacount=4 progbufsize=2
Info : Exposing additional CSR 3040
Info : Exposing additional CSR 3041
Info : Exposing additional CSR 3042
Info : Exposing additional CSR 3043
Info : Exposing additional CSR 3044
Info : Exposing additional CSR 3045
Info : Exposing additional CSR 3046
Info : Exposing additional CSR 3047
Info : Exposing additional CSR 3048
Info : Exposing additional CSR 3049
Info : Exposing additional CSR 3050
Info : Exposing additional CSR 3051
Info : Exposing additional CSR 3052
Info : Exposing additional CSR 3053
Info : Exposing additional CSR 3054
Info : Exposing additional CSR 3055
Info : Exposing additional CSR 3056
Info : Exposing additional CSR 3057
Info : Exposing additional CSR 3058
Info : Exposing additional CSR 3059
Info : Exposing additional CSR 3060
Info : Exposing additional CSR 3061
Info : Exposing additional CSR 3062
Info : Exposing additional CSR 3063
Info : Exposing additional CSR 3064
Info : Exposing additional CSR 3065
Info : Exposing additional CSR 3066
Info : Exposing additional CSR 3067
Info : Exposing additional CSR 3068
Info : Exposing additional CSR 3069
Info : Exposing additional CSR 3070
Info : Exposing additional CSR 3071
Info : Examined RISC-V core; found 1 harts
Info :  hart 0: XLEN=32, misa=0x40901105
Info : Listening on port 3333 for gdb connections
Info : device id = 0x19060410
Info : flash_size_in_kb = 0x00000040
Info : flash size = 64kbytes
Info : JTAG tap: riscv.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
Warn : JTAG tap: riscv.cpu       UNEXPECTED: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
Error: JTAG tap: riscv.cpu  expected 1 of 1: 0x1e200a6d (mfg: 0x536 (Nuclei System Technology Co.,Ltd.), part: 0xe200, ver: 0x1)
Info : JTAG tap: auto0.tap tap/device found: 0x790007a3 (mfg: 0x3d1 (GigaDevice Semiconductor (Beijing)), part: 0x9000, ver: 0x7)
Error: Trying to use configured scan chain anyway...
Warn : Bypassing JTAG setup events due to errors
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
Info : Hart 0 unexpectedly reset!

*** [upload] Error 1
========================================================================= [FAILED] Took 13.91 seconds =========================================================================
The terminal process "platformio 'run', '--target', 'upload'" terminated with exit code: 1.

The micro-controller emulating the FT2232 is a CH552T

The lite looks like this:-
rv-debugger lite

The RV-Debugger looks like this :-
rv-debugger

Ok some more updates

Programming my longan nano’s ( lite and non lite versions) the flash size is being misreported (64K, when one is 128K). It works on both devices though so not sure what is happening here.

Having had hack around with openocd scripts (which i know very little about) and a look at what platformio is doing it looks like the gd32vf103.cfg openocd script si responsible for the reset, problem, wrong reporting of memory size and the identification warnings/errors reportefd above.

Knowing what to put into a search though flagged up work by these two guys on the issues and their solutions. Which I guess could do to be interpreted by someone that does know what they are doing, into platformio proper.

OpenOCD script for GD32VF103 with improvised reset procedure

I tried elfmimi’s script in place of my own (default platformio 5.1.0) gd32vf103.cfg commenting out lines 7 thru 13 as they duplicate lines in sipeed-rv-debugger.cfg and it seems to now recognise the correct flash size. It also eliminated the annoying jtag errors by replacing the tap id in line 17 with the correct ones as mine do not seem to be masqueraded.

Not got around to trying out the invocations that actually do the reset and fix this problem as I am too far into tweaking platformio with tweaks that will be lost on the next update. But so far the results have been better.

Just in case it is not clear I can not take any credit for elfmimi and joba’s work. I just borrowed some of it and tried it. It would be great though to see the results of their efforts integrated into platformio to improve support for the longan nano (and lite) boards though.

1 Like

For completness a terminal excerpt showing the improvments:-

Uploading .pio/build/sipeed-longan-nano-lite/firmware.elf
Open On-Chip Debugger 0.10.0+dev-00911-gcfbca74bd (2019-09-12-09:31)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Warn : Transport "jtag" was already selected
jtag
adapter speed: 1000 kHz

Info : clock speed 1000 kHz
Info : JTAG tap: riscv.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes Technology Corporation), part: 0x0005, ver: 0x1)
Info : JTAG tap: gd32v.tap tap/device found: 0x790007a3 (mfg: 0x3d1 (GigaDevice Semiconductor (Beijing)), part: 0x9000, ver: 0x7)
Info : datacount=4 progbufsize=2
Info : Examined RISC-V core; found 1 harts
Info :  hart 0: XLEN=32, misa=0x40901105
Info : Listening on port 3333 for gdb connections
Info : device id = 0x19060410
Info : flash_size_in_kb = 0x00000040
Info : flash size = 64kbytes
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
Info : Hart 0 unexpectedly reset!

*** [upload] Error 1

Just to show the difference against the foregoing excerpts. This was programming a longan nano lite and the flash size is correctly reported as 64K. Programing the longan nano the flash size is also now correctly reported as 128K in the terminal session…

1 Like

Another interesting feature-ette of the Sipeed RV-Debugger Lite is that the serial port on it does not support 115200.

Just the following:-
2400 4800 9600 19200 38400 43000 56000 57600 128k 256k

I guess 115200 must be a division of the micro-controllers clock that is not supported.

However the next fastest speed of 128000 seems to work OK

--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters
--- Miniterm on /dev/ttyUSB1  128000,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---

USART0 Initialised to 128000 8N1 no flow control

Booted
Device Info:-
Flash:      64kB
SRAM:       20kB
Device ID: 3934057C 00053935 FFFFFFFF

Having a debugger that also has a serial port to monitor output during the development phase without needing to plug in a separate device is handy. Just watch out for what is for many (particularly those used to AVR and Arduino) the default baud rate not being supported.