Files
nixos-hardware/compulab/ucm-imx95/bsp/ucm-imx95-boot.nix
2025-10-30 14:52:25 +01:00

89 lines
2.8 KiB
Nix

{
pkgs,
}:
with pkgs;
let
imx95-atf = pkgs.callPackage ./ucm-imx95-atf.nix { };
imx95-firmware = pkgs.callPackage ./ucm-imx95-firmware.nix { };
imx95-uboot = pkgs.callPackage ./ucm-imx95-uboot.nix { };
imx95-optee-os = pkgs.callPackage ./ucm-imx95-optee-os.nix { };
imx95-sm-fw = pkgs.callPackage ./ucm-imx95-sm-fw.nix { };
imx95-oei-ddr = pkgs.callPackage ./ucm-imx95-oei-ddr.nix { };
imx95-oei-tcm = pkgs.callPackage ./ucm-imx95-oei-tcm.nix { };
src = pkgs.fetchFromGitHub {
owner = "nxp-imx";
repo = "imx-mkimage";
#tag: lf-6.6.52-2.2.1
rev = "f620fb8ef7a04c8dbed8119880f5eeffe3e69746";
sha256 = "sha256-JZlX122uZntCIISI1H3Hw+tnk+N/gBJpFFDaZoY8W3c=";
};
shortRev = builtins.substring 0 8 src.rev;
in
{
imx95-boot = pkgs.stdenv.mkDerivation rec {
inherit src;
name = "imx95-mkimage";
version = "lf-6.6.36";
postPatch = ''
substituteInPlace Makefile \
--replace-fail 'git rev-parse --short=8 HEAD' 'echo ${shortRev}'
substituteInPlace Makefile \
--replace-fail 'CC = gcc' 'CC = clang'
substituteInPlace iMX95/soc.mak \
--replace-fail 'xxd' "${pkgs.vim.xxd}/bin/xxd"
substituteInPlace scripts/fspi_fcb_gen.sh \
--replace-fail 'xxd' "${pkgs.vim.xxd}/bin/xxd"
substituteInPlace scripts/fspi_packer.sh \
--replace-fail 'xxd' "${pkgs.vim.xxd}/bin/xxd"
patchShebangs scripts
'';
nativeBuildInputs = [
clang
git
dtc
];
buildInputs = [
git
glibc.static
zlib
zlib.static
];
buildPhase = ''
runHook preBuild
if [ -f ${imx95-uboot}/u-boot.bin ]; then
install -m 0644 ${imx95-uboot}/u-boot.bin ./iMX95/u-boot.bin
else
cat ${imx95-uboot}/u-boot-nodtb.bin ${imx95-uboot}/ucm-imx95.dtb > ./iMX95/u-boot.bin
fi
install -m 0644 ${imx95-uboot}/u-boot-spl.bin ./iMX95/u-boot-spl.bin
install -m 0644 ${imx95-uboot}/u-boot-nodtb.bin ./iMX95/u-boot-nodtb.bin
install -m 0644 ${imx95-uboot}/ucm-imx95.dtb ./iMX95/ucm-imx95.dtb
install -m 0644 ${imx95-optee-os}/tee.bin ./iMX95/tee.bin
install -m 0644 ${imx95-atf}/bl31.bin ./iMX95/bl31.bin
install -m 0644 ${imx95-sm-fw}/m33_image.bin ./iMX95/m33_image.bin
install -m 0644 ${imx95-oei-ddr}/oei-m33-ddr.bin ./iMX95/oei-m33-ddr.bin
install -m 0644 ${imx95-oei-tcm}/oei-m33-tcm.bin ./iMX95/oei-m33-tcm.bin
install -m 0644 ${imx95-firmware}/ddr/lpddr5* ./iMX95/
install -m 0644 ${imx95-firmware}/ahab/mx95a0-ahab-container.img ./iMX95/
install -m 0644 ${imx95-firmware}/m7_image.bin ./iMX95/
make SOC=iMX95 REV=A0 OEI=YES LPDDR_TYPE=lpddr5 flash_all
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/image
install -m 0644 ./iMX95/flash.bin $out/image
runHook postInstall
'';
};
}