Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save schuds/687cfd43e24cb26101ac815e29c0a11b to your computer and use it in GitHub Desktop.
Save schuds/687cfd43e24cb26101ac815e29c0a11b to your computer and use it in GitHub Desktop.
Install Coral AI PCIe Edge TPU on Raspberry Pi 5
#!/bin/bash
# Install vim, curl, and wget using apt-get
# - vim: A text editor
# - curl: A tool to transfer data from or to a server
# - wget: A network downloader
# The '-y' flag automatically answers 'yes' to prompts
sudo apt-get install vim curl wget -y
# Add the Google Coral Edge TPU repository to the system's source list
# This repository contains packages specifically for the Coral Edge TPU
echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list
# Download and add the Google GPG key to the system
# This key is used to ensure the integrity and authenticity of the packages
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
# Update the package lists for packages that need upgrading, as well as new packages that have just come to the repositories
sudo apt-get update
sudo apt-get install raspberrypi-kernel-headers -y
sudo apt-get install dh-dkms devscripts git -y
sudo apt-get install devscripts debhelper -y
git clone https://github.com/google/gasket-driver.git
# Install the Gasket driver and Edge TPU runtime
# - gasket-dkms: The kernel module for Google's Gasket driver framework
# - libedgetpu1-std: Standard version of the Edge TPU runtime library
sudo apt-get install gasket-dkms -y
sudo apt-get install libedgetpu1-std -y
cd gasket-driver; debuild -us -uc -tc -b; cd ..
sudo dpkg -i gasket-dkms_1.0-18_all.deb
sudo modprobe gasket
sudo modprobe apex
# Add 'kernel=kernel8.img' to the boot configuration
# This sets the kernel image to be used by the Raspberry Pi
echo "kernel=kernel8.img" | sudo tee -a /boot/firmware/config.txt
# Back up the current Device Tree Blob (DTB) file for Raspberry Pi
# A DTB is a binary file that contains hardware information used by the operating system
sudo cp /boot/firmware/bcm2712-rpi-5-b.dtb /boot/firmware/bcm2712-rpi-5-b.dtb.bak
# Decompile the DTB into a Device Tree Source (DTS) file for editing
# - Ignore any warnings during decompilation
sudo dtc -I dtb -O dts /boot/firmware/bcm2712-rpi-5-b.dtb -o ~/test.dts
# Modify the Device Tree Source
# Replace 'msi-parent' value to change the Message Signaled Interrupts (MSI) parent setting
sudo sed -i '/pcie@110000 {/,/msi-parent = <0x2[fc]>;/{s/<0x2f>/<0x67>/; s/<0x2c>/<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
# Reboot the system to apply changes
sudo reboot now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment