"dfu-suffix not found" for Longan Nano build

I’m running a PlatformIO build under Ubuntu for a Longan Nano board.

This is the platformio.ini file:

platform = gd32v
framework = gd32vf103-sdk
board = sipeed-longan-nano
monitor_speed = 115200

When I run the build it fails with the error dfu-suffix not found:

$ $HOME/.local/bin/platformio run -d stepper -v
Processing sipeed-longan-nano (platform: gd32v; framework: gd32vf103-sdk; board: sipeed-longan-nano; monitor_speed: 115200; upload_protocol: dfu)
bin/dfu-suffix -v 0x28e9 -p 0x0189 -d 0xffff -a .pio/build/sipeed-longan-nano/firmware.bin
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
sh: 1: bin/dfu-suffix: not found
RAM:   [=         ]   7.9% (used 2574 bytes from 32768 bytes)
*** [.pio/build/sipeed-longan-nano/firmware.bin] Error 127
Flash: [=         ]   6.8% (used 8884 bytes from 131072 bytes)
text       data     bss     dec     hex filename
   8764     120    2454   11338    2c4a .pio/build/sipeed-longan-nano/firmware.elf
============================================== [FAILED] Took 0.78 seconds ========

I have the dfu-utils package installed, and the dfu-suffix command is available:

$ dpkg -l | grep dfu
ii  dfu-util                         0.8-1                                      amd64        Device firmware update (DFU) USB programmer
$ which dfu-suffix

Why is the platformiocommand trying to invoke the dfu-suffix command with the relative pathname bin/dfu-suffix? Is that intended? I found this in the file ~/.platformio/platforms/gd32v/builder/main.py:

    # Add special DFU header to the binary image
        join("$BUILD_DIR", "${PROGNAME}.bin"),
            " ".join([
                    "tool-dfuutil") or "", "bin", "dfu-suffix"),
                "-v %s" % vid,
                "-p %s" % pid,
                "-d 0xffff", "-a", "$TARGET"
            ]), "Adding dfu suffix to ${PROGNAME}.bin"))

How is the dfu-suffix command expected to be installed so it can be invoked by the platformio command?

1 Like

PlatformIO will never use globally installed user programs. It only uses what it has in its ~/.platformio/packages folder. Wouldn’t be very portable if it realied on user-installed programs.

Does ~/.platformio/tool-dfuutil exist?

If not, can you add upload_protocol = dfu to the platformio.ini and retry?

No, it doesn’t , neither does ~/.platformio/packages/tool-dfuutil. Wouldn’t it maybe need to be in the packages subdirectory, as the entry in the main.py file says join(platform.get_package_dir( "tool-dfuutil") or "", "bin", "dfu-suffix")?

I’m sorry, in the initial post I had lost the last line when copying my platform.ini file. The upload_protocol line is already there. This is the full platformio.ini file minus comments:

platform = gd32v
framework = gd32vf103-sdk
board = sipeed-longan-nano
monitor_speed = 115200
upload_protocol = dfu

Okay yeah that’s the actual path I wanted to check.

Hm, there seems to be a bug in the auto-installation of this package this. Can you please go to Service End for Bintray, JCenter, GoCenter, and ChartCenter | JFrog, download the .tar.gz and extract it to ~/.platformio/packages/tool-dfuutil? (Assuming you’re using x86_x64 Linux here)

1 Like

That did the trick, thank you!

Should I report this somewhere? If so, where?

I’ve opened an issue at https://github.com/sipeed/platform-gd32v/issues/28.

1 Like