2023-12-25 21:14:17 +01:00
|
|
|
{ stdenv, gcc11Stdenv, buildUBoot, fetchurl, fetchFromGitLab, lib, bison }:
|
2023-02-13 23:23:27 +01:00
|
|
|
let
|
|
|
|
firmware-imx = stdenv.mkDerivation (fa: {
|
|
|
|
pname = "firmware-imx";
|
2023-09-10 12:25:10 +02:00
|
|
|
version = "8.20";
|
2023-02-13 23:23:27 +01:00
|
|
|
src = fetchurl {
|
|
|
|
url = "https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/${fa.pname}-${fa.version}.bin";
|
2023-09-10 12:25:10 +02:00
|
|
|
hash = "sha256-9txqXI/ZuROhU2DTzNU9GI2wWgioWUxRjldiJHjHI4M=";
|
2023-02-13 23:23:27 +01:00
|
|
|
};
|
|
|
|
unpackPhase = ''
|
|
|
|
cp $src firmware
|
|
|
|
chmod +x firmware
|
|
|
|
./firmware --auto-accept
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
|
|
|
cd ${fa.pname}-${fa.version}/firmware
|
2023-08-16 00:21:11 +02:00
|
|
|
cp ddr/synopsys/lpddr4*.bin hdmi/cadence/signed_*_imx8m.bin $out
|
2023-02-13 23:23:27 +01:00
|
|
|
'';
|
|
|
|
meta.license = lib.licenses.unfree;
|
|
|
|
});
|
|
|
|
|
2023-08-16 00:21:11 +02:00
|
|
|
arm-trusted-firmware-imx8mq = gcc11Stdenv.mkDerivation (fa: {
|
2023-02-13 23:23:27 +01:00
|
|
|
pname = "arm-trusted-firmware-bl31";
|
|
|
|
version = "unstable-2020-07-08";
|
|
|
|
src = fetchFromGitLab {
|
|
|
|
domain = "source.puri.sm";
|
|
|
|
owner = "Librem5";
|
|
|
|
repo = "arm-trusted-firmware";
|
|
|
|
rev = "1fd3ff86cd4a05cd3e5637bf5a6902ac58fcafb9";
|
|
|
|
hash = "sha256-fzpUxq+Hz7pijv5Mvzz+bUkaH79YSaugVUnViF7NB3A=";
|
|
|
|
};
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
hardeningDisable = [ "all" ];
|
|
|
|
NIX_LDFLAGS = "--no-warn-rwx-segments";
|
|
|
|
buildFlags = [ "PLAT=imx8mq" "bl31" ];
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp build/imx8mq/release/bl31.bin $out
|
|
|
|
'';
|
|
|
|
dontStrip = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
ubootLibrem5 = buildUBoot {
|
2023-08-16 00:21:11 +02:00
|
|
|
version = "unstable-2022-12-15";
|
2023-02-13 23:23:27 +01:00
|
|
|
defconfig = "librem5_defconfig";
|
|
|
|
src = fetchFromGitLab {
|
|
|
|
domain = "source.puri.sm";
|
2023-08-16 00:21:11 +02:00
|
|
|
owner = "Librem5";
|
2023-02-13 23:23:27 +01:00
|
|
|
repo = "uboot-imx";
|
2023-08-16 00:21:11 +02:00
|
|
|
rev = "956aa590c93977992743b41c45d3c7ee5a024915"; # this is the latest commit on the upstream/librem5 branch
|
|
|
|
hash = "sha256-MsIIlarN+WFFEzc0ptLAgS7BwJ6Cosy42xo0EwPn1AU=";
|
2023-02-13 23:23:27 +01:00
|
|
|
};
|
2024-06-06 10:43:08 +02:00
|
|
|
patches = [];
|
2023-02-13 23:23:27 +01:00
|
|
|
BL31 = "${arm-trusted-firmware-imx8mq}/bl31.bin";
|
|
|
|
preConfigure = ''
|
|
|
|
cp $BL31 .
|
|
|
|
cp ${firmware-imx}/* .
|
|
|
|
'';
|
|
|
|
preInstall = ''
|
|
|
|
cp flash.bin u-boot.imx
|
|
|
|
'';
|
|
|
|
filesToInstall = [ "u-boot.imx" ];
|
|
|
|
postInstall = ''
|
|
|
|
mkdir $out/bin
|
|
|
|
sed 's|TARGET="/usr/lib/u-boot/librem5.*"|TARGET="${placeholder "out"}"|' \
|
|
|
|
$src/debian/bin/u-boot-install-librem5 > $out/bin/u-boot-install-librem5
|
2023-08-16 00:21:11 +02:00
|
|
|
chmod +x $out/bin/u-boot-install-librem5
|
2023-02-13 23:23:27 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
ubootLibrem5
|