tici: check that peripherals are fully booted (#30942)

* tici: check that peripherals are fully booted

* default

* typo

* fix

---------

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: 5f191321fd
This commit is contained in:
Adeeb Shihadeh 2024-01-08 15:09:38 -08:00 committed by GitHub
parent 8b1a12644e
commit e905a35467
3 changed files with 17 additions and 0 deletions

View File

@ -312,6 +312,9 @@ def thermald_thread(end_event, hw_queue) -> None:
# must be at an engageable thermal band to go onroad
startup_conditions["device_temp_engageable"] = thermal_status < ThermalStatus.red
# ensure device is fully booted
startup_conditions["device_booted"] = startup_conditions.get("device_booted", False) or HARDWARE.booted()
# if the temperature enters the danger zone, go offroad to cool down
onroad_conditions["device_temp_good"] = thermal_status < ThermalStatus.danger
extra_text = f"{offroad_comp_temp:.1f}C"

View File

@ -23,6 +23,9 @@ class HardwareBase(ABC):
except Exception:
return default
def booted(self) -> bool:
return True
@abstractmethod
def reboot(self, reason=None):
pass

View File

@ -74,6 +74,11 @@ def sudo_write(val, path):
# fallback for debugfs files
os.system(f"sudo su -c 'echo {val} > {path}'")
def sudo_read(path: str) -> str:
try:
return subprocess.check_output(f"sudo cat {path}", shell=True, encoding='utf8')
except Exception:
return ""
def affine_irq(val, action):
irqs = get_irqs_for_action(action)
@ -554,6 +559,12 @@ class Tici(HardwareBase):
time.sleep(0.5)
gpio_set(GPIO.STM_BOOT0, 0)
def booted(self):
# this normally boots within 8s, but on rare occasions takes 30+s
encoder_state = sudo_read("/sys/kernel/debug/msm_vidc/core0/info")
if "Core state: 0" in encoder_state and (time.monotonic() < 60*2):
return False
return True
if __name__ == "__main__":
t = Tici()