diff --git a/compulab/README.md b/compulab/README.md new file mode 100644 index 000000000..69e79e1e3 --- /dev/null +++ b/compulab/README.md @@ -0,0 +1,29 @@ +# UCM-iMX95 SOM support + +## Supported devices +- [UCM-iMX95 System-on-Module](https://www.compulab.com/products/som-evaluation-kits/ucm-imx95-evaluation-kit/) (**ucm-imx95**) – based on the NXP i.MX95 SoC (A0 silicon), with device-specific boot components(OEI, SM, ATF), U-Boot, and Linux kernel support, including a NixOS configuration example. + +## How to use +This overlay provides configuration and hardware support for the **CompuLab UCM-iMX95** platform, based on the **NXP i.MX95 A0 silicon**. It enables generating NixOS images suitable for booting via U-Boot, using the CompuLab UCM-iMX95 Evaluation Kit carrier board. + +### Boot flow +The boot flow for the UCM-iMX95 platform follows the standard NXP i.MX95 sequence: + +Boot ROM → OEI (initially in TCM, then DDR) → System Manager (SM) → ARM Trusted Firmware (ATF) → U-Boot → Linux kernel → NixOS userspace + +Boot ROM initializes the SoC and loads OEI, which runs in TCM to perform early setup, then configures DDR and loads the System Manager (SM). SM completes SoC initialization and passes control to ATF, which handles secure world setup and then transfers execution to U-Boot, eventually booting the Linux kernel and NixOS root filesystem. + +### Example NixOS configuration +```nix +{ nixos-hardware, }: { + system = "aarch64-linux"; + modules = [ + nixos-hardware.nixosModules.ucm-imx95 + ]; +} +``` + +### Notes +- The configuration includes device-tree, kernel, and bootloader components are optimized for the UCM-iMX95 SoM and evk. +- The generated NixOS image supports booting from SD card or eMMC, depending on the hardware configuration. +- The boot components (OEI in TCM/DDR, SM, ATF, U-Boot) follow the standard NXP release layout for i.MX95 platforms. diff --git a/compulab/ucm-imx95/bsp/ucm-imx95-atf.nix b/compulab/ucm-imx95/bsp/ucm-imx95-atf.nix new file mode 100644 index 000000000..fea07f794 --- /dev/null +++ b/compulab/ucm-imx95/bsp/ucm-imx95-atf.nix @@ -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" ]; + }; +} diff --git a/compulab/ucm-imx95/bsp/ucm-imx95-boot.nix b/compulab/ucm-imx95/bsp/ucm-imx95-boot.nix new file mode 100644 index 000000000..feedebafb --- /dev/null +++ b/compulab/ucm-imx95/bsp/ucm-imx95-boot.nix @@ -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 + ''; + }; +} diff --git a/compulab/ucm-imx95/bsp/ucm-imx95-firmware.nix b/compulab/ucm-imx95/bsp/ucm-imx95-firmware.nix new file mode 100644 index 000000000..18f3aa7cc --- /dev/null +++ b/compulab/ucm-imx95/bsp/ucm-imx95-firmware.nix @@ -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/ + ''; +} diff --git a/compulab/ucm-imx95/bsp/ucm-imx95-linux.nix b/compulab/ucm-imx95/bsp/ucm-imx95-linux.nix new file mode 100644 index 000000000..8aa94c221 --- /dev/null +++ b/compulab/ucm-imx95/bsp/ucm-imx95-linux.nix @@ -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 { }) +) diff --git a/compulab/ucm-imx95/bsp/ucm-imx95-oei-ddr.nix b/compulab/ucm-imx95/bsp/ucm-imx95-oei-ddr.nix new file mode 100644 index 000000000..d7b8868ab --- /dev/null +++ b/compulab/ucm-imx95/bsp/ucm-imx95-oei-ddr.nix @@ -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" ]; + }; +} diff --git a/compulab/ucm-imx95/bsp/ucm-imx95-oei-tcm.nix b/compulab/ucm-imx95/bsp/ucm-imx95-oei-tcm.nix new file mode 100644 index 000000000..e698990ae --- /dev/null +++ b/compulab/ucm-imx95/bsp/ucm-imx95-oei-tcm.nix @@ -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" ]; + }; +} diff --git a/compulab/ucm-imx95/bsp/ucm-imx95-optee-os.nix b/compulab/ucm-imx95/bsp/ucm-imx95-optee-os.nix new file mode 100644 index 000000000..bf6806a4e --- /dev/null +++ b/compulab/ucm-imx95/bsp/ucm-imx95-optee-os.nix @@ -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 + ''; +} diff --git a/compulab/ucm-imx95/bsp/ucm-imx95-sm-fw.nix b/compulab/ucm-imx95/bsp/ucm-imx95-sm-fw.nix new file mode 100644 index 000000000..2628f1513 --- /dev/null +++ b/compulab/ucm-imx95/bsp/ucm-imx95-sm-fw.nix @@ -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" ]; + }; +} diff --git a/compulab/ucm-imx95/bsp/ucm-imx95-uboot.nix b/compulab/ucm-imx95/bsp/ucm-imx95-uboot.nix new file mode 100644 index 000000000..68434e57d --- /dev/null +++ b/compulab/ucm-imx95/bsp/ucm-imx95-uboot.nix @@ -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; +} diff --git a/compulab/ucm-imx95/default.nix b/compulab/ucm-imx95/default.nix new file mode 100644 index 000000000..81fcb392a --- /dev/null +++ b/compulab/ucm-imx95/default.nix @@ -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"; + }; +} diff --git a/compulab/ucm-imx95/modules.nix b/compulab/ucm-imx95/modules.nix new file mode 100644 index 000000000..c0e8f2663 --- /dev/null +++ b/compulab/ucm-imx95/modules.nix @@ -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; +} diff --git a/compulab/ucm-imx95/overlay.nix b/compulab/ucm-imx95/overlay.nix new file mode 100644 index 000000000..942a37119 --- /dev/null +++ b/compulab/ucm-imx95/overlay.nix @@ -0,0 +1,3 @@ +final: _prev: { + inherit (final.callPackage ./bsp/ucm-imx95-boot.nix { pkgs = final; }) imx95-boot; +} diff --git a/flake.nix b/flake.nix index 32fb1e0f8..984448962 100644 --- a/flake.nix +++ b/flake.nix @@ -331,6 +331,7 @@ nxp-imx8mp-evk = import ./nxp/imx8mp-evk; nxp-imx8mq-evk = import ./nxp/imx8mq-evk; nxp-imx8qm-mek = import ./nxp/imx8qm-mek; + ucm-imx95 = import ./compulab/ucm-imx95; hardkernel-odroid-hc4 = import ./hardkernel/odroid-hc4; hardkernel-odroid-h3 = import ./hardkernel/odroid-h3; hardkernel-odroid-h4 = import ./hardkernel/odroid-h4;