Build Coral Gasket DKMS Driver with a Container Build Env

Build the Google Coral Gasket DKMS driver using a containerized build environment.

Build Coral Gasket DKMS Driver with a Container Build Env
Coral mPCIe

Due to some signs of abandonment by Google, the Gasket driver build process has become less simple as there are some requirements that are only met by using an older version of Debian or Ubuntu to perform the build.

The Gasket driver is a hard requirement for use of the mini PCIe and M.2 Google Coral TPU devices, which I am specifically using with Frigate NVR for object detection.

Frigate NVR
NVR with realtime local object detection for IP cameras

The specific build environment requirements make for a good opportunity to use a container for this process so we don't have to setup an instance with an older OS or attempt workarounds on a newer OS.

I automated this build process using Gitlab CI, you can find the already built .deb package in my package repo for this project here:

https://gitlab.largenut.com/largenut/gasket-driver/-/packages/

I'm going over the process for using a container as the build environment for building the Coral gasket driver .deb package for Ubuntu or Debian usage.

Setting up the Dockerfile

mkdir -p /opt/gasket
cd /opt/gasket
vi Dockerfile

Paste the following Dockerfile:

FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
RUN set -ex \
&& sed -i -- 's/# deb-src/deb-src/g' /etc/apt/sources.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
cdbs \
git \
dkms \
devscripts \
equivs \
fakeroot \
&& git clone https://github.com/google/gasket-driver.git \
&& apt-get clean \
&& rm -rf /tmp/* /var/tmp/* \
&& cd gasket-driver \
&& debuild -us -uc -tc -b

Save the Dockerfile for use in the container image build step.

Dockerfile credit – 5Wp6WJaZrk on Reddit

Build the container image

docker build -t gasket-buld-env -f Dockerfile .

This builds the image that we will run the container to perform the build of the Gasket driver .deb package.

Run the build container & build the Gasket .deb package

docker run --name gasket gasket-buld-env
docker cp gasket:/gasket-dkms_1.0-18_all.deb .

This runs the built container image, when this runs the container is going to perform the build. Once this is complete, you copy the resulting .deb file from the container to your local directory.

ls -lah /opt/gasket | grep .deb
-rw-r--r--  1 root root 49K Jun 18 16:45 gasket-dkms_1.0-18_all.deb

Install the Gasket DKMS driver for Coral

# Install dependencies
sudo apt install build-essential dkms linux-headers-$(uname -r)

# Install package
sudo dpkg -i gasket-dkms_1.0-18_all.deb

Loading the module & Verifying the Coral is usable

# Load the gasket and apex modules
sudo modprobe gasket
sudo modprobe apex

# Verify Gasket and Apex are loaded
lsmod | grep gasket
lsmod | grep apex

# Check for gasket devices -- may not exist if using only a Coral, this is normal to not see.
ls -la /dev/gasket*

# Check for apex devices -- Coral devices
ls -la /dev/apex*

The output should look like this:

ls -la /dev/apex*
crw-rw---- 1 root root 120, 0 Jun 20 11:53 /dev/apex_0

We can also confirm that the Coral shows with 'lscpi'

lspci | grep Coral
02:00.0 System peripheral: Global Unichip Corp. Coral Edge TPU

Frigate Coral Detector Metrics

Frigate Coral Metrics

Gasket Driver Source

GitHub - google/gasket-driver
Contribute to google/gasket-driver development by creating an account on GitHub.