Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions compulab/ucm-imx95/bsp/ucm-imx95-atf.nix
Original file line number Diff line number Diff line change
@@ -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 changes: 87 additions & 0 deletions compulab/ucm-imx95/bsp/ucm-imx95-boot.nix
Original file line number Diff line number Diff line change
@@ -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 changes: 24 additions & 0 deletions compulab/ucm-imx95/bsp/ucm-imx95-firmware.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{ pkgs, ... }:
with pkgs;
stdenv.mkDerivation rec {
pname = "comms-sbc-firmware";
version = "v0_6.36";

src = builtins.fetchGit {
url = "[email protected]: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 changes: 62 additions & 0 deletions compulab/ucm-imx95/bsp/ucm-imx95-linux.nix
Original file line number Diff line number Diff line change
@@ -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 changes: 63 additions & 0 deletions compulab/ucm-imx95/bsp/ucm-imx95-oei-ddr.nix
Original file line number Diff line number Diff line change
@@ -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 changes: 63 additions & 0 deletions compulab/ucm-imx95/bsp/ucm-imx95-oei-tcm.nix
Original file line number Diff line number Diff line change
@@ -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" ];
};
}
Loading