Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6b2bc29
changed brakelight hpp
sakiyamadev Mar 28, 2026
976c004
merging
sakiyamadev Mar 28, 2026
824335d
merge master
sakiyamadev Mar 29, 2026
fda0d37
merging master
sakiyamadev Apr 1, 2026
6de79df
merging
sakiyamadev Apr 21, 2026
246390f
merging
sakiyamadev Apr 22, 2026
4734324
merging
sakiyamadev Apr 28, 2026
669d82c
Merge branch 'master' of https://github.com/UBCFormulaElectric/Consol…
sakiyamadev Apr 29, 2026
cda30f9
Merge branch 'master' of https://github.com/UBCFormulaElectric/Consol…
sakiyamadev May 2, 2026
5fc6a33
Merge branch 'master' of https://github.com/UBCFormulaElectric/Consol…
sakiyamadev May 2, 2026
8a08346
Merge branch 'master' of https://github.com/UBCFormulaElectric/Consol…
sakiyamadev May 13, 2026
3d52234
Merge branch 'master' of https://github.com/UBCFormulaElectric/Consol…
sakiyamadev May 15, 2026
3dbf501
merge masterMerge branch 'master' of https://github.com/UBCFormulaEle…
sakiyamadev May 22, 2026
86d85bc
added parallel to update ver1
sakiyamadev May 22, 2026
414c935
Merge branch 'master' of https://github.com/UBCFormulaElectric/Consol…
sakiyamadev May 22, 2026
942f0e8
Merge branch 'master' into shun/boot_parallel
sakiyamadev May 22, 2026
55a25a0
edits to update
sakiyamadev May 22, 2026
ebc3c3b
parallelized erase
sakiyamadev May 24, 2026
d70a100
quick patches
sakiyamadev May 24, 2026
d994da9
Merge branch 'master' of https://github.com/UBCFormulaElectric/Consol…
sakiyamadev May 24, 2026
3349226
Merge branch 'master' into shun/boot_parallel
sakiyamadev May 24, 2026
c61f9bd
small fixes
sakiyamadev Jun 3, 2026
2f11fba
:wq
sakiyamadev Jun 3, 2026
8a9e5e5
idk what this is
sakiyamadev Jun 3, 2026
82df3f4
testing whats wrong
sakiyamadev Jun 3, 2026
1c4e034
fixes
sakiyamadev Jun 3, 2026
a3fdc7a
python version change
sakiyamadev Jun 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ message("")
message("🐍 Python Configuration")

# ====== Generate PYTHON_COMMAND ======
find_package(Python3 3.10.0...3.13.7 COMPONENTS Interpreter REQUIRED)
<<<<<<< Updated upstream
find_package(Python3 3.10.0...3.14.5 COMPONENTS Interpreter REQUIRED)
=======
find_package(Python3 3.10.0...3.14.6 COMPONENTS Interpreter REQUIRED)
>>>>>>> Stashed changes
message(" ℹ️ Found Python ${Python3_VERSION}")
set(PYTHON_COMMAND ${Python3_EXECUTABLE})

Expand Down
26 changes: 1 addition & 25 deletions scripts/canup/boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,30 +181,6 @@ def __hash__(self) -> int:
path=os.path.join("firmware", "dev", "h5dev", "h5dev_app_metadata.hex")
)

hexray_CRIT = Board(
name="CRIT",
boot_id_range_start=0x18000000,
app_id_range_start=900,
mcu=STM32H562_MCU,
path=os.path.join("firmware", "hexray", "CRIT", "hexray_CRIT_app_metadata.hex"),
)

hexray_BMS = Board(
name="BMS",
boot_id_range_start=0x04000000,
app_id_range_start=400,
mcu=STM32H733_MCU,
path=os.path.join("firmware", "hexray", "BMS", "hexray_BMS_app_metadata.hex"),
)

hexray_FSM = Board(
name="FSM",
boot_id_range_start=0x10000000,
app_id_range_start=600,
mcu=STM32H562_MCU,
path=os.path.join("firmware", "hexray", "FSM", "hexray_FSM_app_metadata.hex"),
)

