Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Coral Dev Linux kernel v5.x support

  • Currently Google coral dev runs on Mendel OS which supports Linux kernel v4.14
    • https://coral.googlesource.com/linux-imx/
  • linux-imx already support v5.4 for i.MX8
    • https://source.codeaurora.org/external/imx/linux-imx/
  • I've tried to build v5.10 from vanilla kernel source
    • Able to use the imx8mq-phanbell.dts dts
    • But, TPU PCI not recognized
    • More support required here?
  • When will Mendel OS (or Google Coral Dev) support Linux v5.x (Eg. v5.10, v5.4)?
like image 341
ChethanSuresh Avatar asked Aug 10 '26 19:08

ChethanSuresh


2 Answers

Google Coral Dev Edge TPU with linux-5.15.y

Background

  • Currently Mendel OS does not support v5.x kernel version
  • Able to boot Coral dev with linux-5.15.y.

Goal

  • Support Coral dev Edge TPU with linux-5.15.y kernel version

Build linux-5.15.y for Google Coral Dev

  • Clone https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
  • Checkout linux-5.15.y
$ git log --oneline -1 
81d8d30c35ed (HEAD -> linux-5.15.y, tag: v5.15.35, origin/linux-5.15.y) Linux 5.15.35

$ export ARCH=arm64; export CROSS_COMPILE=aarch64-linux-gnu-
$ make O=build defconfig 
$ make O=build menuconfig 
$ make O=build -j8 Image dtbs 
$ cp build/arch/arm64/boot/Image build/arch/arm64/boot/dts/freescale/imx8mq-phanbell.dtb /tftpboot/coral/

// u-boot commands
tftpboot ${fdt_addr} 192.168.0.xx:coral/imx8mq-phanbell.dtb
tftpboot ${loadaddr} 192.168.0.xx:coral/Image
setenv bootargs console=ttymxc0,115200 console=tty0 earlycon=ec_imx6q,0x30860000,115200 root=/dev/mmcblk1p2 rootfstype=ext4 rw rootwait init=/sbin/init net.ifnames=0 pci=pcie_bus_perf
booti ${loadaddr} - ${fdt_addr}
  • Able to boot 5.15.y, but Edge TPU pci is not found
$ uname -a 
Linux coral-sdcard 5.15.35 #1 SMP PREEMPT Thu Apr 28 11:47:54 IST 2022 aarch64 GNU/Linux
$ lspci

Build and load Coral Gasket Driver

  • Clone https://github.com/google/gasket-driver
  • Cross compile on x86_64
$ git clone https://github.com/google/gasket-driver
$ export ARCH=arm64; export CROSS_COMPILE=aarch64-linux-gnu-
$ cd gasket-driver
$ cd src

// In Makefile update linux src path
// -C /path/to/linux/build

$ make 
$ file apex.ko gasket.ko 
apex.ko:   ELF 64-bit LSB relocatable, ARM aarch64, version 1 (SYSV), BuildID[sha1]=b49b35e0e0747682a5d0e7a085dc424991c3327e, with debug_info, not stripped
gasket.ko: ELF 64-bit LSB relocatable, ARM aarch64, version 1 (SYSV), BuildID[sha1]=cdb25b4ecf240c3b3ff8cacbcc5c533da377aa36, with debug_info, not stripped
  • Copy the .ko files to Coral dev and load kernel modules
# uname -a 
Linux coral-sdcard 5.15.35 #1 SMP PREEMPT Thu Apr 28 11:47:54 IST 2022 aarch64 GNU/Linux

# insmod gasket.ko 
# insmod apex.ko 
# lsmod 
Module                  Size  Used by
apex                   20480  0
gasket                 98304  1 apex

# lspci -nn
<empty>
  • Running sample model
# 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
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 160, in load_delegate
    delegate = Delegate(library, options)
  File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 119, in __init__
    raise ValueError(capture.message)
ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "examples/classify_image.py", line 121, in <module>
    main()
  File "examples/classify_image.py", line 71, in main
    interpreter = make_interpreter(*args.model.split('@'))
  File "/usr/lib/python3/dist-packages/pycoral/utils/edgetpu.py", line 87, in make_interpreter
    delegates = [load_edgetpu_delegate({'device': device} if device else {})]
  File "/usr/lib/python3/dist-packages/pycoral/utils/edgetpu.py", line 52, in load_edgetpu_delegate
    return tflite.load_delegate(_EDGETPU_SHARED_LIB, options or {})
  File "/usr/lib/python3/dist-packages/tflite_runtime/interpreter.py", line 163, in load_delegate
    library, str(e)))
ValueError: Failed to load delegate from libedgetpu.so.1
  • Still unable to detect the Edge TPU
like image 164
ChethanSuresh Avatar answered Aug 13 '26 11:08

ChethanSuresh


@chethansuresh I have used you guide here and ended up in the same place. The issue is that the PCI buses are not showing up. run lshw on both the google release (4.x) versus 6.11. I believe the same issue you had with 5.15.

I haven’t figured out the missing dtsi / dts file yet.

It’s fixed by adding the following to imx8mq-phanbell.dts

&pcie0 {
    status = "okay";
};

&pcie1 {
    status = "okay";
};
like image 37
Rudi Heitbaum Avatar answered Aug 13 '26 09:08

Rudi Heitbaum



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!