Hi, I am having problems trying to program the Sipeed Longan Nano.
My operating system is Linux Mint 20.1 Cinnamon.
Steps I have done so far: -
- Install Visual Studio Code
Download “code_1.54.3-1615806378_amd64.deb”
sudo apt install ./code_1.54.3-1615806378_amd64.deb - Install Python 3 virtual environment
sudo apt-get install python3-venv - Install PlatformIO
Use extensions in Visual Studio Code - Create a new project
Board Sipeed Longan Nano
Framework Arduino - Code in “main.cpp”
#include <Arduino.h>
void setup() {
pinMode(PC13, OUTPUT);
pinMode(PA1, OUTPUT);
pinMode(PA2, OUTPUT);
}
void loop() {
digitalWrite(PC13, HIGH);
digitalWrite(PA1, HIGH);
digitalWrite(PA2, HIGH);
delay(1000);
digitalWrite(PC13, LOW);
digitalWrite(PA1, LOW);
digitalWrite(PA2, LOW);
delay(1000);
}
- Contents of “platform.ini”
[env:sipeed-longan-nano]
platform = gd32v
board = sipeed-longan-nano
framework = arduino
upload_protocol = dfu
- Connect Sipeed Longan Nano via USB & program
Boot → Reset → Boot
Program (Click program arrow)
Message → Tool Manager: Installing tool-openocd-gd32v @ ~0.1.1 - Terminal output
> Executing task in folder Longan1: platformio run --target upload <
Processing sipeed-longan-nano (platform: gd32v; board: sipeed-longan-nano; framework: arduino)
----------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/pa1ge/boards/gd32v/sipeed-longan-nano.html
PLATFORM: GigaDevice GD32V (1.2.0) > Sipeed Longan Nano
HARDWARE: GD32VF103CBT6 108MHz, 32KB RAM, 128KB Flash
DEBUG: Current (altera-usb-blaster) External (altera-usb-blaster, gd-link, jlink, rv-link, sipeed-rv-debugger, um232h)
PACKAGES:
- framework-arduino-gd32v 0.1.1
- tool-dfuutil 1.9.200310
- tool-gd32vflash 0.1.0
- tool-openocd-gd32v 0.1.1
- 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
Building in release mode
Checking size .pio/build/sipeed-longan-nano/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 7.2% (used 2358 bytes from 32768 bytes)
Flash: [= ] 6.3% (used 8250 bytes from 131072 bytes)
Configuring upload protocol...
AVAILABLE: altera-usb-blaster, dfu, gd-link, jlink, rv-link, 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-2020 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/[/code]
dfu-util: Cannot open DFU device 28e9:0189
dfu-util: No DFU capable USB device available
*** [upload] Error 74
======================== [FAILED] Took 0.58 seconds ========================
The terminal process "platformio 'run', '--target', 'upload'" terminated with exit code: 1.
- Update “udev rules”
curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/master/scripts/99-platformio-udev.rules | sudo tee /etc/udev/rules.d/99-platformio-udev.rules - Restart udev server
sudo service udev restart - Program Sipeed Longan Nano via USB
Boot → Reset → Boot
Program (Click program arrow) - Terminal output
> Executing task in folder Longan1: platformio run --target upload <
Processing sipeed-longan-nano (platform: gd32v; board: sipeed-longan-nano; framework: arduino)
----------------------------------------------------------------------------
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.2.0) > Sipeed Longan Nano
HARDWARE: GD32VF103CBT6 108MHz, 32KB RAM, 128KB Flash
DEBUG: Current (altera-usb-blaster) External (altera-usb-blaster, gd-link, jlink, rv-link, sipeed-rv-debugger, um232h)
PACKAGES:
- framework-arduino-gd32v 0.1.1
- tool-dfuutil 1.9.200310
- tool-gd32vflash 0.1.0
- tool-openocd-gd32v 0.1.1
- 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
Building in release mode
Checking size .pio/build/sipeed-longan-nano/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 7.2% (used 2358 bytes from 32768 bytes)
Flash: [= ] 6.3% (used 8250 bytes from 131072 bytes)
Configuring upload protocol...
AVAILABLE: altera-usb-blaster, dfu, gd-link, jlink, rv-link, 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-2020 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
Opening DFU capable USB device...
ID 28e9:0189
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuERROR, status = 10
dfuERROR, clearing status
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 2048
DfuSe interface name: "Internal Flash "
Found GD32VF103, which reports a bad page size and count for its internal memory.
Fixed layout based on part number: page size 1024, count 64.
Downloading to address = 0x08000000, size = 8268
Erase [ ] 0% 0 bytes
Erase [====== ] 24% 2048 bytes
Erase [============ ] 49% 4096 bytes
Erase [================== ] 74% 6144 bytes
Erase [======================== ] 99% 8192 bytes
Download [ ] 0% 0 bytes
Download [====== ] 24% 2048 bytes
Download [============ ] 49% 4096 bytes
Download [================== ] 74% 6144 bytes
Download [======================== ] 99% 8192 bytes
Download [=========================] 100% 8268 bytes
Download done.
File downloaded successfully
Transitioning to dfuMANIFEST state
======================= [SUCCESS] Took 2.68 seconds =======================
- LEDs do not blink, also “bad page size…”
- In a terminal install DFU utility
sudo apt install dfu-util - Program via new DFU utility in a terminal
Boot → Reset → Boot
sudo dfu-util -a 0 -s 0x08000000:leave -D firmware.bin - Terminal output
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
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
Match vendor ID from file: 28e9
Match product ID from file: 0189
Opening DFU capable USB device...
ID 28e9:0189
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuERROR, status = 10
dfuERROR, clearing status
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 2048
DfuSe interface name: "Internal Flash "
Downloading to address = 0x08000000, size = 8268
Download [=========================] 100% 8268 bytes
Download done.
File downloaded successfully
Transitioning to dfuMANIFEST state
- LEDs do not blink, but no message about “bad page size…”
- List USB devices
Boot → Reset → Boot
lsusb
Bus 001 Device 013: ID 28e9:0189 GDMicroelectronics GD32 0x418 DFU Bootloade
- DFU utility list
Boot → Reset → Boot
sudo dfu-util --list
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
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
Found DFU: [28e9:0189] ver=1000, devnum=14, cfg=1, intf=0, path="1-3", alt=1, name="@Option Bytes /0x1FFFF800/01*016 g", serial="??"
Found DFU: [28e9:0189] ver=1000, devnum=14, cfg=1, intf=0, path="1-3", alt=0, name="@Internal Flash /0x08000000/512*002Kg", serial="??"
What do I need to change / do to get the Sipeed Longan Nano to program and get a blinking LED working? Thanks…