Flash partition table image according to eMMC size.
Change-Id: I0c00905355ffdad91d068f5264aff5178d9921eb
diff --git a/flash.sh b/flash.sh
index c964522..3377268 100755
--- a/flash.sh
+++ b/flash.sh
@@ -13,11 +13,30 @@
PRODUCT_OUT=${PRODUCT_OUT:=${ROOTDIR}/out/target/product/imx8m_phanbell}
fi
+function partition_table_image {
+ case $1 in
+ 7818182656)
+ echo "partition-table-8gb.img" ;;
+ 15634268160)
+ echo "partition-table-16gb.img" ;;
+ 62537072640)
+ echo "partition-table-64gb.img" ;;
+ *)
+ echo "invalid-partition-table-$1.img" ;;
+ esac
+}
+# Flash bootloader
fastboot flash bootloader0 ${PRODUCT_OUT}/u-boot.imx
-fastboot flash gpt ${PRODUCT_OUT}/partition-table.img
fastboot reboot-bootloader
-fastboot erase misc
-fastboot flash boot ${PRODUCT_OUT}/boot.img
-fastboot flash rootfs ${PRODUCT_OUT}/rootfs.img
-fastboot reboot
+
+# Flash partition table
+MMC_SIZE=$(fastboot getvar mmc_size 2>&1 | grep mmc_size | cut -d " " -f 2)
+fastboot flash gpt ${PRODUCT_OUT}/$(partition_table_image ${MMC_SIZE})
+fastboot reboot-bootloader
+
+# Flash filesystems
+#fastboot erase misc
+#fastboot flash boot ${PRODUCT_OUT}/boot.img
+#fastboot flash rootfs ${PRODUCT_OUT}/rootfs.img
+#fastboot reboot
diff --git a/partition-table.json b/partition-table.json
index 266beaf..dbe4f10 100644
--- a/partition-table.json
+++ b/partition-table.json
@@ -1,6 +1,5 @@
{
"settings": {
- "disk_size": "7818182656",
"disk_alignment": "8 MiB",
"disk_guid": "85b83f23-51c4-4403-8bac-906ff5800f4e"
},