platform: msm-shared: Add UBI image awareness to fastboot code

Current implementation of flasher in LK just writes the provided image as RAW data.
This is not good enough when writing a UBI image since some UBI META data should
be preserved.

When flashing a UBI image, the flasher should do the following for each non-bad PEB.
- Read the content of this PEB from the UBI image (PEB size bytes) into a buffer.
- Stripe min. I/O units full of 0xFF bytes from the end of the buffer Erase the PEB.
- Change the EC header in the buffer - put the new erase counter value there and
  re-calculate the CRC-32 checksum.
- Write the buffer to the physical eraseblock.

Sometimes the flashed image is smaller than the partition. The remaining PEBs should be
erased and a new ec header written to them.
For each erased PEB a valid ec header should be written.

With the above mentioned changes the first boot time after flashing the image was
reduced by ~50%.

When flashing on an erased partition there is no need to re-erase the blocks. With this
change flashing time was reduced by additional 3%.

Change-Id: Ie131cc2ccbf64e92510a055fb57389ae17a7f45f
3 files changed