Skip to content

Instantly share code, notes, and snippets.

@dataslayermedia
Last active November 27, 2024 03:33
Show Gist options
  • Save dataslayermedia/714ec5a9601249d9ee754919dea49c7e to your computer and use it in GitHub Desktop.
Save dataslayermedia/714ec5a9601249d9ee754919dea49c7e to your computer and use it in GitHub Desktop.
Install Coral AI PCIe Edge TPU on Raspberry Pi 5
#!/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
@sadontsev
Copy link

@mikegapinski you're the best.
It did indeed help. The driver is working now.

So now I'm wondering what exactly am I missing to see both cores (as I remember they're supposed to be displayed separately).
I'll try to look into it myself, however if you're got some ideas, you're welcome :)

@mikegapinski
Copy link

@sadontsev you need the HAT Ai Dual if you want to see two accelerators. This board has a PCIe switch for the Dual Edge TPU

@sadontsev
Copy link

@mikegapinski yeah, thanks. I was promised by the seller that mine would support it. But maybe it was a trick.

Here's some info

@mikegapinski
Copy link

@mikegapinski yeah, thanks. I was promised by the seller that mine would support it. But maybe it was a trick.

Here's some info

In theory it does support it, but not fully. The Dual Edge variant needs a dedicated board

@sadontsev
Copy link

sadontsev commented May 18, 2024

@mikegapinski yeah, you're right.

Upd, maybe I found what's wrong:
$ dmesg
...
[ 5496.544355] apex 0000:01:00.0: RAM did not enable within timeout (12000 ms)
[ 5496.544364] apex 0000:01:00.0: Error in device open cb: -110
...

Which may related to the connection issue. See comment section here
Yet, it was too early to celebrate. For whatever reason, the TPU cannot be identified yet either by Frigate or simple Python script (bare metal w/ pyenv or via Docker).
I even tried a clean OS installation on a spare card but didn't help.
I appreciate if someone can suggest the next steps here:

Frigate:
Relevant pieces of the config:
--device /dev/apex_0:/dev/apex_0 \

detectors:
  coral1:
    type: edgetpu
    device: pci:0

Error:

