Skip to content

Commit

Permalink
dummy tmp patch
Browse files Browse the repository at this point in the history
Signed-off-by: Brian McGillion <[email protected]>
  • Loading branch information
brianmcgillion committed Dec 18, 2024
1 parent dac1787 commit 6960883
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 98 deletions.
39 changes: 20 additions & 19 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
#TODO: carrying the extra patch(es) until merged to unstable
#nixpkgs.url = "github:tiiuae/nixpkgs/nixos-unstable-gbenchmark";
#nixpkgs.url = "flake:mylocalnixpkgs";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
#TODO pinned to the a version to get working
nixpkgs.url = "github:NixOS/nixpkgs/3566ab7246670a43abd2ffa913cc62dad9cdf7d5";

ghafpkgs = {
url = "github:tiiuae/ghafpkgs";
Expand Down Expand Up @@ -114,11 +115,9 @@

nixos-hardware.url = "github:NixOS/nixos-hardware";

jetpack-nixos = {
#url = "github:anduril/jetpack-nixos
url = "github:anduril/jetpack-nixos";
#inputs.nixpkgs.follows = "nixpkgs";
};
#jetpack-nixos.url = "flake:mylocaljetpack";
#pinned to the pr https://github.com/anduril/jetpack-nixos/pull/257 until merged
jetpack-nixos.url = "github:anduril/jetpack-nixos/b2e93894c48de6ce2fd98cf36a228cbc8123016d";

disko = {
url = "github:nix-community/disko";
Expand Down
92 changes: 92 additions & 0 deletions lib/mk-flash-script/backup.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors
# SPDX-License-Identifier: Apache-2.0
#
# Function to generate NVIDIA Jetson Orin flash script
{
nixpkgs,
hostConfiguration,
jetpack-nixos,
flash-tools-system,
}:
let
cfg = hostConfiguration.config.hardware.nvidia-jetpack;
inherit (jetpack-nixos.legacyPackages.${flash-tools-system}) flash-tools;

inherit (hostConfiguration) pkgs;
inherit (pkgs.nvidia-jetpack) mkFlashScript;

# jetpack-nixos has the cross-compilation set up in a slightly strange way,
# the packages under x86_64-linux are actually cross-compiled packages for
# aarch64-linux. So we will get devicePkgs from x86_64-linux if we are cross
# compiling, otherwise we end up building UEFI firmware etc. binaries used by
# flash-script natively.
isCross =
hostConfiguration.config.nixpkgs.buildPlatform.system
!= hostConfiguration.config.nixpkgs.hostPlatform.system;
devicePkgsSystem = if isCross then "x86_64-linux" else "aarch64-linux";
devicePkgs =
jetpack-nixos.legacyPackages.${devicePkgsSystem}.devicePkgsFromNixosConfig
hostConfiguration.config;

inherit (jetpack-nixos.legacyPackages.${devicePkgsSystem}) l4tVersion;
inherit (pkgs.nvidia-jetpack) mkFlashScript;

preFlashCommands =
nixpkgs.lib.optionalString (flash-tools-system == "aarch64-linux") ''
echo "WARNING! WARNING! WARNING!"
echo "You are trying to run aarch64-linux hosted version of the flash-script."
echo "It runs flashing tools with QEMU using user-mode emulation of x86 cpu."
echo "There are no known reports from anyone who would have gotten this working ever."
echo "If this fails, YOU HAVE BEEN WARNED, and don't open a bug report!"
echo ""
''
+ hostConfiguration.config.ghaf.hardware.nvidia.orin.flashScriptOverrides.preFlashCommands;

flashScript = (
mkFlashScript {
inherit flash-tools;
args = [ ];
# = flash-tools.overrideAttrs (
# {
# postPatch ? "",
# ...
# }:
# {
# postPatch = postPatch + cfg.flashScriptOverrides.postPatch;
# }
# );
# preFlashCommands =
# nixpkgs.lib.optionalString (flash-tools-system == "aarch64-linux") ''
# echo "WARNING! WARNING! WARNING!"
# echo "You are trying to run aarch64-linux hosted version of the flash-script."
# echo "It runs flashing tools with QEMU using user-mode emulation of x86 cpu."
# echo "There are no known reports from anyone who would have gotten this working ever."
# echo "If this fails, YOU HAVE BEEN WARNED, and don't open a bug report!"
# echo ""
# ''
# + hostConfiguration.config.ghaf.hardware.nvidia.orin.flashScriptOverrides.preFlashCommands;
}
);

patchFlashScript =
builtins.replaceStrings
[
"@pzstd@"
"@sed@"
"@patch@"
"@l4tVersion@"
"@isCross@"
]
[
"${nixpkgs.legacyPackages.${flash-tools-system}.zstd}/bin/pzstd"
"${nixpkgs.legacyPackages.${flash-tools-system}.gnused}/bin/sed"
"${nixpkgs.legacyPackages.${flash-tools-system}.patch}/bin/patch"
"${l4tVersion}"
"${if isCross then "true" else "false"}"
];
in
nixpkgs.legacyPackages.${flash-tools-system}.writeShellApplication {
name = "flash-ghaf";
text = patchFlashScript mkFlashScript flash-tools {inherit preFlashCommands;};

}
67 changes: 5 additions & 62 deletions lib/mk-flash-script/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,65 +8,8 @@
jetpack-nixos,
flash-tools-system,
}:
let
cfg = hostConfiguration.config.hardware.nvidia-jetpack;
inherit (jetpack-nixos.legacyPackages.${flash-tools-system}) flash-tools;

# jetpack-nixos has the cross-compilation set up in a slightly strange way,
# the packages under x86_64-linux are actually cross-compiled packages for
# aarch64-linux. So we will get devicePkgs from x86_64-linux if we are cross
# compiling, otherwise we end up building UEFI firmware etc. binaries used by
# flash-script natively.
isCross =
hostConfiguration.config.nixpkgs.buildPlatform.system
!= hostConfiguration.config.nixpkgs.hostPlatform.system;
devicePkgsSystem = if isCross then "x86_64-linux" else "aarch64-linux";
devicePkgs =
jetpack-nixos.legacyPackages.${devicePkgsSystem}.devicePkgsFromNixosConfig
hostConfiguration.config;

inherit (jetpack-nixos.legacyPackages.${devicePkgsSystem}) l4tVersion;

flashScript = devicePkgs.mkFlashScript {
flash-tools = flash-tools.overrideAttrs (
{
postPatch ? "",
...
}:
{
postPatch = postPatch + cfg.flashScriptOverrides.postPatch;
}
);
preFlashCommands =
nixpkgs.lib.optionalString (flash-tools-system == "aarch64-linux") ''
echo "WARNING! WARNING! WARNING!"
echo "You are trying to run aarch64-linux hosted version of the flash-script."
echo "It runs flashing tools with QEMU using user-mode emulation of x86 cpu."
echo "There are no known reports from anyone who would have gotten this working ever."
echo "If this fails, YOU HAVE BEEN WARNED, and don't open a bug report!"
echo ""
''
+ hostConfiguration.config.ghaf.hardware.nvidia.orin.flashScriptOverrides.preFlashCommands;
};

patchFlashScript =
builtins.replaceStrings
[
"@pzstd@"
"@sed@"
"@patch@"
"@l4tVersion@"
"@isCross@"
]
[
"${nixpkgs.legacyPackages.${flash-tools-system}.zstd}/bin/pzstd"
"${nixpkgs.legacyPackages.${flash-tools-system}.gnused}/bin/sed"
"${nixpkgs.legacyPackages.${flash-tools-system}.patch}/bin/patch"
"${l4tVersion}"
"${if isCross then "true" else "false"}"
];
in
nixpkgs.legacyPackages.${flash-tools-system}.writeShellApplication {
name = "flash-ghaf";
text = patchFlashScript flashScript;
}
hostConfiguration.pkgs.nvidia-jetpack.flashScript
# nixpkgs.legacyPackages.${flash-tools-system}.writeShellApplication {
# name = "flash-ghaf";
# text = "${hostConfiguration.pkgs.nvidia-jetpack.flashScript}";
# }
13 changes: 2 additions & 11 deletions targets/nvidia-jetson-orin/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,8 @@ in

packages = {
aarch64-linux =
builtins.listToAttrs (map (t: lib.nameValuePair t.name t.package) targets)
# EXPERIMENTAL: The aarch64-linux hosted flashing support is experimental
# and it simply might not work. Providing the script anyway
// builtins.listToAttrs (
map (
t: lib.nameValuePair "${t.name}-flash-script" (generate-flash-script t "aarch64-linux")
) targets
)
// builtins.listToAttrs (
map (t: lib.nameValuePair "${t.name}-flash-qspi" (generate-flash-qspi t "aarch64-linux")) targets
);
# should only build images as the flashers are not supported on aarch64-linux
builtins.listToAttrs (map (t: lib.nameValuePair t.name t.package) targets);
x86_64-linux =
builtins.listToAttrs (map (t: lib.nameValuePair t.name t.package) crossTargets)
// builtins.listToAttrs (
Expand Down

0 comments on commit 6960883

Please sign in to comment.