CONFIGS = {
"h7dev": [h7dev],
"h5dev": [h5dev],
Expand All @@ -216,5 +192,5 @@ def __hash__(self) -> int:
"hexray_VC" : [hexray_VC],
"hexray_FD": [hexray_DAM, hexray_VC, hexray_BMS],
"hexray_Sx" : [hexray_CRIT, hexray_FSM, hexray_RSM],
"hexray" : [hexray_RSM, hexray_BMS, hexray_CRIT, hexray_DAM, hexray_CRIT, hexray_FSM, hexray_VC],
"hexray" : [hexray_RSM, hexray_BMS, hexray_CRIT, hexray_DAM, hexray_FSM, hexray_VC],
}
63 changes: 48 additions & 15 deletions scripts/canup/bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"""

from typing import Callable, Optional
import queue
import threading
import math
import can
import time
Expand Down Expand Up @@ -53,25 +55,44 @@ def __init__(
board: boards.Board,
ui_callback: Callable,
ih: intelhex.IntelHex = None,
timeout: int = 1000,
timeout: int = 10,
is_fd: bool = False,
inbox: Optional[queue.Queue] = None,
send_lock: Optional[threading.Lock] = None,
) -> None:
self.bus: can.Bus = bus
self.ih: intelhex.IntelHex = ih
self.board: boards.Board = board
self.timeout: int = timeout
self.ui_callback: Callable = ui_callback
self.is_fd = is_fd
# Optional inbox for routed messages (used when a receiver/dispatcher is active)
self.inbox: Optional[queue.Queue] = inbox
# Optional lock to protect bus.send across threads
self.send_lock: Optional[threading.Lock] = send_lock

def _send(self, msg: can.Message, timeout: Optional[float] = None) -> None:
if self.send_lock:
with self.send_lock:
# preserve timeout semantics
if timeout is not None:
self.bus.send(msg, timeout=timeout)
else:
self.bus.send(msg)
else:
if timeout is not None:
self.bus.send(msg, timeout=timeout)
else:
self.bus.send(msg)

def goto_bootloader(self) -> bool:
"""
Pushes all boards to bootloader mode.
:throws: TimeoutError if the boards do not respond
:return: None
"""
self.bus.send(
self._send(
can.Message(
# arbitration_id=board_config.app_id_range_start + 8,
arbitration_id=(
self.board.boot_id_range_start | GO_TO_BOOT_CAN_ID_LOWBITS
),
Expand All @@ -92,7 +113,7 @@ def goto_bootloader(self) -> bool:
)

def goto_app(self) -> bool:
self.bus.send(
self._send(
can.Message(
arbitration_id=self.board.boot_id_range_start | GO_TO_APP_LOWBITS,
data=[],
Expand All @@ -104,7 +125,8 @@ def goto_app(self) -> bool:
# TODO add retry protocol
return (
self._await_can_msg(
lambda msg: msg.arbitration_id == self.board.app_id_range_start + 0,
lambda msg: msg.arbitration_id
== (self.board.app_id_range_start | MCU_10HZ_STATUS_CAN_ID_LOWBITS),
5,
)
is not None
Expand All @@ -130,7 +152,7 @@ def _validator(msg: can.Message) -> bool:
else None
)

self.bus.send(
self._send(
can.Message(
arbitration_id=self.board.boot_id_range_start | START_UPDATE_ID_LOWBITS,
data=[],
Expand Down Expand Up @@ -172,7 +194,7 @@ def _validator(msg: can.Message):
if sector.write_protect:
raise RuntimeError(f"Attempted to write to a readonly memory sector!{sectors}")

self.bus.send(
self._send(
can.Message(
arbitration_id=self.board.boot_id_range_start
| ERASE_SECTOR_CAN_ID_LOWBITS,
Expand Down Expand Up @@ -209,12 +231,12 @@ def program(self) -> None:
"Programming data", self.size_bytes(), i * CAN_FRAME_SIZE
)

data = [self.ih[address + i] for i in range(0, 8)]
data = [self.ih[address + offset] for offset in range(0, CAN_FRAME_SIZE)]

success = False
while not success:
try:
self.bus.send(
self._send(
can.Message(
arbitration_id=self.board.boot_id_range_start
| PROGRAM_CAN_ID_LOWBITS,
Expand Down Expand Up @@ -255,7 +277,7 @@ def _validator(msg: can.Message):
else None
)

self.bus.send(
self._send(
can.Message(
arbitration_id=self.board.boot_id_range_start | VERIFY_CAN_ID_LOWBITS,
data=[],
Expand All @@ -268,7 +290,7 @@ def _validator(msg: can.Message):
return None

if rx_msg.dlc < 1:
raise RuntimeError("Zero Message recieved")
raise RuntimeError("Zero Message received")

return rx_msg.data[0]

Expand Down Expand Up @@ -374,9 +396,18 @@ def _await_can_msg(

start = time.time()
while time.time() - start < timeout:
rx_msg: can.Message = self.bus.recv(timeout=1)
if rx_msg is None:
continue
# If an inbox is present, read routed messages from it. Otherwise fall back to
# reading directly from the bus.
if self.inbox is not None:
try:
rx_msg: can.Message = self.inbox.get(timeout=1)
except queue.Empty:
continue
else:
rx_msg: can.Message = self.bus.recv(timeout=1)
if rx_msg is None:
continue

if validator(rx_msg):
return rx_msg
return None
Expand All @@ -393,6 +424,8 @@ def size_bytes(self) -> int:

"""
return int(
math.ceil((self.ih.maxaddr() - self.ih.minaddr()) / MIN_PROG_SIZE_BYTES)
math.ceil(
(self.ih.maxaddr() - self.ih.minaddr() + 1) / MIN_PROG_SIZE_BYTES
)
* MIN_PROG_SIZE_BYTES
)
Loading
Loading