From aac9d9ecf427afcfe727d569e561a29ee3d9a1f3 Mon Sep 17 00:00:00 2001 From: Daniel Koepping Date: Wed, 22 Jul 2026 10:25:58 -0700 Subject: [PATCH] ui: show eGPU icon when enumerated (#38407) * ui: react to egpu hotplug instead of waiting for modeld params * use chestnutPresent --- openpilot/common/params_keys.h | 2 -- openpilot/selfdrive/modeld/helpers.py | 5 +++++ openpilot/selfdrive/modeld/modeld.py | 10 +++------- openpilot/selfdrive/ui/ui_state.py | 10 ++++++---- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/openpilot/common/params_keys.h b/openpilot/common/params_keys.h index 7ecac1c729..4565f3d5b2 100644 --- a/openpilot/common/params_keys.h +++ b/openpilot/common/params_keys.h @@ -126,7 +126,5 @@ inline static std::unordered_map keys = { {"UpdaterLastFetchTime", {PERSISTENT, TIME}}, {"UptimeOffroad", {PERSISTENT, FLOAT, "0.0"}}, {"UptimeOnroad", {PERSISTENT, FLOAT, "0.0"}}, - {"UsbGpuPresent", {CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION, BOOL}}, - {"UsbGpuCompiled", {CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION, BOOL}}, {"Version", {PERSISTENT, STRING}}, }; diff --git a/openpilot/selfdrive/modeld/helpers.py b/openpilot/selfdrive/modeld/helpers.py index 7c322c5993..8516325140 100644 --- a/openpilot/selfdrive/modeld/helpers.py +++ b/openpilot/selfdrive/modeld/helpers.py @@ -6,6 +6,8 @@ import struct import tempfile from pathlib import Path +from openpilot.common.file_chunker import get_manifest_path + MODELS_DIR = Path(__file__).resolve().parent / 'models' TG_INPUT_DEVICES_PATH = MODELS_DIR / 'tg_input_devices.json' USBGPU_VID = 0xADD1 @@ -53,3 +55,6 @@ def usbgpu_present() -> bool: except Exception: pass return False + +def usbgpu_compiled() -> bool: + return Path(get_manifest_path(modeld_pkl_path(usbgpu=True))).is_file() diff --git a/openpilot/selfdrive/modeld/modeld.py b/openpilot/selfdrive/modeld/modeld.py index 41a1f44e5f..cd8740b462 100755 --- a/openpilot/selfdrive/modeld/modeld.py +++ b/openpilot/selfdrive/modeld/modeld.py @@ -22,9 +22,9 @@ from openpilot.selfdrive.controls.lib.drive_helpers import get_accel_from_plan, from openpilot.selfdrive.modeld.parse_model_outputs import Parser from openpilot.selfdrive.modeld.compile_modeld import make_input_queues, WARP_INPUTS, POLICY_INPUTS from openpilot.selfdrive.modeld.fill_model_msg import fill_model_msg, fill_driving_model_data, fill_pose_msg, PublishState -from openpilot.common.file_chunker import open_file_chunked, get_manifest_path +from openpilot.common.file_chunker import open_file_chunked from openpilot.selfdrive.modeld.constants import ModelConstants, Plan -from openpilot.selfdrive.modeld.helpers import usbgpu_present, modeld_pkl_path, get_tg_input_devices, load_oob +from openpilot.selfdrive.modeld.helpers import usbgpu_present, usbgpu_compiled, modeld_pkl_path, get_tg_input_devices, load_oob from openpilot.selfdrive.modeld.usbgpu_link import wait_usbgpu_link PROCESS_NAME = "openpilot.selfdrive.modeld.modeld" @@ -137,12 +137,8 @@ class ModelState: def main(demo=False): cloudlog.warning("modeld init") - _present = usbgpu_present() - _compiled = os.path.isfile(get_manifest_path(modeld_pkl_path(usbgpu=True))) - USBGPU = _present and _compiled + USBGPU = usbgpu_present() and usbgpu_compiled() params = Params() - params.put_bool("UsbGpuPresent", _present) - params.put_bool("UsbGpuCompiled", _compiled) config_realtime_process(7, 54) diff --git a/openpilot/selfdrive/ui/ui_state.py b/openpilot/selfdrive/ui/ui_state.py index 78388593c8..7efcf2a7c9 100644 --- a/openpilot/selfdrive/ui/ui_state.py +++ b/openpilot/selfdrive/ui/ui_state.py @@ -12,6 +12,7 @@ from openpilot.common.swaglog import cloudlog from openpilot.selfdrive.ui.lib.prime_state import PrimeState from openpilot.system.ui.lib.application import gui_app from openpilot.common.hardware import HARDWARE, PC +from openpilot.selfdrive.modeld.helpers import usbgpu_compiled BACKLIGHT_OFFROAD = 65 if HARDWARE.get_device_type() == "mici" else 50 PARAM_UPDATE_TIME = 1 / 5.0 @@ -75,8 +76,8 @@ class UIState: self.is_release = self.params.get_bool("IsReleaseBranch") self.always_on_dm: bool = self.params.get_bool("AlwaysOnDM") self.experimental_mode: bool = self.params.get_bool("ExperimentalMode") - self.usbgpu: bool = self.params.get_bool("UsbGpuPresent") - self.usbgpu_compiled: bool = self.params.get_bool("UsbGpuCompiled") + self.usbgpu: bool = False + self.usbgpu_compiled: bool = usbgpu_compiled() self.started: bool = False self.ignition: bool = False self.recording_audio: bool = False @@ -203,8 +204,9 @@ class UIState: self.is_metric = self.params.get_bool("IsMetric") self.always_on_dm = self.params.get_bool("AlwaysOnDM") self.experimental_mode = self.params.get_bool("ExperimentalMode") - self.usbgpu = self.params.get_bool("UsbGpuPresent") - self.usbgpu_compiled = self.params.get_bool("UsbGpuCompiled") + self.usbgpu = self.sm["deviceState"].chestnutPresent + if not self.usbgpu_compiled: + self.usbgpu_compiled = usbgpu_compiled() class Device: