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:
- Go into
/usr/local/bin/
and create acoral-init
folder
cd /usr/local/bin
mkdir coral-init
cd coral-init
- 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
- Download coral firmware from google inside this folder:
wget https://github.com/google-coral/libedgetpu/raw/master/driver/usb/apex_latest_single_ep.bin
-
Install dfu-util:
apt install dfu-util
-
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
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!