mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-06 00:36:25 +08:00
fix TinyEnclosure transport
This commit is contained in:
@@ -220,7 +220,7 @@ class USBPCIDevice(PCIDevice):
|
||||
def __init__(self, devpref:str, dev, pcibus):
|
||||
self.pcibus, self.peer_group = pcibus, f"USBPCIDevice_{pcibus}"
|
||||
self.lock_fd = System.flock_acquire(f"{devpref.lower()}_{pcibus.lower()}.lock")
|
||||
usb = USB3(dev, 0x81, 0x83, 0x02, 0x04, use_bot=True)
|
||||
usb = USB3(dev, 0x81, 0x83, 0x02, 0x04)
|
||||
if DEBUG >= 1: print(f"am {self.pcibus}: product string: {usb.product!r}")
|
||||
self.usb: CustomASM24Controller | ASM24Controller = CustomASM24Controller(usb) if usb.is_custom else ASM24Controller(usb)
|
||||
self._bar_info = System.pci_setup_usb_bars(self.usb, gpu_bus=4, mem_base=0x10000000, pref_mem_base=(32 << 30))
|
||||
|
||||
@@ -5,6 +5,10 @@ from tinygrad.helpers import DEBUG, DEV, to_mv, round_up, OSX, getenv, ceildiv
|
||||
from tinygrad.runtime.support.hcq import MMIOInterface
|
||||
from tinygrad.runtime.support import c
|
||||
|
||||
CUSTOM_ASM24_PRODUCT_PREFIXES = ("custom", "USB 3.2 PCIe TinyEnclosure")
|
||||
|
||||
def is_custom_asm24_product(product:str) -> bool: return product.startswith(CUSTOM_ASM24_PRODUCT_PREFIXES)
|
||||
|
||||
def alloc_cbuffer(sz:int) -> tuple[ctypes.Array, memoryview]: return (buf:=(ctypes.c_ubyte * sz)()), to_mv(ctypes.addressof(buf), sz)
|
||||
def checked(fn, msg=None):
|
||||
@functools.wraps(fn)
|
||||
@@ -63,7 +67,7 @@ class USB3:
|
||||
checked(libusb.libusb_get_device_descriptor)(libusb.libusb_get_device(self.handle), ctypes.byref(_desc))
|
||||
_ret = checked(libusb.libusb_get_string_descriptor_ascii)(self.handle, _desc.iProduct, _buf, 256)
|
||||
self.product = bytes(_buf[:_ret]).decode("ascii", errors="replace")
|
||||
self.is_custom = self.product.startswith("custom")
|
||||
self.is_custom = is_custom_asm24_product(self.product)
|
||||
if self.is_custom: self.use_bot = use_bot = True
|
||||
|
||||
# Detach kernel driver if needed
|
||||
|
||||
Reference in New Issue
Block a user