u-boot/drivers/usb/gadget
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
..
udc Various Makefiles: Add SPDX-License-Identifier tags 2015-11-10 09:19:52 -05:00
at91_udc.c usb: gadget: at91_udc: add at91_udc into U-Boot 2015-09-11 09:35:40 +02:00
at91_udc.h Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
atmel_usba_udc.c usb: modify usb_gadget_handle_interrupts to take controller index 2015-04-14 05:48:11 +02:00
atmel_usba_udc.h USB: gadget: add atmel usba udc driver 2013-09-24 17:51:35 +02:00
bcm_udc_otg.h usb: gadget: bcm_udc_otg files 2015-07-22 08:57:54 +02:00
bcm_udc_otg_phy.c usb: s3c-otg: Rename local headers to dwc2_*h 2015-12-17 21:54:40 +01:00
ci_udc.c usb:ci_udc: Remove ULPI setting for i.MX OTG controller 2016-01-16 07:06:55 +01:00
ci_udc.h ci_udc: Update the ci_udc driver to support bulk transfers 2015-05-29 12:41:04 +02:00
composite.c Use correct spelling of "U-Boot" 2016-02-06 12:00:59 +01:00
config.c Use correct spelling of "U-Boot" 2016-02-06 12:00:59 +01:00
core.c Add GPL-2.0+ SPDX-License-Identifier to source files 2013-07-24 09:44:38 -04:00
designware_udc.c linux/kernel.h: sync min, max, min3, max3 macros with Linux 2014-11-23 06:48:30 -05:00
dwc2_udc_otg.c usb: gadget: dwc2_udc_otg: modified the check condition for max packet size of ep_in in high speed 2016-02-04 12:38:26 +01:00
dwc2_udc_otg_phy.c usb: s3c-otg: Rename usb/s3c_udc.h to usb/dwc2_udc.h 2015-12-17 21:54:41 +01:00
dwc2_udc_otg_priv.h usb: s3c-otg: Rename usb/s3c_udc.h to usb/dwc2_udc.h 2015-12-17 21:54:41 +01:00
dwc2_udc_otg_regs.h usb: s3c-otg: Rename remaining macros 2015-12-17 21:54:40 +01:00
dwc2_udc_otg_xfer_dma.c usb: s3c-otg: Tweak the comments 2015-12-17 21:54:40 +01:00
ep0.c cosmetic: replace MIN, MAX with min, max 2014-09-24 18:30:29 -04:00
ep0.h Add GPL-2.0+ SPDX-License-Identifier to source files 2013-07-24 09:44:38 -04:00
epautoconf.c Use correct spelling of "U-Boot" 2016-02-06 12:00:59 +01:00
ether.c Use correct spelling of "U-Boot" 2016-02-06 12:00:59 +01:00
f_dfu.c dfu: usb: f_dfu: Set deferred call for dfu_flush() function 2016-02-24 19:12:32 +01:00
f_dfu.h usb: dfu: f_dfu: Provide infrastructure to adjust DFU's Poll Timeout value 2013-12-18 19:53:19 +01:00
f_fastboot.c Fix GCC format-security errors and convert sprintfs. 2016-01-14 22:11:34 -05:00
f_mass_storage.c ums: support multiple LUNs at once 2016-01-13 21:05:19 -05:00
f_thor.c Move console definitions into a new console.h file 2015-11-19 20:27:50 -07:00
f_thor.h f_thor: Dont perform reset at the end of thor 2015-09-07 13:41:03 +02:00
fotg210.c usb: modify usb_gadget_handle_interrupts to take controller index 2015-04-14 05:48:11 +02:00
g_dnl.c usb: gadget: don't leak configs when unbinding 2015-09-11 17:15:21 -04:00
gadget_chips.h Use correct spelling of "U-Boot" 2016-02-06 12:00:59 +01:00
Makefile usb: s3c-otg: Rename USB_GADGET_S3C_UDC_OTG* to USB_GADGET_DWC2_OTG* 2015-12-17 21:54:40 +01:00
mpc8xx_udc.c cosmetic: replace MIN, MAX with min, max 2014-09-24 18:30:29 -04:00
ndis.h USB: Add USB RNDIS gadget protocol 2011-02-19 20:32:37 +01:00
pxa25x_udc.c usb: modify usb_gadget_handle_interrupts to take controller index 2015-04-14 05:48:11 +02:00
pxa25x_udc.h Add GPL-2.0+ SPDX-License-Identifier to source files 2013-07-24 09:44:38 -04:00
pxa27x_udc.c usb: pxa27x_udc: clean-up include file order 2015-08-24 20:30:38 +02:00
rndis.c Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
rndis.h Add more SPDX-License-Identifier tags 2016-01-19 08:31:21 -05:00
storage_common.c ums: support multiple LUNs at once 2016-01-13 21:05:19 -05:00
usbstring.c Use correct spelling of "U-Boot" 2016-02-06 12:00:59 +01:00