Skip to content

Commit

Permalink
Merge pull request #119 from danielfullmer/r35.4.1
Browse files Browse the repository at this point in the history
Update to Jetpack 5.1.2 / L4T 35.4.1
  • Loading branch information
danielfullmer authored Mar 26, 2024
2 parents 12d4ee7 + 9b7f613 commit 6f6fc3b
Show file tree
Hide file tree
Showing 26 changed files with 1,041 additions and 652 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2022-2023 Anduril Industries
Copyright 2022-2024 Anduril Industries

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
12 changes: 6 additions & 6 deletions UPGRADE_CHECKLIST.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
### Updating
- [ ] Update `l4tVersion`, `bspVersion`, and `cudaVersion` in default.nix
- [ ] Update `l4tVersion`, `jetpackVersion`, and `cudaVersion` in default.nix
- [ ] Update branch/revision/sha256s in:
- [ ] `default.nix`
- [ ] `kernel/default.nix`
- [ ] `kernel/display-driver.nix`
- [ ] `uefi-firmware.nix`
- [ ] `optee.nix`
- [ ] Grep for "sha256 = ", see if there is anything else not covered
- [ ] Grep for the previous version strings e.g. "35.3.1"
- [ ] Update the kernel version in `kernel/default.nix` if it chaged.
- [ ] Grep for the previous version strings e.g. "35.4.1"
- [ ] Compare files from `unpackedDebs` before and after
- [ ] Ensure the soc variants in `modules/flash-script.nix` match those in jetson_board_spec.cfg from BSP
- [ ] Ensure logic in ota-utils/ota_helpers.func matches nvidia-l4t-init/opt/nvidia/nv-l4t-bootloader-config.sh
- [ ] Ensure the soc variants in `modules/flash-script.nix` match those in `jetson_board_spec.cfg` from BSP
- [ ] Ensure logic in `ota-utils/ota_helpers.func` matches `nvidia-l4t-init/opt/nvidia/nv-l4t-bootloader-config.sh`
- [ ] Run `nix build .#genL4tJson` and copy output to `pkgs/containers/l4t.json`

### Testing
Expand Down
13 changes: 0 additions & 13 deletions debs/default.nix

This file was deleted.

37 changes: 25 additions & 12 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
, lib
, runCommand
, fetchurl
, fetchgit
, bzip2_1_1
, dpkg
, pkgs
Expand All @@ -20,19 +21,20 @@ let

pkgsAarch64 = if pkgs.stdenv.buildPlatform.isAarch64 then pkgs else pkgs.pkgsCross.aarch64-multiplatform;

jetpackVersion = "5.1.2";
l4tVersion = "35.4.1";
cudaVersion = "11.4";

# https://developer.nvidia.com/embedded/jetson-linux-archive
# https://repo.download.nvidia.com/jetson/

src = fetchurl {
url = "https://developer.download.nvidia.com/embedded/L4T/r35_Release_v3.1/release/Jetson_Linux_R35.3.1_aarch64.tbz2";
sha256 = "sha256-gKVVBKLOnNwKMo7bb9BpBhXE/96cKzL05k4KGjQyouI=";
url = with lib.versions; "https://developer.download.nvidia.com/embedded/L4T/r${major l4tVersion}_Release_v${minor l4tVersion}.${patch l4tVersion}/release/Jetson_Linux_R${l4tVersion}_aarch64.tbz2";
sha256 = "sha256-crdaDH+jv270GuBmNLtnw4qSaCFV0SBgJtvuSmuaAW8=";
};

debs = import ./debs { inherit lib fetchurl; };

jetpackVersion = "5.1.1";
l4tVersion = "35.3.1";
cudaVersion = "11.4";
sourceInfo = import ./sourceinfo { inherit lib fetchurl fetchgit l4tVersion; };
inherit (sourceInfo) debs gitRepos;

# we use a more recent version of bzip2 here because we hit this bug extracting nvidia's archives:
# https://bugs.launchpad.net/ubuntu/+source/bzip2/+bug/1834494
Expand All @@ -42,27 +44,36 @@ let
'';

# Here for convenience, to see what is in upstream Jetpack
unpackedDebs = pkgs.runCommand "unpackedDebs" { nativeBuildInputs = [ dpkg ]; } ''
unpackedDebs = pkgs.runCommand "unpackedDebs-${l4tVersion}" { nativeBuildInputs = [ dpkg ]; } ''
mkdir -p $out
${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: p: "echo Unpacking ${n}; dpkg -x ${p.src} $out/${n}") debs.common)}
${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: p: "echo Unpacking ${n}; dpkg -x ${p.src} $out/${n}") debs.t234)}
'';

# Also just for convenience,
unpackedDebsFilenames = pkgs.runCommand "unpackedDebsFilenames" { nativeBuildInputs = [ dpkg ]; } ''
unpackedDebsFilenames = pkgs.runCommand "unpackedDebsFilenames-${l4tVersion}" { nativeBuildInputs = [ dpkg ]; } ''
mkdir -p $out
${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: p: "echo Extracting file list from ${n}; dpkg --fsys-tarfile ${p.src} | tar --list > $out/${n}") debs.common)}
${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: p: "echo Extracting file list from ${n}; dpkg --fsys-tarfile ${p.src} | tar --list > $out/${n}") debs.t234)}
'';

unpackedGitRepos = pkgs.runCommand "unpackedGitRepos-${l4tVersion}" { } (
lib.mapAttrsToList
(relpath: repo: ''
mkdir -p $out/${relpath}
cp --no-preserve=all -r ${repo}/. $out/${relpath}
'')
gitRepos
);

inherit (pkgsAarch64.callPackages ./pkgs/uefi-firmware { inherit l4tVersion; })
edk2-jetson uefi-firmware;

inherit (pkgsAarch64.callPackages ./pkgs/optee {
# Nvidia's recommended toolchain is gcc9:
# https://nv-tegra.nvidia.com/r/gitweb?p=tegra/optee-src/nv-optee.git;a=blob;f=optee/atf_and_optee_README.txt;h=591edda3d4ec96997e054ebd21fc8326983d3464;hb=5ac2ab218ba9116f1df4a0bb5092b1f6d810e8f7#l33
stdenv = pkgsAarch64.gcc9Stdenv;
inherit bspSrc l4tVersion;
inherit bspSrc gitRepos l4tVersion;
}) buildTOS buildOpteeTaDevKit opteeClient;

