Add img2simg tool that splits a large image into <n> sparse files

img2simg can take a large binary and chop it into multiple sparse
images.  Each sparse image that is output has two chunks: a Don't
Care chunk to offset to where the data should be placed, and a
Raw chunk that actually contains the data to be placed there.
So, for example, if you have a 12 GB random file that you want to
place into userdata for testing e-MMC, you can run img2simg on it
to chop it into multiple sparse files and then "fastboot flash
userdata" on each of the sparse files.

    Usage: img2simg [OPTIONS] <raw_image_file>
    The <raw_image_file> will be split into as many sparse
    files as needed.  Each sparse file will contain a single
    DONT CARE chunk to offset to the correct block and then
    a single RAW chunk containing a portion of the data from
    the raw image file.  The sparse files will be named by
    appending a number to the name of the raw image file.

    OPTIONS (Defaults are enclosed by square brackets):
      -s SUFFIX      Format appended number with SUFFIX [%03d]
      -B SIZE        Use a block size of SIZE [4K]
      -C SIZE        Use a chunk size of SIZE [64M]
    SIZE is a decimal integer that may optionally be
    followed by a suffix that specifies a multiplier for
    the integer:
	   c         1 byte (the default when omitted)
	   w         2 bytes
	   b         512 bytes
	   kB        1000 bytes
	   K         1024 bytes
	   MB        1000*1000 bytes
	   M         1024*1024 bytes
	   GB        1000*1000*1000 bytes
	   G         1024*1024*1024 bytes

Change-Id: I6d3ee9deef21dcbc6bc95e2c5b822154705b4e35
Signed-off-by: Scott Anderson <saa@android.com>
2 files changed