diff --git a/flash/factory.common b/flash/factory.common index 9131a7d209d506f8a6eb45c4bf8ec3da5377ff17..d6d076d235289ca10cf0a8c3043b43af53202f21 100755 --- a/flash/factory.common +++ b/flash/factory.common @@ -144,6 +144,11 @@ switch_to_fastbootd() { echo "INFO: Device is now in fastbootd mode." } +# Flash (or manipulate) relevant early partitions +flash_device_early() { + flash_images_ab_or_abort "${sn}" "${FLASH_AB_EARLY_IMGS}" + flash_images_a_or_abort "${sn}" "${FLASH_A_EARLY_IMGS}" +} # Flash (or manipulate) relevant partitions flash_device() { @@ -156,6 +161,12 @@ then "${FASTBOOT_BIN}" -s "${sn}" reboot bootloader fi +if [ "${WIPE_SUPER}" = "true" ] +then + echo "INFO: Wiping super image" + "${FASTBOOT_BIN}" -s "${sn}" wipe-super "${IMAGES_DIR}/super_empty.img" +fi + flash_images_ab_or_abort "${sn}" "${FLASH_AB_IMGS}" flash_images_a_or_abort "${sn}" "${FLASH_A_IMGS}" @@ -177,9 +188,12 @@ flash_factory() { USE_FASTBOOTD="${USE_FASTBOOTD:-false}" FW_BL_RESTART="${FW_BL_RESTART:-false}" CLEAN_FLASH="${CLEAN_FLASH:-false}" + WIPE_SUPER="${WIPE_SUPER:-false}" VIRTUAL_AB="${VIRTUAL_AB:-false}" FLASH_AB_FW_IMGS="${FLASH_AB_FW_IMGS:-}" FLASH_A_FW_IMGS="${FLASH_A_FW_IMGS:-}" + FLASH_AB_EARLY_IMGS="${FLASH_AB_EARLY_IMGS:-}" + FLASH_A_EARLY_IMGS="${FLASH_A_EARLY_IMGS:-}" FLASH_AB_IMGS="${FLASH_AB_IMGS:-}" FLASH_A_IMGS="${FLASH_A_IMGS:-}" ERASE_IMGS="${ERASE_IMGS:-}" @@ -190,13 +204,16 @@ flash_factory() { # If only one device is found $sn will store its serial number find_device + # Check if the device is properly unlocked + check_unlock_status + + # Retrofit devices require flashing boot before switching to fastbootd + flash_device_early + if [ "${USE_FASTBOOTD}" = "true" ]; then switch_to_fastbootd fi - # Check if the device is properly unlocked - check_unlock_status - # Flash the device flash_device