From 1d7a287b1763a672e4a77935edc741284abf2c7d Mon Sep 17 00:00:00 2001 From: K900 Date: Sat, 4 Nov 2023 11:21:51 +0300 Subject: [PATCH 1/4] ubootTools: fix cross properly this time When we're building a ubootTools, we want to produce a set of tools that runs on the host, so we want their dependencies to be built for hostPlatform. When we're building an uboot, the tools will run on the builder as part of the build, so we want their dependencies to be built for buildPlatform. --- pkgs/misc/uboot/default.nix | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/pkgs/misc/uboot/default.nix b/pkgs/misc/uboot/default.nix index 156952831346..79e8fb53bcb6 100644 --- a/pkgs/misc/uboot/default.nix +++ b/pkgs/misc/uboot/default.nix @@ -30,6 +30,16 @@ let url = "https://ftp.denx.de/pub/u-boot/u-boot-${defaultVersion}.tar.bz2"; hash = "sha256-a2pIWBwUq7D5W9h8GvTXQJIkBte4AQAqn5Ryf93gIdU="; }; + + # Dependencies for the tools need to be included as either native or cross, + # depending on which we're building + toolsDeps = [ + ncurses # tools/kwboot + libuuid # tools/mkeficapsule + gnutls # tools/mkeficapsule + openssl # tools/mkimage + ]; + buildUBoot = lib.makeOverridable ({ version ? null , src ? null @@ -40,6 +50,7 @@ let , extraPatches ? [] , extraMakeFlags ? [] , extraMeta ? {} + , crossTools ? false , ... } @ args: stdenv.mkDerivation ({ pname = "uboot-${defconfig}"; @@ -70,15 +81,9 @@ let ])) swig which # for scripts/dtc-version.sh - ]; + ] ++ lib.optionals (!crossTools) toolsDeps; depsBuildBuild = [ buildPackages.stdenv.cc ]; - - buildInputs = [ - ncurses # tools/kwboot - libuuid # tools/mkeficapsule - gnutls # tools/mkeficapsule - openssl # tools - ]; + buildInputs = lib.optionals crossTools toolsDeps; hardeningDisable = [ "all" ]; @@ -133,7 +138,9 @@ in { hardeningDisable = []; dontStrip = false; extraMeta.platforms = lib.platforms.linux; - extraMakeFlags = [ "HOST_TOOLS_ALL=y" "CROSS_BUILD_TOOLS=1" "NO_SDL=1" "tools" ]; + + crossTools = true; + extraMakeFlags = [ "HOST_TOOLS_ALL=y" "NO_SDL=1" "cross_tools" ]; outputs = [ "out" "man" ]; From 0fe8e5b5f0e8669ad1ddd82705addea67d44c454 Mon Sep 17 00:00:00 2001 From: K900 Date: Sat, 4 Nov 2023 11:23:36 +0300 Subject: [PATCH 2/4] uboot: fix patchShebangs invocation The scripts for Rockchip targets were moved to scripts/ upstream. --- pkgs/misc/uboot/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/misc/uboot/default.nix b/pkgs/misc/uboot/default.nix index 79e8fb53bcb6..376bcbb24474 100644 --- a/pkgs/misc/uboot/default.nix +++ b/pkgs/misc/uboot/default.nix @@ -64,7 +64,7 @@ let postPatch = '' patchShebangs tools - patchShebangs arch/arm/mach-rockchip + patchShebangs scripts ''; nativeBuildInputs = [ From ba9e0d2e3fe4365dc6bd4b8c6e682ae3fff6d3f1 Mon Sep 17 00:00:00 2001 From: K900 Date: Sat, 4 Nov 2023 11:23:58 +0300 Subject: [PATCH 3/4] uboot: set SCP=/dev/null for all the allwinners This is required to be set explicitly now, or the build fails. --- pkgs/misc/uboot/default.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/misc/uboot/default.nix b/pkgs/misc/uboot/default.nix index 376bcbb24474..45a123f3412d 100644 --- a/pkgs/misc/uboot/default.nix +++ b/pkgs/misc/uboot/default.nix @@ -190,6 +190,7 @@ in { defconfig = "bananapi_m64_defconfig"; extraMeta.platforms = ["aarch64-linux"]; BL31 = "${armTrustedFirmwareAllwinner}/bl31.bin"; + SCP = "/dev/null"; filesToInstall = ["u-boot-sunxi-with-spl.bin"]; }; @@ -348,6 +349,7 @@ in { defconfig = "a64-olinuxino-emmc_defconfig"; extraMeta.platforms = ["aarch64-linux"]; BL31 = "${armTrustedFirmwareAllwinner}/bl31.bin"; + SCP = "/dev/null"; filesToInstall = ["u-boot-sunxi-with-spl.bin"]; }; @@ -361,6 +363,7 @@ in { defconfig = "orangepi_zero_plus2_defconfig"; extraMeta.platforms = ["aarch64-linux"]; BL31 = "${armTrustedFirmwareAllwinner}/bl31.bin"; + SCP = "/dev/null"; filesToInstall = ["u-boot-sunxi-with-spl.bin"]; }; @@ -381,6 +384,7 @@ in { defconfig = "orangepi_3_defconfig"; extraMeta.platforms = ["aarch64-linux"]; BL31 = "${armTrustedFirmwareAllwinnerH6}/bl31.bin"; + SCP = "/dev/null"; filesToInstall = ["u-boot-sunxi-with-spl.bin"]; }; @@ -394,6 +398,7 @@ in { defconfig = "pine64_plus_defconfig"; extraMeta.platforms = ["aarch64-linux"]; BL31 = "${armTrustedFirmwareAllwinner}/bl31.bin"; + SCP = "/dev/null"; filesToInstall = ["u-boot-sunxi-with-spl.bin"]; }; @@ -401,6 +406,7 @@ in { defconfig = "pine64-lts_defconfig"; extraMeta.platforms = ["aarch64-linux"]; BL31 = "${armTrustedFirmwareAllwinner}/bl31.bin"; + SCP = "/dev/null"; filesToInstall = ["u-boot-sunxi-with-spl.bin"]; }; @@ -408,6 +414,7 @@ in { defconfig = "pinebook_defconfig"; extraMeta.platforms = ["aarch64-linux"]; BL31 = "${armTrustedFirmwareAllwinner}/bl31.bin"; + SCP = "/dev/null"; filesToInstall = ["u-boot-sunxi-with-spl.bin"]; }; @@ -549,6 +556,7 @@ in { defconfig = "sopine_baseboard_defconfig"; extraMeta.platforms = ["aarch64-linux"]; BL31 = "${armTrustedFirmwareAllwinner}/bl31.bin"; + SCP = "/dev/null"; filesToInstall = ["u-boot-sunxi-with-spl.bin"]; }; From 6a62bacc28a6ba4951b8efe1eca01a3bf1136020 Mon Sep 17 00:00:00 2001 From: K900 Date: Sat, 4 Nov 2023 11:24:16 +0300 Subject: [PATCH 4/4] ubootClearfog: fix output file name Renamed upstream. --- pkgs/misc/uboot/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/misc/uboot/default.nix b/pkgs/misc/uboot/default.nix index 45a123f3412d..54a5f6be0920 100644 --- a/pkgs/misc/uboot/default.nix +++ b/pkgs/misc/uboot/default.nix @@ -198,7 +198,7 @@ in { ubootClearfog = buildUBoot { defconfig = "clearfog_defconfig"; extraMeta.platforms = ["armv7l-linux"]; - filesToInstall = ["u-boot-spl.kwb"]; + filesToInstall = ["u-boot-with-spl.kwb"]; }; ubootCubieboard2 = buildUBoot {