#!/usr/bin/env bash # Prints the facts every other script branches on, one KEY=value per line, so a # caller can `eval "$(detect_platform.sh)"`. # # The point of the whole repo is that these differ between Jetsons and nothing is # assumed: the original Nano is tegra210 on L4T R32 (JetPack 4, Ubuntu 18.04, # CUDA 10.2), an Orin is tegra234 on R35/R36 (JetPack 5/6). One install procedure, # values read here, binaries built locally to match. set -euo pipefail # L4T release, e.g. "32.7.1" or "36.4.3". Two sources; the file is the reliable # one on every generation, the package is the cross-check. l4t="" if [[ -f /etc/nv_tegra_release ]]; then # "# R32 (release), REVISION: 7.1, ..." -> 32.7.1 rel=$(sed -n 's/^# R\([0-9]*\).*REVISION: \([0-9.]*\).*/\1.\2/p' /etc/nv_tegra_release) l4t="$rel" fi if [[ -z "$l4t" ]] && command -v dpkg-query >/dev/null 2>&1; then l4t=$(dpkg-query --showformat='${Version}' -W nvidia-l4t-core 2>/dev/null \ | sed 's/-.*//') || true fi major="${l4t%%.*}" # SoC family, from the device tree — the ground truth for what can run here. soc="unknown" if [[ -r /proc/device-tree/compatible ]]; then comp=$(tr '\0' '\n' < /proc/device-tree/compatible) case "$comp" in *tegra210*) soc="tegra210" ;; # Nano, TX1 *tegra186*) soc="tegra186" ;; # TX2 *tegra194*) soc="tegra194" ;; # Xavier *tegra234*) soc="tegra234" ;; # Orin *tegra264*) soc="tegra264" ;; # Thor esac fi model="unknown" [[ -r /proc/device-tree/model ]] && model=$(tr -d '\0' < /proc/device-tree/model) # JetPack generation follows from the L4T major, and it is what decides toolchain # and dependency names. case "$major" in 32) jetpack="4" ;; 35) jetpack="5" ;; 36) jetpack="6" ;; 38) jetpack="7" ;; *) jetpack="unknown" ;; esac echo "L4T=${l4t:-unknown}" echo "L4T_MAJOR=${major:-unknown}" echo "JETPACK=${jetpack}" echo "SOC=${soc}" echo "ARCH=$(uname -m)" echo "MODEL=${model}"