From bdbaf6f074523162bef86da10e68f4b633899da4 Mon Sep 17 00:00:00 2001 From: royjr Date: Sat, 22 Aug 2026 00:47:46 -0400 Subject: [PATCH] Update flash.py --- openpilot/system/hardware/chestnut/flash.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openpilot/system/hardware/chestnut/flash.py b/openpilot/system/hardware/chestnut/flash.py index f0d828031d..802ed31618 100755 --- a/openpilot/system/hardware/chestnut/flash.py +++ b/openpilot/system/hardware/chestnut/flash.py @@ -105,7 +105,7 @@ def open_device(path): return os.open(f"/dev/bus/usb/{bus:03d}/{dev:03d}", os.O_RDWR) -def link_up() -> bool: +def link_up(reset: bool = False) -> bool: # asm enumerates on USB-C alone, gpu is only usable once pcie link is up try: path, _, _ = find_chestnut() @@ -115,6 +115,10 @@ def link_up() -> bool: except (OSError, RuntimeError): return False try: + if reset: + # a consumer killed mid device_fini leaves the link wedged, drop power to force a retrain + fcntl.ioctl(fd, USBDEVFS_CONTROL, Ctrl(0x40, 0xF3, 0, 0, 0, 2000, None)) + time.sleep(0.5) fcntl.ioctl(fd, USBDEVFS_CONTROL, Ctrl(0x40, 0xF3, 1, 0, 0, 2000, None)) buf = (ctypes.c_ubyte * 1)() fcntl.ioctl(fd, USBDEVFS_CONTROL, Ctrl(0xC0, 0xE4, 0xB450, 0, 1, 1000, ctypes.cast(buf, ctypes.c_void_p)))