From c53710df4a21d63d454488845b629805be9be623 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 21 May 2023 21:19:19 -0700 Subject: [PATCH] cleanup fw filename conventions (#1434) * cleanup fn * import os * fix path --- python/__init__.py | 7 ++++--- python/constants.py | 14 +++++++------- python/dfu.py | 6 ++++-- release/make_release.sh | 5 +---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/python/__init__.py b/python/__init__.py index 7425ff1f97a..f5ef57312b3 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -14,7 +14,7 @@ from itertools import accumulate from .base import BaseHandle -from .constants import McuType +from .constants import FW_PATH, McuType from .dfu import PandaDFU from .isotp import isotp_send, isotp_recv from .spi import PandaSpiHandle, PandaSpiException @@ -485,7 +485,7 @@ def flash_static(handle, code, mcu_type): def flash(self, fn=None, code=None, reconnect=True): if not fn: - fn = self._mcu_type.config.app_path + fn = os.path.join(FW_PATH, self._mcu_type.config.app_fn) assert os.path.isfile(fn) logging.debug("flash: main version is %s", self.get_version()) if not self.bootstub: @@ -536,7 +536,8 @@ def wait_for_dfu(dfu_serial: str, timeout: Optional[int] = None) -> bool: def up_to_date(self) -> bool: current = self.get_signature() - expected = Panda.get_signature_from_firmware(self.get_mcu_type().config.app_path) + fn = os.path.join(FW_PATH, self.get_mcu_type().config.app_fn) + expected = Panda.get_signature_from_firmware(fn) return (current == expected) def call_control_api(self, msg): diff --git a/python/constants.py b/python/constants.py index c55fd2c9b80..4c3e778ad11 100644 --- a/python/constants.py +++ b/python/constants.py @@ -3,7 +3,7 @@ from typing import List, NamedTuple BASEDIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../") - +FW_PATH = os.path.join(BASEDIR, "board/obj/") class McuConfig(NamedTuple): mcu: str @@ -13,9 +13,9 @@ class McuConfig(NamedTuple): sector_sizes: List[int] serial_number_address: int app_address: int - app_path: str + app_fn: str bootstub_address: int - bootstub_path: str + bootstub_fn: str Fx = ( 0x1FFF7A10, @@ -23,9 +23,9 @@ class McuConfig(NamedTuple): [0x4000 for _ in range(4)] + [0x10000] + [0x20000 for _ in range(11)], 0x1FFF79C0, 0x8004000, - os.path.join(BASEDIR, "board", "obj", "panda.bin.signed"), + "panda.bin.signed", 0x8000000, - os.path.join(BASEDIR, "board", "obj", "bootstub.panda.bin"), + "bootstub.panda.bin", ) F2Config = McuConfig("STM32F2", 0x411, *Fx) F4Config = McuConfig("STM32F4", 0x463, *Fx) @@ -39,9 +39,9 @@ class McuConfig(NamedTuple): [0x20000 for _ in range(7)], 0x080FFFC0, 0x8020000, - os.path.join(BASEDIR, "board", "obj", "panda_h7.bin.signed"), + "panda_h7.bin.signed", 0x8000000, - os.path.join(BASEDIR, "board", "obj", "bootstub.panda_h7.bin"), + "bootstub.panda_h7.bin", ) @enum.unique diff --git a/python/dfu.py b/python/dfu.py index f1d20842bac..bebc243ced7 100644 --- a/python/dfu.py +++ b/python/dfu.py @@ -1,3 +1,4 @@ +import os import usb1 import struct import binascii @@ -6,7 +7,7 @@ from .base import BaseSTBootloaderHandle from .spi import STBootloaderSPIHandle, PandaSpiException from .usb import STBootloaderUSBHandle -from .constants import McuType +from .constants import FW_PATH, McuType class PandaDFU: @@ -112,7 +113,8 @@ def program_bootstub(self, code_bootstub): self._handle.program(self._mcu_type.config.bootstub_address, code_bootstub) def recover(self): - with open(self._mcu_type.config.bootstub_path, "rb") as f: + fn = os.path.join(FW_PATH, self._mcu_type.config.bootstub_fn) + with open(fn, "rb") as f: code = f.read() self.program_bootstub(code) self.reset() diff --git a/release/make_release.sh b/release/make_release.sh index 150c5107364..5628c4998db 100755 --- a/release/make_release.sh +++ b/release/make_release.sh @@ -19,7 +19,4 @@ rm obj/* scons -u cd obj RELEASE_NAME=$(awk '{print $1}' version) -rm panda.bin panda_h7.bin -mv panda.bin.signed panda.bin -mv panda_h7.bin.signed panda_h7.bin -zip -j ../../release/panda-$RELEASE_NAME.zip version panda.bin bootstub.panda.bin panda_h7.bin bootstub.panda_h7.bin +zip -j ../../release/panda-$RELEASE_NAME.zip version panda.bin.signed bootstub.panda.bin panda_h7.bin.signed bootstub.panda_h7.bin