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:-
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.
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
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.
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.
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…
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.