mirror of
				https://github.com/NixOS/nixos-hardware.git
				synced 2025-11-04 17:27:14 +08:00 
			
		
		
		
	Add support for UCM-iMX95 Evaluation Kit platform
The CompuLab UCM-iMX95 Evaluation Kit provides a platform for comprehensive evaluation of the NXP i.MX95 application processor. This change adds support in NixOS hardware to provide a template for customized i.MX95-based platforms. UCM-iMX95: https://www.compulab.com/products/som-evaluation-kits/ucm-imx95-evaluation-kit/ Signed-off-by: Govind Singh <govind.singh@tii.ae>
This commit is contained in:
		
				
					committed by
					
						
						Jörg Thalheim
					
				
			
			
				
	
			
			
			
						parent
						
							43ffe9ac82
						
					
				
				
					commit
					fe21eda733
				
			
							
								
								
									
										57
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-atf.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-atf.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,57 @@
 | 
			
		||||
{
 | 
			
		||||
  lib,
 | 
			
		||||
  fetchgit,
 | 
			
		||||
  stdenv,
 | 
			
		||||
  buildPackages,
 | 
			
		||||
  pkgsCross,
 | 
			
		||||
  openssl,
 | 
			
		||||
}:
 | 
			
		||||
 | 
			
		||||
let
 | 
			
		||||
  target-board = "imx95";
 | 
			
		||||
in
 | 
			
		||||
