-
-
Save dataslayermedia/714ec5a9601249d9ee754919dea49c7e to your computer and use it in GitHub Desktop.
#!/bin/bash | |
cd / | |
sudo apt update | |
echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list | |
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - | |
sudo apt-get update | |
sudo apt-get install libedgetpu1-std | |
sudo apt install -y devscripts debhelper | |
sudo apt install dkms | |
sudo apt-get install dh-dkms | |
# Clone the Gasket driver repository | |
sudo git clone https://github.com/google/gasket-driver.git | |
# Change directory to the cloned repository | |
cd gasket-driver | |
# Build the Gasket driver package | |
sudo debuild -us -uc -tc -b | |
# Go back to the parent directory | |
cd .. | |
# Install the built Gasket driver package | |
sudo dpkg -i gasket-dkms_1.0-18_all.deb | |
sudo sh -c "echo 'SUBSYSTEM==\"apex\", MODE=\"0660\", GROUP=\"apex\"' >> /etc/udev/rules.d/65-apex.rules" | |
sudo groupadd apex | |
sudo adduser $USER apex | |
# Update the boot configuration for Raspberry Pi | |
echo "kernel=kernel8.img" | sudo tee -a /boot/firmware/config.txt | |
# Back up the Device Tree Blob (DTB) | |
sudo cp /boot/firmware/bcm2712-rpi-5-b.dtb /boot/firmware/bcm2712-rpi-5-b.dtb.bak | |
# Decompile the DTB into a DTS file | |
sudo dtc -I dtb -O dts /boot/firmware/bcm2712-rpi-5-b.dtb -o ~/test.dts | |
# Modify the Device Tree Source (DTS) | |
sudo sed -i '/pcie@110000 {/,/};/{/msi-parent = <[^>]*>;/{s/msi-parent = <[^>]*>;/msi-parent = <0x67>;/}}' ~/test.dts | |
# Recompile the DTS back into a DTB | |
sudo dtc -I dts -O dtb ~/test.dts -o ~/test.dtb | |
# Replace the old DTB with the new one | |
sudo mv ~/test.dtb /boot/firmware/bcm2712-rpi-5-b.dtb | |
sudo reboot now |
Confirming that the MPW7 hat does not work. The TPU appears at first but after installing the driver it disappears. The Pineberry Pi AI hat works.
MPW7 adapter works with TPU but (at least in my case) only at PCIe Gen1 speed
Just adding a comment to share that modifying the device tree (DTS of msi-parent of pcie@11000 set to 0x67) was the missing bit to make the dual TPU module to work.
My Coral Dual Edge TPU module is inserted into the Magic Smoke M.2 Dual Edge TPU adapter which sits inside the Pineboards Dual M.2 HAT (from the Hailo kit) leaving the smaller 30mm slot where the Hailo was empty, ready for the Raspberry Pi SSD.
I have 2 instances of Frigate running each using one TPU, this is on Ubuntu so I didn't seem to need to add the dtoverlay
or kernel
entries into the boot config as the page file is already on 4k and the external PCIe port and switch were detected out of box after updating the Pi's firmware.
Thanks for your effort guys.
@mateuszdrab there's no need to modify anything anymore :)
For Pi5's running Coral TPU add following to /boot/firmware/config.txt
:
dtparam=pciex1
dtparam=pciex1_gen=3
kernel=kernel8.img
dtoverlay=pineboards-hat-ai
then run:
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list
apt-get install -y gasket-dkms libedgetpu1-std
Restart the pi and it magically works 🥳
@mateuszdrab there's no need to modify anything anymore :) For Pi5's running Coral TPU add following to
/boot/firmware/config.txt
:dtparam=pciex1 dtparam=pciex1_gen=3 kernel=kernel8.img dtoverlay=pineboards-hat-ai
then run:
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list apt-get install -y gasket-dkms libedgetpu1-std
Restart the pi and it magically works 🥳
That could potentially be the case on Raspberry Pi OS but on Ubuntu it's not or at least was not for me.
Gasket would not install from apt due to some error so had to be compiled from source.
Kernel8 seems not needed since Ubuntu is on 4k page size anyway, dtoverlay did not work since the file is not found but the device is found in lspci anyway
Without changing the device tree msi-parent option the card would be detected by lspci but Frigate was not able to initialize it and I saw interrupt errors in dmesg.
Guessing that Ubuntu is behind a bit with the fixes.
thanks! that only worked for me.

i put my coral tpu m.2 here -
and was sceptical to start it working but did:

i also followed steps:
and use feranick to work it on python3.11.
have to downgrade numpy==1.26.4
before that i could see device /dev/apex_0 but inference gave me 'Failed to load delegate from libedgetpu.so.1'