db845c: Add support for cache partition am: 70f37c6519 am: 0a3a97805e

Original change: https://android-review.googlesource.com/c/device/linaro/dragonboard/+/1449168

Change-Id: I48dacbf72662f73072fb2d9534967c822853fb17
diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk
index b879d96..d527c0e 100644
--- a/BoardConfigCommon.mk
+++ b/BoardConfigCommon.mk
@@ -41,6 +41,9 @@
 TARGET_COPY_OUT_PRODUCT := product
 BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE := ext4
 BOARD_USES_METADATA_PARTITION := true
+# Cache partition size: 64M
+BOARD_CACHEIMAGE_PARTITION_SIZE := 67108864
+BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
 # Super partition
 TARGET_USE_DYNAMIC_PARTITIONS := true
 BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT := true
diff --git a/fstab.common b/fstab.common
index dbba930..9634d9c 100644
--- a/fstab.common
+++ b/fstab.common
@@ -5,3 +5,4 @@
 /dev/block/platform/soc@0/1d84000.ufshc/by-name/userdata /data		ext4	discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1,inlinecrypt	wait,formattable,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized
 /dev/block/by-name/metadata	/metadata	ext4	noatime,nosuid,nodev,discard					wait,formattable
 /devices/platform/soc@0/8804000.sdhci/mmc_host/mmc*	auto	auto	defaults	voldmanaged=sdcard1:auto
+/dev/block/platform/soc@0/1d84000.ufshc/by-name/cache /cache	 ext4	nodev,noatime,nosuid,errors=panic wait
diff --git a/installer/db845c/flash-all-aosp.sh b/installer/db845c/flash-all-aosp.sh
index e6b1995..b3c677b 100755
--- a/installer/db845c/flash-all-aosp.sh
+++ b/installer/db845c/flash-all-aosp.sh
@@ -40,6 +40,8 @@
 fastboot flash boot "${ANDROID_PRODUCT_OUT}"/boot.img
 echo "FLASH-ALL-AOSP: Flash super/dynamic image"
 fastboot flash super "${ANDROID_PRODUCT_OUT}"/super.img
+echo "FLASH-ALL-AOSP: Flash cache image"
+fastboot flash cache "${ANDROID_PRODUCT_OUT}"/cache.img
 echo "FLASH-ALL-AOSP: Flash userdata image"
 fastboot flash userdata "${ANDROID_PRODUCT_OUT}"/userdata.img
 
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index bf856df..bc69fcc 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -4,6 +4,7 @@
 /dev/block/platform/soc@0/1d84000\.ufshc/by-name/metadata	u:object_r:metadata_block_device:s0
 /dev/block/platform/soc@0/1d84000\.ufshc/by-name/super		u:object_r:super_block_device:s0
 /dev/block/platform/soc@0/1d84000\.ufshc/by-name/userdata	u:object_r:userdata_block_device:s0
+/dev/block/platform/soc@0/1d84000\.ufshc/by-name/cache		u:object_r:cache_block_device:s0
 
 /dev/dri				u:object_r:dri_device:s0
 /dev/dri/card0				u:object_r:graphics_device:s0