[scripts] Add ramdisk option to package-image.sh
Mediatek devices crash in the bootloader when the
decompressed kernel is written to the ramdisk
region. Add an option to package-image.sh that
will prevent a ramdisk from being added to the
boot image, and use this option in the Cleo and
mt8167s_ref flash scripts. The default behavior
has not changed, so other devices shouldn't be
affected.
ZX-3356 #done
Test: mt8167 ref board boots.
Test: Ran package-image.sh and inspected the boot
image with a hex editor.
Change-Id: If084e162d2bfe9b4ad37339c9b4daacc43791861
diff --git a/scripts/flash-cleo b/scripts/flash-cleo
index 637ef93..a6d70f3 100755
--- a/scripts/flash-cleo
+++ b/scripts/flash-cleo
@@ -33,6 +33,6 @@
done
shift $((OPTIND-1))
-"${ZIRCON_DIR}/kernel/target/arm64/board/cleo/package-image.sh" -B "${ZIRCON_DIR}/build-arm64" "${EXTRA_ARGS[@]}"
+"${ZIRCON_DIR}/kernel/target/arm64/board/cleo/package-image.sh" -B "${ZIRCON_DIR}/build-arm64" -r "${EXTRA_ARGS[@]}"
"${SCRIPTS_DIR}/flash-avb" -b cleo "$@"
diff --git a/scripts/flash-mt8167s_ref b/scripts/flash-mt8167s_ref
index 8b17d11..2edc39c 100755
--- a/scripts/flash-mt8167s_ref
+++ b/scripts/flash-mt8167s_ref
@@ -33,6 +33,6 @@
done
shift $((OPTIND-1))
-"${ZIRCON_DIR}/kernel/target/arm64/board/mt8167s_ref/package-image.sh" -B "${ZIRCON_DIR}/build-arm64" "${EXTRA_ARGS[@]}"
+"${ZIRCON_DIR}/kernel/target/arm64/board/mt8167s_ref/package-image.sh" -B "${ZIRCON_DIR}/build-arm64" -r "${EXTRA_ARGS[@]}"
"${SCRIPTS_DIR}/flash-avb" -b mt8167s_ref "$@"
diff --git a/scripts/package-image.sh b/scripts/package-image.sh
index cf62a12..00669d8 100755
--- a/scripts/package-image.sh
+++ b/scripts/package-image.sh
@@ -27,6 +27,7 @@
VBMETA_IMG=
ZIRCON_BOOTIMAGE=
MKBOOTIMG_ARGS=
+USE_RAMDISK=true
function HELP {
echo "help:"
@@ -44,6 +45,7 @@
echo "-m : Add mexec option to command line"
echo "-M : membase for mkbootimg (default ${MEMBASE})"
echo "-o : output boot.img file (defaults to <build-dir>/<board>-boot.img)"
+ echo "-r : don't add a ramdisk to the boot image"
echo "-v : output vbmeta.img file (defaults to <build-dir>/<board>-vbmeta.img)"
echo "-z : input zircon ZBI file (defaults to <build-dir>/<board>-boot.img)"
exit 1
@@ -53,7 +55,7 @@
DTB_OFFSET=0x03000000
BOOT_PARTITION_SIZE=33554432
-while getopts "ab:B:c:C::d:D:ghK:lmM:r:o:v:z:" FLAG; do
+while getopts "ab:B:c:C::d:D:ghK:lmM:o:rv:z:" FLAG; do
case $FLAG in
a) USE_AVB=true;;
b) BOARD="${OPTARG}";;
@@ -69,6 +71,7 @@
m) MEXEC=true;;
M) MEMBASE="${OPTARG}";;
o) BOOT_IMG="${OPTARG}";;
+ r) USE_RAMDISK=false;;
v) VBMETA_IMG="${OPTARG}";;
z) ZIRCON_BOOTIMAGE="${OPTARG}";;
\?)
@@ -178,11 +181,17 @@
RAMDISK="${BUILD_DIR}/dummy-ramdisk"
echo "foo" > "${RAMDISK}"
+if [[ ${USE_RAMDISK} == true ]]; then
+ RAMDISK_OPTION="--ramdisk ${RAMDISK}"
+else
+ RAMDISK_OPTION=""
+fi
+
# create our boot.img
"${MKBOOTIMG}" \
--kernel "${COMPRESSED_BOOTIMAGE_DTB}" \
--kernel_offset ${KERNEL_OFFSET} \
- --ramdisk "${RAMDISK}" \
+ ${RAMDISK_OPTION} \
--base ${MEMBASE} \
--tags_offset 0xE000000 \
--cmdline "${MKBOOTIMG_CMDLINE}" \