Skip to content

Commit

Permalink
cleanup fw filename conventions (commaai#1434)
Browse files Browse the repository at this point in the history
* cleanup fn

* import os

* fix path
  • Loading branch information
adeebshihadeh authored May 22, 2023
1 parent a8f8518 commit 4dd2735
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
7 changes: 4 additions & 3 deletions python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down
14 changes: 7 additions & 7 deletions python/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -13,19 +13,19 @@ 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,
0x800,
[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)
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions python/dfu.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import usb1
import struct
import binascii
Expand All @@ -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:
Expand Down Expand Up @@ -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()
5 changes: 1 addition & 4 deletions release/make_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4dd2735

Please sign in to comment.