Skip to content

Commit

Permalink
jetson-uefi: fix prepare_payload
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodong-Yang committed May 13, 2024
1 parent 2234974 commit 86d36ae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
29 changes: 17 additions & 12 deletions otaclient/app/boot_control/_jetson_uefi.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,25 +151,30 @@ def _ensure_efivarfs_mounted(cls) -> None:
) from e

def _prepare_payload(self) -> None:
"""Copy the Capsule update payload to the specified location."""
"""Copy the Capsule update payloads to specific location at esp partition."""
try:
CMDHelperFuncs.mount_rw(self.esp_part, self.esp_mp)
except Exception as e:
_err_msg = f"failed to mount {self.esp_part=} to {self.esp_mp}: {e!r}"
logger.error(_err_msg)
raise JetsonUEFIBootControlError(_err_msg) from e

capsule_payload_location = Path(self.esp_mp) / boot_cfg.CAPSULE_PAYLOAD_LOCATION
try:
for capsule_fname in boot_cfg.FIRMWARE_LIST:
capsule_payload_fpath = self.standby_slot_mp / capsule_fname
shutil.copy(capsule_payload_fpath, capsule_payload_location)
except Exception as e:
_err_msg = f"failed to copy update Capsule from {capsule_payload_fpath} to {capsule_payload_location}: {e!r}"
logger.error(_err_msg)
raise JetsonUEFIBootControlError(_err_msg) from e
finally:
CMDHelperFuncs.umount(self.esp_mp, raise_exception=False)
capsule_at_esp = Path(self.esp_mp) / boot_cfg.CAPSULE_PAYLOAD_AT_ESP
capsule_at_standby_slot = self.standby_slot_mp / Path(
boot_cfg.CAPSULE_PAYLOAD_AT_ROOTFS
).relative_to("/")
for capsule_fname in boot_cfg.FIRMWARE_LIST:
try:
shutil.copy(
src=capsule_at_standby_slot / capsule_fname,
dst=capsule_at_esp / capsule_fname,
)
except Exception as e:
logger.warning(
f"failed to copy {capsule_fname} from {capsule_at_standby_slot} to {capsule_at_esp}: {e!r}"
)
logger.warning(f"skip {capsule_fname}")
CMDHelperFuncs.umount(self.esp_mp, raise_exception=False)

def _write_efivar(self) -> None:
"""Write magic efivar to trigger firmware Capsule update in next boot.
Expand Down
3 changes: 2 additions & 1 deletion otaclient/app/boot_control/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ class JetsonUEFIBootControlConfig(JetsonBootCommon):
EFIVARS_DPATH = "/sys/firmware/efi/efivars/"
UPDATE_TRIGGER_EFIVAR = "OsIndications-8be4df61-93ca-11d2-aa0d-00e098032b8c"
MAGIC_BYTES = b"\x07\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00"
CAPSULE_PAYLOAD_LOCATION = "EFI/UpdateCapsule"
CAPSULE_PAYLOAD_AT_ESP = "EFI/UpdateCapsule"
CAPSULE_PAYLOAD_AT_ROOTFS = "/opt/ota_package/"


@dataclass
Expand Down

0 comments on commit 86d36ae

Please sign in to comment.