|
| 1 | +{ |
| 2 | + lib, |
| 3 | + pkgs |
| 4 | +}: |
| 5 | +let |
| 6 | + inherit (pkgs.buildPackages) python3; |
| 7 | + toolchain = pkgs.gccStdenv.cc; |
| 8 | + binutils = pkgs.gccStdenv.cc.bintools.bintools_bin; |
| 9 | + cpp = pkgs.gcc; |
| 10 | +in |
| 11 | +pkgs.stdenv.mkDerivation rec { |
| 12 | + pname = "imx93-optee-os"; |
| 13 | + version = "lf-6.12.3_1.0.0"; |
| 14 | + |
| 15 | + nativeBuildInputs = [ |
| 16 | + python3 |
| 17 | + ]; |
| 18 | + |
| 19 | + enableParallelBuilding = true; |
| 20 | + |
| 21 | + propagatedBuildInputs = with python3.pkgs; [ |
| 22 | + pycryptodomex |
| 23 | + pyelftools |
| 24 | + cryptography |
| 25 | + ]; |
| 26 | + |
| 27 | + src = pkgs.fetchgit { |
| 28 | + url = "https://github.com/nxp-imx/imx-optee-os.git"; |
| 29 | + rev = "8dd180b6d149c1e1314b5869697179f665bd9ca3"; |
| 30 | + sha256 = "sha256-PoolRscdyeGevrOa5YymPTQ36edVvReMM5WshRTz+uk="; |
| 31 | + }; |
| 32 | + meta = with lib; { |
| 33 | + homepage = "https://github.com/nxp-imx/imx-optee-os"; |
| 34 | + license = [ licenses.bsd2 ]; |
| 35 | + maintainers = with maintainers; [ govindsi ]; |
| 36 | + platforms = [ "aarch64-linux" ]; |
| 37 | + }; |
| 38 | + |
| 39 | + postPatch = '' |
| 40 | + substituteInPlace scripts/arm32_sysreg.py \ |
| 41 | + --replace '/usr/bin/env python3' '${python3}/bin/python' |
| 42 | + substituteInPlace scripts/gen_tee_bin.py \ |
| 43 | + --replace '/usr/bin/env python3' '${python3}/bin/python' |
| 44 | + substituteInPlace scripts/pem_to_pub_c.py \ |
| 45 | + --replace '/usr/bin/env python3' '${python3}/bin/python' |
| 46 | + substituteInPlace ta/pkcs11/scripts/verify-helpers.sh \ |
| 47 | + --replace '/bin/bash' '${pkgs.bash}/bin/bash' |
| 48 | + substituteInPlace mk/gcc.mk \ |
| 49 | + --replace "\$(CROSS_COMPILE_\$(sm))objcopy" ${binutils}/bin/${toolchain.targetPrefix}objcopy |
| 50 | + substituteInPlace mk/gcc.mk \ |
| 51 | + --replace "\$(CROSS_COMPILE_\$(sm))objdump" ${binutils}/bin/${toolchain.targetPrefix}objdump |
| 52 | + substituteInPlace mk/gcc.mk \ |
| 53 | + --replace "\$(CROSS_COMPILE_\$(sm))nm" ${binutils}/bin/${toolchain.targetPrefix}nm |
| 54 | + substituteInPlace mk/gcc.mk \ |
| 55 | + --replace "\$(CROSS_COMPILE_\$(sm))readelf" ${binutils}/bin/${toolchain.targetPrefix}readelf |
| 56 | + substituteInPlace mk/gcc.mk \ |
| 57 | + --replace "\$(CROSS_COMPILE_\$(sm))ar" ${binutils}/bin/${toolchain.targetPrefix}ar |
| 58 | + substituteInPlace mk/gcc.mk \ |
| 59 | + --replace "\$(CROSS_COMPILE_\$(sm))cpp" ${cpp}/bin/cpp |
| 60 | + ''; |
| 61 | + |
| 62 | + makeFlags = [ |
| 63 | + "PLATFORM=imx-mx93evk" |
| 64 | + "CFG_ARM64_core=y" |
| 65 | + "CFG_TEE_TA_LOG_LEVEL=0" |
| 66 | + "CFG_TEE_CORE_LOG_LEVEL=0" |
| 67 | + "CROSS_COMPILE=${toolchain}/bin/${toolchain.targetPrefix}" |
| 68 | + "CROSS_COMPILE64=${toolchain}/bin/${toolchain.targetPrefix}" |
| 69 | + ]; |
| 70 | + |
| 71 | + installPhase = '' |
| 72 | + mkdir -p $out |
| 73 | + cp ./out/arm-plat-imx/core/tee-raw.bin $out/tee.bin |
| 74 | + ''; |
| 75 | +} |
0 commit comments