stdenv.mkDerivation rec {
 | 
			
		||||
  pname = "imx95-atf";
 | 
			
		||||
  version = "2.13.0";
 | 
			
		||||
  platform = target-board;
 | 
			
		||||
  enableParallelBuilding = true;
 | 
			
		||||
 | 
			
		||||
  src = fetchgit {
 | 
			
		||||
    url = "https://github.com/nxp-imx/imx-atf.git";
 | 
			
		||||
    rev = "28affcae957cb8194917b5246276630f9e6343e1";
 | 
			
		||||
    sha256 = "sha256-a8F+Lf8pwML+tCwawS0N/mrSXWPmFhlUeOg0MCRK3VE=";
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  # Compiler dependencies
 | 
			
		||||
  depsBuildBuild = [ buildPackages.stdenv.cc ];
 | 
			
		||||
  nativeBuildInputs = [ pkgsCross.aarch64-embedded.stdenv.cc ];
 | 
			
		||||
 | 
			
		||||
  buildInputs = [ openssl ];
 | 
			
		||||
 | 
			
		||||
  makeFlags = [
 | 
			
		||||
    "HOSTCC=$(CC_FOR_BUILD)"
 | 
			
		||||
    "CROSS_COMPILE=${pkgsCross.aarch64-embedded.stdenv.cc.targetPrefix}"
 | 
			
		||||
    "PLAT=${platform}"
 | 
			
		||||
    "SPD=opteed"
 | 
			
		||||
    "bl31"
 | 
			
		||||
    "LDFLAGS=-no-warn-rwx-segments"
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  installPhase = ''
 | 
			
		||||
    runHook preInstall
 | 
			
		||||
    mkdir -p $out
 | 
			
		||||
    cp build/${target-board}/release/bl31.bin $out
 | 
			
		||||
    runHook postInstall
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  hardeningDisable = [ "all" ];
 | 
			
		||||
  dontStrip = true;
 | 
			
		||||
 | 
			
		||||
  meta = with lib; {
 | 
			
		||||
    homepage = "https://github.com/nxp-imx/imx-atf";
 | 
			
		||||
    description = "Reference implementation of secure world software for ARMv8-A";
 | 
			
		||||
    license = [ licenses.bsd3 ];
 | 
			
		||||
    maintainers = with maintainers; [ govindsi ];
 | 
			
		||||
    platforms = [ "aarch64-linux" ];
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										87
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-boot.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										87
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-boot.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,87 @@
 | 
			
		||||
{
 | 
			
		||||
  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.fetchgit {
 | 
			
		||||
    url = "https://github.com/nxp-imx/imx-mkimage.git";
 | 
			
		||||
    #tag: lf-6.6.36
 | 
			
		||||
    rev = "4622115cbc037f79039c4522faeced4aabea986b";
 | 
			
		||||
    sha256 = "sha256-2gz0GxlB3jwy8PC6+cP3+MpyUzqE1vDTw8nuxK6vo3g=";
 | 
			
		||||
  };
 | 
			
		||||
  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 'git rev-parse --short=8 HEAD' 'echo ${shortRev}'
 | 
			
		||||
      substituteInPlace Makefile \
 | 
			
		||||
          --replace 'CC = gcc' 'CC = clang'
 | 
			
		||||
      substituteInPlace iMX95/soc.mak \
 | 
			
		||||
        --replace 'xxd' "${pkgs.vim.xxd}/bin/xxd"
 | 
			
		||||
      substituteInPlace scripts/fspi_fcb_gen.sh \
 | 
			
		||||
        --replace 'xxd' "${pkgs.vim.xxd}/bin/xxd"
 | 
			
		||||
      substituteInPlace scripts/fspi_packer.sh \
 | 
			
		||||
        --replace '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}/ucm-imx95/lpddr5* ./iMX95/
 | 
			
		||||
      install -m 0644 ${imx95-firmware}/ucm-imx95/mx95a0-ahab-container.img ./iMX95/
 | 
			
		||||
      install -m 0644 ${imx95-firmware}/ucm-imx95/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
 | 
			
		||||
    '';
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										24
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-firmware.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-firmware.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
			
		||||
{ pkgs, ... }:
 | 
			
		||||
with pkgs;
 | 
			
		||||
stdenv.mkDerivation rec {
 | 
			
		||||
  pname = "comms-sbc-firmware";
 | 
			
		||||
  version = "v0_6.36";
 | 
			
		||||
 | 
			
		||||
  src = builtins.fetchGit {
 | 
			
		||||
    url = "git@github.com:tiiuae/comms-sbc-firmware.git";
 | 
			
		||||
    rev = "06394d6d983955734257fdc7f719e454a3ce07f4";
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  nativeBuildInputs = [
 | 
			
		||||
    pkgs.rsync
 | 
			
		||||
    pkgs.coreutils
 | 
			
		||||
  ];
 | 
			
		||||
  dontUnpack = true;
 | 
			
		||||
  dontStrip = true;
 | 
			
		||||
 | 
			
		||||
  installPhase = ''
 | 
			
		||||
    mkdir -p $out
 | 
			
		||||
    # copy everything except .git
 | 
			
		||||
    rsync -a --exclude='.git' $src/ $out/
 | 
			
		||||
  '';
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										62
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-linux.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-linux.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,62 @@
 | 
			
		||||
{ lib, pkgs, ... }@args:
 | 
			
		||||
with pkgs;
 | 
			
		||||
buildLinux (
 | 
			
		||||
  args
 | 
			
		||||
  // rec {
 | 
			
		||||
    version = "6.6.36";
 | 
			
		||||
    name = "imx95-linux";
 | 
			
		||||
 | 
			
		||||
    # modDirVersion needs to be x.y.z, will automatically add .0 if needed
 | 
			
		||||
    modDirVersion = version;
 | 
			
		||||
 | 
			
		||||
    defconfig = "compulab-mx95_defconfig";
 | 
			
		||||
 | 
			
		||||
    # https://github.com/NixOS/nixpkgs/pull/366004
 | 
			
		||||
    # introduced a breaking change that if a module is declared but it is not being used it will faill.
 | 
			
		||||
    ignoreConfigErrors = true;
 | 
			
		||||
 | 
			
		||||
    kernelPatches = [
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    autoModules = false;
 | 
			
		||||
 | 
			
		||||
    extraConfig = ''
 | 
			
		||||
      CRYPTO_TLS m
 | 
			
		||||
      TLS y
 | 
			
		||||
      MD_RAID0 m
 | 
			
		||||
      MD_RAID1 m
 | 
			
		||||
      MD_RAID10 m
 | 
			
		||||
      MD_RAID456 m
 | 
			
		||||
      DM_VERITY m
 | 
			
		||||
      LOGO y
 | 
			
		||||
      FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER n
 | 
			
		||||
      FB_EFI n
 | 
			
		||||
      EFI_STUB y
 | 
			
		||||
      EFI y
 | 
			
		||||
      VIRTIO y
 | 
			
		||||
      VIRTIO_PCI y
 | 
			
		||||
      VIRTIO_BLK y
 | 
			
		||||
      DRM_VIRTIO_GPU y
 | 
			
		||||
      EXT4_FS y
 | 
			
		||||
      USBIP_CORE m
 | 
			
		||||
      USBIP_VHCI_HCD m
 | 
			
		||||
      USBIP_HOST m
 | 
			
		||||
      USBIP_VUDC m
 | 
			
		||||
    '';
 | 
			
		||||
 | 
			
		||||
    src = fetchFromGitHub {
 | 
			
		||||
      owner = "compulab-yokneam";
 | 
			
		||||
      repo = "linux-compulab";
 | 
			
		||||
      # tag: linux-compulab_6.6.36
 | 
			
		||||
      rev = "b93daaad0807fb15d4f3f1a6e5be843ac7532ef7";
 | 
			
		||||
      sha256 = "sha256-wCeuGXBTz3H6OFWBA1M1/t/9WgxBVjQ8FU/wvAUVW2w=";
 | 
			
		||||
    };
 | 
			
		||||
    meta = with lib; {
 | 
			
		||||
      homepage = "https://github.com/compulab-yokneam/linux-compulab";
 | 
			
		||||
      license = [ licenses.gpl2Only ];
 | 
			
		||||
      maintainers = with maintainers; [ govindsi ];
 | 
			
		||||
      platforms = [ "aarch64-linux" ];
 | 
			
		||||
    };
 | 
			
		||||
  }
 | 
			
		||||
  // (args.argsOverride or { })
 | 
			
		||||
)
 | 
			
		||||
							
								
								
									
										63
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-oei-ddr.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-oei-ddr.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,63 @@
 | 
			
		||||
{
 | 
			
		||||
  lib,
 | 
			
		||||
  pkgs,
 | 
			
		||||
}:
 | 
			
		||||
pkgs.stdenv.mkDerivation rec {
 | 
			
		||||
  pname = "imx95-imx-oei";
 | 
			
		||||
  version = "lf-6.6.36-2.1.0";
 | 
			
		||||
 | 
			
		||||
  nativeBuildInputs = [
 | 
			
		||||
    pkgs.buildPackages.python3
 | 
			
		||||
    pkgs.gcc-arm-embedded
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  src = pkgs.fetchgit {
 | 
			
		||||
    url = "https://github.com/nxp-imx/imx-oei.git";
 | 
			
		||||
    rev = "5fca9f47544d03c52ca371eadfffbfd2454e6925";
 | 
			
		||||
    sha256 = "sha256-Sb6u1NlhJpDCOKBu3HqUb4BLEy0F8LYVnJE0tRSvzWc=";
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  patches = [
 | 
			
		||||
    (pkgs.fetchpatch {
 | 
			
		||||
      url = "https://raw.githubusercontent.com/compulab-yokneam/meta-bsp-imx95/scarthgap/recipes-bsp/imx-oei/imx-oei/0001-Add-CompuLab-lpddr5_timing.c.patch";
 | 
			
		||||
      sha256 = "sha256-6ZpBOXw2aIhD2i9Wx368xfHq6NvdZghWHU9u8+gRTj8=";
 | 
			
		||||
    })
 | 
			
		||||
    (pkgs.fetchpatch {
 | 
			
		||||
      url = "https://raw.githubusercontent.com/compulab-yokneam/meta-bsp-imx95/scarthgap/recipes-bsp/imx-oei/imx-oei/0002-board-mx95lp5-Fix-default-DDR_CONFIG-timing-name.patch";
 | 
			
		||||
      sha256 = "sha256-WZ/vYaTC2iKIC+jnHtnPriCxK9gjRsOv2Uy13Ye4698=";
 | 
			
		||||
    })
 | 
			
		||||
    (pkgs.fetchpatch {
 | 
			
		||||
      url = "https://raw.githubusercontent.com/compulab-yokneam/meta-bsp-imx95/scarthgap/recipes-bsp/imx-oei/imx-oei/0003-Add-CompuLab-lpddr5_timing_4g.c.patch";
 | 
			
		||||
      sha256 = "sha256-yyierv2USZlM8Cuxf4FDj4+UtILvJQH9BJSj+fmayL8=";
 | 
			
		||||
    })
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  postPatch = ''
 | 
			
		||||
    substituteInPlace oei/makefiles/build_info.mak \
 | 
			
		||||
      --replace "/bin/echo" "echo"
 | 
			
		||||
    substituteInPlace Makefile \
 | 
			
		||||
      --replace "/bin/echo" "echo"
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  makeFlags = [
 | 
			
		||||
    "board=mx95lp5"
 | 
			
		||||
    "CROSS_COMPILE=${pkgs.gcc-arm-embedded}/bin/arm-none-eabi-"
 | 
			
		||||
    "OEI_CROSS_COMPILE=${pkgs.gcc-arm-embedded}/bin/arm-none-eabi-"
 | 
			
		||||
    "ARCH=arm"
 | 
			
		||||
    "DDR_CONFIG=lpddr5_timing"
 | 
			
		||||
    "oei=ddr"
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  installPhase = ''
 | 
			
		||||
    mkdir -p $out
 | 
			
		||||
    cp build/mx95lp5/ddr/oei-m33-ddr.bin $out/
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  meta = with lib; {
 | 
			
		||||
    homepage = "https://github.com/nxp-imx/imx-oei";
 | 
			
		||||
    description = "Optional Executable Image assembler for i.MX95 processors";
 | 
			
		||||
    license = [ licenses.bsd3 ];
 | 
			
		||||
    maintainers = with maintainers; [ govindsi ];
 | 
			
		||||
    platforms = [ "aarch64-linux" ];
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										63
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-oei-tcm.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-oei-tcm.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,63 @@
 | 
			
		||||
{
 | 
			
		||||
  lib,
 | 
			
		||||
  pkgs,
 | 
			
		||||
}:
 | 
			
		||||
pkgs.stdenv.mkDerivation rec {
 | 
			
		||||
  pname = "imx95-imx-oei-tcm";
 | 
			
		||||
  version = "lf-6.6.36-2.1.0";
 | 
			
		||||
 | 
			
		||||
  nativeBuildInputs = [
 | 
			
		||||
    pkgs.buildPackages.python3
 | 
			
		||||
    pkgs.gcc-arm-embedded
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  src = pkgs.fetchgit {
 | 
			
		||||
    url = "https://github.com/nxp-imx/imx-oei.git";
 | 
			
		||||
    rev = "5fca9f47544d03c52ca371eadfffbfd2454e6925";
 | 
			
		||||
    sha256 = "sha256-Sb6u1NlhJpDCOKBu3HqUb4BLEy0F8LYVnJE0tRSvzWc=";
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  patches = [
 | 
			
		||||
    (pkgs.fetchpatch {
 | 
			
		||||
      url = "https://raw.githubusercontent.com/compulab-yokneam/meta-bsp-imx95/scarthgap/recipes-bsp/imx-oei/imx-oei/0001-Add-CompuLab-lpddr5_timing.c.patch";
 | 
			
		||||
      sha256 = "sha256-6ZpBOXw2aIhD2i9Wx368xfHq6NvdZghWHU9u8+gRTj8=";
 | 
			
		||||
    })
 | 
			
		||||
    (pkgs.fetchpatch {
 | 
			
		||||
      url = "https://raw.githubusercontent.com/compulab-yokneam/meta-bsp-imx95/scarthgap/recipes-bsp/imx-oei/imx-oei/0002-board-mx95lp5-Fix-default-DDR_CONFIG-timing-name.patch";
 | 
			
		||||
      sha256 = "sha256-WZ/vYaTC2iKIC+jnHtnPriCxK9gjRsOv2Uy13Ye4698=";
 | 
			
		||||
    })
 | 
			
		||||
    (pkgs.fetchpatch {
 | 
			
		||||
      url = "https://raw.githubusercontent.com/compulab-yokneam/meta-bsp-imx95/scarthgap/recipes-bsp/imx-oei/imx-oei/0003-Add-CompuLab-lpddr5_timing_4g.c.patch";
 | 
			
		||||
      sha256 = "sha256-yyierv2USZlM8Cuxf4FDj4+UtILvJQH9BJSj+fmayL8=";
 | 
			
		||||
    })
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  postPatch = ''
 | 
			
		||||
    substituteInPlace oei/makefiles/build_info.mak \
 | 
			
		||||
      --replace "/bin/echo" "echo"
 | 
			
		||||
    substituteInPlace Makefile \
 | 
			
		||||
      --replace "/bin/echo" "echo"
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  makeFlags = [
 | 
			
		||||
    "board=mx95lp5"
 | 
			
		||||
    "CROSS_COMPILE=${pkgs.gcc-arm-embedded}/bin/arm-none-eabi-"
 | 
			
		||||
    "OEI_CROSS_COMPILE=${pkgs.gcc-arm-embedded}/bin/arm-none-eabi-"
 | 
			
		||||
    "ARCH=arm"
 | 
			
		||||
    "DDR_CONFIG=lpddr5_timing"
 | 
			
		||||
    "oei=tcm"
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  installPhase = ''
 | 
			
		||||
    mkdir -p $out
 | 
			
		||||
    cp build/mx95lp5/tcm/oei-m33-tcm.bin $out/
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  meta = with lib; {
 | 
			
		||||
    homepage = "https://github.com/nxp-imx/imx-oei";
 | 
			
		||||
    description = "Optional Executable Image assembler for i.MX95 processors";
 | 
			
		||||
    license = [ licenses.bsd3 ];
 | 
			
		||||
    maintainers = with maintainers; [ govindsi ];
 | 
			
		||||
    platforms = [ "aarch64-linux" ];
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										75
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-optee-os.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-optee-os.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,75 @@
 | 
			
		||||
{
 | 
			
		||||
  lib,
 | 
			
		||||
  pkgs,
 | 
			
		||||
}:
 | 
			
		||||
let
 | 
			
		||||
  inherit (pkgs.buildPackages) python3;
 | 
			
		||||
  toolchain = pkgs.gccStdenv.cc;
 | 
			
		||||
  binutils = pkgs.gccStdenv.cc.bintools.bintools_bin;
 | 
			
		||||
  cpp = pkgs.gcc;
 | 
			
		||||
in
 | 
			
		||||
pkgs.stdenv.mkDerivation rec {
 | 
			
		||||
  pname = "imx95-optee-os";
 | 
			
		||||
  version = "lf-6.6.36_2.1.0";
 | 
			
		||||
 | 
			
		||||
  nativeBuildInputs = [
 | 
			
		||||
    python3
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  enableParallelBuilding = true;
 | 
			
		||||
 | 
			
		||||
  propagatedBuildInputs = with python3.pkgs; [
 | 
			
		||||
    pycryptodomex
 | 
			
		||||
    pyelftools
 | 
			
		||||
    cryptography
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  src = pkgs.fetchgit {
 | 
			
		||||
    url = "https://github.com/nxp-imx/imx-optee-os.git";
 | 
			
		||||
    rev = "612bc5a642a4608d282abeee2349d86de996d7ee";
 | 
			
		||||
    sha256 = "sha256-A7p3KPijwipivs9Qw9Mr62RWwaMBGTz7J8WP5JYoSOs=";
 | 
			
		||||
  };
 | 
			
		||||
  meta = with lib; {
 | 
			
		||||
    homepage = "https://github.com/nxp-imx/imx-optee-os";
 | 
			
		||||
    license = [ licenses.bsd2 ];
 | 
			
		||||
    maintainers = with maintainers; [ govindsi ];
 | 
			
		||||
    platforms = [ "aarch64-linux" ];
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  postPatch = ''
 | 
			
		||||
    substituteInPlace scripts/arm32_sysreg.py \
 | 
			
		||||
      --replace '/usr/bin/env python3' '${python3}/bin/python'
 | 
			
		||||
    substituteInPlace scripts/gen_tee_bin.py \
 | 
			
		||||
      --replace '/usr/bin/env python3' '${python3}/bin/python'
 | 
			
		||||
    substituteInPlace scripts/pem_to_pub_c.py \
 | 
			
		||||
      --replace '/usr/bin/env python3' '${python3}/bin/python'
 | 
			
		||||
    substituteInPlace ta/pkcs11/scripts/verify-helpers.sh \
 | 
			
		||||
      --replace '/bin/bash' '${pkgs.bash}/bin/bash'
 | 
			
		||||
    substituteInPlace mk/gcc.mk \
 | 
			
		||||
      --replace "\$(CROSS_COMPILE_\$(sm))objcopy" ${binutils}/bin/${toolchain.targetPrefix}objcopy
 | 
			
		||||
    substituteInPlace mk/gcc.mk \
 | 
			
		||||
      --replace "\$(CROSS_COMPILE_\$(sm))objdump" ${binutils}/bin/${toolchain.targetPrefix}objdump
 | 
			
		||||
    substituteInPlace mk/gcc.mk \
 | 
			
		||||
      --replace "\$(CROSS_COMPILE_\$(sm))nm" ${binutils}/bin/${toolchain.targetPrefix}nm
 | 
			
		||||
    substituteInPlace mk/gcc.mk \
 | 
			
		||||
      --replace "\$(CROSS_COMPILE_\$(sm))readelf" ${binutils}/bin/${toolchain.targetPrefix}readelf
 | 
			
		||||
    substituteInPlace mk/gcc.mk \
 | 
			
		||||
      --replace "\$(CROSS_COMPILE_\$(sm))ar" ${binutils}/bin/${toolchain.targetPrefix}ar
 | 
			
		||||
    substituteInPlace mk/gcc.mk \
 | 
			
		||||
      --replace "\$(CROSS_COMPILE_\$(sm))cpp" ${cpp}/bin/cpp
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  makeFlags = [
 | 
			
		||||
    "PLATFORM=imx-mx95evk"
 | 
			
		||||
    "CFG_ARM64_core=y"
 | 
			
		||||
    "CFG_TEE_TA_LOG_LEVEL=0"
 | 
			
		||||
    "CFG_TEE_CORE_LOG_LEVEL=0"
 | 
			
		||||
    "CROSS_COMPILE=${toolchain}/bin/${toolchain.targetPrefix}"
 | 
			
		||||
    "CROSS_COMPILE64=${toolchain}/bin/${toolchain.targetPrefix}"
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  installPhase = ''
 | 
			
		||||
    mkdir -p $out
 | 
			
		||||
    cp ./out/arm-plat-imx/core/tee-raw.bin $out/tee.bin
 | 
			
		||||
  '';
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										79
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-sm-fw.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-sm-fw.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,79 @@
 | 
			
		||||
{
 | 
			
		||||
  lib,
 | 
			
		||||
  pkgs,
 | 
			
		||||
}:
 | 
			
		||||
pkgs.stdenv.mkDerivation rec {
 | 
			
		||||
  pname = "imx95-sm-fw";
 | 
			
		||||
  version = "lf-6.6.36-2.1.0";
 | 
			
		||||
 | 
			
		||||
  nativeBuildInputs = [
 | 
			
		||||
    pkgs.buildPackages.python3
 | 
			
		||||
    pkgs.gcc-arm-embedded
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  propagatedBuildInputs = with pkgs.buildPackages.python3.pkgs; [
 | 
			
		||||
    pycryptodomex
 | 
			
		||||
    pyelftools
 | 
			
		||||
    cryptography
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  src = pkgs.fetchgit {
 | 
			
		||||
    url = "https://github.com/nxp-imx/imx-sm.git";
 | 
			
		||||
    rev = "709deccd9338399eb39b5cf99a60eab4fa60d539";
 | 
			
		||||
    sha256 = "sha256-02Cl+XhWGSFswspdBJ/4B/mBm4XTs/qKotx0BXMQpJk=";
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  patches = [
 | 
			
		||||
    (pkgs.fetchpatch {
 | 
			
		||||
      url = "https://raw.githubusercontent.com/compulab-yokneam/meta-bsp-imx95/scarthgap-6.6.36-EVAL-UCM-iMX95-1.0/recipes-bsp/imx-system-manager/imx-system-manager/0001-Add-mcimx95cust-board.patch";
 | 
			
		||||
      sha256 = "sha256-zvZ4bNew+yRPmaZQMrAH087KpCLRqz6zdElfe72Dtuc=";
 | 
			
		||||
    })
 | 
			
		||||
    (pkgs.fetchpatch {
 | 
			
		||||
      url = "https://raw.githubusercontent.com/compulab-yokneam/meta-bsp-imx95/scarthgap-6.6.36-EVAL-UCM-iMX95-1.0/recipes-bsp/imx-system-manager/imx-system-manager/0002-Fix-null-pionter-except.patch";
 | 
			
		||||
      sha256 = "sha256-q72VEvJqm2CmOxdWMqGibgXS5lY08mC4srEcy00QdrE=";
 | 
			
		||||
    })
 | 
			
		||||
    (pkgs.fetchpatch {
 | 
			
		||||
      url = "https://raw.githubusercontent.com/compulab-yokneam/meta-bsp-imx95/scarthgap-6.6.36-EVAL-UCM-iMX95-1.0/recipes-bsp/imx-system-manager/imx-system-manager/0001-update-for-yocto-6.6.36-compatibility.patch";
 | 
			
		||||
      sha256 = "sha256-JzHqDiD/ZOu6VQQI0JxY17RQ3bA2t1aP3O1sjLPguWs=";
 | 
			
		||||
    })
 | 
			
		||||
    (pkgs.fetchpatch {
 | 
			
		||||
      url = "https://raw.githubusercontent.com/compulab-yokneam/meta-bsp-imx95/scarthgap-6.6.36-EVAL-UCM-iMX95-1.0/recipes-bsp/imx-system-manager/imx-system-manager/0003-sm-Disable-GPIO1-10-interrupt.patch";
 | 
			
		||||
      sha256 = "sha256-dhcDv7Uq856+MBonczMPznk+tuqUFxTcHiKLX+myCVA=";
 | 
			
		||||
    })
 | 
			
		||||
    (pkgs.fetchpatch {
 | 
			
		||||
      url = "https://raw.githubusercontent.com/compulab-yokneam/meta-bsp-imx95/scarthgap-6.6.36-EVAL-UCM-iMX95-1.0/recipes-bsp/imx-system-manager/imx-system-manager/0004-configs-mx95cust-change-LPTPM1-ownership.patch";
 | 
			
		||||
      sha256 = "sha256-NcLu6+zXpiSz1bHKW14Zuf6F/4pzKsekb+zaRtKjSTY=";
 | 
			
		||||
    })
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  postPatch = ''
 | 
			
		||||
    substituteInPlace sm/makefiles/gcc_cross.mak \
 | 
			
		||||
      --replace "\$(SM_CROSS_COMPILE)objcopy" ${pkgs.gcc-arm-embedded}/bin/arm-none-eabi-objcopy
 | 
			
		||||
    substituteInPlace sm/makefiles/build_info.mak \
 | 
			
		||||
      --replace "/bin/echo" "echo"
 | 
			
		||||
    substituteInPlace sm/makefiles/gcc_cross.mak \
 | 
			
		||||
      --replace 'SM_CROSS_COMPILE ?= $(TOOLS)/arm-gnu-toolchain-*-none-eabi/bin/arm-none-eabi-' \
 | 
			
		||||
                'SM_CROSS_COMPILE ?= $(CROSS_COMPILE)'
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  makeFlags = [
 | 
			
		||||
    "config=mx95cust"
 | 
			
		||||
    "M=2"
 | 
			
		||||
    "CROSS_COMPILE=${pkgs.gcc-arm-embedded}/bin/arm-none-eabi-"
 | 
			
		||||
    "CROSS_COMPILE64=${pkgs.gcc-arm-embedded}/bin/arm-none-eabi-"
 | 
			
		||||
    "ARCH=arm"
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  installPhase = ''
 | 
			
		||||
    mkdir -p $out
 | 
			
		||||
    cp build/mx95cust/m33_image.bin $out/
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  meta = with lib; {
 | 
			
		||||
    homepage = "https://github.com/nxp-imx/imx-sm";
 | 
			
		||||
    description = "System Manager firmware for i.MX processors";
 | 
			
		||||
    license = [ licenses.bsd3 ];
 | 
			
		||||
    maintainers = with maintainers; [ govindsi ];
 | 
			
		||||
    platforms = [ "aarch64-linux" ];
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										93
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-uboot.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								compulab/ucm-imx95/bsp/ucm-imx95-uboot.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,93 @@
 | 
			
		||||
{
 | 
			
		||||
  stdenv,
 | 
			
		||||
  lib,
 | 
			
		||||
  bison,
 | 
			
		||||
  dtc,
 | 
			
		||||
  fetchgit,
 | 
			
		||||
  flex,
 | 
			
		||||
  gnutls,
 | 
			
		||||
  libuuid,
 | 
			
		||||
  ncurses,
 | 
			
		||||
  openssl,
 | 
			
		||||
  which,
 | 
			
		||||
  perl,
 | 
			
		||||
  buildPackages,
 | 
			
		||||
  efitools,
 | 
			
		||||
}:
 | 
			
		||||
let
 | 
			
		||||
  ubsrc = fetchgit {
 | 
			
		||||
    url = "https://github.com/compulab-yokneam/u-boot-compulab.git";
 | 
			
		||||
    # tag: lf_v2024.04
 | 
			
		||||
    rev = "824401fe487d7d3cbcf251bd60270bd7fe8d21d0";
 | 
			
		||||
    sha256 = "sha256-m+YW7+XF/jcNKfyb5533LXGyOWvStqY+MCczAdcNGZI=";
 | 
			
		||||
  };
 | 
			
		||||
in
 | 
			
		||||
stdenv.mkDerivation {
 | 
			
		||||
  pname = "imx95-uboot";
 | 
			
		||||
  version = "2024.04";
 | 
			
		||||
  src = ubsrc;
 | 
			
		||||
 | 
			
		||||
  postPatch = ''
 | 
			
		||||
    patchShebangs tools
 | 
			
		||||
    patchShebangs scripts
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  nativeBuildInputs = [
 | 
			
		||||
    bison
 | 
			
		||||
    flex
 | 
			
		||||
    openssl
 | 
			
		||||
    which
 | 
			
		||||
    ncurses
 | 
			
		||||
    libuuid
 | 
			
		||||
    gnutls
 | 
			
		||||
    openssl
 | 
			
		||||
    perl
 | 
			
		||||
    efitools
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  depsBuildBuild = [ buildPackages.stdenv.cc ];
 | 
			
		||||
  hardeningDisable = [ "all" ];
 | 
			
		||||
  enableParallelBuilding = true;
 | 
			
		||||
 | 
			
		||||
  makeFlags = [
 | 
			
		||||
    "DTC=${lib.getExe buildPackages.dtc}"
 | 
			
		||||
    "CROSS_COMPILE=${stdenv.cc.targetPrefix}"
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  extraConfig = ''
 | 
			
		||||
    CONFIG_USE_BOOTCOMMAND=y
 | 
			
		||||
    CONFIG_BOOTCOMMAND="setenv ramdisk_addr_r 0x97000000; setenv fdt_addr_r 0x96000000; run distro_bootcmd; "
 | 
			
		||||
    CONFIG_CMD_BOOTEFI_SELFTEST=y
 | 
			
		||||
    CONFIG_CMD_BOOTEFI=y
 | 
			
		||||
    CONFIG_EFI_LOADER=y
 | 
			
		||||
    CONFIG_BLK=y
 | 
			
		||||
    CONFIG_PARTITIONS=y
 | 
			
		||||
    CONFIG_DM_DEVICE_REMOVE=n
 | 
			
		||||
    CONFIG_CMD_CACHE=y
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  passAsFile = [ "extraConfig" ];
 | 
			
		||||
 | 
			
		||||
  configurePhase = ''
 | 
			
		||||
    runHook preConfigure
 | 
			
		||||
 | 
			
		||||
    make ucm-imx95_defconfig
 | 
			
		||||
    cat $extraConfigPath >> .config
 | 
			
		||||
 | 
			
		||||
    runHook postConfigure
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  installPhase = ''
 | 
			
		||||
    runHook preInstall
 | 
			
		||||
 | 
			
		||||
    mkdir -p $out
 | 
			
		||||
    cp ./u-boot-nodtb.bin $out
 | 
			
		||||
    cp ./spl/u-boot-spl.bin $out
 | 
			
		||||
    cp ./arch/arm/dts/ucm-imx95.dtb $out
 | 
			
		||||
    cp .config  $out
 | 
			
		||||
 | 
			
		||||
    runHook postInstall
 | 
			
		||||
  '';
 | 
			
		||||
 | 
			
		||||
  dontStrip = true;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										19
									
								
								compulab/ucm-imx95/default.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								compulab/ucm-imx95/default.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
{ pkgs, ... }:
 | 
			
		||||
{
 | 
			
		||||
  nixpkgs.overlays = [
 | 
			
		||||
    (import ./overlay.nix)
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  imports = [
 | 
			
		||||
    ./modules.nix
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  boot.loader.grub.extraFiles = {
 | 
			
		||||
    "ucm-imx95.dtb" = "${pkgs.callPackage ./bsp/ucm-imx95-linux.nix { }}/dtbs/compulab/ucm-imx95.dtb";
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  hardware.deviceTree = {
 | 
			
		||||
    filter = "ucm-imx95.dtb";
 | 
			
		||||
    name = "ucm-imx95.dtb";
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										17
									
								
								compulab/ucm-imx95/modules.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								compulab/ucm-imx95/modules.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
{
 | 
			
		||||
  pkgs,
 | 
			
		||||
  lib,
 | 
			
		||||
  ...
 | 
			
		||||
}:
 | 
			
		||||
{
 | 
			
		||||
  nixpkgs.hostPlatform = "aarch64-linux";
 | 
			
		||||
 | 
			
		||||
  boot = {
 | 
			
		||||
    kernelPackages = pkgs.linuxPackagesFor (pkgs.callPackage ./bsp/ucm-imx95-linux.nix { });
 | 
			
		||||
    initrd.includeDefaultModules = lib.mkForce false;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  disabledModules = [ "profiles/all-hardware.nix" ];
 | 
			
		||||
 | 
			
		||||
  hardware.deviceTree.enable = true;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										3
									
								
								compulab/ucm-imx95/overlay.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								compulab/ucm-imx95/overlay.nix
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
final: _prev: {
 | 
			
		||||
  inherit (final.callPackage ./bsp/ucm-imx95-boot.nix { pkgs = final; }) imx95-boot;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user