From dd1eb8733dbae94958a9327e9247d9400815a5ba Mon Sep 17 00:00:00 2001 From: Devin Moore Date: Wed, 5 Jan 2022 00:20:15 +0000 Subject: [PATCH 1/2] fastboot: Support flashing init_boot.img into init_boot partition init_boot_a and init_boot_b partitions are used in A/B devices. Bug: 203698939 Test: m Change-Id: If00f581ab7ae340d78d7d55eebafd92ac15d2bc1 --- fastboot/fastboot.bash | 2 +- fastboot/fastboot.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fastboot/fastboot.bash b/fastboot/fastboot.bash index 53974554d..e9bf9e940 100644 --- a/fastboot/fastboot.bash +++ b/fastboot/fastboot.bash @@ -109,7 +109,7 @@ _fastboot_cmd_flash() { cur="${COMP_WORDS[COMP_CWORD]}" if [[ $i -eq $COMP_CWORD ]]; then - partitions="boot bootloader dtbo modem odm odm_dlkm oem product pvmfw radio recovery system system_dlkm vbmeta vendor vendor_dlkm" + partitions="boot bootloader dtbo init_boot modem odm odm_dlkm oem product pvmfw radio recovery system system_dlkm vbmeta vendor vendor_dlkm" COMPREPLY=( $(compgen -W "$partitions" -- $cur) ) else _fastboot_util_complete_local_file "${cur}" '!*.img' diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index c8ef94f1d..32a22bbf5 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -141,6 +141,10 @@ struct Image { static Image images[] = { // clang-format off { "boot", "boot.img", "boot.sig", "boot", false, ImageType::BootCritical }, + { "init_boot", + "init_boot.img", "init_boot.sig", + "init_boot", + false, ImageType::BootCritical }, { nullptr, "boot_other.img", "boot.sig", "boot", true, ImageType::Normal }, { "cache", "cache.img", "cache.sig", "cache", true, ImageType::Extra }, { "dtbo", "dtbo.img", "dtbo.sig", "dtbo", true, ImageType::BootCritical }, From 1af1202fbdf03d309c0d56df1e93341a8d863daf Mon Sep 17 00:00:00 2001 From: Devin Moore Date: Thu, 6 Jan 2022 01:11:23 +0000 Subject: [PATCH 2/2] fastboot: copy AVB footer from init_boot.img to end of partition Similar to GKI boot.img, init_boot.img is released as a specific size and should be able to be flashed into partitions that have different sizes. So the AVB footer is moved from the end of the init_boot.img to the end of the partition in the case that the partition is larger than the image. Bug: 203698939 Test: m Change-Id: Ib5a63a7bf1b4be4eba4941972750f12e3edb3a17 --- fastboot/device/flashing.cpp | 3 ++- fastboot/fastboot.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fastboot/device/flashing.cpp b/fastboot/device/flashing.cpp index 3f9bcdc14..7bef72af1 100644 --- a/fastboot/device/flashing.cpp +++ b/fastboot/device/flashing.cpp @@ -172,7 +172,8 @@ int Flash(FastbootDevice* device, const std::string& partition_name) { return -EOVERFLOW; } else if (data.size() < block_device_size && (partition_name == "boot" || partition_name == "boot_a" || - partition_name == "boot_b")) { + partition_name == "boot_b" || partition_name == "init_boot" || + partition_name == "init_boot_a" || partition_name == "init_boot_b")) { CopyAVBFooter(&data, block_device_size); } if (android::base::GetProperty("ro.system.build.type", "") != "user") { diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index 32a22bbf5..ab429df50 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -1076,7 +1076,8 @@ static void flash_buf(const std::string& partition, struct fastboot_buffer *buf) { sparse_file** s; - if (partition == "boot" || partition == "boot_a" || partition == "boot_b") { + if (partition == "boot" || partition == "boot_a" || partition == "boot_b" || + partition == "init_boot" || partition == "init_boot_a" || partition == "init_boot_b") { copy_boot_avb_footer(partition, buf); }