usb: gadget: fastboot: Add sparse image support
Sparse images are needed for fastboot to flash images that do not
fit into memory.

Android fastboot is kind of a dumb protocol. It first sends you a
big image and afterwards it tells you where to put this image. This
of course limits fastboot to files smaller than the available memory.
To bypass this issue fastboot has so called Sparse image support. This
is a new image format that can contain holes in the data so a big image
can be written in multiple steps with holes in other areas each step.

Implementing this for UBI images is kind of tricky since ubiformat
normally expects to get a single image. Preparations to ubiformat
a device in multiple parts have been done in previous patches.
It is however, only for the first part possible to detect if it is
a UBI image. The other parts are just binary data and we cannot
know if we have to pass this data raw to the flash or use ubiformat.
For this reason this patch makes the 'u' flag in the partition
description mandatory for proper UBI image flashing on MTD devices.

fastboot passes a max_download_size variable to the host. This
variable contains the image size fastboot can take in one go.
We have to choose a good compromise here. On one hand we do not
want to risk that we actually do not have enough memory to hold the
transferred image, on the other hand we want images like bootloaders
not as sparse images, but in one go instead to make atomic exchange
of the bootloader possible. Right now we have chosen 8MiB which
should be big enough for all bootloaders. The value is configurable
via global.usbgadget.fastboot_max_download_size.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
1 parent 1930c3d commit 04413763ad3c3c0580c6a35bc44a92d08638e058
@Sascha Hauer Sascha Hauer authored on 9 Jan 2018
Showing 3 changed files
View
Documentation/user/usb.rst
View
drivers/usb/gadget/Kconfig
View
drivers/usb/gadget/f_fastboot.c