platform-gd32v
platform-gd32v copied to clipboard
Example programs don't run when using dfu download
I've been trying to get the example blink programs to run.
Since I don't have a debugger or serial port, I need to use dfu method for uploading.
So I only add upload_protocol = dfu
to the platformio.ini
After I run the command below and press the reset button, nothing happens.
~/code/platform-gd32v/examples/longan-nano-blink$ platformio run --target upload
The command output shows that the download was successfull. (I do get the Error 74 from dfu-util, but it seems that doesn't matter. ) The same happens when I try the arduino-blink. See the output below.
When I attached the board the first time, the RGB LED demo was running. After downloading it stopped. So downloading should be successfull. Only the code that was uploaded doesn't seem to run correct. I run Debian Linux 10.2 and I installed platformio using pip3. I checked that I have the original Longan Nano instead of the lite, as was the case with another issue.
breetai@thinktop2:~/code/platform-gd32v/examples/arduino-blink$ platformio run -e sipeed-longan-nano --target upload
Processing sipeed-longan-nano (platform: gd32v; framework: arduino; board: sipeed-longan-nano)
--------------------------------------------------------------------------------------------------------
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.1.2 > 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-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
Building in release mode
Checking size .pio/build/sipeed-longan-nano/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
DATA: [= ] 7.2% (used 2358 bytes from 32768 bytes)
PROGRAM: [= ] 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-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/
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 = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 2048
GD32 flash memory access detected
Device model: GD32VF103CB
Memory segment (0x08000000 - 0801ffff)(rew)
Erase size 1024, page count 128
Downloading to address = 0x08000000, size = 8268
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
dfu-util: Error during download get_status
*** [upload] Error 74
====================================== [FAILED] Took 1.65 seconds ======================================
Environment Status Duration
------------------ -------- ------------
gd32vf103v-eval IGNORED
sipeed-longan-nano FAILED 00:00:01.652
================================ 1 failed, 0 succeeded in 00:00:01.652 ================================
breetai@thinktop2:~/code/platform-gd32v/examples/arduino-blink$
When using the latest revision of dfu-util from the offical source it works. The official branch: https://sourceforge.net/p/dfu-util/dfu-util/ci/master/tree/ See this merge request. https://sourceforge.net/p/dfu-util/dfu-util/ci/f2b7d4b1113ef6c3ada31a0654c9aefebcdb1de5/ by Thomas Hebb. I would suggest to integrate this new revision of dfu-utils in the platform.io package.
I have the same issue.
However, installing the latest version of dfu-util
as @jhaand suggested doesn't work in my case...
Exactly same issue like @pcotret…
I already tried different versions of dfu-util
, no luck so far.
@dr-br. FYI, I found another way to use my Longan Nano :
https://github.com/dwelch67/gigadevice_samples/tree/master/Sipeed.Longan.Nano
dfu-util -a 0 -D notmain.bin -s 0x08000000
Now, my LED blinks!
Problem solved:
The dfu-util bundled with platformio has not been patched accordingly. So, when I was running platformio run -e sipeed-longan-nano --target upload
all the different versions of dfu-util
which I compiled and which I was assuming to be in use simply have not been used.
So, now I build with platformio run
and flash to device using the patched dfu-util
.
Now, my LCD plays videos :) !
EDIT: Details on working setup
- dfu-util version
https://git.code.sf.net/p/dfu-util/dfu-util
git clone https://git.code.sf.net/p/dfu-util/dfu-util
cd dfu-util && ./autogen.sh && ./configure --prefix=$HOME && make -j install
- build
platformio run
from within the examples directory - firmware flashing
dfu-util -d 28e9:0189 -a 0 --dfuse-address 0x08000000:leave -D .pio/build/sipeed-longan-nano/firmware.bin
from within the examples directory
@btx000 @Zepan could you resolve this issue?
I've had this issue for several months on both "longan nano" and "longan nano lite" (the one with lesser specs, based on GD32VF103C8T6 instead of GD32VF103CBT6).
Please update the dfu-utils in platformio.
Hi @orzel, OK. Just need to find a proper way to override the new dfu-util
in my platformIO setup ;)
@dr-br and @jhaand mentioned that the uploading works just fine with the original package, so we've switched this platform to the latest tool-dfuutil
package available in our CDN. It'd great if someone could test uploading via dfu
using the upstream version of the platform, e.g.:
[env:sipeed-longan-nano]
platform = https://github.com/sipeed/platform-gd32v.git
framework = arduino
board = sipeed-longan-nano
monitor_speed = 115200
@btx000 @Zepan Is there anything special that differs your fork from the official dfu-utils
repository?
@dr-br and @jhaand mentioned that the uploading works just fine with the original package, so we've switched this platform to the latest
tool-dfuutil
package available in our CDN. It'd great if someone could test uploading viadfu
using the upstream version of the platform, e.g.:[env:sipeed-longan-nano] platform = https://github.com/sipeed/platform-gd32v.git framework = arduino board = sipeed-longan-nano monitor_speed = 115200
@btx000 @Zepan Is there anything special that differs your fork from the official
dfu-utils
repository?
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
Download [ ] 0% 0 bytesdfu-util: dfuse_download: libusb_control_transfer returned -4
*** [upload] Error 74
========================== [FAILED] Took 8.87 seconds ==========================
I get the above error when running on Debian Linux. This is compiling the Arduino Blink Example.
Hi @rj45jack, thanks for testing. Looks like -4
means LIBUSB_ERROR_NO_DEVICE
. Could I ask you to compile dfu-util
from sources (@dr-br provided a nice instruction) and try to manually upload the binary using freshly compiled dfu-util
?
Thanks!
@valeros Building from source worked. Still unsure why it failed previously with a -4, looks like the Nano reset after detection? Not 100% sure on that.
@rj45jack Could you please check out what version of libusb library is installed in your system?
@valeros Here is what my system reports for libusb:
||/ Name Version Architecture Description
+++-======================-============-============-===================================================
ii libusb-1.0-0:amd64 2:1.0.22-2 amd64 userspace USB programming library
ii libusb-1.0-0-dev:amd64 2:1.0.22-2 amd64 userspace USB programming library development files
ii libusb-1.0-doc 2:1.0.22-2 all documentation for userspace USB programming
un libusbguard0 <none> <none> (no description available)
FWIW, DFU upload works for me out of the box when using the stable PlatformIO 5.2.4 against a Longan Nano v1.1.
My platformio.ini
reads:
[env:sipeed-longan-nano]
platform = gd32v
board = sipeed-longan-nano
framework = gd32vf103-sdk
upload_protocol = dfu
And I needed to add an udev rule for fixing the permissions:
$ cat /etc/udev/rules.d/99-platformio-udev.rules
#GD32V DFU Bootloader
ATTRS{idVendor}=="28e9", ATTRS{idProduct}=="0189", MODE="0660", GROUP="dialout", ENV{ID_MM_DEVICE_IGNORE}="1", ENV{ID_MM_PORT_IGNORE}="1"
So uploading my code works fine, however, the upload process reports success followed by a failure! Example:
$ pio run --target upload
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.2.1) > 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-gd32vf103-sdk 1.0.0
- tool-dfuutil 1.9.200310
- tool-gd32vflash 0.1.0
- tool-openocd-gd32v 0.1.1
- toolchain-gd32v 9.2.0
[..]
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 = 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 128.
Downloading to address = 0x08000000, size = 6584
Erase [ ] 0% 0 bytes
Erase [======= ] 31% 2048 bytes
Erase [=============== ] 62% 4096 bytes
Erase [======================= ] 93% 6144 bytes
Download [ ] 0% 0 bytes
Download [======= ] 31% 2048 bytes
Download [=============== ] 62% 4096 bytes
Download [======================= ] 93% 6144 bytes
Download [=========================] 100% 6584 bytes
Download done.
File downloaded successfully
dfu-util: Error during download get_status
*** [upload] Error 74
Although the get_status
fails, the device resets fine into my uploaded program and executes it as expected.
I saw that this issue remained open until now. I see that dfu-util has 2 new releases since opening this issue. The latest release concerns 0.11.
Platformio shows 4 interim releases on their project page for dfuutil. https://registry.platformio.org/tools/platformio/tool-dfuutil/versions
It seems that the revision numbers from Platformio differ from dfu-util. The latest revision could (1.9.211020) correspond to the 0.11 release of dfu-util. So that could work.
However when building for gd32, still the old version gets installed. (tool-dfuutil @ 1.9.200310) If I try to manually upgrade the dfuutil pkg to the latest release, it seems that it only contains the Macos_arm64 package. Not the Linux_x64 or other builds. So that explains why the dfuutil package still concerns the old release.
In order to help everyone, a new package for all platforms should become available via Platformio. Should I write a new issue for this, or do we continue with this one?
Edit: I see this is also mentioned via https://github.com/sipeed/Longan_GD32VF_examples/issues/5
Reply to https://github.com/sipeed/platform-gd32v/issues/17#issuecomment-591584483
@btx000 @Zepan could you resolve this issue?
@ivankravets The dfu-util is a tool maintained by Platformio according to the registry (tool-dfuutil), not Sipeed. The latest update only supports MacOS Arm64 according the compatibility chart. The rest is stuck with the old version from 2 years ago.
https://registry.platformio.org/tools/platformio/tool-dfuutil/versions
It would be really nice if all platforms would have dfu-util 0.11 available out of the box. But I can't figure out the process or where to submit an issue to trigger this.
Can you please help?
There is a new update of tool-dfuutil 1.11.0 available that supports most larger Operating systems. See https://registry.platformio.org/tools/platformio/tool-dfuutil/versions
I will write a PR to merge this for the platform.json
Could we close this issue?
Yes we can close this issue.
There is a new update of tool-dfuutil 1.11.0 available that supports most larger Operating systems.
Unfortunately not for Raspberry Pi OS (linux_armv7l
):
$ pio pkg install -g --tool "platformio/tool-dfuutil@^1.11.0"
Tool Manager: Installing platformio/tool-dfuutil @ ^1.11.0
Error: Could not find the package with 'platformio/tool-dfuutil @ ^1.11.0' requirements for your system 'linux_armv7l'
Any idea how to compile this from source? The platformio registry claims the source is on sourceforge but this isn't the case unfortunately, I can only find 0.11 and older..
No support for Rasberry Pi. Please add support for ARM32 and ARM64.
There is a new update of tool-dfuutil 1.11.0 available that supports most larger Operating systems.
Unfortunately not for Raspberry Pi OS (
linux_armv7l
):$ pio pkg install -g --tool "platformio/tool-dfuutil@^1.11.0" Tool Manager: Installing platformio/tool-dfuutil @ ^1.11.0 Error: Could not find the package with 'platformio/tool-dfuutil @ ^1.11.0' requirements for your system 'linux_armv7l'
Any idea how to compile this from source? The platformio registry claims the source is on sourceforge but this isn't the case unfortunately, I can only find 0.11 and older..
SF names 0.11 but that corresponds to Platformio 1.11
This has been stale for long enough. Closing.