cleanup MCU definitions (#1226)

* cleanup MCU definitions

* rename

* enum

* enum

* fix that
This commit is contained in:
Adeeb Shihadeh
2023-01-26 20:54:11 -08:00
committed by GitHub
parent 33e576214d
commit 76d0459182
8 changed files with 96 additions and 77 deletions

50
python/constants.py Normal file
View File

@@ -0,0 +1,50 @@
import os
import enum
from typing import List, NamedTuple
BASEDIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../")
class McuConfig(NamedTuple):
mcu: str
block_size: int
sector_sizes: List[int]
serial_number_address: int
app_address: int
app_path: str
bootstub_address: int
bootstub_path: str
Fx = (
0x800,
[0x4000 for _ in range(4)] + [0x10000] + [0x20000 for _ in range(11)],
0x1FFF79C0,
0x8004000,
os.path.join(BASEDIR, "board", "obj", "panda.bin.signed"),
0x8000000,
os.path.join(BASEDIR, "board", "obj", "bootstub.panda.bin"),
)
F2Config = McuConfig("STM32F2", *Fx)
F4Config = McuConfig("STM32F4", *Fx)
H7Config = McuConfig(
"STM32H7",
0x400,
# there is an 8th sector, but we use that for the provisioning chunk, so don't program over that!
[0x20000 for _ in range(7)],
0x080FFFC0,
0x8020000,
os.path.join(BASEDIR, "board", "obj", "panda_h7.bin.signed"),
0x8000000,
os.path.join(BASEDIR, "board", "obj", "bootstub.panda_h7.bin"),
)
@enum.unique
class McuType(enum.Enum):
F2 = F2Config
F4 = F4Config
H7 = H7Config
@property
def config(self):
return self.value