Using USB to host computer <-> longan nano communication

Hi,

I just received my Longan Nano kit and plugged the usb wire on my Linux (debian) computer.

The kit is been powered and the RGB led is blinking. But I see nothing in Linux dmesg.

Does somebody know how to use USB protocol with the Longan Nano to establish communication between the board and a Linux computer ?

you need press boot button before insert usb, then it will come into DFU mode

1 Like

Thank Zepan, it works.
Have you a link on documentation about this DFU mode ?

Most of the operations are the same under Linux and Win using the PlatformIO IDE. You can refer to the Longan Wiki.

If you are not using the root user, you may need to add udev rules, refer to the PIO documentation.

Hi @Zepan,

I held the Boot button and “lsusb” showed a new device with no description:

Bus 001 Device 092: ID 28e9:0189

However, PlatformIO still can’t see it.

When I attach the SiSpeed RISC-V debugger PlatformIO sees the device, however, I can’t upload and I get the following error:

Processing sipeed-longan-nano (platform: gd32v; board: sipeed-longan-nano; framework: gd32vf103-sdk)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/gd32v/sipeed-longan-nano.html
PLATFORM: GigaDevice GD32V 1.0.0 > Sipeed Longan Nano
HARDWARE: GD32VF103CBT6 108MHz, 32KB RAM, 128KB Flash
DEBUG: Current (altera-usb-blaster) External (altera-usb-blaster, gd-link, jlink, sipeed-rv-debugger, um232h)
PACKAGES: framework-gd32vf103-sdk 1.0.0, tool-openocd-gd32v 0.1.1, tool-gd32vflash 0.1.0, toolchain-gd32v 9.2.0
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Checking size .pio/build/sipeed-longan-nano/firmware.elf
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [=         ]   7.0% (used 2310 bytes from 32768 bytes)
PROGRAM: [=         ]   5.0% (used 6572 bytes from 131072 bytes)
Configuring upload protocol...
AVAILABLE: altera-usb-blaster, gd-link, jlink, serial, sipeed-rv-debugger, um232h
CURRENT: upload_protocol = serial
Looking for upload port...
Auto-detected: /dev/ttyUSB0
Uploading .pio/build/sipeed-longan-nano/firmware.bin
Failed to init device.
stm32flash Arduino_STM32_0.9

http://github.com/rogerclarkmelbourne/arduino_stm32

Using Parser : Raw BINARY
Interface serial_posix: 115200 8E1

*** [upload] Error 1
======================================================================================== [FAILED] Took 1.31 seconds ========================================================================================
The terminal process terminated with exit code: 1

It keeps trying to use the STM flash:

Failed to init device.
stm32flash Arduino_STM32_0.9

I am confused because I have configured the .ini file:

[env:sipeed-longan-nano]

platform = gd32v

board = sipeed-longan-nano

framework = gd32vf103-sdk

; change microcontroller

board_build.mcu = GD32VF103CBT6

; change MCU frequency

board_build.f_cpu = 108000000L

; upload_protocol = sipeed-rv-debugger

Am I missing something?

Thanks.

Hi,
The usb interface on the board is directly connected to the GD32V chip, not the serial port transfer USB, so if you want to download the program, please choose DFU download.

You need add:
upload_protocol = dfu

1 Like

Thanks.

Where would I learn about these things? Is there a manual or site?

1 Like

@BigBits, @Zepan,

I switched my protocol to dfu but now I get a dfu util error:

Processing sipeed-longan-nano (platform: gd32v; board: sipeed-longan-nano; framework: gd32vf103-sdk)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/gd32v/sipeed-longan-nano.html
PLATFORM: GigaDevice GD32V 1.0.0 > Sipeed Longan Nano
HARDWARE: GD32VF103CBT6 108MHz, 32KB RAM, 128KB Flash
DEBUG: Current (altera-usb-blaster) External (altera-usb-blaster, gd-link, jlink, sipeed-rv-debugger, um232h)
PACKAGES: framework-gd32vf103-sdk 1.0.0, tool-openocd-gd32v 0.1.1, tool-gd32vflash 0.1.0, toolchain-gd32v 9.2.0
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Checking size .pio/build/sipeed-longan-nano/firmware.elf
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [=         ]   7.0% (used 2310 bytes from 32768 bytes)
PROGRAM: [=         ]   5.0% (used 6572 bytes from 131072 bytes)
Configuring upload protocol...
AVAILABLE: altera-usb-blaster, dfu, gd-link, jlink, serial, sipeed-rv-debugger, um232h
CURRENT: upload_protocol = dfu
Uploading .pio/build/sipeed-longan-nano/firmware.bin
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
dfu-util: Invalid DFU suffix signature
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!

dfu-util: Cannot open DFU device 28e9:0189
dfu-util: No DFU capable USB device available
*** [upload] Error 74
======================================================================================== [FAILED] Took 0.28 seconds ========================================================================================
The terminal process terminated with exit code: 1

lsusb reports:

Bus 001 Device 097: ID 28e9:0189  
Bus 001 Device 098: ID 0403:6010 Future Technology Devices International, Ltd FT2232C/D/H Dual UART/FIFO IC

It seems like I must have the debugger plugged in otherwise nothing is recognized. I thought I could program it using just the USB connector and the RISC-V debug tool was for debugging.

I must be doing something wrong or missing something.

Argh! What am I missing???