How to enable sparse image in android

cancel
Showing results for 
Search instead for 
Did you mean: 

How to enable sparse image in android

How to enable sparse image in android

There are two format system image(ext4): raw and sparse. The raw image is  larger, you can mount it to ext4 directly(mount -t ext4 system.img system). The sparse image is supported lp5.0, it is a bit smaller. The below part will take IMX7D SDB board as example. You can change the setting according your platform hardware.

 

1 generate sparse image

 

In Lollipop 5.0 and 5.1, both raw image and sparse image will be generated by default.

sparse system image is located in: out/target/product/sabresd_7d/system_sparse.img

raw system image is located in:out/target/product/sabresd_7d/system.img

Below are the steps used in android build system to generate system.img

  • build out sparse image(-s means the building system image is sparse)

          make_ext4fs -s -T -1 -S out/target/product/sabresd_7d/root/file_contexts -l 374476800 -a system           out/target/product/sabresd_7d/obj/PACKAGING/systemimage_intermediates/system.img out/target/product/sabresd_7d/system

  • transform sparse image to raw image

          simg2img out/target/product/sabresd_7d/system_sparse.img out/target/product/sabresd_7d/system.img

 

2 burn sparse image to sd/emmc

     There are two ways to program the sparse image into android boot storage

  • Transform the sparse image into raw image in host Linux PC. And use the commands dd commands to program the raw image into the boot storage.
  • Program the sparse image with MFG Tool in i.MX Android release package.

               Steps:

      • copy system_sparse.img to files/android/sabresd/.
      • copy simg2img binary (in simg2img.zip) to files/android/.
      • You also need update mfgtools-without-rootfs.tar\mfgtools\Profiles\Linux\OS Firmware\ucl2.xml

 

     diff --git a/Profiles/Linux/OS Firmware/ucl2.xml b/Profiles/Linux/OS Firmware/ucl2.xml      index 3b15ddd..3c3d2ae 100755      --- a/Profiles/Linux/OS Firmware/ucl2.xml      +++ b/Profiles/Linux/OS Firmware/ucl2.xml        @@ -621,8 +621,12 @@              <CMD state="Updater" type="push" body="$ mkfs.ext4 /dev/mmcblk%mmc%p6">Formatting cache partition</CMD>                <CMD state="Updater" type="push" body="$ mkfs.ext4 /dev/mmcblk%mmc%p7">Formatting device partition</CMD>      -       <CMD state="Updater" type="push" body="pipe dd of=/dev/mmcblk%mmc%p5 bs=512" file="files/android/sabresd/system.img">Sending and writting system.img</CMD>      -      +       <CMD state="Updater" type="push" body="send" file="files/android/simg2img" ifdev="MX7D">Sending simg2img</CMD>      +       <CMD state="Updater" type="push" body="$ cp $FILE /tmp/simg2img ">cp simg2img</CMD>      +       <CMD state="Updater" type="push" body="$ chmod  777 /tmp/simg2img ">chmod 777</CMD>      +       <CMD state="Updater" type="push" body="$  mount -o remount,size=512M rootfs /">change size of tmpfs</CMD>      +       <CMD state="Updater" type="push" body="send" file="files/android/sabresd/system_sparse.img" ifdev="MX7D">Sending system_sparse.img</CMD>      +       <CMD state="Updater" type="push" body="$ /tmp/simg2img $FILE /dev/mmcblk%mmc%p5">Sending and writting system_sparse.img</CMD>              <!-- Write userdata.img is optional, for some customer this is needed, but it's optional. -->              <!-- Also, userdata.img will have android unit test, you can use this to do some auto test. -->              <!--    <CMD state="Updater" type="push" onError="ignore" body="pipe dd of=/dev/mmcblk0p7" file="file/android/userdate.img"> Sending userdata.

 

