2019-12-05 21:16:06 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch, openssl, pkgsCross, buildPackages }:
|
2018-02-24 02:46:39 +00:00
|
|
|
|
|
|
|
let
|
2018-03-20 00:31:31 +00:00
|
|
|
buildArmTrustedFirmware = { filesToInstall
|
2018-02-24 02:46:39 +00:00
|
|
|
, installDir ? "$out"
|
2019-12-05 21:16:06 +00:00
|
|
|
, platform ? null
|
2018-02-24 02:46:39 +00:00
|
|
|
, extraMakeFlags ? []
|
|
|
|
, extraMeta ? {}
|
2021-05-22 10:08:02 +01:00
|
|
|
, version ? "2.5"
|
2018-02-24 02:46:39 +00:00
|
|
|
, ... } @ args:
|
2019-08-13 22:52:01 +01:00
|
|
|
stdenv.mkDerivation ({
|
2018-02-24 02:46:39 +00:00
|
|
|
|
2019-12-05 21:16:06 +00:00
|
|
|
name = "arm-trusted-firmware${lib.optionalString (platform != null) "-${platform}"}-${version}";
|
2018-11-04 23:44:40 +00:00
|
|
|
inherit version;
|
2018-02-24 02:46:39 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ARM-software";
|
|
|
|
repo = "arm-trusted-firmware";
|
2020-04-22 10:00:10 +01:00
|
|
|
rev = "v${version}";
|
2021-06-22 11:33:21 +01:00
|
|
|
sha256 = "0w3blkqgmyb5bahlp04hmh8abrflbzy0qg83kmj1x9nv4mw66f3b";
|
2018-02-24 02:46:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
|
|
|
|
2018-12-30 22:39:29 +00:00
|
|
|
# For Cortex-M0 firmware in RK3399
|
|
|
|
nativeBuildInputs = [ pkgsCross.arm-embedded.stdenv.cc ];
|
|
|
|
|
2019-12-05 21:16:06 +00:00
|
|
|
buildInputs = [ openssl ];
|
|
|
|
|
2018-02-24 02:46:39 +00:00
|
|
|
makeFlags = [
|
|
|
|
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
|
2019-12-05 21:16:06 +00:00
|
|
|
] ++ (lib.optional (platform != null) "PLAT=${platform}")
|
|
|
|
++ extraMakeFlags;
|
2018-02-24 02:46:39 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p ${installDir}
|
2019-12-05 21:16:06 +00:00
|
|
|
cp ${lib.concatStringsSep " " filesToInstall} ${installDir}
|
2018-02-24 02:46:39 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
hardeningDisable = [ "all" ];
|
|
|
|
dontStrip = true;
|
|
|
|
|
2018-03-23 17:03:26 +00:00
|
|
|
# Fatal error: can't create build/sun50iw1p1/release/bl31/sunxi_clocks.o: No such file or directory
|
|
|
|
enableParallelBuilding = false;
|
2018-02-24 02:46:39 +00:00
|
|
|
|
2019-12-05 21:16:06 +00:00
|
|
|
meta = with lib; {
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://github.com/ARM-software/arm-trusted-firmware";
|
2018-02-24 02:46:39 +00:00
|
|
|
description = "A reference implementation of secure world software for ARMv8-A";
|
|
|
|
license = licenses.bsd3;
|
2020-04-22 10:00:10 +01:00
|
|
|
maintainers = with maintainers; [ lopsided98 ];
|
2018-02-24 02:46:39 +00:00
|
|
|
} // extraMeta;
|
|
|
|
} // builtins.removeAttrs args [ "extraMeta" ]);
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
in {
|
2018-02-24 02:46:39 +00:00
|
|
|
inherit buildArmTrustedFirmware;
|
|
|
|
|
2019-12-05 21:16:06 +00:00
|
|
|
armTrustedFirmwareTools = buildArmTrustedFirmware rec {
|
|
|
|
extraMakeFlags = [
|
|
|
|
"HOSTCC=${stdenv.cc.targetPrefix}gcc"
|
|
|
|
"fiptool" "certtool" "sptool"
|
|
|
|
];
|
|
|
|
filesToInstall = [
|
|
|
|
"tools/fiptool/fiptool"
|
|
|
|
"tools/cert_create/cert_create"
|
|
|
|
"tools/sptool/sptool"
|
|
|
|
];
|
|
|
|
postInstall = ''
|
|
|
|
mkdir -p "$out/bin"
|
|
|
|
find "$out" -type f -executable -exec mv -t "$out/bin" {} +
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2017-12-11 01:54:11 +00:00
|
|
|
armTrustedFirmwareAllwinner = buildArmTrustedFirmware rec {
|
2019-05-18 18:40:16 +01:00
|
|
|
platform = "sun50i_a64";
|
2018-03-20 00:31:31 +00:00
|
|
|
extraMeta.platforms = ["aarch64-linux"];
|
2017-12-11 01:54:11 +00:00
|
|
|
filesToInstall = ["build/${platform}/release/bl31.bin"];
|
|
|
|
};
|
|
|
|
|
|
|
|
armTrustedFirmwareQemu = buildArmTrustedFirmware rec {
|
|
|
|
platform = "qemu";
|
2018-03-20 00:31:31 +00:00
|
|
|
extraMeta.platforms = ["aarch64-linux"];
|
2017-12-11 01:54:11 +00:00
|
|
|
filesToInstall = [
|
|
|
|
"build/${platform}/release/bl1.bin"
|
|
|
|
"build/${platform}/release/bl2.bin"
|
|
|
|
"build/${platform}/release/bl31.bin"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2018-02-24 02:46:39 +00:00
|
|
|
armTrustedFirmwareRK3328 = buildArmTrustedFirmware rec {
|
|
|
|
extraMakeFlags = [ "bl31" ];
|
|
|
|
platform = "rk3328";
|
2018-03-20 00:31:31 +00:00
|
|
|
extraMeta.platforms = ["aarch64-linux"];
|
2018-02-24 02:46:39 +00:00
|
|
|
filesToInstall = [ "build/${platform}/release/bl31/bl31.elf"];
|
|
|
|
};
|
2018-12-30 22:39:29 +00:00
|
|
|
|
|
|
|
armTrustedFirmwareRK3399 = buildArmTrustedFirmware rec {
|
|
|
|
extraMakeFlags = [ "bl31" ];
|
|
|
|
platform = "rk3399";
|
|
|
|
extraMeta.platforms = ["aarch64-linux"];
|
|
|
|
filesToInstall = [ "build/${platform}/release/bl31/bl31.elf"];
|
|
|
|
};
|
2019-12-05 21:17:36 +00:00
|
|
|
|
|
|
|
armTrustedFirmwareS905 = buildArmTrustedFirmware rec {
|
|
|
|
extraMakeFlags = [ "bl31" ];
|
|
|
|
platform = "gxbb";
|
|
|
|
extraMeta.platforms = ["aarch64-linux"];
|
|
|
|
filesToInstall = [ "build/${platform}/release/bl31.bin"];
|
|
|
|
};
|
2018-02-24 02:46:39 +00:00
|
|
|
}
|