mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-22 17:43:47 +08:00
Update flash.py
This commit is contained in:
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user