Coral EdgeTPU USB Support

I would appreciate your assistance in resolving an issue with recognizing the Coral EdgeTPU USB device in OpenWRT. It's a neat hardware accelerator that provides on-device machine learning inference capabilities for edge computing applications. It comes with documentation for on Raspberry Pi and Debian distro's, including a DKMS module.

Screenshot from 2023-06-15 18-43-57
Here's a summary of the problem and the steps I've taken so far:

Problem: The Coral EdgeTPU USB is not recognized with its proper description in OpenWRT.
Steps taken:

  1. Connected the Coral accelerator USB to my OpenWRT device.
  2. Ran the command lsusb -d 1a6e:089a -v and received 1a6e:089a without a device name.

Additional details:

  1. Tested on OpenWRT 22.03.3 , OpenWRT 23.05.0-rc1 and OpenWRT 22.03.5 with the same behavior.
  2. The Coral accelerator USB is recognized correctly 1a6e:089a Global Unichip Corp. on my Ubuntu workstation.

I kindly request your guidance and suggestions to troubleshoot and resolve this issue. Any insights into kernel modules, drivers, or configurations required for proper recognition of the Coral EdgeTPU USB in OpenWRT would be appreciated.

Verbose command output added below:

Bus 006 Device 004: ID 1a6e:089a  
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               3.10
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         9
  idVendor           0x1a6e 
  idProduct          0x089a 
  bcdDevice            1.00
  iManufacturer           0 
  iProduct                0 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x001b
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              896mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       254 
      bInterfaceSubClass      1 
      bInterfaceProtocol      2 
      iInterface              0 
      Device Firmware Upgrade Interface Descriptor:
        bLength                             9
        bDescriptorType                    33
        bmAttributes                        7
          Will Not Detach
          Manifestation Tolerant
          Upload Supported
          Download Supported
        wDetachTimeout                   1000 milliseconds
        wTransferSize                     256 bytes
        bcdDFUVersion                   1.01
Binary Object Store Descriptor:
  bLength                 5
  bDescriptorType        15
  wTotalLength       0x0016
  bNumDeviceCaps          2
  USB 2.0 Extension Device Capability:
    bLength                 7
    bDescriptorType        16
    bDevCapabilityType      2
    bmAttributes   0x00000006
      BESL Link Power Management (LPM) Supported
  SuperSpeed USB Device Capability:
    bLength                10
    bDescriptorType        16
    bDevCapabilityType      3
    bmAttributes         0x00
    wSpeedsSupported   0x000c
      Device can operate at High Speed (480Mbps)
      Device can operate at SuperSpeed (5Gbps)
    bFunctionalitySupport   2
      Lowest fully-functional device speed is High Speed (480Mbps)
    bU1DevExitLat          10 micro seconds
    bU2DevExitLat        2047 micro seconds
Device Status:     0x0000
  (Bus Powered)

Any help is appreciated!

What kernel module does it utilize in Ubuntu?

1 Like

Thank you for your reply. Could it be 'usbfs' ?

[Working] Libreelec:
This is what lsusb gives me when I plug it into a Raspberry Pi. It works without installing any additional software.

/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    ID 1d6b:0003 Linux Foundation 3.0 root hub
    |__ Port 1: Dev 3, If 0, Class=Vendor Specific Class, Driver=usbfs, 5000M
        ID 18d1:9302 Google Inc. 
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        ID 2109:3431 VIA Labs, Inc. Hub
        |__ Port 3: Dev 3, If 0, Class=Mass Storage, Driver=usb-storage, 480M
            ID 14cd:1212 Super Top microSD card reader (SY-T18)
        |__ Port 4: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
            ID 2571:4101  
        |__ Port 4: Dev 4, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
            ID 2571:4101 

[Not working] Openwrt, device is plugged at Bus 006 Device 005: :

/:  Bus 08.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M
    ID 1d6b:0003  
    |__ Port 1: Dev 2, If 0, Class=, Driver=uas, 5000M
        ID 0bc2:203a  
/:  Bus 07.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M
    ID 1d6b:0002  
