Skip to content

Instantly share code, notes, and snippets.

@azsde
Created December 22, 2024 12:43
Show Gist options
  • Save azsde/ea4337f7999744eb0b7f9e63d3dce386 to your computer and use it in GitHub Desktop.
Save azsde/ea4337f7999744eb0b7f9e63d3dce386 to your computer and use it in GitHub Desktop.
Google Coral Init Automation on Proxmox

USB Google Coral Automation on Proxmox

Google did some weird stuff with their Google Coral USB, it has two different VID:PID depending on if the device has been initialized or not, which can cause issues when automating USB passthrough to a VM. Here are the instruction to overcome said issues:

Init the google coral automatically

  1. Go into /usr/local/bin/ and create a coral-init folder
cd /usr/local/bin
mkdir coral-init
cd coral-init
  1. Create a coral-init.sh script and copy paste the following:
#!/bin/bash

echo "Running Google Coral TPU Init Script $1" > /var/log/coral-init.log
lsusb | grep 18d1:9302 > /dev/null
if [ $? -eq 0 ]; then
    echo "Google Coral TPU already intialized!" | tee -a /var/log/coral-init.log
    exit 0
fi

lsusb | grep 1a6e:089a > /dev/null
if [ $? -ne 0 ]; then
    echo -e "Didn't detect uninitialized Google Coral TPU:\n$(lsusb)" | tee -a /var/log/coral-init.log
    exit 1
fi

echo "Initializing coral..." | tee -a /var/log/vm-pre-start.log
dfu-util -D /usr/local/bin/coral-init/apex_latest_single_ep.bin -d "1a6e:089a" -R
if [ $? -ne 251 ]; then
    echo "Error occured!" | tee -a /var/log/coral-init.log
    exit 2
fi

echo -e "Done! USBs:\n$(lsusb)" | tee -a /var/log/coral-init.log

Do not forget to make the script executable: chmod +x coral-init.sh

  1. Download coral firmware from google inside this folder:

wget https://github.com/google-coral/libedgetpu/raw/master/driver/usb/apex_latest_single_ep.bin

  1. Install dfu-util: apt install dfu-util

  2. Create a udev-rule to call the script automatically:

vim /etc/udev/rules.d/95-coral-init.rules

Paste the following: ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="1a6e", ATTR{idProduct}=="089a", RUN+="/usr/local/bin/coral-init/coral-init.sh"

Reload the udev rules: udevadm control --reload-rules && udevadm trigger

Now every time the google coral is plugged in, it will be initialized automatically

@drewclauson
Copy link

Google did some weird stuff with their Google Coral USB, it has two different VID:PID depending on if the device has been initialized or not, which can cause issues when automating USB passthrough to a VM.

This is the succinct statement that I've been looking for as to why this seems like it's so hard to do in Proxmox!

This was the final step I needed to get the Google Coral USB TPU automatically initializing after losing power and coming back online. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment