Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save dataslayermedia/714ec5a9601249d9ee754919dea49c7e to your computer and use it in GitHub Desktop.

Select an option

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

Gus1994 commented Mar 30, 2024 •

Copy link
Copy Markdown

ghost commented Apr 2, 2024

Copy link
Copy Markdown

@Gus1994 @dataslayermedia @askpatrickw @ezaul i am getting this error
mv: failed to preserve ownership for '/boot/firmware/bcm2712-rpi-5-b.dtb': Operation not permitted
sudo mv ~/test.dtb /boot/firmware/bcm2712-rpi-5-b.dtb
can someone please help me i have a project and my Raspberry pi is not able to recognize the peripheral device

@mjforan

mjforan commented Apr 2, 2024 •

Copy link
Copy Markdown

mv: failed to preserve ownership for '/boot/firmware/bcm2712-rpi-5-b.dtb': Operation not permitted sudo mv ~/test.dtb /boot/firmware/bcm2712-rpi-5-b.dtb

It's just saying it had to change permissions while moving the file. If you check the destination folder it should be there.

ghost commented Apr 2, 2024 •

Copy link
Copy Markdown

@mjforan but the problem is that i cannot check the destination folder as it is not even a folder rather its a device tree file in which made changes
these are the commands that i followed
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>/<0x66>/; s/<0x2c>/<0x66>/}' ~/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

now the problem is that it is still not recognizing my TPU
and i have made changes of 67 instead of 66 as said above
the script is also outdated if you can tell me your way of recognizing if you can for pineberry
as one of my friends had a NVME base and a M B/E key it worked fine for him just using the offical coral documentation but for me who has the "official pineberry stuff" it is not working i have even contacted the pineberry customer care they gave me link to this git repo
if someone can please HELPPPPP!!!!!!!!!!!!!!!!!!

@mjforan

mjforan commented Apr 2, 2024

Copy link
Copy Markdown

@ChetanKukreja

the problem is that i cannot check the destination folder as it is not even a folder rather its a device tree file in which made changes

You are using the mv command, which takes two arguments. The first argument is the source path and the second is the destination. You can use the ls command on the destination path to verify the file was moved correctly.

Did you reboot after applying these changes? Did you verify you are running the correct kernel? Have you installed the driver packages? Does the device show at all in lspci?

ghost commented Apr 2, 2024

Copy link
Copy Markdown
1231 @mjforan can you please guide me through this i have given you the image of the ls command also given you the reply when i lspci chetan@raspberrypi:~ $ lspci 00:00.0 PCI bridge: Broadcom Inc. and subsidiaries Device 2712 (rev 21) 01:00.0 Ethernet controller: Device 1de4:0001 (can you also tell me what do you mean by correct kernel)?

@mjforan

mjforan commented Apr 2, 2024

Copy link
Copy Markdown

@ChetanKukreja

You must think for yourself a little my friend. You can see in that image that the file you moved is there in the correct place.

Line 27 of the gist shows how to set the correct kernel version, and it can be verified by uname -r , making sure -v8 is at the end.

The TPU device does not show up in your lspci output. Make sure the hardware is connected properly.

ghost commented Apr 2, 2024

Copy link
Copy Markdown

@mjforan i will tell you in detail what i did till now and what is my terminal i am on
Linux raspberrypi 6.6.20+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.20-1+rpt1 (2024-03-07) aarch64 GNU/Linux
i followed the following commands
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
and then when it came to gasket it showed error so i installed gasket from a forum i found https://forum.proxmox.com/threads/update-error-with-coral-tpu-drivers.136888/#post-608975
using this i did install the gasket file also the libedgetpu1

now i followed this command
echo "kernel=kernel8.img" | sudo tee -a /boot/config.txt
but on opening found that /boot/config.txt is moved to /boot/firmware/config.txt
so made changes in that also
i added this from the jeffgerling blog
dtparam=pciex1
dtparam=pciex1_gen=2

now i executed the following commands sudo cp /boot/firmware/bcm2712-rpi-5-b.dtb /boot/firmware/bcm2712-rpi-5-b.dtb.bak

Decompile the current dtb (ignore warnings)

dtc -I dtb -O dts /boot/firmware/bcm2712-rpi-5-b.dtb -o ~/test.dts
and made changes to test.dtb
instead of 66 made it 67
then followed the following command
dtc -I dts -O dtb ~/test.dts -o ~/test.dtb
sudo mv ~/test.dtb /boot/firmware/bcm2712-rpi-5-b.dtb

