Skip to content
Advertisement

DFU not transferring data in barebox

Am working on a custom board – has no removable storage (sd) and only one UART. I need to transfer files on the the QSPI storage using barebox bootloader.

I am trying to use DFU to transfer various files to write to QSPI

Device tree has the follow among other things

&usbotg1 { 
dr_mode = "otg"; 
status = "okay"; 
}; 

&usbphy1 { 
fsl,tx-d-cal = <106>; 
};

On the board, the OTG mode has been set to peripheral and dfu started for accepting file

barebox@Freescale:/ otg.mode=peripheral 
barebox@Freescale:/ dfu /tmp/qspi-header(qspi)src 
udc0: registering UDC driver [g_dfu]
dfu: register alt0(qspi) with device /tmp/qspi-header 
g_dfu usbgadget: g_dfu ready 
g_dfu usbgadget: high-speed config #1: USB DFU 

On the system the board is getting detected as DFU device

harkirat@harkirat-devsys:~$ sudo dfu-util -l 
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 sourceforge.net/p/dfu-util/… 

Found DFU: [1d50:60a2] ver=0316, devnum=13, cfg=1, intf=0, path="1-2", alt=0, name="qspi", serial="UNKNOWN" 

So when transferring a file

harkirat@harkirat-devsys:~$ sudo dfu-util -a qspi -D qspi-header 
dfu-util 0.9 

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.

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 1d50:60a2 
Run-time device DFU version 0100 
Claiming USB DFU Interface... 
Setting Alternate Setting #0 ... 
Determining device status: state = dfuIDLE, status = 0 
dfuIDLE, continuing 
DFU mode device DFU version 0100 
Device returned transfer size 4096 
Copying data from PC to DFU device 
Download [=========================] 100% 512 bytes 
Download done. 
state(6) = dfuMANIFEST-SYNC, status(0) = No error condition is present 
state(7) = dfuMANIFEST, status(0) = No error condition is present 
state(6) = dfuMANIFEST-SYNC, status(0) = No error condition is present 
state(7) = dfuMANIFEST, status(0) = No error condition is present 
state(6) = dfuMANIFEST-SYNC, status(0) = No error condition is present 
state(7) = dfuMANIFEST, status(0) = No error condition is present 
state(6) = dfuMANIFEST-SYNC, status(0) = No error condition is present 
state(7) = dfuMANIFEST, status(0) = No error condition is present 
state(6) = dfuMANIFEST-SYNC, status(0) = No error condition is present 

The last two lines keep repeating themselves. Eventually at Ctrl-C on both

It does say file Download done. but there is nothing on the receiving end. At the board

…
g_dfu usbgadget: high-speed config #1: USB DFU 
g_dfu udc0: unregistering UDC driver [fsl-usb2-udc] 
dfu: Interrupted system call 
barebox@Freescale:/ ls /tmp/ 
barebox@Freescale:/

so the question is why????

Advertisement

Answer

A regression matching your problem was recently reported as being caused by

697f53a90224 (“usb: gadget: dfu: Wrap fs operation in workqueue”)

There has been a first fix here:

https://lore.barebox.org/barebox/20210830144835.27458-1-jmaselbas@kalray.eu

Try and see if that fixes your issue.

It’s unfortunate the regression slipped through, but most users seem to either use fastboot or DFU with the multigadget functionality (usbgadget -D command instead of dfu command). I’d suggest you do likewise with a new project. fastboot has special support for UBI (u) flag, which allows it to call ubiformat transparently on a volume when updating and it can reeexport barebox_update handlers, so you could just update with e.g.:

fastboot flash bbu-nand barebox-myboard.img
fastboot flash rootfs-nand my.ubi

The usbgadget command allows the gadget to work in the ‘background’. So you can continue to use the shell and export more than one gadget at the same time: e.g. a USB serial console and DFU at the same time. This should still work despite the aforementioned regression as that one only broke the dfu command.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement