Request auto-connection for system-files in tegra gadget

Hey all. I would like to request auto-connection of system-files with the tegra gadget snap.


  • name: tegra
  • description: This gadget enables Nvidia AGX Orin and Orin Nano/NX to work with Ubuntu Core.
  • snapcraft: snapcraft.yaml
  • upstream: This gadget snap reuses the pc snap from here
  • interfaces:
    • system-files:
      • request-type: auto-connection
      • reasoning: In order to run certain workloads on nvidia tegra platforms, we need certain device nodes present on the system. For example, in order to use the hardware encoders/decoders on an NX platform with nvidia’s gstreamer plugins, we need /dev/v4l2-nvdec and /dev/v4l2-nvenc on the system. This is handled on Classic using udev rules with the following lines:
KERNEL=="15480000.nvdec", DRIVER=="tegra-nvdec", ACTION=="bind", RUN+="/bin/mknod -m 666 /dev/v4l2-nvdec c 1 3"
KERNEL=="154c0000.nvenc", DRIVER=="tegra-nvenc", ACTION=="bind", RUN+="/bin/mknod -m 666 /dev/v4l2-nvenc c 1 3"

We would like to do the same on Core by auto-connecting the system-files interface inside the gadget snap and copying the necessary udev rules to /etc/udev/rules.d using an install and post-refresh hook.

Hi @sebwey, apologies for the delay in getting to this request - from your description this seems reasonable but to grant it we need a bit more information - can you please include the complete system-files plug definition which the snap is using as I can’t see it in the linked snapcraft.yaml? Thanks

Hi @alexmurray thanks for your answer.

Here is the snapcraft.yaml that I used for testing the udev rules:

name: tegra
version: '22-0.1'
type: gadget
base: core22
summary: Gadget for Nvidia Tegra devices
description: |
    This gadget enables Nvidia AGX Orin and Orin Nano/NX to work with Ubuntu Core.
confinement: devmode
grade: stable

package-repositories:
  - type: apt
    ppa: ubuntu-tegra/updates

architectures:
  - build-on: [arm64]
    build-for: [arm64]

plugs:
  system-files:
    write:
      - /etc/udev/rules.d

# Min version to support shim 15.7 and min-size
assumes:
  - snapd2.60.1

parts:
  boot-assets:
    plugin: dump
    source: .
    stage-snaps:
      - pc/22/stable
    override-build: |
      # We need to install directly in the project dir as snapcraft checks there
      # for gadget.yaml instead of looking first at the prime folder.
      install -m 644 "$CRAFT_PART_INSTALL"/meta.pc/gadget.yaml "$CRAFT_PROJECT_DIR"/gadget.yaml
      craftctl default

  udev-rules:
    plugin: nil
    stage-packages:
      - nvidia-tegra-drivers-36
    stage:
      - etc/udev/rules.d

And here is the install hook that I’m intending to use to install the rules:

#!/usr/bin/bash

cp $SNAP/etc/udev/rules.d/* /etc/udev/rules.d/

This makes sense to me so +1 from me. I’d also recommend following the interface naming as seen on The system-files interface | Snapcraft documentation. So something like:

plugs:
  etc-udev-rules-dot-d:
    interface: system-files
    write:
    - /etc/udev/rules.d

what do other @reviewers think?

After working on another issue, we realised that we need to copy a .link file into /etc/systemd/network as well, in order to rename an ethernet interface. On top of that we will have to use an install-device hook to install this file early in the boot process and then we want to use a post-refresh hook to update these files whenever the gadget snap gets refreshed.

The new snapcraft.yaml would look like this:

name: tegra
version: '22-0.1'
type: gadget
base: core22
summary: Gadget for Nvidia Tegra devices
description: |
    This gadget enables Nvidia AGX Orin and Orin Nano/NX to work with Ubuntu Core.
confinement: strict
grade: stable

package-repositories:
  - type: apt
    ppa: ubuntu-tegra/updates

architectures:
  - build-on: [arm64]
    build-for: [arm64]

plugs:
  etc-udev-rules-dot-d:
    interface: system-files
    write:
    - /etc/udev/rules.d
    - /run/mnt/ubuntu-data/system-data/_writable_defaults/etc/udev/rules.d
  etc-systemd-network:
    interface: system-files
    write:
    - /etc/systemd/network
    - /run/mnt/ubuntu-data/system-data/_writable_defaults/etc/systemd/network

# Min version to support shim 15.7 and min-size
assumes:
  - snapd2.60.1

parts:
  boot-assets:
    plugin: dump
    source: .
    stage-snaps:
      - pc/22/stable
    override-build: |
      # We need to install directly in the project dir as snapcraft checks there
      # for gadget.yaml instead of looking first at the prime folder.
      install -m 644 "$CRAFT_PART_INSTALL"/meta.pc/gadget.yaml "$CRAFT_PROJECT_DIR"/gadget.yaml
      craftctl default

  udev-rules:
    plugin: nil
    stage-packages:
      - nvidia-tegra-drivers-36
    stage:
      - etc/udev/rules.d

  interface-config:
    plugin: nil
    stage-packages:
      - nvidia-tegra-defaults
    stage:
      - etc/systemd/network

+1 from me too for auto-connect of these system-files interfaces for the tegra gadget snap.

+2 votes for, 0 votes against, this is now live. Note as there is no snap revision published to the store that has these new interfaces I have not been able to test this but I have granted the declaration based on the above so with any luck when a new revision is uploaded it will pass the automated review, but if not please let me know and I’ll take a look. Thanks.