after that i dont get a coral device

@mjforan

mjforan commented Apr 2, 2024

Copy link
Copy Markdown

@ChetanKukreja
How is the coral device connected to your raspberry pi?

ghost commented Apr 2, 2024 •

Copy link
Copy Markdown

@mjforan
WhatsApp Image 2024-04-03 at 00 09 16_606c623f
as you see the hat is getting power

@mjforan

mjforan commented Apr 2, 2024

Copy link
Copy Markdown

@ChetanKukreja Looks ok to me. I suggest creating a help post somewhere else (stack overflow, raspberry pi forum, etc.) because this gist is not an appropriate place for extensive debugging help.

@schuds

schuds commented Apr 2, 2024 •

Copy link
Copy Markdown

For any others experiencing the same issues I had, this helped:
google-coral/edgetpu#808 (comment)

For reference:
I followed Reddimus' guide.
I am on kernel 6.6.20 using the PineberryPi HatDrive! AI.
My issue was that my accelerator wasn't found (solved this using the aforementioned msi-parent = <0x67>).
My next issue was that gasket-dkms package would not correctly install.
What finally worked for me was the following from google-coral/edgetpu issue #808 as follows:

@themana

sudo apt update
sudo apt upgrade
sudo apt install devscripts debhelper -y

Then clone and the rest

❯ git clone https://github.com/google/gasket-driver.git
Cloning into 'gasket-driver'...
...
❯ cd gasket-driver; debuild -us -uc -tc -b; cd ..
...
dpkg-deb: building package 'gasket-dkms' in '../gasket-dkms_1.0-18_all.deb'.
...
❯ ls -l gasket-dkms*
-rw-r--r-- 1 dewet dewet 49000 Jan 17 13:17 gasket-dkms_1.0-18_all.deb
-rw-r--r-- 1 dewet dewet  1788 Jan 17 13:18 gasket-dkms_1.0-18_amd64.build
-rw-r--r-- 1 dewet dewet  5642 Jan 17 13:17 gasket-dkms_1.0-18_amd64.buildinfo
-rw-r--r-- 1 dewet dewet  1017 Jan 17 13:17 gasket-dkms_1.0-18_amd64.changes

You can install that .deb on any systems that need to build the kernel module, and it will be rebuilt automatically with newer kernel packages being installed:

❯ sudo dpkg -i gasket-dkms_1.0-18_all.deb
...
Setting up gasket-dkms (1.0-18) ...
...
Building for 6.5.0-14-generic
Building initial module for 6.5.0-14-generic
...
depmod...
Time: 0h:00m:10s
❯ sudo modprobe apex
❯ lsmod | grep apex
apex                   28672  0
gasket                135168  1 apex

Hope this also helps others in the same boat!

@schuds

schuds commented Apr 3, 2024 •

Copy link
Copy Markdown

Had to change line #29 to:
echo "kernel=kernel8.img" | sudo tee -a /boot/firmware/config.txt

@askpatrickw

Copy link
Copy Markdown

Had to change line #29 to: echo "kernel=kernel8.img" | sudo tee -a /boot/firmware/config.txt

Good catch for Raspbian OS latest on the RPI 5.

cat /boot/config.txt

DO NOT EDIT THIS FILE

The file you are looking for has moved to /boot/firmware/config.txt

@dasTholo

dasTholo commented Apr 4, 2024 •

Copy link
Copy Markdown

Yeaha! I have the Dual TPU Running at the AI Hat with bigs
thank you @feranick feranick GH Page and thank you @dataslayermedia for this script

a few changes at RPi5:

Linux escapepod 6.6.20+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.20-1+rpt1 (2024-03-07) aarch64 GNU/Linux

echo "kernel=kernel8.img" | sudo tee -a /boot/firmware/config.txt
echo "dtparam=pciex1" | sudo tee -a /boot/firmware/config.txt
echo "pciex1_gen=3" | sudo tee -a /boot/firmware/config.txt
Maybe this is possible in an Onliner

change dts stuff, thanks at @ChetanKukreja
sudo sed -i '/pcie@110000 {/,/msi-parent = <0x2[fc]>;/{s/<0x2f>/<0x67>/; s/<0x2c>/<0x67>/}' ~/test.dts

Python Modules @ Python 3.11:

python -c "import pycoral; print(pycoral.__version__)"
2.0.1
python -c "import tflite_runtime; print(tflite_runtime.__version__)"
2.16.1

i ve init my project with rye my pyproject.toml is like this

[project]
name = "coral-t"
version = "0.1.0"
description = "Add your description here"
dependencies = [
    "tflite-runtime @ https://github.com/feranick/TFlite-builds/releases/download/v.2.16.1/tflite_runtime-2.16.1-cp311-cp311-linux_aarch64.whl",
    "pycoral @ https://github.com/feranick/pycoral/releases/download/v2.0.1TF2.16.1/pycoral-2.0.1-cp311-cp311-linux_aarch64.whl",
]
readme = "README.md"
requires-python = ">= 3.11"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.rye]
managed = true
dev-dependencies = []

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
packages = ["src/coral_t"]

Output:

(coral-t) ➜ coral_t git:(master) ✗ python3 examples/classify_image.py
--model test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite
--labels test_data/inat_bird_labels.txt
--input test_data/parrot.jpg
----Debug2----
test_data/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite
----INFERENCE TIME----
Note: The first inference on Edge TPU is slow because it includes loading the model into Edge TPU memory.
12.9ms
2.7ms
2.7ms
2.7ms
2.7ms
-------RESULTS--------
Ara macao (Scarlet Macaw): 0.75781

@dasTholo

dasTholo commented Apr 4, 2024

Copy link
Copy Markdown

Next question is. How can i add the second tpu. I have an Dual TPU M2 Card but can only find /dev/apex_0

@mjforan

mjforan commented Apr 4, 2024

Copy link
Copy Markdown

@dasTholo The Pi 5 only exposes one PCIe lane so you will need a HAT to multiplex both devices over the single lane. I don't think there are any dual-lane E HATs yet, but Pineberry Pi does make dual-slot HATs. You might be able to install two single-TPU devices, one A+E and one B+M key.

@dasTholo

dasTholo commented Apr 4, 2024

Copy link
Copy Markdown

