nixpkgs-suyu/pkgs/misc/arm-trusted-firmware/default.nix

122 lines
3.5 KiB
Nix
Raw Normal View History

2021-11-13 22:06:21 +01:00
{ lib, stdenv, fetchFromGitHub, openssl, pkgsCross, buildPackages }:
let
buildArmTrustedFirmware = { filesToInstall
, installDir ? "$out"
, platform ? null
, extraMakeFlags ? []
, extraMeta ? {}
2021-12-11 23:59:11 +01:00
, version ? "2.6"
, ... } @ args:
2019-08-13 23:52:01 +02:00
stdenv.mkDerivation ({
2022-01-23 13:39:52 +01:00
pname = "arm-trusted-firmware${lib.optionalString (platform != null) "-${platform}"}";
inherit version;
src = fetchFromGitHub {
owner = "ARM-software";
repo = "arm-trusted-firmware";
2020-04-22 11:00:10 +02:00
rev = "v${version}";
2021-12-11 23:59:11 +01:00
sha256 = "sha256-qT9DdTvMcUrvRzgmVf2qmKB+Rb1WOB4p1rM+fsewGcg=";
};
patches = [ ./remove-hdcp-blob.patch ];
depsBuildBuild = [ buildPackages.stdenv.cc ];
2018-12-30 23:39:29 +01:00
# For Cortex-M0 firmware in RK3399
nativeBuildInputs = [ pkgsCross.arm-embedded.stdenv.cc ];
buildInputs = [ openssl ];
makeFlags = [
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
] ++ (lib.optional (platform != null) "PLAT=${platform}")
++ extraMakeFlags;
installPhase = ''
runHook preInstall
mkdir -p ${installDir}
cp ${lib.concatStringsSep " " filesToInstall} ${installDir}
runHook postInstall
'';
hardeningDisable = [ "all" ];
dontStrip = true;
# Fatal error: can't create build/sun50iw1p1/release/bl31/sunxi_clocks.o: No such file or directory
enableParallelBuilding = false;
meta = with lib; {
homepage = "https://github.com/ARM-software/arm-trusted-firmware";
description = "A reference implementation of secure world software for ARMv8-A";
license = licenses.bsd3;
2020-04-22 11:00:10 +02:00
maintainers = with maintainers; [ lopsided98 ];
} // extraMeta;
} // builtins.removeAttrs args [ "extraMeta" ]);
2019-08-13 23:52:01 +02:00
in {
inherit buildArmTrustedFirmware;
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" {} +
'';
};
armTrustedFirmwareAllwinner = buildArmTrustedFirmware rec {
platform = "sun50i_a64";
extraMeta.platforms = ["aarch64-linux"];
filesToInstall = ["build/${platform}/release/bl31.bin"];
2021-06-05 01:20:46 +02:00
};
armTrustedFirmwareAllwinnerH616 = buildArmTrustedFirmware rec {
platform = "sun50i_h616";
extraMeta.platforms = ["aarch64-linux"];
filesToInstall = ["build/${platform}/release/bl31.bin"];
};
armTrustedFirmwareQemu = buildArmTrustedFirmware rec {
platform = "qemu";
extraMeta.platforms = ["aarch64-linux"];
filesToInstall = [
"build/${platform}/release/bl1.bin"
"build/${platform}/release/bl2.bin"
"build/${platform}/release/bl31.bin"
];
};
armTrustedFirmwareRK3328 = buildArmTrustedFirmware rec {
extraMakeFlags = [ "bl31" ];
platform = "rk3328";
extraMeta.platforms = ["aarch64-linux"];
filesToInstall = [ "build/${platform}/release/bl31/bl31.elf"];
};
2018-12-30 23:39:29 +01:00
armTrustedFirmwareRK3399 = buildArmTrustedFirmware rec {
extraMakeFlags = [ "bl31" ];
platform = "rk3399";
extraMeta.platforms = ["aarch64-linux"];
filesToInstall = [ "build/${platform}/release/bl31/bl31.elf"];
};
armTrustedFirmwareS905 = buildArmTrustedFirmware rec {
extraMakeFlags = [ "bl31" ];
platform = "gxbb";
extraMeta.platforms = ["aarch64-linux"];
filesToInstall = [ "build/${platform}/release/bl31.bin"];
};
}