3 Support sparse image in uboot(v2014.04)

     Cheery-pick sparse image related patches. Use write_sparse_image to burn sparse system image.

     For detail information, Please check the attached file(uboot(v2014.04)which support sparseimage.zip )

 

     The step of apply these patches:

  • cd myandroid/bootable/bootloader/uboot-imx/
  • copy uboot(v2014.04) which support sparseimage.zip to myandroid/bootable/bootloader/uboot-imx/

        unzip uboot(v2014.04) which support sparseimage.zip

  • git am 0001-add-header-for-Android-sparse-image-format.patch

        git am 0002-add-code-to-handle-Android-sparse-image-format.patch

        git am 0003-update-code-which-handles-Android-sparse-image-forma.patch

        git am 0004-cleanup-code-which-handles-the-Android-sparse-image-.patch

        git am 0005-implement-the-Android-sparse-image-format.patch

        git am 0006-aboot-fix-block-addressing-for-don-t-care-chunk-type.patch

        git am 0007-MA-6732-Add-sparse-image-flash-support-for-uboot-s-f.patch

 

 

    

 

The page will keep updating.

 

Reference:

     How to enable userdata.img and cache.img in lollipop

Attachments
Comments

Hello Sanshan Zhang,

When I building android(Lollipop 5.0.0.1) for imx6slevk board , system.img is not able to generate from system_sparse.img.

Following error is obtained:

Install system fs image: out/target/product/evk_6sl/system_sparse.img

out/target/product/evk_6sl/system_sparse.img+out/target/product/evk_6sl/obj/PACKAGING/recovery_patch_intermediates/recovery_from_boot.p maxsize=481738752 blocksize=4224 total=403801046 reserve=4866048

if [ true = true ]; then \

        simg2img out/target/product/evk_6sl/system_sparse.img out/target/product/evk_6sl/system.img; \

        fi

/bin/bash: line 1: simg2img: command not found

make: *** [out/target/product/evk_6sl/system_sparse.img] Error 127

make: *** Deleting file `out/target/product/evk_6sl/system_sparse.img'

Is their any patches to apply which Support sparse image in android..

please help me sort out this issue...

Regards,

Kishore P

Hi kishore,

Does you have check whether /out/host/linux-x86/bin/simg2img exist?

If   it exists, you can check if the /out/host/linux-x86/bin/ is export to PATH.

Hello Sanshan Zhang,

  Thanks for reply, simg2img is exit in /out/host/linux-x86/bin path and it is exported to PATH also.

Any think we have to enable in the kernel extra other than default option given by freescale...?

>$PATH

bash: /usr/lib/jvm/java-7-openjdk-amd64/bin:/home/test/Android_Source/out/host/linux-x86/bin:/home/test/Android_Source/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8/bin:/home/test/Android_Source/prebuilts/gcc/linux-x86/:/home/test/Android_Source/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin:/home/test/Android_Source/development/scripts:/home/test/Android_Source/prebuilts/devtools/tools:/home/test/Android_Source/prebuilts/android-emulator/linux-x86_64:/home/test/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games: No such file or directory

Regards,

Kishore P

If it exist and export it's path, i think you can try "simg2img -h". See what's the log.

Hello Sanshan,

   I replaced "simg2img" with "simg2img -h" , but results is same ,

out/target/product/evk_6sl/system_sparse.img+out/target/product/evk_6sl/obj/PACKAGING/recovery_patch_intermediates/recovery_from_boot.p maxsize=481738752 blocksize=4224 total=403801046 reserve=4866048

if [ true = true ]; then \

        simg2img -h out/target/product/evk_6sl/system_sparse.img out/target/product/evk_6sl/system.img; \

        fi

/bin/bash: line 1: simg2img: command not found

make: *** [out/target/product/evk_6sl/system_sparse.img] Error 127

make: *** Deleting file `out/target/product/evk_6sl/system_sparse.img'

Regards,

Kishore P

Hello Sanshan,

  If we go for --help following output is showed

...:~/Android_Source$ simg2img --help

    Usage: simg2img <sparse_image_files> <raw_image_file>

But still /bin/bash: line 1: simg2img: command not found

error is got.

Regards,

Kishore P

Version history
Revision #:
2 of 2
Last update:
2 weeks ago
Updated by:
 
Contributors