1 How to build out userdata.img and cache.img
The default fsl android bsp don't support userdata.img and cache.img. You need add the below patch to build out these images.
The hardware for below patch is imx7D. You can adjust your patch according your hardware.
diff --git a/imx7/BoardConfigCommon.mk b/imx7/BoardConfigCommon.mk
index 14e4881..c207727 100644
--- a/imx7/BoardConfigCommon.mk
+++ b/imx7/BoardConfigCommon.mk
@@ -61,7 +61,11 @@ BOARD_BOOTIMAGE_PARTITION_SIZE := 16777216
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 16777216
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 377487360
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
+TARGET_USERIMAGES_USE_EXT4 := true
+BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
+BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
BOARD_FLASH_BLOCK_SIZE := 4096
TARGET_RECOVERY_UI_LIB := librecovery_ui_imx
-
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
2 How to add pre-install apk.
I add a content pre-app in device/fsl/imx7. helloworld.apk is the added pre-install apk.
diff --git a/imx7/pre-app/AnTutuV2.4.apk b/imx7/pre-app/helloworld.apk
new file mode 100755
index 0000000..a96003a
Binary files /dev/null and b/imx7/pre-app/AnTutuV2.4.apk differ
diff --git a/imx7/sabresd_7d.mk b/imx7/sabresd_7d.mk
index d7c5c76..11be86c 100644
--- a/imx7/sabresd_7d.mk
+++ b/imx7/sabresd_7d.mk
@@ -27,7 +27,8 @@ PRODUCT_COPY_FILES += \
device/fsl/common/input/20b8000_kpp.idc:system/usr/idc/20b8000_kpp.idc \
device/fsl/common/input/20b8000_kpp.kl:system/usr/keylayout/20b8000_kpp.kl \
device/fsl/sabresd_7d/audio_policy.conf:system/etc/audio_policy.conf \
- device/fsl/sabresd_7d/audio_effects.conf:system/vendor/etc/audio_effects.conf
+ device/fsl/sabresd_7d/audio_effects.conf:system/vendor/etc/audio_effects.conf \
+ device/fsl/imx7/pre-app/*:data/.
3 What are userdata.img and cache.img for?
userdata.img: we need to integrate some customized APKs which should be preinstalled but should be able removed/updated by end user after product delivery. Which means they cannot be installed as system APPs in /system/app folder but User APPs in /data/app folder. At this point, we need compile userimage by ourself.
Cache.img: /cache include the content when apk start running. You may storage some special content which app need. I have not find any advantage to pre-build cache.img.
Note:
a. The userdata.img and cache.img's format is sparse ext4 image. You need convert it through simg2img.
The tool simg2img located at lp5.1_sabresd_7d_4_20/out/host/linux-x86/bin/simg2img
You can use below command to get raw ext4 userdata.img which can be burned into emmc/sd.
out/host/linux-x86/bin/simg2img userdata.img userdata_raw.img
b. BOARD_USERDATAIMAGE_PARTITION_SIZE BOARD_CACHEIMAGE_PARTITION_SIZE define the size of data and cache partition
Reference: