From 03a50dbad68196ce9ccce6129f467eb80e201ff1 Mon Sep 17 00:00:00 2001 From: mawei <15377594951@jihulab.com> Date: Wed, 2 Sep 2026 10:50:36 +0000 Subject: [PATCH] Toyota: Toyota Sienna 2021-26 PATCHED support (EPS-bypassed SecOC, lateral-only) --- opendbc_repo/docs/CARS.md | 3 ++- .../opendbc/car/torque_data/substitute.toml | 1 + opendbc_repo/opendbc/car/toyota/interface.py | 5 +++++ .../opendbc/car/toyota/tests/test_toyota.py | 12 +++++++++++- opendbc_repo/opendbc/car/toyota/values.py | 19 +++++++++++++++++++ .../opendbc/sunnypilot/car/car_list.json | 15 +++++++++++++++ .../sunnypilot/car/toyota/fingerprints_ext.py | 18 ++++++++++++++++++ 7 files changed, 71 insertions(+), 2 deletions(-) diff --git a/opendbc_repo/docs/CARS.md b/opendbc_repo/docs/CARS.md index 43f7b8166..308600278 100644 --- a/opendbc_repo/docs/CARS.md +++ b/opendbc_repo/docs/CARS.md @@ -1,6 +1,6 @@ -# Support Information for 402 Known Cars +# Support Information for 403 Known Cars |Make|Model|Package|Support Level| |---|---|---|:---:| @@ -359,6 +359,7 @@ |Toyota|Sequoia 2023-25|All|[Not compatible](#can-bus-security)| |Toyota|Sienna 2018-20|All|[Upstream](#upstream)| |Toyota|Sienna 2021-23|All|[Custom](#secoc-cars-with-recoverable-keys)| +|Toyota|Sienna 2021-26|All|[Custom](#secoc-cars-with-eps-patched)| |Toyota|Sienna 2024-25|All|[Not compatible](#can-bus-security)| |Toyota|Tundra 2022-25|All|[Not compatible](#can-bus-security)| |Toyota|Venza 2021-25|All|[Not compatible](#can-bus-security)| diff --git a/opendbc_repo/opendbc/car/torque_data/substitute.toml b/opendbc_repo/opendbc/car/torque_data/substitute.toml index 945ab3596..d3e524121 100644 --- a/opendbc_repo/opendbc/car/torque_data/substitute.toml +++ b/opendbc_repo/opendbc/car/torque_data/substitute.toml @@ -10,6 +10,7 @@ legend = ["LAT_ACCEL_FACTOR", "MAX_LAT_ACCEL_MEASURED", "FRICTION"] "TOYOTA_ALPHARD_TSS2" = "TOYOTA_SIENNA" "TOYOTA_PRIUS_V" = "TOYOTA_PRIUS" "TOYOTA_SIENNA_4TH_GEN" = "TOYOTA_RAV4_PRIME" +"TOYOTA_SIENNA_PATCHED" = "TOYOTA_RAV4_PRIME" "LEXUS_IS" = "LEXUS_NX" "LEXUS_CTH" = "LEXUS_NX" "LEXUS_ES" = "TOYOTA_CAMRY" diff --git a/opendbc_repo/opendbc/car/toyota/interface.py b/opendbc_repo/opendbc/car/toyota/interface.py index 579d28306..fa8d6de5e 100644 --- a/opendbc_repo/opendbc/car/toyota/interface.py +++ b/opendbc_repo/opendbc/car/toyota/interface.py @@ -106,6 +106,11 @@ class CarInterface(CarInterfaceBase): ret.openpilotLongitudinalControl = ((bool(ret.flags & ToyotaFlags.TSS2) and not (ret.flags & ToyotaFlags.RADAR_ACC)) or bool(ret.flags & ToyotaFlags.DISABLE_RADAR.value)) + # This platform only uses openpilot for lateral control. All longitudinal + # control and its SecOC traffic remain stock. + if ret.flags & ToyotaFlags.EPS_BYPASS_SECOC.value: + ret.openpilotLongitudinalControl = False + ret.autoResumeSng = ret.openpilotLongitudinalControl and candidate in NO_STOP_TIMER_CAR if not ret.openpilotLongitudinalControl: diff --git a/opendbc_repo/opendbc/car/toyota/tests/test_toyota.py b/opendbc_repo/opendbc/car/toyota/tests/test_toyota.py index 9d825d359..4bd7727f8 100644 --- a/opendbc_repo/opendbc/car/toyota/tests/test_toyota.py +++ b/opendbc_repo/opendbc/car/toyota/tests/test_toyota.py @@ -1,11 +1,12 @@ import unittest -from opendbc.car import Bus +from opendbc.car import Bus, gen_empty_fingerprint from opendbc.car.structs import CarParams from opendbc.car.fw_versions import build_fw_dict from opendbc.car.toyota.fingerprints import FW_VERSIONS from opendbc.car.toyota.values import CAR, DBC, ToyotaFlags, FW_QUERY_CONFIG, PLATFORM_CODE_ECUS, \ FUZZY_EXCLUDED_PLATFORMS, get_platform_codes +from opendbc.car.toyota.interface import CarInterface from opendbc.testing import fuzzy_test Ecu = CarParams.Ecu @@ -29,6 +30,15 @@ class TestToyotaInterfaces(unittest.TestCase): # At this time, only RAV4 2023 is expected to use LTA/angle control assert cars_with(ToyotaFlags.ANGLE_CONTROL) == {CAR.TOYOTA_RAV4_TSS2_2023} + def test_eps_bypass_secoc(self): + # Only the patched Sienna uses EPS-bypassed SecOC + assert cars_with(ToyotaFlags.EPS_BYPASS_SECOC) == {CAR.TOYOTA_SIENNA_PATCHED} + + # EPS-bypass SecOC platforms are lateral-only: longitudinal remains stock + CP = CarInterface.get_params(CAR.TOYOTA_SIENNA_PATCHED, gen_empty_fingerprint(), list(), + alpha_long=False, is_release=False, docs=False) + assert not CP.openpilotLongitudinalControl + def test_tss2_dbc(self): # We make some assumptions about TSS2 platforms, # like looking up certain signals only in this DBC diff --git a/opendbc_repo/opendbc/car/toyota/values.py b/opendbc_repo/opendbc/car/toyota/values.py index b2cab322c..3015a77f3 100644 --- a/opendbc_repo/opendbc/car/toyota/values.py +++ b/opendbc_repo/opendbc/car/toyota/values.py @@ -74,6 +74,9 @@ class ToyotaFlags(IntFlag): # these cars can utilize 2.0 m/s^2 RAISED_ACCEL_LIMIT = 1024 SECOC = 2048 + # The EPS firmware accepts dummy SecOC MACs for lateral frames. Longitudinal + # control remains entirely stock on this platform. + EPS_BYPASS_SECOC = 4096 # deprecated flags # these cars are speculated to allow stop and go when the DSU is unplugged or disabled with sDSU @@ -102,6 +105,17 @@ class ToyotaSecOcCarDocs(ToyotaCarDocs): support_link: str = "#secoc-cars-with-recoverable-keys" +@dataclass +class ToyotaSiennaPatchedCarDocs(ToyotaSecOcCarDocs): + support_link: str = "#secoc-cars-with-eps-patched" + + def __post_init__(self): + super().__post_init__() + self.model = "Sienna" + self.years = "2021-26" + self.year_list = ["2021", "2022", "2023", "2024", "2025", "2026"] + + @dataclass class ToyotaTSS2PlatformConfig(PlatformConfig): dbc_dict: dict = field(default_factory=lambda: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas')) @@ -310,6 +324,11 @@ class CAR(Platforms): [ToyotaSecOcCarDocs("Toyota Sienna 2021-23", min_enable_speed=MIN_ACC_SPEED)], CarSpecs(mass=4625. * CV.LB_TO_KG, wheelbase=3.06, steerRatio=17.8, tireStiffnessFactor=0.444), ) + TOYOTA_SIENNA_PATCHED = ToyotaSecOCPlatformConfig( + [ToyotaSiennaPatchedCarDocs("Toyota Sienna 2021-26 PATCHED", min_enable_speed=MIN_ACC_SPEED)], + CarSpecs(mass=4625. * CV.LB_TO_KG, wheelbase=3.06, steerRatio=17.8, tireStiffnessFactor=0.444), + flags=ToyotaFlags.EPS_BYPASS_SECOC, + ) # Lexus LEXUS_CTH = PlatformConfig( diff --git a/opendbc_repo/opendbc/sunnypilot/car/car_list.json b/opendbc_repo/opendbc/sunnypilot/car/car_list.json index 536c42582..9a13fc6e0 100644 --- a/opendbc_repo/opendbc/sunnypilot/car/car_list.json +++ b/opendbc_repo/opendbc/sunnypilot/car/car_list.json @@ -3927,6 +3927,21 @@ ], "package": "All" }, + "Toyota Sienna 2021-26 PATCHED": { + "platform": "TOYOTA_SIENNA_PATCHED", + "make": "Toyota", + "brand": "toyota", + "model": "Sienna", + "year": [ + "2021", + "2022", + "2023", + "2024", + "2025", + "2026" + ], + "package": "All" + }, "Toyota Yaris (Non-US only) 2020, 2023": { "platform": "TOYOTA_YARIS", "make": "Toyota", diff --git a/opendbc_repo/opendbc/sunnypilot/car/toyota/fingerprints_ext.py b/opendbc_repo/opendbc/sunnypilot/car/toyota/fingerprints_ext.py index 5ed391b5f..5544fd971 100644 --- a/opendbc_repo/opendbc/sunnypilot/car/toyota/fingerprints_ext.py +++ b/opendbc_repo/opendbc/sunnypilot/car/toyota/fingerprints_ext.py @@ -1,6 +1,24 @@ from opendbc.car.structs import CarParams +from opendbc.car.toyota.values import CAR Ecu = CarParams.Ecu FW_VERSIONS_EXT = { + CAR.TOYOTA_SIENNA_PATCHED: { + (Ecu.engine, 0x700, None): [ + b'\x01896630867000\x00\x00\x00\x00', + ], + (Ecu.abs, 0x7b0, None): [ + b'\x01F15264510100\x00\x00\x00\x00', + ], + (Ecu.eps, 0x7a1, None): [ + b'\x018965B4512000\x00\x00\x00\x00', + ], + (Ecu.fwdRadar, 0x750, 0xf): [ + b'\x018821F4501000\x00\x00\x00\x00', + ], + (Ecu.fwdCamera, 0x750, 0x6d): [ + b'\x028646F0805200\x00\x00\x00\x008646G4202100\x00\x00\x00\x00', + ], + }, }