libusb_control_transfer returned -1

Hi,

I have a Longan Nano and I am trying to program it over USB with a Linux machine.

I read the default image from the board:

maple% dfu-util --device 28e9:0189 --alt 0 --upload LOGAN_IMG           
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 = 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
Limiting default upload to 16384 bytes
Upload	[=========================] 100%        16384 bytes
Upload done.
maple%

and then tried to re-flash as a test of the tooling:

maple% dfu-util --device 28e9:0189 --alt 0 --dfuse-address 0x08000000:leave --download LOGAN_IMG 
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/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
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 = 16384
Download	[=========================] 100%        16384 bytes
Download done.
File downloaded successfully
dfu-util: dfuse_download: libusb_control_transfer returned -1
maple%

Now the board doesn’t boot with a white screen and blinking LED like it used to. What does this error mean?

Cheers.

You seem to be using the unpatched dfu-utils, but some minor changes were needed to get it to work with the GD32VF that the Nano uses.

PlatformIO Core will fetch a copy for you (it gets stored in ~/.platformio/packages/tool-gd32vflash/dfu-util), I think built from https://github.com/riscv-mcu/gd32-dfu-utils

I have the same issue with the same return code and the error is reported from the terminal in PlatformIO. I use the version that gets installed with PlatformIO for GD32V:

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 = 11004

Download        [                         ]   0%            0 bytes
Download        [                         ]   0%            0 bytes
Download        [====                     ]  18%         2048 bytes
Download        [=========                ]  37%         4096 bytes
Download        [=============            ]  55%         6144 bytes
Download        [==================       ]  74%         8192 bytes
Download        [=======================  ]  93%        10240 bytes
Download        [=========================] 100%        11004 bytes
Download done.
File downloaded successfully
dfu-util: dfuse_download: libusb_control_transfer returned -1
*** [upload] Error 74
========================================================== [FAILED] Took 3.38 seconds ==========================================================
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

That message is unrelated. I recall reading that this was a failure (or perhaps a permissions problem) for a post-transfer operation, I think related to a post-transfer reset, but I forget where I read it. It doesn’t affect the actual flashing of the firmware, so far as I can tell.

Thanks Kevin,
yes correct. The firmware gets flashed. So it’s no show stopper. Still this should be fixed at some point. Thanks for the hint. I will search a bit for more information.