Skip to content

Commit

Permalink
jetson-cboot: fix firmware update
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodong-Yang committed May 15, 2024
1 parent db97a0e commit 448332f
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions otaclient/app/boot_control/_jetson_cboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def _nv_firmware_update(self) -> Optional[bool]:
new_bsp_v = parse_bsp_version(_new_bsp_v_fpath.read_text())
except Exception as e:
logger.warning(f"failed to detect new image's BSP version: {e!r}")
logger.info("skip firmware update due to new image BSP version unknown")
logger.warning("skip firmware update due to new image BSP version unknown")
return

logger.info(f"BUP package version: {new_bsp_v=}")
Expand Down Expand Up @@ -459,17 +459,6 @@ def _nv_firmware_update(self) -> Optional[bool]:
f"stdout={e.stdout.decode()}"
)
logger.error(_err_msg)
logger.warning("firmware update interrupted, failing OTA...")

# if the firmware update is interrupted halfway(some of the BUP is applied),
# revert bootloader slot switch
if _firmware_applied:
logger.warning(
"revert bootloader slot switch to current active slot"
)
_NVBootctrl.set_active_boot_slot(
self._cboot_control.current_bootloader_slot
)
return False

# ------ register new firmware version ------ #
Expand All @@ -481,7 +470,6 @@ def _nv_firmware_update(self) -> Optional[bool]:
standby_bootloader_slot, new_bsp_v
)
return True
logger.info("no firmware payload BUP available, skip firmware update")

# APIs

Expand Down Expand Up @@ -529,12 +517,23 @@ def post_update(self) -> Generator[None, None, None]:
)

# ------ firmware update ------ #
if not self._nv_firmware_update():
firmware_update_result = self._nv_firmware_update()
if firmware_update_result:
self._firmware_ver_control.write_current_firmware_bsp_version()
elif firmware_update_result is None:
logger.info("no firmware update occurs")
else:
logger.error("firmware update failed, failing OTA...")
logger.warning(
"revert bootloader slot switch to current active slot due to failed firmware update"
)
_NVBootctrl.set_active_boot_slot(
self._cboot_control.current_bootloader_slot
)
raise JetsonCBootContrlError("firmware update failed")

# ------ write BSP version files ------ #
# ------ preserve BSP version files to standby slot ------ #
self._firmware_ver_control.write_standby_firmware_bsp_version()
self._firmware_ver_control.write_current_firmware_bsp_version()

# ------ preserve /boot/ota folder to standby rootfs ------ #
preserve_ota_config_files_to_standby(
Expand Down

0 comments on commit 448332f

Please sign in to comment.