diff --git a/device-pkgs/default.nix b/device-pkgs/default.nix index dd3a6995..a2fe963c 100644 --- a/device-pkgs/default.nix +++ b/device-pkgs/default.nix @@ -48,7 +48,6 @@ let tosImage = buildTOS tosArgs; taDevKit = buildOpteeTaDevKit tosArgs; - # TODO: Unify with fuseScript below mkFlashScript = args: import ./flash-script.nix ({ inherit lib flashArgs partitionTemplate; @@ -279,16 +278,24 @@ let fuseScript = writeShellApplication { name = "fuse-${hostName}"; - text = import ./fuse-script.nix { + text = import ./flash-script.nix { inherit lib; flash-tools = flash-tools-patched; - inherit fuseArgs; - - chipId = - if cfg.som == null then null - else if lib.hasPrefix "orin-" cfg.som then "0x23" - else if lib.hasPrefix "xavier-" cfg.som then "0x19" - else throw "Unknown SoC type"; + flashCommands = + let + chipId = + if cfg.som == null then null + else if lib.hasPrefix "orin-" cfg.som then "0x23" + else if lib.hasPrefix "xavier-" cfg.som then "0x19" + else throw "Unknown SoC type"; + in + '' + ./odmfuse.sh -i ${chipId} "$@" ${builtins.toString fuseArgs} + ''; + + # Fuse script needs device tree files, which aren't already present for + # non-devkit boards, so we need to get our built version of them + dtbsDir = config.hardware.deviceTree.package; }; }; in diff --git a/device-pkgs/fuse-script.nix b/device-pkgs/fuse-script.nix deleted file mode 100644 index 71d62910..00000000 --- a/device-pkgs/fuse-script.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ lib, flash-tools, chipId, fuseArgs ? [ ] }: -'' - set -euo pipefail - - if [[ -z ''${WORKDIR-} ]]; then - WORKDIR=$(mktemp -d) - function on_exit() { - rm -rf "$WORKDIR" - } - trap on_exit EXIT - fi - - cp -r ${flash-tools}/. "$WORKDIR" - chmod -R u+w "$WORKDIR" - cd "$WORKDIR" - - # Make nvidia's odmfuse script happy by adding all this stuff to our PATH - export PATH=${lib.makeBinPath flash-tools.flashDeps}:$PATH - - # -i chipID needs to be the first entry - ./odmfuse.sh -i ${chipId} "$@" ${builtins.toString fuseArgs} -''