u-boot-brain/drivers/usb
Lukasz Majewski fc18f8d170 dfu: usb: f_dfu: Set deferred call for dfu_flush() function
This patch fixes situation when one would like to write large file into
medium with the file system (fat, ext4, etc).
This change sets file size limitation to the DFU internal buffer size.

Since u-boot is not supporting interrupts and seek on file systems, it
becomes challenging to store large file appropriately.

To reproduce this error - create large file (around 26 MiB) and sent it
to the target board.

Lets examine the flow of USB transactions:

0. DFU uses EP0 with 64B MPS [Max Packet Size]

1. Send file - OUT (PC->target) - dat_26MiB.img is sent with 4096 B transactions

2. Get status - OUT (PC->target) - wait for DFU_STATE_dfuDNLOAD_IDLE (0x05) sent
				   from target board - IN transaction
				   (target->PC)

3. The whole file content is sent to target - OUT (PC->target) with ZLP [Zero
					      Length Packet]

Now the interesting part starts:

4. OUT (PC->target) Setup transaction (request to share DFU state)

5. IN (target->PC) - reply the current DFU state
	- In the UDC driver the req->completion (with dfu_flush) is called
	  after successful IN transfer.
	- The dfu_flush() (called from req->completion callback) saves the
	  whole file at once (u-boot doesn't support seek on fs).
	  Such operation takes considerable time. When the file
	  is large - e.g. 26MiB - this time may be more than 5 seconds.

6. OUT (PC->target) - ZLP, is send in the same time when dfu_flush()
 writes data to eMMC memory.
 The dfu-util application has hard coded timeout on USB transaction
 completion set to 5 seconds (it uses libusb calls).

When the file to store is large (e.g. 26 MiB) the time needed to write it
may excess the dfu-util timeout and following error message will be displayed:
"unable to read DFU status" on the HOST PC console.

This change is supposed to leverage DFU's part responsible for storing files
on file systems. Other DFU operations - i.e. raw/partition write to NAND and
eMMC should work as before.

The only functional change is the error reporting. When dfu_flush() fails
the u-boot prompt will exit with error information and dfu-util application
exits afterwards as well.

Test HW:
- Odroid XU3 (Exynos5433) - test with large file
- Trats (Exynos4210) - test for regression - eMMC, raw,

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Reported-by: Alex Gdalevich <agdalevich@axion-biosystems.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
Tested-by: Heiko Schocher <hs@denx.de>
2016-02-24 19:12:32 +01:00
..
dwc3 bug.h: move BUILD_BUG_* defines to include/linux/bug.h 2016-01-25 10:39:59 -05:00
emul usb: sandbox: Add a USB emulation driver 2015-11-19 20:27:52 -07:00
eth usb: eth: add Realtek RTL8152B/RTL8153 DRIVER 2016-01-23 16:22:34 +01:00
gadget dfu: usb: f_dfu: Set deferred call for dfu_flush() function 2016-02-24 19:12:32 +01:00
host usb: ehci: Be explicit about the BE IO accessors 2016-02-24 19:12:32 +01:00
musb Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
musb-new Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
phy usb: xhci: omap: Remove common dwc3 drv functions calls 2015-07-22 08:55:44 +02:00
ulpi Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
Kconfig usb: musb-new: Kconfig support for USB_MUSB_HOST and USB_MUSB_GADGET 2015-08-05 17:20:34 +02:00