|
| 1 | +{ |
| 2 | + callPackage, |
| 3 | + fetchFromGitHub, |
| 4 | + stdenv, |
| 5 | + clang, |
| 6 | + git, |
| 7 | + dtc, |
| 8 | + glibc, |
| 9 | + zlib, |
| 10 | + vim, |
| 11 | +}: |
| 12 | +let |
| 13 | + |
| 14 | + imx95-atf = callPackage ./ucm-imx95-atf.nix { }; |
| 15 | + imx95-firmware = callPackage ./ucm-imx95-firmware.nix { }; |
| 16 | + imx95-uboot = callPackage ./ucm-imx95-uboot.nix { }; |
| 17 | + imx95-optee-os = callPackage ./ucm-imx95-optee-os.nix { }; |
| 18 | + imx95-sm-fw = callPackage ./ucm-imx95-sm-fw.nix { }; |
| 19 | + imx95-oei-ddr = callPackage ./ucm-imx95-oei-ddr.nix { }; |
| 20 | + imx95-oei-tcm = callPackage ./ucm-imx95-oei-tcm.nix { }; |
| 21 | + src = fetchFromGitHub { |
| 22 | + owner = "nxp-imx"; |
| 23 | + repo = "imx-mkimage"; |
| 24 | + #tag: lf-6.6.52-2.2.1 |
| 25 | + rev = "f620fb8ef7a04c8dbed8119880f5eeffe3e69746"; |
| 26 | + sha256 = "sha256-JZlX122uZntCIISI1H3Hw+tnk+N/gBJpFFDaZoY8W3c="; |
| 27 | + }; |
| 28 | + shortRev = builtins.substring 0 8 src.rev; |
| 29 | +in |
| 30 | +{ |
| 31 | + imx95-boot = stdenv.mkDerivation rec { |
| 32 | + inherit src; |
| 33 | + name = "imx95-mkimage"; |
| 34 | + version = "lf-6.6.52-2.2.1"; |
| 35 | + |
| 36 | + postPatch = '' |
| 37 | + substituteInPlace Makefile \ |
| 38 | + --replace-fail 'git rev-parse --short=8 HEAD' 'echo ${shortRev}' |
| 39 | + substituteInPlace Makefile \ |
| 40 | + --replace-fail 'CC = gcc' 'CC = clang' |
| 41 | + substituteInPlace iMX95/soc.mak \ |
| 42 | + --replace-fail 'xxd' "${vim.xxd}/bin/xxd" |
| 43 | + substituteInPlace scripts/fspi_fcb_gen.sh \ |
| 44 | + --replace-fail 'xxd' "${vim.xxd}/bin/xxd" |
| 45 | + substituteInPlace scripts/fspi_packer.sh \ |
| 46 | + --replace-fail 'xxd' "${vim.xxd}/bin/xxd" |
| 47 | + patchShebangs scripts |
| 48 | + ''; |
| 49 | + |
| 50 | + nativeBuildInputs = [ |
| 51 | + clang |
| 52 | + git |
| 53 | + dtc |
| 54 | + ]; |
| 55 | + |
| 56 | + buildInputs = [ |
| 57 | + glibc.static |
| 58 | + zlib |
| 59 | + zlib.static |
| 60 | + ]; |
| 61 | + |
| 62 | + buildPhase = '' |
| 63 | + runHook preBuild |
| 64 | +
|
| 65 | + if [ -f ${imx95-uboot}/u-boot.bin ]; then |
| 66 | + install -m 0644 ${imx95-uboot}/u-boot.bin ./iMX95/u-boot.bin |
| 67 | + else |
| 68 | + cat ${imx95-uboot}/u-boot-nodtb.bin ${imx95-uboot}/ucm-imx95.dtb > ./iMX95/u-boot.bin |
| 69 | + fi |
| 70 | + install -m 0644 ${imx95-uboot}/u-boot-spl.bin ./iMX95/u-boot-spl.bin |
| 71 | + install -m 0644 ${imx95-uboot}/u-boot-nodtb.bin ./iMX95/u-boot-nodtb.bin |
| 72 | + install -m 0644 ${imx95-uboot}/ucm-imx95.dtb ./iMX95/ucm-imx95.dtb |
| 73 | + install -m 0644 ${imx95-optee-os}/tee.bin ./iMX95/tee.bin |
| 74 | + install -m 0644 ${imx95-atf}/bl31.bin ./iMX95/bl31.bin |
| 75 | + install -m 0644 ${imx95-sm-fw}/m33_image.bin ./iMX95/m33_image.bin |
| 76 | + install -m 0644 ${imx95-oei-ddr}/oei-m33-ddr.bin ./iMX95/oei-m33-ddr.bin |
| 77 | + install -m 0644 ${imx95-oei-tcm}/oei-m33-tcm.bin ./iMX95/oei-m33-tcm.bin |
| 78 | + install -m 0644 ${imx95-firmware}/ddr/lpddr5* ./iMX95/ |
| 79 | + install -m 0644 ${imx95-firmware}/ahab/mx95a0-ahab-container.img ./iMX95/ |
| 80 | + install -m 0644 ${imx95-firmware}/m7_image.bin ./iMX95/ |
| 81 | +
|
| 82 | + make SOC=iMX95 REV=A0 OEI=YES LPDDR_TYPE=lpddr5 flash_all |
| 83 | +
|
| 84 | + runHook postBuild |
| 85 | + ''; |
| 86 | + |
| 87 | + installPhase = '' |
| 88 | + runHook preInstall |
| 89 | + mkdir -p $out/image |
| 90 | + install -m 0644 ./iMX95/flash.bin $out/image |
| 91 | + runHook postInstall |
| 92 | + ''; |
| 93 | + }; |
| 94 | +} |
0 commit comments