mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-07-13 09:12:08 +08:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 813ef1ee65 | |||
| 3749b49186 | |||
| 6bea70ac86 | |||
| 25b6f84bb0 | |||
| 73092daefc |
+21
-15
@@ -32,8 +32,7 @@ def flash_panda(panda_serial: str) -> Panda:
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
# skip flashing if the detected panda is not supported
|
# skip flashing if the detected panda is not supported
|
||||||
supported_panda = check_panda_support(panda)
|
if panda.get_type() not in Panda.SUPPORTED_DEVICES:
|
||||||
if not supported_panda:
|
|
||||||
cloudlog.warning(f"Panda {panda_serial} is not supported (hw_type: {panda.get_type()}), skipping flash...")
|
cloudlog.warning(f"Panda {panda_serial} is not supported (hw_type: {panda.get_type()}), skipping flash...")
|
||||||
return panda
|
return panda
|
||||||
|
|
||||||
@@ -69,10 +68,19 @@ def flash_panda(panda_serial: str) -> Panda:
|
|||||||
return panda
|
return panda
|
||||||
|
|
||||||
|
|
||||||
def check_panda_support(panda) -> bool:
|
def check_panda_support(panda_serials: list[str]) -> bool:
|
||||||
hw_type = panda.get_type()
|
unsupported = []
|
||||||
if hw_type in Panda.SUPPORTED_DEVICES:
|
for serial in panda_serials:
|
||||||
return True
|
panda = Panda(serial)
|
||||||
|
hw_type = panda.get_type()
|
||||||
|
panda.close()
|
||||||
|
if hw_type in Panda.SUPPORTED_DEVICES:
|
||||||
|
return True
|
||||||
|
|
||||||
|
unsupported.append((serial, hw_type))
|
||||||
|
|
||||||
|
for serial, hw_type in unsupported:
|
||||||
|
cloudlog.warning(f"Panda {serial} is not supported (hw_type: {hw_type}), skipping...")
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -126,13 +134,17 @@ def main() -> None:
|
|||||||
|
|
||||||
cloudlog.info(f"{len(panda_serials)} panda(s) found, connecting - {panda_serials}")
|
cloudlog.info(f"{len(panda_serials)} panda(s) found, connecting - {panda_serials}")
|
||||||
|
|
||||||
|
# custom flasher for xnor's Rivian Longitudinal Upgrade Kit
|
||||||
|
flash_rivian_long(panda_serials)
|
||||||
|
|
||||||
|
# skip flashing and health check if no supported panda is detected
|
||||||
|
if not check_panda_support(panda_serials):
|
||||||
|
continue
|
||||||
|
|
||||||
# Flash the first panda
|
# Flash the first panda
|
||||||
panda_serial = panda_serials[0]
|
panda_serial = panda_serials[0]
|
||||||
panda = flash_panda(panda_serial)
|
panda = flash_panda(panda_serial)
|
||||||
|
|
||||||
# flash Rivian longitudinal upgrade panda
|
|
||||||
flash_rivian_long(panda)
|
|
||||||
|
|
||||||
# Ensure internal panda is present if expected
|
# Ensure internal panda is present if expected
|
||||||
if HARDWARE.has_internal_panda() and not panda.is_internal():
|
if HARDWARE.has_internal_panda() and not panda.is_internal():
|
||||||
cloudlog.error("Internal panda is missing, trying again")
|
cloudlog.error("Internal panda is missing, trying again")
|
||||||
@@ -143,12 +155,6 @@ def main() -> None:
|
|||||||
# log panda fw version
|
# log panda fw version
|
||||||
params.put("PandaSignatures", panda.get_signature())
|
params.put("PandaSignatures", panda.get_signature())
|
||||||
|
|
||||||
# skip health check if the detected panda is not supported
|
|
||||||
supported_panda = check_panda_support(panda)
|
|
||||||
if not supported_panda:
|
|
||||||
cloudlog.warning(f"Panda {panda.get_usb_serial()} is not supported (hw_type: {panda.get_type()}), skipping health check...")
|
|
||||||
continue
|
|
||||||
|
|
||||||
# check health for lost heartbeat
|
# check health for lost heartbeat
|
||||||
health = panda.health()
|
health = panda.health()
|
||||||
if health["heartbeat_lost"]:
|
if health["heartbeat_lost"]:
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ def _flash_panda(panda: Panda) -> None:
|
|||||||
panda.reconnect()
|
panda.reconnect()
|
||||||
|
|
||||||
|
|
||||||
def flash_rivian_long(panda: Panda) -> None:
|
def flash_rivian_long(panda_serials: list[str]) -> None:
|
||||||
if not os.path.isfile(FW_PATH):
|
if not os.path.isfile(FW_PATH):
|
||||||
cloudlog.error(f"Rivian longitudinal upgrade firmware not found at {FW_PATH}")
|
cloudlog.error(f"Rivian longitudinal upgrade firmware not found at {FW_PATH}")
|
||||||
return
|
return
|
||||||
@@ -83,13 +83,19 @@ def flash_rivian_long(panda: Panda) -> None:
|
|||||||
cloudlog.info("Not a Rivian, skipping longitudinal upgrade...")
|
cloudlog.info("Not a Rivian, skipping longitudinal upgrade...")
|
||||||
return
|
return
|
||||||
|
|
||||||
# only flash external black pandas (HW_TYPE_BLACK = 0x03)
|
for serial in panda_serials:
|
||||||
if panda.get_type() == b'\x03' and not panda.is_internal():
|
panda = Panda(serial)
|
||||||
try:
|
# only flash external black pandas (HW_TYPE_BLACK = 0x03)
|
||||||
_flash_panda(panda)
|
if panda.get_type() == b'\x03' and not panda.is_internal():
|
||||||
except Exception:
|
try:
|
||||||
cloudlog.exception(f"Failed to flash F4 panda {panda.get_usb_serial()}")
|
_flash_panda(panda)
|
||||||
|
cloudlog.info(f"Successfully flashed xnor's Rivian Longitudinal Upgrade Kit: {serial}")
|
||||||
|
except Exception:
|
||||||
|
cloudlog.exception(f"Failed to flash xnor's Rivian Longitudinal Upgrade Kit: {serial}")
|
||||||
|
panda.close()
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
flash_rivian_long(Panda())
|
flash_rivian_long(Panda.list())
|
||||||
|
|||||||
Reference in New Issue
Block a user