flash-tools = callPackage ./pkgs/flash-tools {
Expand All @@ -86,7 +97,7 @@ let

kernel = callPackage ./kernel { inherit (l4t) l4t-xusb-firmware; kernelPatches = [ ]; };
kernelPackagesOverlay = self: super: {
nvidia-display-driver = self.callPackage ./kernel/display-driver.nix { inherit l4tVersion; };
nvidia-display-driver = self.callPackage ./kernel/display-driver.nix { inherit gitRepos l4tVersion; };
};
kernelPackages = (pkgs.linuxPackagesFor kernel).extend kernelPackagesOverlay;

Expand All @@ -112,6 +123,7 @@ let
value = c;
}) [
{ som = "orin-agx"; carrierBoard = "devkit"; }
{ som = "orin-agx-industrial"; carrierBoard = "devkit"; }
{ som = "orin-nx"; carrierBoard = "devkit"; }
{ som = "orin-nano"; carrierBoard = "devkit"; }
{ som = "xavier-agx"; carrierBoard = "devkit"; }
Expand Down Expand Up @@ -144,7 +156,8 @@ rec {
inherit jetpackVersion l4tVersion cudaVersion;

# Just for convenience
inherit bspSrc debs unpackedDebs unpackedDebsFilenames;
inherit bspSrc debs gitRepos;
inherit unpackedDebs unpackedDebsFilenames unpackedGitRepos;

inherit cudaPackages samples;
inherit flash-tools;
Expand Down
2 changes: 2 additions & 0 deletions device-pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
, buildOpteeTaDevKit
, python3
, openssl
, gcc
, dtc
, l4tVersion
, pkgsAarch64
Expand Down Expand Up @@ -112,6 +113,7 @@ let
in
import ./flashcmd-script.nix {
inherit lib;
inherit gcc dtc;
flash-tools = flash-tools-flashcmd;
};

Expand Down
5 changes: 4 additions & 1 deletion device-pkgs/flashcmd-script.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, flash-tools }:
{ lib, flash-tools, gcc, dtc }:
''
set -euo pipefail
Expand All @@ -14,6 +14,9 @@
chmod -R u+w "$WORKDIR"
cd "$WORKDIR"
# bootloader/tegraflash_impl_t234.py needs these to modify dtbs ;(
export PATH=${lib.makeBinPath [ gcc dtc ]}:$PATH
cd bootloader
bash ./flashcmd.txt
''

This file was deleted.

19 changes: 3 additions & 16 deletions kernel/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let
pkgsAarch64 = if isNative then pkgs else pkgs.pkgsCross.aarch64-multiplatform;
in
pkgsAarch64.buildLinux (args // {
version = "5.10.104" + lib.optionalString realtime "-rt63";
version = "5.10.120" + lib.optionalString realtime "-rt70";
extraMeta.branch = "5.10";

defconfig = "tegra_defconfig";
Expand All @@ -26,8 +26,8 @@ pkgsAarch64.buildLinux (args // {
src = fetchFromGitHub {
owner = "OE4T";
repo = "linux-tegra-5.10";
rev = "7191dccf8670635906182cc2da862d9c0fdcb93a"; # latest on oe4t-patches-l4t-r35.3.ga as of 2023-07-27
sha256 = "sha256-s71v4Bzc2jF9l65FY7OlrB/zi8Vkty+dBxZry8MyBno=";
rev = "76678311c10b59a385a6d74152f3a0b976ae2a67"; # latest on oe4t-patches-l4t-r35.4.ga as of 2023-09-27
sha256 = "sha256-jHqIYDztVs/yw/oMxr4oPabxXk+l+CPlRrODEaduBgg=";
};
# Remove device tree overlays with some incorrect "remote-endpoint" nodes.
# They are strings, but should be phandles. Otherwise, it fails to compile
Expand Down Expand Up @@ -89,19 +89,6 @@ pkgsAarch64.buildLinux (args // {

# Lower priority of tegra-se crypto modules since they're slow and flaky
{ patch = ./0008-Lower-priority-of-tegra-se-crypto.patch; }

# Fix gcc13 compilation failure
{ patch = ./0009-bonding-gcc13-synchronize-bond_-a-t-lb_xmit-types.patch; }

# Fixes a memory leak by kernel tegra serial driver
# This manifested via slab unreclaimable growing unbounded via repeated kmalloc-256 calls
# This patch is present in 35.4.1 and should be removed when we update
{
patch = fetchpatch {
url = "https://github.com/OE4T/linux-tegra-5.10/commit/d5b90d6b9365250adb73b2fe5b52a5228df3b1d9.patch";
sha256 = "sha256-a5LL4avaxQ3WYr9fRPMCfHrl4iAp1yhH95R+iI/PwYc=";
};
}
] ++ kernelPatches;

structuredExtraConfig = with lib.kernel; {
Expand Down
8 changes: 2 additions & 6 deletions kernel/display-driver.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
# TODO: Should try to merge with upstream nixpkgs's open.nix nvidia driver
{ stdenv
, lib
, fetchgit
, kernel
, gitRepos
, l4tVersion
}:

stdenv.mkDerivation rec {
pname = "nvidia-display-driver";
version = "jetson_${l4tVersion}";

src = fetchgit {
url = "https://nv-tegra.nvidia.com/tegra/kernel-src/nv-kernel-display-driver.git";
rev = version;
sha256 = "sha256-nXLrls3r9wRrZUGQIPZZS34hSt7ccsb4TZfaiIebMSU=";
};
src = gitRepos."tegra/kernel-src/nv-kernel-display-driver";

setSourceRoot = "sourceRoot=$(echo */NVIDIA-kernel-module-source-TempVersion)";

Expand Down
2 changes: 1 addition & 1 deletion modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ in
# with additional possibilies in an external NixOS module. See:
# "Extensible option types" in the NixOS manual
# The "generic" value signals that jetpack-nixos should try to maximize compatility across all varisnts. This may lead
type = types.enum [ "generic" "orin-agx" "orin-nx" "orin-nano" "xavier-agx" "xavier-nx" "xavier-nx-emmc" ];
type = types.enum [ "generic" "orin-agx" "orin-agx-industrial" "orin-nx" "orin-nano" "xavier-agx" "xavier-nx" "xavier-nx-emmc" ];
default = "generic";
description = lib.mdDoc ''
Jetson SoM (System-on-Module) to target. Can be set to "generic" to target a generic jetson device, but some things may not work.
Expand Down
10 changes: 10 additions & 0 deletions modules/devices.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ let

nvpModelConf = {
orin-agx = "${pkgs.nvidia-jetpack.l4t-nvpmodel}/etc/nvpmodel/nvpmodel_p3701_0000.conf";
orin-agx-industrial = "${pkgs.nvidia-jetpack.l4t-nvpmodel}/etc/nvpmodel/nvpmodel_p3701_0008.conf";
orin-nx = "${pkgs.nvidia-jetpack.l4t-nvpmodel}/etc/nvpmodel/nvpmodel_p3767_0000.conf";
orin-nano = "${pkgs.nvidia-jetpack.l4t-nvpmodel}/etc/nvpmodel/nvpmodel_p3767_0003.conf";
xavier-agx = "${pkgs.nvidia-jetpack.l4t-nvpmodel}/etc/nvpmodel/nvpmodel_t194.conf";
Expand All @@ -20,6 +21,7 @@ let

nvfancontrolConf = {
orin-agx = "${pkgs.nvidia-jetpack.l4t-nvfancontrol}/etc/nvpower/nvfancontrol/nvfancontrol_p3701_0000.conf";
orin-agx-industrial = "${pkgs.nvidia-jetpack.l4t-nvfancontrol}/etc/nvpower/nvfancontrol/nvfancontrol_p3701_0008.conf";
orin-nx = "${pkgs.nvidia-jetpack.l4t-nvfancontrol}/etc/nvpower/nvfancontrol/nvfancontrol_p3767_0000.conf";
orin-nano = "${pkgs.nvidia-jetpack.l4t-nvfancontrol}/etc/nvpower/nvfancontrol/nvfancontrol_p3767_0000.conf";
xavier-agx = "${pkgs.nvidia-jetpack.l4t-nvfancontrol}/etc/nvpower/nvfancontrol/nvfancontrol_p2888.conf";
Expand Down Expand Up @@ -80,6 +82,14 @@ lib.mkMerge [{
partitionTemplate = mkDefault "${pkgs.nvidia-jetpack.bspSrc}/bootloader/t186ref/cfg/flash_t234_qspi.xml";
})

(mkIf (cfg.som == "orin-agx-industrial") {
targetBoard = mkDefault "jetson-agx-orin-devkit-industrial";
# Remove the sdmmc part of this flash.xmo file. The industrial spi part is still different
partitionTemplate = mkDefault (pkgs.runCommand "flash.xml" { nativeBuildInputs = [ pkgs.buildPackages.xmlstarlet ]; } ''
xmlstarlet ed -d '//device[@type="sdmmc_user"]' ${pkgs.nvidia-jetpack.bspSrc}/bootloader/t186ref/cfg/flash_t234_qspi_sdmmc_industrial.xml >$out
'');
})

(mkIf (cfg.som == "orin-nx" || cfg.som == "orin-nano") {
targetBoard = mkDefault "jetson-orin-nano-devkit";
# Use this instead if you want to use the original Xavier NX Devkit module (p3509-a02)
Expand Down
6 changes: 5 additions & 1 deletion modules/flash-script.nix
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ in
default = null;
};

# See: https://docs.nvidia.com/jetson/archives/r35.3.1/DeveloperGuide/text/SD/Security/SecureBoot.html#prepare-an-sbk-key
# See: https://docs.nvidia.com/jetson/archives/r35.4.1/DeveloperGuide/text/SD/Security/SecureBoot.html#prepare-an-sbk-key
secureBoot = {
pkcFile = mkOption {
type = types.nullOr types.path;
Expand Down Expand Up @@ -386,6 +386,10 @@ in
{ boardid = "3701"; boardsku = "0005"; fab = "000"; boardrev = ""; fuselevel = "fuselevel_production"; chiprev = ""; } # 64GB
];

orin-agx-industrial = [
{ boardid = "3701"; boardsku = "0008"; fab = "300"; boardrev = ""; fuselevel = "fuselevel_production"; chiprev = ""; }
];

orin-nx = [
{ boardid = "3767"; boardsku = "0000"; fab = "000"; boardrev = ""; fuselevel = "fuselevel_production"; chiprev = ""; } # Orin NX 16GB
{ boardid = "3767"; boardsku = "0001"; fab = "000"; boardrev = ""; fuselevel = "fuselevel_production"; chiprev = ""; } # Orin NX 8GB
Expand Down
Loading

0 comments on commit 6f6fc3b

Please sign in to comment.