Skip to content

Commit

Permalink
minor fix jetson_cboot related
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodong-Yang committed May 10, 2024
1 parent d003534 commit 0e7ddc8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
9 changes: 4 additions & 5 deletions otaclient/app/boot_control/_jetson_cboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
import subprocess
from functools import partial
from pathlib import Path
from subprocess import CalledProcessError, CompletedProcess, run
from typing import Generator, Literal, Optional
from typing import Generator, Optional

from otaclient.app import errors as ota_errors
from otaclient.app.common import (
Expand All @@ -36,15 +35,17 @@
)
from otaclient.app.proto import wrapper

from ..configs import config as cfg
from ._common import CMDHelperFuncs, OTAStatusFilesControl, SlotMountHelper
from ._jetson_common import (
NVBootctrlTarget,
FirmwareBSPVersionControl,
NVBootctrlCommon,
SlotID,
parse_bsp_version,
update_extlinux_cfg,
)
from .configs import cboot_cfg as cfg
from .configs import cboot_cfg as boot_cfg
from .protocol import BootControllerProtocol

logger = logging.getLogger(__name__)
Expand All @@ -61,8 +62,6 @@ class _NVBootctrl(NVBootctrlCommon):
Without -t option, the target will be bootloader by default.
"""

NVBootctrlTarget = Literal["bootloader", "rootfs"]

@classmethod
def mark_boot_successful(
cls, slot_id: SlotID, *, target: Optional[NVBootctrlTarget] = None
Expand Down
19 changes: 11 additions & 8 deletions otaclient/app/boot_control/_jetson_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,26 @@ def dump(to_export: BSPVersion) -> str:
return f"R{to_export.major_ver}.{to_export.major_rev}.{to_export.minor_rev}"


BSPVersionStr = Annotated[
BSPVersion,
BeforeValidator(BSPVersion.parse),
PlainSerializer(BSPVersion.dump, return_type=str),
]
"""BSPVersion in string representation, used by FirmwareBSPVersion model."""


class FirmwareBSPVersion(BaseModel):
"""
BSP version string schema: Rxx.yy.z
"""

BSPVersionStr = Annotated[
BSPVersion,
BeforeValidator(BSPVersion.parse),
PlainSerializer(BSPVersion.dump, return_type=str),
]
"""BSPVersion in string representation, used by FirmwareBSPVersion model."""

slot_a: Optional[BSPVersionStr] = None
slot_b: Optional[BSPVersionStr] = None


NVBootctrlTarget = Literal["bootloader", "rootfs"]


class NVBootctrlCommon:
"""Helper for calling nvbootctrl commands.
Expand All @@ -111,7 +115,6 @@ class NVBootctrlCommon:
"""

NVBOOTCTRL = "nvbootctrl"
NVBootctrlTarget = Literal["bootloader", "rootfs"]

@classmethod
def _nvbootctrl(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_boot_control/test_jetson_cboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
import pytest

from otaclient.app.boot_control import _jetson_cboot
from otaclient.app.boot_control._jetson_cboot import _CBootControl
from otaclient.app.boot_control._jetson_common import (
BSPVersion,
FirmwareBSPVersion,
SlotID,
parse_bsp_version,
)
from otaclient.app.boot_control._jetson_cboot import _CBootControl

logger = logging.getLogger(__name__)

Expand Down

0 comments on commit 0e7ddc8

Please sign in to comment.