If an OTA updated is interrupted (e.g. power off) at a couple of key points then attempts to retry the same update (or updates containing the same alt image components) will always fail.
Log output:
Sha1 checksum for /tmp/recovery-dtb_alt_part.tmp (b13396fa7dbc17a6ced972c4fd08fc71b812dbba != 6a521e1d2a632c26e53b83d2cc4b0edecfc1e68c) does not match
recovery-dtb_alt needs to be erased
Current update state: err.
Enter error update state, exiting update process...
Failed to run "update_specified_partitions_alt recovery-dtb /raymarine/Data/ota_work/external_device/images-R36-ToT/tegra234-p3768-0000+p3767-0000-nv-raymarine-bluefin-v2.dtb.rec /tmp/sha1sum.tmp "
Failed to run "install_partition_with_alt /raymarine/Data/ota_work/external_device/images-R36-ToT recovery-dtb"
Failed to run "update_misc_partitions /raymarine/Data/ota_work /raymarine/Data/ota_work/external_device/images-R36-ToT"
The root cause is an interruption in updating the alt partitions - after the partition names have been switched but before the old partition is erased.
This should be caught in state S3 in the function check_update_state in nv_ota_update_alt_part.func but instead drops through with current_state=err, as at this point the old partition still matches the new image and the condition for state S3 is not met
The function check_update_state examines three conditional variables as booleans to determine the state of the existing and _alt partitions. This give eight possible combinations. In seven of the eight combinations a resulting state is set { S1, S2, S3, S4 }. In the eighth combination (is_part_new=true, is_part_alt_erased=false, is_part_alt_new=true) an error condition is set despite the state being recoverable. The patch allows recovery in all cases.