Google Coral Dev Linux kernel v5.x support

1k views Asked by At
1

There are 1 answers

0
ChethanSuresh On

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

$ 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

$ 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