mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 00:03:45 +08:00
remote start fix?
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import json
|
||||
import math
|
||||
import numpy as np
|
||||
import os
|
||||
import requests
|
||||
import shutil
|
||||
import subprocess
|
||||
@@ -22,7 +23,7 @@ from opendbc.can.parser import CANParser
|
||||
from openpilot.common.realtime import DT_DMON, DT_HW
|
||||
from openpilot.selfdrive.car.toyota.carcontroller import LOCK_CMD
|
||||
from openpilot.system.hardware import HARDWARE
|
||||
from panda import Panda
|
||||
from panda import Panda, FW_PATH
|
||||
|
||||
from openpilot.frogpilot.common.frogpilot_variables import EARTH_RADIUS, KONIK_PATH, MAPD_PATH, MAPS_PATH, params, params_cache, params_memory
|
||||
|
||||
@@ -151,11 +152,21 @@ def extract_zip(zip_file, extract_path):
|
||||
print(f"Extraction completed: {zip_file} has been removed")
|
||||
|
||||
def flash_panda():
|
||||
remote_start = params.get_bool("RemoteStartBootsComma")
|
||||
for serial in Panda.list():
|
||||
try:
|
||||
panda = Panda(serial)
|
||||
flash_fn = None
|
||||
if remote_start:
|
||||
app_fn = panda.get_mcu_type().config.app_fn
|
||||
remote_fn = "panda_h7_remote.bin.signed" if app_fn == "panda_h7.bin.signed" else "panda_remote.bin.signed"
|
||||
candidate = os.path.join(FW_PATH, remote_fn)
|
||||
if os.path.isfile(candidate):
|
||||
flash_fn = candidate
|
||||
else:
|
||||
print(f"Remote-start panda firmware missing: {candidate}. Falling back to default firmware.")
|
||||
panda.reset(enter_bootstub=True)
|
||||
panda.flash()
|
||||
panda.flash(fn=flash_fn)
|
||||
panda.close()
|
||||
except Exception as exception:
|
||||
print(f"Error flashing Panda {serial}: {exception}")
|
||||
|
||||
@@ -6,6 +6,8 @@ Import('build_project', 'base_project_f4', 'base_project_h7')
|
||||
build_projects = {
|
||||
"panda": base_project_f4,
|
||||
"panda_h7": base_project_h7,
|
||||
"panda_remote": base_project_f4,
|
||||
"panda_h7_remote": base_project_h7,
|
||||
}
|
||||
|
||||
for project_name, project in build_projects.items():
|
||||
@@ -18,4 +20,7 @@ for project_name, project in build_projects.items():
|
||||
if "H723" in os.environ:
|
||||
flags.append('-DSTM32H723')
|
||||
|
||||
if "remote" in project_name:
|
||||
flags.append('-DPANDA_GM_REMOTE_START_C9')
|
||||
|
||||
build_project(project_name, project, flags)
|
||||
|
||||
@@ -203,7 +203,11 @@ void ignition_can_hook(CANPacket_t *to_push) {
|
||||
int len = GET_LEN(to_push);
|
||||
|
||||
// GM exception
|
||||
#ifdef PANDA_GM_REMOTE_START_C9
|
||||
if (true) {
|
||||
#else
|
||||
if (gm_remote_start_boots_comma) {
|
||||
#endif
|
||||
if ((addr == 0xC9) && (len == 8)) {
|
||||
// Matches SystemPowerMode (1=Run, 0=Off)
|
||||
ignition_can = (GET_BYTE(to_push, 6) & 0x10U) != 0U;
|
||||
|
||||
@@ -118,7 +118,7 @@ std::optional<std::string> Panda::get_serial() {
|
||||
|
||||
bool Panda::up_to_date() {
|
||||
if (auto fw_sig = get_firmware_version()) {
|
||||
for (auto fn : { "panda.bin.signed", "panda_h7.bin.signed" }) {
|
||||
for (auto fn : { "panda.bin.signed", "panda_h7.bin.signed", "panda_remote.bin.signed", "panda_h7_remote.bin.signed" }) {
|
||||
auto content = util::read_file(std::string("../../panda/board/obj/") + fn);
|
||||
if (content.size() >= fw_sig->size() &&
|
||||
memcmp(content.data() + content.size() - fw_sig->size(), fw_sig->data(), fw_sig->size()) == 0) {
|
||||
|
||||
@@ -13,15 +13,25 @@ from openpilot.system.hardware import HARDWARE
|
||||
from openpilot.common.swaglog import cloudlog
|
||||
|
||||
|
||||
def get_expected_signature(panda: Panda) -> bytes:
|
||||
def get_expected_firmware_path(panda: Panda, remote_start: bool) -> str:
|
||||
app_fn = panda.get_mcu_type().config.app_fn
|
||||
if remote_start:
|
||||
remote_fn = "panda_h7_remote.bin.signed" if app_fn == "panda_h7.bin.signed" else "panda_remote.bin.signed"
|
||||
remote_path = os.path.join(FW_PATH, remote_fn)
|
||||
if os.path.isfile(remote_path):
|
||||
return remote_path
|
||||
cloudlog.warning(f"Remote-start panda firmware not found: {remote_path}, falling back to default")
|
||||
return os.path.join(FW_PATH, app_fn)
|
||||
|
||||
def get_expected_signature(panda: Panda, remote_start: bool) -> bytes:
|
||||
try:
|
||||
fn = os.path.join(FW_PATH, panda.get_mcu_type().config.app_fn)
|
||||
fn = get_expected_firmware_path(panda, remote_start)
|
||||
return Panda.get_signature_from_firmware(fn)
|
||||
except Exception:
|
||||
cloudlog.exception("Error computing expected signature")
|
||||
return b""
|
||||
|
||||
def flash_panda(panda_serial: str) -> Panda:
|
||||
def flash_panda(panda_serial: str, remote_start: bool) -> Panda:
|
||||
try:
|
||||
panda = Panda(panda_serial)
|
||||
except PandaProtocolMismatch:
|
||||
@@ -29,7 +39,8 @@ def flash_panda(panda_serial: str) -> Panda:
|
||||
HARDWARE.recover_internal_panda()
|
||||
raise
|
||||
|
||||
fw_signature = get_expected_signature(panda)
|
||||
fw_path = get_expected_firmware_path(panda, remote_start)
|
||||
fw_signature = get_expected_signature(panda, remote_start)
|
||||
internal_panda = panda.is_internal()
|
||||
|
||||
panda_version = "bootstub" if panda.bootstub else panda.get_version()
|
||||
@@ -38,7 +49,7 @@ def flash_panda(panda_serial: str) -> Panda:
|
||||
|
||||
if panda.bootstub or panda_signature != fw_signature:
|
||||
cloudlog.info("Panda firmware out of date, update required")
|
||||
panda.flash()
|
||||
panda.flash(fn=fw_path)
|
||||
cloudlog.info("Done flashing")
|
||||
|
||||
if panda.bootstub:
|
||||
@@ -105,8 +116,9 @@ def main() -> NoReturn:
|
||||
|
||||
# Flash pandas
|
||||
pandas: list[Panda] = []
|
||||
remote_start = params.get_bool("RemoteStartBootsComma")
|
||||
for serial in panda_serials:
|
||||
pandas.append(flash_panda(serial))
|
||||
pandas.append(flash_panda(serial, remote_start))
|
||||
|
||||
# Ensure internal panda is present if expected
|
||||
internal_pandas = [panda for panda in pandas if panda.is_internal()]
|
||||
|
||||
Reference in New Issue
Block a user