@mjforan
That is sad. I didn't know that. I had specially ordered the DualTPU. But I don't quite understand (I haven't found any other docs on this yet) how you can address both TPUs on an x86, for example. As they are both on the same PCIe port.

I have the Pineberry with M-Key and E-Key
https://pineberrypi.com/products/hatdrive-ai-nvme-2230-2242-gen-2-coral-edge-tpu-for-raspberry-pi-5

If I understand you correctly, then I could put another TPU in the other slot? This one here?
https://coral.ai/products/m2-accelerator-bm/

@mjforan

mjforan commented Apr 4, 2024 •

Copy link
Copy Markdown

@dasTholo the m.2 specification is not just a single PCIe "port", but has many different configurations. The "key" is the shape of the connector. The A+E variant of the coral can plug in to the E key port on a computer which is commonly used for WiFi cards while the B+M variant can use the M key port typically used for SSDs. On the dual TPU version there are two separate PCIe devices, each of which requires a separate x1 PCIe interface (x1 means one lane). Even on larger computers, many E-key ports only have one PCIe interface - the coral page you linked to notes:

Although the M.2 Specification (section 5.1.2) declares E-key sockets provide two instances of PCIe x1, most manufacturers provide only one. To use both Edge TPUs, be sure your socket connects both instances to the host.

If I understand you correctly, then I could put another TPU in the other slot? This one here? https://coral.ai/products/m2-accelerator-bm/

Exactly. You will need to cut down the TPU to get it to fit (it is designed to do that). I can't personally guarantee that this will work - you might want to ask Pineberry Pi before buying another TPU. Let us know if it does work out for you!

@dataslayermedia

Copy link
Copy Markdown
Author

@mjforan That is sad. I didn't know that. I had specially ordered the DualTPU. But I don't quite understand (I haven't found any other docs on this yet) how you can address both TPUs on an x86, for example. As they are both on the same PCIe port.

I have the Pineberry with M-Key and E-Key https://pineberrypi.com/products/hatdrive-ai-nvme-2230-2242-gen-2-coral-edge-tpu-for-raspberry-pi-5

If I understand you correctly, then I could put another TPU in the other slot? This one here? https://coral.ai/products/m2-accelerator-bm/

The dual TPU requires special considerations you need a specific adapter as well as a motherboard that will allow it. Magic Blue Smoke makes available a range of such adapters here.

But getting it to work on a Raspberry Pi 5 introduces yet another obstacle you would need a PCIe expansion slot and even then it's likely the motherboard will only make one TPU available. But I will try that soon to determine if it works.

@dataslayermedia

Copy link
Copy Markdown
Author

I fixed the script as of April 7th, it looks like the gasket package now needs some finessing to work on the RPI. But the latest revision worked for me.

@DrFurunkel

Copy link
Copy Markdown

@dataslayermedia Thanks for the script. I set up this for a friend. I tested this against a fresh install and in addition to your script, I had to do following two steps in advance.

  • "apt install dkms"
  • Switching to X11 instead of Wayland using the raspi-config tool. Otherwise there was no GUI anymore, after reboot. Didn't found the root cause. Might be related to the HDMI Display type.

@garylzimmer

garylzimmer commented Apr 17, 2024 •

Copy link
Copy Markdown

I ran into trouble with this script today with a fresh install of Rasp Pi OS on Rasp Pi 5. I believe the HAT is correctly installed considering the LED on it is green. Here's what I believe to be the relevant logs:

Setting up gasket-dkms (1.0-18) ...
Removing old gasket-1.0 DKMS files...
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.20+rpt-rpi-2712 6.6.20+rpt-rpi-v8
Building initial module for 6.6.20+rpt-rpi-2712
Deprecated feature: REMAKE_INITRD (/var/lib/dkms/gasket/1.0/source/dkms.conf)
Error! Bad return status for module build on kernel: 6.6.20+rpt-rpi-2712 (aarch64)
Consult /var/lib/dkms/gasket/1.0/build/make.log for more information.
dpkg: error processing package gasket-dkms (--configure):
 installed gasket-dkms package post-installation script subprocess returned error exit status 10

Errors were encountered while processing:
 gasket-dkms

E: Sub-process /usr/bin/dpkg returned an error code (1)


DKMS make.log for gasket-1.0 for kernel 6.6.20+rpt-rpi-v8 (aarch64)
Tue 16 Apr 22:56:32 EDT 2024
make: Entering directory '/usr/src/linux-headers-6.6.20+rpt-rpi-v8'
/var/lib/dkms/gasket/1.0/build/gasket core.o
/var/lib/dkms/gasket/1.0/build/gasket_ioctl.o
/var/lib/dkms/gasket/1.0/build/gasket_interrupt.o
/var/lib/dkms/gasket/1.0/build/gasket_page_table.o
/var/lib/dkms/gasket/1.0/build/gasket_sysfs.o
/var/lib/dkms/gasket/1.0/build/apex_driver.o
/var/lib/dkms/gasket/1.0/build/apex_driver.c: 1143:12: warning: 'apex_pci_resume' defined but not used [-Wunused-function]
1143 | static int apex pci_resume (struct pci_dev *pci_dev)

/var/lib/dkms/gasket/1.0/build/apex_driver.c: 1128:12: warning: 'apex_pci_suspend' defined but not used [-Wunused-function]
1128 | static int apex pci_suspend (struct pci_dev *pci_dev, pm_message_t state) {

/var/lib/dkms/gasket/1.0/build/apex.o
/var/lib/dkms/gasket/1.0/build/gasket.o
MODPOST /var/lib/dkms/gasket/1.0/build/Module. symvers
/var/lib/dkms/gasket/1.0/build/gasket.mod.o
/var/lib/dkms/gasket/1.0/build/apex.mod. o
/var/lib/dkms/gasket/1.0/build/apex. ko
/var/lib/dkms/gasket/1.0/build/gasket. ko
make: Leaving directory '/usr/src/linux-headers-6.6.20+rpt-rpi-v8'

EDIT: I read the whole thread and used these commands before re-running the script and it seems to have worked!

https://gist.github.com/dataslayermedia/714ec5a9601249d9ee754919dea49c7e?permalink_comment_id=5010019#gistcomment-5010019

sudo apt update
sudo apt upgrade
sudo apt install devscripts debhelper -y

@pierslawson

pierslawson commented Apr 27, 2024 •

Copy link
Copy Markdown

Hi

Thankyou for creating this. I have been using it to install onto the Raspberry Pi OS Lite (64bit). I don't know if there are more things missing on the Lite version that the script relies on, but the build of gasket fails. When I repeat the build I got this:

sudo debuild -us -uc -tc -b
dpkg-buildpackage -us -uc -ui -tc -b
dpkg-buildpackage: info: source package gasket-dkms
dpkg-buildpackage: info: source version 1.0-18
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by Coral <coral-support@google.com>
dpkg-source --before-build .
dpkg-buildpackage: info: host architecture arm64
dpkg-checkbuilddeps: error: Unmet build dependencies: dkms
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)
debuild: fatal error at line 1182:
dpkg-buildpackage -us -uc -ui -tc -b failed

After a few attempts, I found that running before running your script meant it worked:

sudo apt-get install raspberrypi-kernel-headers

@askpatrickw

Copy link
Copy Markdown

@pierslawson, are you seeing /dev/apex0 when you're done? I get successful builds but the Coral is not showing up as far as I can tell. Just looking for someone to confirm OS-Lite is working for them. ty!

@pierslawson

Copy link
Copy Markdown

Yes, I see /dev/apex_0 One thing to check is that you can see the device before you do anything else (i.e. on a fresh install of the OS. At first I wasn't seeing it and assumed that was normal if the driver had not yet been installed. However, after disconnecting and reconnecting the hat (whilst reformatting the SD card for about the 10th time) I happened to notice it was there before the script had been run. Then after updating the headers first, it all worked.

Note this is where I got the idea for updating the headers: https://gist.github.com/Reddimus/c6948d08a4f4b54ee9d075270bd79c3b
However use dataslayermedia's script as it is been modified since reddimus branched it.

@scaredyfish

Copy link
Copy Markdown

I've been having trouble getting this working. I get nothing in lspci:

00:00.0 PCI bridge: Broadcom Inc. and subsidiaries Device 2712 (rev 21)
01:00.0 Ethernet controller: Device 1de4:0001

Firstly, I think the I think the msi-parent value has changed again, so just to clarify, I want msi-parent to match the phandle, right?

pcie@110000 {
			compatible = "brcm,bcm2712-pcie";
			reg = <0x10 0x110000 0x00 0x9310>;
			device_type = "pci";
			max-link-speed = <0x02>;
			#address-cells = <0x03>;
			#interrupt-cells = <0x01>;
			#size-cells = <0x02>;
			interrupt-parent = <0x01>;
			interrupts = <0x00 0xdf 0x04 0x00 0xe0 0x04>;
			interrupt-names = "pcie\0msi";
			interrupt-map-mask = <0x00 0x00 0x00 0x07>;
			interrupt-map = <0x00 0x00 0x00 0x01 0x01 0x00 0xdb 0x04 0x00 0x00 0x00 0x02 0x01 0x00 0xdc 0x04 0x00 0x00 0x00 0x03 0x01 0x00 0xdd 0x04 0x00 0x00 0x00 0x04 0x01 0x00 0xde 0x04>;
			resets = <0x2c 0x07 0x2c 0x2b 0x2d>;
			reset-names = "swinit\0bridge\0rescal";
			msi-controller;
			msi-parent = <0x6d>;
			ranges = <0x2000000 0x00 0x00 0x1b 0x00 0x00 0xfffffffc 0x43000000 0x04 0x00 0x18 0x00 0x03 0x00>;
			dma-ranges = <0x3000000 0x10 0x00 0x00 0x00 0x10 0x00>;
			brcm,enable-l1ss;
			status = "disabled";
			phandle = <0x6d>;
		};

But it's still not working - in dmesg I get nothing about apex, but I get this:

brcm-pcie 1000110000.pcie: link down

Just to clarify - should lspci show the device before starting? And if it doesn't show it's likely a hardware fault or physical installation issue - is that correct?

@ezaul

ezaul commented May 6, 2024 •

Copy link
Copy Markdown

I've been having trouble getting this working. I get nothing in lspci:

00:00.0 PCI bridge: Broadcom Inc. and subsidiaries Device 2712 (rev 21)
01:00.0 Ethernet controller: Device 1de4:0001

Firstly, I think the I think the msi-parent value has changed again, so just to clarify, I want msi-parent to match the phandle, right?

pcie@110000 {
			compatible = "brcm,bcm2712-pcie";
			reg = <0x10 0x110000 0x00 0x9310>;
			device_type = "pci";
			max-link-speed = <0x02>;
			#address-cells = <0x03>;
			#interrupt-cells = <0x01>;
			#size-cells = <0x02>;
			interrupt-parent = <0x01>;
			interrupts = <0x00 0xdf 0x04 0x00 0xe0 0x04>;
			interrupt-names = "pcie\0msi";
			interrupt-map-mask = <0x00 0x00 0x00 0x07>;
			interrupt-map = <0x00 0x00 0x00 0x01 0x01 0x00 0xdb 0x04 0x00 0x00 0x00 0x02 0x01 0x00 0xdc 0x04 0x00 0x00 0x00 0x03 0x01 0x00 0xdd 0x04 0x00 0x00 0x00 0x04 0x01 0x00 0xde 0x04>;
			resets = <0x2c 0x07 0x2c 0x2b 0x2d>;
			reset-names = "swinit\0bridge\0rescal";
			msi-controller;
			msi-parent = <0x6d>;
			ranges = <0x2000000 0x00 0x00 0x1b 0x00 0x00 0xfffffffc 0x43000000 0x04 0x00 0x18 0x00 0x03 0x00>;
			dma-ranges = <0x3000000 0x10 0x00 0x00 0x00 0x10 0x00>;
			brcm,enable-l1ss;
			status = "disabled";
			phandle = <0x6d>;
		};

But it's still not working - in dmesg I get nothing about apex, but I get this:

brcm-pcie 1000110000.pcie: link down

Just to clarify - should lspci show the device before starting? And if it doesn't show it's likely a hardware fault or physical installation issue - is that correct?

Hello, what version of the kernel are you using?

uname -ra ?

I'm using 6.6.29-v8-16k+ #1760 SMP PREEMPT Mon Apr 29 14:44:20 BST 2024 aarch64 GNU/Linux and PCIe devices also stopped working

@lukaszraczylo

lukaszraczylo commented May 6, 2024 •

Copy link
Copy Markdown

I can confirm that with the current kernel - 6.6.28+rpt-rpi-v8

[    1.473214] brcm-pcie 1000110000.pcie: host bridge /axi/pcie@110000 ranges:
[    1.480216] brcm-pcie 1000110000.pcie:   No bus range found for /axi/pcie@110000, using [bus 00-ff]
[    1.489758] brcm-pcie 1000110000.pcie:      MEM 0x1b00000000..0x1bfffffffb -> 0x0000000000
[    1.498061] brcm-pcie 1000110000.pcie:      MEM 0x1800000000..0x1affffffff -> 0x0400000000
[    1.506361] brcm-pcie 1000110000.pcie:   IB MEM 0x0000000000..0x0fffffffff -> 0x1000000000
[    1.515832] brcm-pcie 1000110000.pcie: Forcing gen 3
[    1.520819] brcm-pcie 1000110000.pcie: Unable to find MSI PCI address
[    1.527284] brcm-pcie: probe of 1000110000.pcie failed with error -22
[    1.533802] brcm-pcie 1000120000.pcie: host bridge /axi/pcie@120000 ranges:
[    1.540792] brcm-pcie 1000120000.pcie:   No bus range found for /axi/pcie@120000, using [bus 00-ff]
[    1.549879] brcm-pcie 1000120000.pcie:      MEM 0x1f00000000..0x1ffffffffb -> 0x0000000000
[    1.558176] brcm-pcie 1000120000.pcie:      MEM 0x1c00000000..0x1effffffff -> 0x0400000000
[    1.566477] brcm-pcie 1000120000.pcie:   IB MEM 0x1f00000000..0x1f003fffff -> 0x0000000000
[    1.574775] brcm-pcie 1000120000.pcie:   IB MEM 0x0000000000..0x0fffffffff -> 0x1000000000
[    1.584227] brcm-pcie 1000120000.pcie: Forcing gen 2
[    1.589405] brcm-pcie 1000120000.pcie: PCI host bridge to bus 0000:00

Update #1: wget https://github.com/raspberrypi/firmware/raw/master/boot/bcm2712-rpi-5-b.dtb and moving the file mv bcm2712-rpi-5-b.dtb /boot/firmware/bcm2712-rpi-5-b.dtb then rebooting did the trick - /dev/apex_0 is an actual device now.

@scaredyfish

Copy link
Copy Markdown

@lukaszraczylo @ezaul I think this is because the msi-parent now needs to be 0x6d in the latest updates

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