GPU Hardware Accelerated Flatpaks for Jetson (t210, t186, t194, and t234)

The following are install instructions for custom Jetson BSP flatpaks made by myself to alllow for hardware accelerated GPU use (OpenGL, GLES, EGL, and Vulkan) in all flatpaks. Flatpak’s for BSP 32.3.1, 32.7.3, 35.1.0, and 35.2.1 have been made. It is simple to make your own following the sources if you need to make one for any other BSP version. 32.3.1 and 32.7.3 have been tested fully functional, however I do not own Jetson hardware capable of running 35.x.x so you can comment if the flatpak’s work or not :)

Install script. Make sure are within your sudo timeout before copy/pasting directly into your terminal:

# For Ubuntu Bionic, you NEED the flatpak PPA first since the flatpak version from ubuntu no longer functions with flathub
sudo apt update
# install packages for add-apt-repository and glxinfo programs
sudo apt install software-properties-common mesa-utils -y
sudo add-apt-repository ppa:alexlarsson/flatpak -y
sudo apt update

# install flatpak
sudo apt install flatpak -y

# add flathub as a repo
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
# the folllowing function should be run with display access for glxinfo to determine the current system BSP version
BSP_version="$(glxinfo -B | grep -E "NVIDIA [0-9]+.[0-9]+.[0-9]+$" | head -n1 | awk '{print $(NF)}')"
if [[ -e "/proc/device-tree/compatible" ]]; then
  CHIP="$(tr -d '\0' </proc/device-tree/compatible)"
  if [[ ${CHIP} =~ "tegra186" ]]; then
    __chip="t186"
  elif [[ ${CHIP} =~ "tegra210" ]]; then
    __chip="t210"
  elif [[ ${CHIP} =~ "tegra194" ]]; then
    __chip="t194"
  elif [[ ${CHIP} =~ "tegra234" ]]; then
    __chip="t234"
  fi
  jetson_chip_model="$__chip"
else
  echo "Could not determine the jetson chip model from the device tree"
fi
echo "Jetson Chip Model $jetson_chip_model and BSP $BSP_version detected."
case "$jetson_chip_model" in
"t186"|"t194"|"t210"|"t234")
  case "$BSP_version" in
  "32.3.1"|"32.7.3"|"35.1.0"|"35.2.1")
    # installing tegra Flatpak BSP and workarounds
    sudo flatpak override --device=all
    sudo flatpak override --share=network
    sudo flatpak override --filesystem=/sys
    echo "export FLATPAK_GL_DRIVERS=nvidia-tegra-${BSP_version//./-}" | sudo tee /etc/profile.d/flatpak_tegra.sh
    echo 'Defaults      env_keep += FLATPAK_GL_DRIVERS' | sudo tee /etc/sudoers.d/flatpak_tegra

    cd /tmp || echo "Could not move to /tmp directory. Is your install corrupted?"
    rm -f org.freedesktop.Platform.GL.nvidia-tegra-${BSP_version//./-}.flatpak
    wget --progress=bar:force:noscroll https://github.com/cobalt2727/L4T-Megascript/raw/master/assets/Flatpak/$jetson_chip_model/org.freedesktop.Platform.GL.nvidia-tegra-${BSP_version//./-}.flatpak || echo "Failed to download $jetson_chip_model org.freedesktop.Platform.GL.nvidia-tegra-${BSP_version//./-}"
    sync

    #Only try to remove flatpak app if it's installed.
    if flatpak list | grep -qF "org.freedesktop.Platform.GL.nvidia-tegra-${BSP_version//./-}" ;then
      sudo flatpak uninstall "org.freedesktop.Platform.GL.nvidia-tegra-${BSP_version//./-}" -y -vv
    fi

    sudo flatpak install --system ./org.freedesktop.Platform.GL.nvidia-tegra-${BSP_version//./-}.flatpak -y -vv || echo "Failed to install org.freedesktop.Platform.GL.nvidia-tegra-${BSP_version//./-}"

    # install the gnome software center flatpak plugin
    sudo apt install -y gnome-software-plugin-flatpak --no-install-recommends
    ;;
  *)
    echo "You are not running L4T 32.3.1, 32.7.3, 35.1.0, or 35.2.1. Flatpak GPU hardware acceleration is not available." ;;
  esac
  ;;
esac

Sources (json files for creating the flatpaks) can be found in their respective subfolders:
https://github.com/cobalt2727/L4T-Megascript/tree/master/assets/Flatpak
Packaging can be accomplished following these commands in the same folder as the json file.
Change the json filename and output version name as required:

sudo flatpak-builder -v --force-clean --delete-build-dirs --disable-cache --arch=aarch64 --repo=nvidia builddir org.freedesktop.Platform.GL.nvidia-tegra-32-3-1.json
sudo flatpak build-bundle ./nvidia org.freedesktop.Platform.GL.nvidia-tegra-32-3-1.flatpak runtime/org.freedesktop.Platform.GL.nvidia-tegra-32-3-1/aarch64/1.4
1 Like

you should also pin the runtime (so flatpak autoremove won’t remove it)

run this command after the others in the same terminal

sudo flatpak pin --system runtime/org.freedesktop.Platform.GL.nvidia-tegra-${BSP_version//./-}/aarch64/1.4

user installed flatpaks (as oppsed to system installed) will also need the overrides

flatpak override --user --device=all
flatpak override --user --share=network
flatpak override --user --filesystem=/sys
1 Like