2024-05-18 13:47:27.411259143    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 160, in load_delegate
2024-05-18 13:47:27.411261273      delegate = Delegate(library, options)
2024-05-18 13:47:27.411262995    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 119, in __init__
2024-05-18 13:47:27.411264198      raise ValueError(capture.message)
2024-05-18 13:47:27.411265106  ValueError
2024-05-18 13:47:27.411306013  
2024-05-18 13:47:27.411308217  During handling of the above exception, another exception occurred:
2024-05-18 13:47:27.411309050  
2024-05-18 13:47:27.411310198  Traceback (most recent call last):
2024-05-18 13:47:27.411312272  [2024-05-18 13:47:15] frigate.comms.mqtt             ERROR   : Unable to publish to eyeofsauron/motion: client is not connected
2024-05-18 13:47:27.411313883    File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
2024-05-18 13:47:27.411314828      self.run()
2024-05-18 13:47:27.411316643    File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run
2024-05-18 13:47:27.411318772      self._target(*self._args, **self._kwargs)
2024-05-18 13:47:27.411320291    File "/opt/frigate/frigate/object_detection.py", line 102, in run_detector
2024-05-18 13:47:27.411321920      object_detector = LocalObjectDetector(detector_config=detector_config)
2024-05-18 13:47:27.411323939    File "/opt/frigate/frigate/object_detection.py", line 53, in __init__
2024-05-18 13:47:27.411350791      self.detect_api = create_detector(detector_config)
2024-05-18 13:47:27.411352828    File "/opt/frigate/frigate/detectors/__init__.py", line 18, in create_detector
2024-05-18 13:47:27.411366994      return api(detector_config)
2024-05-18 13:47:27.411375383    File "/opt/frigate/frigate/detectors/plugins/edgetpu_tfl.py", line 41, in __init__
2024-05-18 13:47:27.411377031      edge_tpu_delegate = load_delegate("libedgetpu.so.1.0", device_config)
2024-05-18 13:47:27.411378772    File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 162, in load_delegate
2024-05-18 13:47:27.411380198      raise ValueError('Failed to load delegate from {}\n{}'.format(
2024-05-18 13:47:27.411381568  ValueError: Failed to load delegate from libedgetpu.so.1.0

Python:

from tflite_runtime.interpreter import Interpreter, load_delegate

try:
    delegate = load_delegate('libedgetpu.so.1')
    print("Edge TPU delegate loaded successfully")

    interpreter = Interpreter(
        model_path='mobilenet_ssd_v2_coco_quant_postprocess_edgetpu.tflite',
        experimental_delegates=[delegate]
    )
    interpreter.allocate_tensors()
    print("Model loaded and tensors allocated")
except ValueError as e:
    print(f"Failed to load Edge TPU delegate: {e}")
    import traceback
    traceback.print_exc()
Traceback (most recent call last):
  File "test_tflite_edgetpu.py", line 4, in <module>
    delegate = load_delegate('libedgetpu.so.1')
  File "/home/max/.pyenv/versions/tpu-env-3.8/lib/python3.8/site-packages/tflite_runtime/interpreter.py", line 168, in load_delegate
    raise ValueError('Failed to load delegate from {}\n{}'.format(
ValueError: Failed to load delegate from libedgetpu.so.1

While the device is here and can be recognised:

(tpu-env-3.8) max@nasnew:~/tpu $ lspci -nn | grep 089a
0000:01:00.0 System peripheral [0880]: Global Unichip Corp. Coral Edge TPU [1ac1:089a]
(tpu-env-3.8) max@nasnew:~/tpu $ ls /dev/apex_*
/dev/apex_0

@mikegapinski
Copy link

This can happen if the board you use does not have proper routing and a high quality FPC cable: raspberrypi/linux#6126

That is why the kernel overlay is not for coral itself, it does not work on all PCIe hats.

You can check for dmesg errors, but I think this is the problem

@askpatrickw
Copy link

FYI: There is an updated rpi-source which fixes the "ERROR: Unexpected processor 4 (use --processor argument)" issue https://github.com/RPi-Distro/rpi-source I installed from master and it fixed it on my RPI 5.

@askpatrickw
Copy link

askpatrickw commented Jun 1, 2024

Todays attempt with a clean SD Card image from the Raspiberry Pi Image

I ran lines 1-46 Up to adding the user to the group and then rebooted.

~ $ uname -a
Linux frigate 6.6.31+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/Linux~ $ ls /dev/a*
/dev/apex_0  /dev/autofs
~ $ lspci -nn | grep 089a
0000:01:00.0 System peripheral [0880]: Global Unichip Corp. Coral Edge TPU [1ac1:089a]

@stephenljk
Copy link

Hi, I found out that when I upgrade to 6.6.31+rpt-rpi-v8

~ $ sudo lspci -vvv|grep -i MSI-X
	Capabilities: [d0] MSI-X: Enable- Count=128 Masked-
	Capabilities: [b0] MSI-X: Enable+ Count=61 Masked-

this will fail [d0] MSI-X: Enable-, going back to 6.6.20+rpt-rpi-v8 everything will work again (as in the sample in pycoral will run). Not sure if its related to your issue. Anyone know why it breaks when upgrade to 6.6.31+rpt-rpi-v8?

@stephenljk
Copy link

Following up on this, i use apt-mark to lock the kernel:

~ $ sudo apt-mark hold linux-headers-rpi-2712
linux-headers-rpi-2712 set on hold.
~ $ sudo apt-mark hold linux-headers-rpi-v8
linux-headers-rpi-v8 set on hold.
~ $ sudo apt-mark hold linux-image-rpi-2712
linux-image-rpi-2712 set on hold.
~ $ sudo apt-mark hold linux-image-rpi-v8
linux-image-rpi-v8 set on hold.
~ $ sudo apt-mark hold linux-libc-dev
linux-libc-dev set on hold.

after upgrade the kernel remain the same but the same issue occurs, so its some other package that got updated and cause the MSI-X issue

@sadontsev
Copy link

This can happen if the board you use does not have proper routing and a high quality FPC cable: raspberrypi/linux#6126

That is why the kernel overlay is not for coral itself, it does not work on all PCIe hats.

You can check for dmesg errors, but I think this is the problem

The Pineberry board has just arrived and it solved all of my problems. Works like magic.

It just works, both cores are visible and usable.

—-
I noticed a new kernel version is available. Do you know if it included everything required to let the hat work just from the box?

@alloydas
Copy link

alloydas commented Jul 4, 2024

This can happen if the board you use does not have proper routing and a high quality FPC cable: raspberrypi/linux#6126
That is why the kernel overlay is not for coral itself, it does not work on all PCIe hats.
You can check for dmesg errors, but I think this is the problem

The Pineberry board has just arrived and it solved all of my problems. Works like magic.

It just works, both cores are visible and usable.

—- I noticed a new kernel version is available. Do you know if it included everything required to let the hat work just from the box?

Hi @sadontsev can you please share which method you have followed? I checked in the Pineborads website, and it says to update the kernel. I am a little bit confused. Do I have to do that or not?

Thanks in advance

@19leva89
Copy link

19leva89 commented Jul 5, 2024

Good day when executing the command
curl -sS https://gist.githubusercontent.com/dataslayermedia/714ec5a9601249d9ee754919dea49c7e/raw/97eafd546f25b4add8b4e08d64afb5b50bc4449e/coral-ai-pcie-edge-tpu-raspberrypi-5-setup | bash

I get an error https://packages.cloud.google.com/apt/dists/coral-edgetpu-stable/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.

Deleting module gasket-1.0 completely from the DKMS tree.
Loading new gasket-1.0 DKMS files...
Deprecated feature: REMAKE_INITRD (/usr/src/gasket-1.0/dkms.conf)
Building for 6.6.36-v8+
Building initial module for 6.6.36-v8+
Deprecated feature: REMAKE_INITRD (/var/lib/dkms/gasket/1.0/source/dkms.conf)
Error! Bad return status for module build on kernel: 6.6.36-v8+ (aarch64)
Consult /var/lib/dkms/gasket/1.0/build/make.log for more information.
dpkg: error while processing package gasket-dkms (--configure):
 subprocess from package gasket-dkms script installed post-installation returned error code 10
Errors occurred while processing the following packages:
 gasket-dkms

Reply to command lspci -nn | grep 089a

0000:03:00.0 System peripheral [0880]: Global Unichip Corp. Coral Edge TPU [1ac1:089a]
0000:04:00.0 System peripheral [0880]: Global Unichip Corp. Coral Edge TPU [1ac1:089a]

Reply to command ls /dev/apex_0
ls: cannot access '/dev/apex_0': No such file or directory

I use this board Dual Edge Coral TPU Bundle for Raspberry Pi 5 with Home Assistant and Frigate

@mikegapinski
Copy link

Error! Bad return status for module build on kernel: 6.6.36-v8+ (aarch64)

This is the actual error, the kernel module failed to build. Since you are using Home Assistant OS the steps could be different. Can you post the contents of /var/lib/dkms/gasket/1.0/build/make.log? The script you used for install is slightly outdated too, please refer to our install guide: https://pineboards.io/blogs/tutorials/how-to-configure-the-google-coral-edge-tpu-on-the-raspberry-pi-5. If you get stuck anywhere I'll reproduce and update our tutorial as well.

As far as I remember 6.6.30+ is now available from apt since it is also required for the Hailo 8L TPU, so kernel upgrade does not require rpi-source

@19leva89
Copy link

19leva89 commented Jul 5, 2024

Error! Bad return status for module build on kernel: 6.6.36-v8+ (aarch64)

This is the actual error, the kernel module failed to build. Since you are using Home Assistant OS the steps could be different. Can you post the contents of /var/lib/dkms/gasket/1.0/build/make.log? The script you used for install is slightly outdated too, please refer to our install guide: https://pineboards.io/blogs/tutorials/how-to-configure-the-google-coral-edge-tpu-on-the-raspberry-pi-5. If you get stuck anywhere I'll reproduce and update our tutorial as well.

As far as I remember 6.6.30+ is now available from apt since it is also required for the Hailo 8L TPU, so kernel upgrade does not require rpi-source

DKMS make.log for gasket-1.0 for kernel 6.6.36-v8+ (aarch64)
Fri 05 Jul 2024 23:21:47 EEST
make: entering directory "/home/pi/linux-3b42260d2130b5ca110c5340ab2bd055eede5968"

 ERROR: Kernel configuration is invalid.
 include/generated/autoconf.h or include/config/auto.conf are missing.
 Run 'make oldconfig && make prepare' on kernel src to fix it.

make[1]: *** [/home/pi/linux-3b42260d2130b5ca110c5340ab2bd055eede5968/Makefile:806: include/config/auto.conf] Error 1
make: *** [Makefile:234: __sub-make] Error 2
make: exit directory "/home/pi/linux-3b42260d2130b5ca110c5340ab2bd055eede5968"

@19leva89
Copy link

19leva89 commented Jul 5, 2024

When I use this instruction https://pineboards.io/blogs/tutorials/how-to-configure-the-google-coral-edge-tpu-on-the-raspberry-pi-5 I also get an warning when Import the repository GPG key:

 curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
100  2659  100  2659    0     0   9308      0 --:--:-- --:--:-- --:--:--  9297
OK

@19leva89
Copy link

19leva89 commented Jul 6, 2024

In the morning, with a fresh head and new thoughts, I installed a new clean Linux raspberrypi 6.6.31+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/Linux and did everything as written in https://pineboards.io/blogs/tutorials/how-to-configure-the-google-coral-edge-tpu-on-the-raspberry-pi-5 and wow, everything worked!

pi@raspberrypi:~ $ ls /dev/apex_*
/dev/apex_0  /dev/apex_1

@alloydas
Copy link

alloydas commented Jul 6, 2024

In the morning, with a fresh head and new thoughts, I installed a new clean Linux raspberrypi 6.6.31+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/Linux and did everything as written in https://pineboards.io/blogs/tutorials/how-to-configure-the-google-coral-edge-tpu-on-the-raspberry-pi-5 and wow, everything worked!

pi@raspberrypi:~ $ ls /dev/apex_*
/dev/apex_0  /dev/apex_1

Hello, @19leva89 I have completed that step and now when I am going to install Pycoral I cannot install it have you tried this one? I want to run Ultralytics YOLO v8.

Thanks in advance

@19leva89
Copy link

19leva89 commented Jul 6, 2024

In the morning, with a fresh head and new thoughts, I installed a new clean Linux raspberrypi 6.6.31+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/Linux and did everything as written in https://pineboards.io/blogs/tutorials/how-to-configure-the-google-coral-edge-tpu-on-the-raspberry-pi-5 and wow, everything worked!

pi@raspberrypi:~ $ ls /dev/apex_*
/dev/apex_0  /dev/apex_1

Hello, @19leva89 I have completed that step and now when I am going to install Pycoral I cannot install it have you tried this one? I want to run Ultralytics YOLO v8.

Thanks in advance

No I haven't tried that, I use Home Assistant with Frigate

@mikegapinski
Copy link

mikegapinski commented Jul 6, 2024 via email

@alloydas
Copy link

alloydas commented Jul 9, 2024

Jeff Geerling has a great article for PyCoral with Docker, very easy setup: https://www.jeffgeerling.com/blog/2023/testing-coral-tpu-accelerator-m2-or-pcie-docker Wysyłane z aplikacji Outlook dla systemu iOShttps://aka.ms/o0ukef

________________________________ Od: 19leva89 @.> Wysłane: Saturday, July 6, 2024 9:52:46 AM Do: 19leva89 @.> DW: Comment @.> Temat: Re: dataslayermedia/coral-ai-pcie-edge-tpu-raspberrypi-5-setup @19leva89 commented on this gist.
________________________________ In the morning, with a fresh head and new thoughts, I installed a new clean Linux raspberrypi 6.6.31+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/Linux and did everything as written in https://pineboards.io/blogs/tutorials/how-to-configure-the-google-coral-edge-tpu-on-the-raspberry-pi-5 and wow, everything worked! @.
:~ $ ls /dev/apex_* /dev/apex_0 /dev/apex_1 Hello, @19leva89https://github.com/19leva89 I have completed that step and now when I am going to install Pycoral I cannot install it have you tried this one? I want to run Ultralytics YOLO v8. Thanks in advance No I haven't tried that, I use Home Assistant with Frigate — Reply to this email directly, view it on GitHubhttps://gist.github.com/dataslayermedia/714ec5a9601249d9ee754919dea49c7e#gistcomment-5112804 or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAHDCBYOEBG3IHFHCKJLCR3ZK6O47BFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTENZVGYZDEMJUU52HE2LHM5SXFJTDOJSWC5DF. You are receiving this email because you commented on the thread. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Thank you @mikegapinski that solution works for me.

Thanks a lot

@marcoscunha
Copy link

Hi all,

I have the Dual Coral TPU with Pineberry board and a raspberry pi 5.
The kernel version is 6.6.31+rpt-rpi-v8 and the distro is the Debian Bookworm Lite.

Changing the DTS of msi-parent of pcie@11000 from 0x027 to 0x66 or 0x67 did not work for me.
I need indeed to change it to 0x6e, which is the value on phandle, to make it works.

Thanks for this discussion!

@marcoscunha
Copy link

Hello,

I rollback the modifications made on my own to DTS to keep raspberry pi's original version.

I want to test device tree overlay proposed by the supplier.

I just add the line dtoverlay=pineboards-hat-ai on /boot/firmware/config.txt,

If you have a kernel greater then 6.6.30 I recommend to use this method instead of modifying the DTS yourself.

Thanks @mikegapinski for the link to the tutorial.

@mikegapinski
Copy link

mikegapinski commented Jul 18, 2024 via email

@lukaszraczylo
Copy link

I can confirm it works with overlays.

      sudo apt-get install vim curl wget -y

      echo "deb [signed-by=/usr/share/keyrings/coral-edgetpu-archive-keyring.gpg] 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 gpg --dearmor -o /usr/share/keyrings/coral-edgetpu-archive-keyring.gpg

      sudo apt update

      sudo apt-get install gasket-dkms -y
      sudo apt-get install libedgetpu1-std -y

      echo -e "\nkernel=kernel8.img" | sudo tee -a /boot/firmware/config.txt
      echo -e "\ndtoverlay=pineboards-hat-ai" | sudo tee -a /boot/firmware/config.txt
      reboot

@Zen3515
Copy link

Zen3515 commented Aug 4, 2024

I've been using coral for 2 years now, today my apt update command suddenly failed with

Err:7 https://packages.cloud.google.com/apt coral-edgetpu-stable InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B53DC80D13EDEF05

Is it also happend to anyone else?

@zoldaten
Copy link

zoldaten commented Aug 5, 2024

Hi all,

I have the Dual Coral TPU with Pineberry board and a raspberry pi 5. The kernel version is 6.6.31+rpt-rpi-v8 and the distro is the Debian Bookworm Lite.

Changing the DTS of msi-parent of pcie@11000 from 0x027 to 0x66 or 0x67 did not work for me. I need indeed to change it to 0x6e, which is the value on phandle, to make it works.

Thanks for this discussion!

thanks! that only worked for me.
i put my coral tpu m.2 here -
2024-08-05_15h43_32

and was sceptical to start it working but did:
2024-08-05_15h41_28

i also followed steps:

sudo apt-get install devscripts
sudo apt install dh-dkms

*https://github.com/google/gasket-driver/issues/27
git clone https://github.com/google/gasket-driver.git
cd gasket-driver/
debuild -us -uc -tc -b
cd ..
sudo dpkg -i gasket-dkms_1.0-18_all.deb (package u built)


/boot/firmware/cmdline.txt
add:
pcie_aspm=off

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'

@astrizhkin
Copy link

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

@mateuszdrab
Copy link

mateuszdrab commented Oct 30, 2024

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.

@lukaszraczylo
Copy link

@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 🥳

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