/:  Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M
    ID 1d6b:0003  
    |__ Port 1: Dev 2, If 0, Class=, Driver=hub/4p, 5000M
        ID 2109:0817  
        |__ Port 2: Dev 5, If 0, Class=, Driver=, 5000M
            ID 1a6e:089a  
        |__ Port 4: Dev 3, If 0, Class=, Driver=hub/4p, 5000M
            ID 2109:0817  
/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M
    ID 1d6b:0002  
    |__ Port 1: Dev 2, If 0, Class=, Driver=hub/4p, 480M
        ID 2109:2817  
        |__ Port 1: Dev 3, If 0, Class=, Driver=mt76x0u, 480M
            ID 0e8d:7610  
        |__ Port 4: Dev 5, If 0, Class=, Driver=hub/4p, 480M
            ID 2109:2817  
            |__ Port 4: Dev 9, If 0, Class=, Driver=ftdi_sio, 12M
                ID 0403:6001  
            |__ Port 2: Dev 7, If 3, Class=, Driver=usbhid, 12M
                ID 413c:a503  
            |__ Port 2: Dev 7, If 1, Class=, Driver=snd-usb-audio, 12M
                ID 413c:a503  
            |__ Port 2: Dev 7, If 2, Class=, Driver=snd-usb-audio, 12M
                ID 413c:a503  
            |__ Port 2: Dev 7, If 0, Class=, Driver=snd-usb-audio, 12M
                ID 413c:a503  
            |__ Port 3: Dev 8, If 0, Class=, Driver=mt76x2u, 480M
                ID 0e8d:7612  
            |__ Port 1: Dev 6, If 0, Class=, Driver=cp210x, 12M
                ID 10c4:ea60  
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=ohci-platform/1p, 12M
    ID 1d6b:0001  
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=ohci-platform/1p, 12M
    ID 1d6b:0001  
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/1p, 480M
    ID 1d6b:0002  
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/1p, 480M
    ID 1d6b:0002  

can't actually find any specific kmod for it on my Fedora box (kernel 6.1),
perhaps you only need the generic kmods for usb support ....

1 Like

Thank you. I'll tinker a bit with those and report back.

A bit of a general Linux question next: I see in cat /sys/kernel/debug/usb/devices, that ProdID=089a has no S: Product= string, but on other machines it has. I wonder if you have observed S: Product= 'empty' before. Is this likely because of a kmod issue? Shouldn't the S: Product= populate regardless?

When I connect the device, dmesg throws: new SuperSpeed Gen 1 USB device number 4 using xhci-hcd
cat /sys/kernel/debug/usb/devices:

T:  Bus=05 Lev=03 Prnt=17 Port=00 Cnt=01 Dev#= 18 Spd=480  MxCh= 0
D:  Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=1a6e ProdID=089a Rev= 1.00
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=498mA
I:* If#= 0 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=02 Driver=(none)

cat /usr/share/hwdata/usb.ids | grep 1a6e
1a6e Global Unichip Corp.

Any tips on how to debug this further?

Doubt it, Coral USB doesn't need any non-generic kernel USB driver.
What it needs is userspace level runtime driver, i.e. libedgetpu. Looks like there is no libedgetpu package in OpenWRT, so you are on your own building it yourself.

Yes, and USB ID changes upon initialization by libedgetpu to "18d1:9302 Google Inc."

What is your OpenWRT hardware, are you sure you got enough resources to run this thing?
For one USB port has to provide quite a lot of power to run Coral at full speed, close to 1A, probably more during short spikes.

I'm using Coral USB to run video object detection in Frigate NVR. Such setup needs at least RPi4 or x64 level hardware.

2 Likes

Hi NotGood, thank you for sharing your insights!

If you have a moment, I would appreciate you plugging in your Coral in your OpenWRT machine to see if it identifies correctly under lsusb? (either as:
1a6e:089a Global Unichip Corp.
or
18d1:9302 Google Inc.

if not, also fine, but thanks for checking!

Mine doesn't have a description, see the image:

Notgood: Looks like there is no libedgetpu package in OpenWRT, so you are on your own building it yourself.:

Thanks for your suggestion! After that, I have found a edgetpu_runtime_20210726.zip and extracted two files from aarch64, which matches my architecture. I assume this is enough:

/usr/lib/libedgetpu.so.1
/usr/lib/libedgetpu.so.1.0

Notgood: Yes, and USB ID changes upon initialization by libedgetpu to "18d1:9302 Google Inc."

Thanks for clarifying about DKMS. I'm unsure about what is required to get the device working. I think it's important to highlight that, lsusb throws 1a6e:089a only. It's almost as if OpenWRT can't recognize the device. When I manually assign a driver, the binding doesn't seem to reach the bus.

root@OpenWrt:/sys/bus/usb/drivers/usbfs# echo "006 005" > bind
ash: write error: No such device

Notgood: What is your OpenWRT hardware, are you sure you got enough resources to run this thing?:

I suspect I do. it's a Rockwell ARM chip with 4gb memory (specs). It's running on a USB hub with external power source (DC 5V/2A).

Again, thank you for your insights, any help debugging this is welcome.

Can't do, it's 300+ km away, running in RPi4 on Ubuntu 22.04

Probably cosmetic issue, I doubt OpenWRT ships full udev database of known USB devices for space saving reasons, see lsusb man page:

lsusb is a utility for displaying information about USB buses in
the system and the devices connected to them. It uses udev's
hardware database to associate a full human-readable name to the
vendor ID and the product ID.

You'd need some userspace application to actually load libedgetpu library, initialize Coral, etc etc.
Quickest way to test is probably through PyCoral, it got some example python scripts, see official docs https://coral.ai/docs/accelerator/get-started#2-install-the-pycoral-library

...assuming you manage to install and run all the PyCoral python requirements on your R4S and Openwrt.

1 Like

Thank you! I didn't realize that lsusb worked like that. This gives me hope! However, I'm still worried about it not reporting any driver.

For now I'm trying to use the adapter as is.

PyCoral python requirements seem to get me into trouble with:
ModuleNotFoundError: No module named 'pycoral', installing with pip leads to old version. I need to investigate further.

My end goal is to run frigate, which I run in docker with usb mappings. when I change config to expect coral, it does put an INFO about TPU found, which fails immediately, log attached:

frigate-1  | 2023-06-16 16:49:14.972137489  Process detector:coral:
frigate-1  | 2023-06-16 16:49:14.972143323  [2023-06-16 16:49:14] frigate.detectors.plugins.edgetpu_tfl INFO    : TPU found
frigate-1  | 2023-06-16 16:49:14.972163739  [2023-06-16 16:49:14] frigate.detectors.plugins.edgetpu_tfl ERROR   : No EdgeTPU was detected. If you do not have a Coral device yet, you must configure CPU detectors.

Frigate docker image already includes own copy of libedgetpu, so it should be able to drive Coral without any additional tweaks on docker host OS.

Make sure you got USB access sorted out through, i.e. devices + privileged, here is a snippet from my docker-compose:

    privileged: true
    ....
    devices:
      - /dev/bus/usb:/dev/bus/usb
    ....
1 Like

Also, Frigate usually throws detailed stack trace in logs if it fails to access Coral USB for some reason.

1 Like

@notgood and @frollic : It's working!

There was an extra spacing in my path to ' /edgetpu_model.tflite' which caused the error I posted above. Removing it all together led to a working situation.

cat /sys/kernel/debug/usb/devices: (now populates with driver)

T:  Bus=06 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#= 12 Spd=5000 MxCh= 0
D:  Ver= 3.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs=  1
P:  Vendor=18d1 ProdID=9302 Rev= 1.00
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=896mA
I:* If#= 0 Alt= 0 #EPs= 6 Cls=ff(vend.) Sub=ff Prot=ff Driver=usbfs
E:  Ad=01(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=03(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=83(I) Atr=03(Int.) MxPS=  64 Ivl=125us

Again, thank you for your guidance, I learned a lot. Leaving my settings below in case someone stumbles on this post:

config.yml:

detectors:
  coral:
    type: edgetpu
    device: usb

docker-compose.yml

     devices:
       - /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions  

what hardware you are running Openwrt on?

it's a Rockwell ARM chip with 4gb memory (specs). It's running on a USB hub with external power source (DC 5V/2A).

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.