Skip to content

Commit 3cce00b

Browse files
committed
Add support for i.MX93-EVK platform
The i.MX93 EVK provides a platform for comprehensive evaluation of the i.MX93 application processors. This change adds support in NixOS hardware to provide a template for customized i.MX93-based platforms. Signed-off-by: Govind Singh <[email protected]>
1 parent d6645c3 commit 3cce00b

File tree

11 files changed

+462
-3
lines changed

11 files changed

+462
-3
lines changed

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@
331331
nxp-imx8mp-evk = import ./nxp/imx8mp-evk;
332332
nxp-imx8mq-evk = import ./nxp/imx8mq-evk;
333333
nxp-imx8qm-mek = import ./nxp/imx8qm-mek;
334+
nxp-imx93-evk = import ./nxp/imx93-evk;
334335
hardkernel-odroid-hc4 = import ./hardkernel/odroid-hc4;
335336
hardkernel-odroid-h3 = import ./hardkernel/odroid-h3;
336337
hardkernel-odroid-h4 = import ./hardkernel/odroid-h4;

nxp/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,18 @@ Code snippet example that enables imx8qm configuration:
2121
}
2222
```
2323

24-
### 2.2 For imx8mq-evk/imx8mp-evk
24+
### 2.2 For imx8mq-evk/imx8mp-evk/imx93-evk
2525
This NXP overlay is used for generating sdimage.
26-
Current configuration uses uboot as a bootloader. It provides an options to use optee-os which is currently disabled. It can be enabled using `enable-tee` boolean argument avalable in `imx8m<q/p>-boot.nix`, which is `false` by default.
26+
Current configuration uses uboot as a bootloader. It provides an options to use optee-os which is currently disabled. It can be enabled using `enable-tee` boolean argument avalable in `imx8m<q/p>-boot.nix`, which is `false` by default in imx8m platform.
2727

28-
Code snippet example that enables 'imx8mp-evk/emx8mq-evk' configuration:
28+
Code snippet example that enables 'imx8mp-evk/imx8mq-evk/imx93-evk' configuration:
2929

3030
```
3131
{ nixos-hardware, }: {
3232
system = "aarch64-linux";
3333
modules = [
3434
nixos-hardware.nixosModules.imx8mp-evk #For imx8mp-evk
35+
#nixos-hardware.nixosModules.imx93-evk #For imx93-evk
3536
#nixos-hardware.nixosModules.imx8mq-evk #For imx8mq-evk
3637
];
3738
}

nxp/imx93-evk/bsp/imx93-atf.nix

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{ lib, fetchgit, stdenv, buildPackages, pkgsCross, openssl }:
2+
3+
let
4+
target-board = "imx93";
5+
in stdenv.mkDerivation rec {
6+
pname = "imx93-atf";
7+
version = "2.10.0";
8+
platform = target-board;
9+
enableParallelBuilding = true;
10+
11+
src = fetchgit {
12+
url = "https://github.com/nxp-imx/imx-atf.git";
13+
rev = "28affcae957cb8194917b5246276630f9e6343e1";
14+
sha256 = "sha256-a8F+Lf8pwML+tCwawS0N/mrSXWPmFhlUeOg0MCRK3VE=";
15+
};
16+
17+
# Compiler dependencies
18+
depsBuildBuild = [ buildPackages.stdenv.cc ];
19+
nativeBuildInputs = [ pkgsCross.aarch64-embedded.stdenv.cc ];
20+
21+
buildInputs = [ openssl ];
22+
23+
makeFlags = [
24+
"HOSTCC=$(CC_FOR_BUILD)"
25+
"CROSS_COMPILE=${pkgsCross.aarch64-embedded.stdenv.cc.targetPrefix}"
26+
"PLAT=${platform}"
27+
"SPD=opteed"
28+
"bl31"
29+
"LDFLAGS=-no-warn-rwx-segments"
30+
];
31+
32+
installPhase = ''
33+
runHook preInstall
34+
mkdir -p $out
35+
cp build/${target-board}/release/bl31.bin $out
36+
runHook postInstall
37+
'';
38+
39+
hardeningDisable = [ "all" ];
40+
dontStrip = true;
41+
42+
meta = with lib; {
43+
homepage = "https://github.com/nxp-imx/imx-atf";
44+
description = "Reference implementation of secure world software for ARMv8-A";
45+
license = [ licenses.bsd3 ];
46+
maintainers = with maintainers; [ govindsi ];
47+
platforms = [ "aarch64-linux" ];
48+
};
49+
}
50+

nxp/imx93-evk/bsp/imx93-boot.nix

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
pkgs,
3+
}:
4+
with pkgs;
5+
let
6+
fw-ver = "202406";
7+
8+
imx93-atf = pkgs.callPackage ./imx93-atf.nix { };
9+
imx93-firmware = pkgs.callPackage ./imx93-firmware.nix { };
10+
imx93-uboot = pkgs.callPackage ./imx93-uboot.nix { };
11+
imx93-optee-os = pkgs.callPackage ./imx93-optee-os.nix { };
12+
src = pkgs.fetchgit {
13+
url = "https://github.com/nxp-imx/imx-mkimage.git";
14+
#tag: lf-6.12.3
15+
rev = "4622115cbc037f79039c4522faeced4aabea986b";
16+
sha256 = "sha256-2gz0GxlB3jwy8PC6+cP3+MpyUzqE1vDTw8nuxK6vo3g=";
17+
};
18+
shortRev = builtins.substring 0 8 src.rev;
19+
in
20+
{
21+
imx93-boot = pkgs.stdenv.mkDerivation rec {
22+
inherit src;
23+
name = "imx93-mkimage";
24+
version = "lf-6.12.3";
25+
26+
postPatch = ''
27+
substituteInPlace Makefile \
28+
--replace 'git rev-parse --short=8 HEAD' 'echo ${shortRev}'
29+
substituteInPlace Makefile \
30+
--replace 'CC = gcc' 'CC = clang'
31+
substituteInPlace iMX93/soc.mak \
32+
--replace 'xxd' "${pkgs.vim.xxd}/bin/xxd"
33+
substituteInPlace scripts/fspi_fcb_gen.sh \
34+
--replace 'xxd' "${pkgs.vim.xxd}/bin/xxd"
35+
substituteInPlace scripts/fspi_packer.sh \
36+
--replace 'xxd' "${pkgs.vim.xxd}/bin/xxd"
37+
patchShebangs scripts
38+
'';
39+
40+
nativeBuildInputs = [
41+
clang
42+
git
43+
dtc
44+
];
45+
46+
buildInputs = [
47+
git
48+
glibc.static
49+
zlib
50+
zlib.static
51+
];
52+
53+
buildPhase = ''
54+
runHook preBuild
55+
56+
make bin
57+
# mkimage is common across imx8 and imx9
58+
make SOC=iMX8M mkimage_imx8
59+
60+
if [ -f ${imx93-uboot}/u-boot.bin ]; then
61+
install -m 0644 ${imx93-uboot}/u-boot.bin ./iMX93/u-boot.bin
62+
else
63+
cat ${imx93-uboot}/u-boot-nodtb.bin ${imx93-uboot}/imx93-11x11-evk.dtb > ./iMX93/u-boot.bin
64+
fi
65+
install -m 0644 ${imx93-uboot}/u-boot-spl.bin ./iMX93/u-boot-spl.bin
66+
install -m 0644 ${imx93-uboot}/u-boot-nodtb.bin ./iMX93/u-boot-nodtb.bin
67+
install -m 0644 ${imx93-uboot}/imx93-11x11-evk.dtb ./iMX93/imx93-11x11-evk.dtb
68+
install -m 0644 ${imx93-optee-os}/tee.bin ./iMX93/tee.bin
69+
install -m 0644 ${imx93-atf}/bl31.bin ./iMX93/bl31.bin
70+
install -m 0644 ${imx93-firmware}/ddr/lpddr4* ./iMX93/
71+
install -m 0644 ${imx93-firmware}/ahab/mx93a1-ahab-container.img ./iMX93/
72+
73+
make SOC=iMX9 flash_singleboot
74+
75+
runHook postBuild
76+
'';
77+
78+
installPhase = ''
79+
runHook preInstall
80+
mkdir -p $out/image
81+
install -m 0644 ./iMX93/flash.bin $out/image
82+
runHook postInstall
83+
'';
84+
};
85+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{ pkgs, ... }:
2+
3+
with pkgs;
4+
stdenv.mkDerivation rec {
5+
pname = "nxp-firmware";
6+
version = "nxp-firmware-8.21-0.11";
7+
8+
# Fetch the two firmware installers from NXP
9+
ddrFirmware = fetchurl {
10+
url = "https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-8.21.bin";
11+
sha256 = "sha256-w0R/D4E0FczqncLvEggMs6yLvAxnOSp0/H1ZIF61pnI=";
12+
};
13+
14+
ahabFirmware = fetchurl {
15+
url = "https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-sentinel-0.11.bin";
16+
sha256 = "sha256-JpSAQXqK6apMxBAauUcof8M0VakxAh29xNm621ISvOs=";
17+
};
18+
19+
nativeBuildInputs = [ coreutils bash ];
20+
21+
dontUnpack = true;
22+
dontStrip = true;
23+
24+
installPhase = ''
25+
mkdir -p $out
26+
27+
echo "Extracting DDR firmware..."
28+
cp ${ddrFirmware} ./firmware-imx-8.21.bin
29+
chmod +x firmware-imx-8.21.bin
30+
./firmware-imx-8.21.bin --auto-accept
31+
32+
echo "Extracting AHAB firmware..."
33+
cp ${ahabFirmware} ./firmware-sentinel-0.11.bin
34+
chmod +x firmware-sentinel-0.11.bin
35+
./firmware-sentinel-0.11.bin --auto-accept
36+
37+
echo "Copying DDR .bin files..."
38+
mkdir -p $out/ddr
39+
cp firmware-imx-8.21/firmware/ddr/synopsys/lpddr4*.bin $out/ddr/
40+
41+
echo "Copying AHAB container image..."
42+
mkdir -p $out/ahab
43+
cp firmware-sentinel-0.11/mx93a1-ahab-container.img $out/ahab/
44+
45+
'';
46+
}
47+

nxp/imx93-evk/bsp/imx93-linux.nix

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{ lib, pkgs, ... }@args:
2+
with pkgs;
3+
buildLinux (
4+
args
5+
// rec {
6+
version = "6.12.3";
7+
name = "imx93-linux";
8+
9+
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
10+
modDirVersion = version;
11+
12+
defconfig = "imx_v8_defconfig";
13+
14+
# https://github.com/NixOS/nixpkgs/pull/366004
15+
# introduced a breaking change that if a module is declared but it is not being used it will faill.
16+
ignoreConfigErrors = true;
17+
18+
kernelPatches = [
19+
];
20+
21+
autoModules = false;
22+
23+
extraConfig = ''
24+
CRYPTO_TLS m
25+
TLS y
26+
MD_RAID0 m
27+
MD_RAID1 m
28+
MD_RAID10 m
29+
MD_RAID456 m
30+
DM_VERITY m
31+
LOGO y
32+
FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER n
33+
FB_EFI n
34+
EFI_STUB y
35+
EFI y
36+
VIRTIO y
37+
VIRTIO_PCI y
38+
VIRTIO_BLK y
39+
DRM_VIRTIO_GPU y
40+
EXT4_FS y
41+
USBIP_CORE m
42+
USBIP_VHCI_HCD m
43+
USBIP_HOST m
44+
USBIP_VUDC m
45+
'';
46+
47+
src = fetchFromGitHub {
48+
owner = "nxp-imx";
49+
repo = "linux-imx";
50+
# tag: lf-6.12.3
51+
rev = "37d02f4dcbbe6677dc9f5fc17f386c05d6a7bd7a";
52+
sha256 = "sha256-1oJMbHR8Ho0zNritEJ+TMOAyYHCW0vwhPkDfLctrZa8=";
53+
};
54+
meta = with lib; {
55+
homepage = "https://github.com/nxp-imx/linux-imx";
56+
license = [ licenses.gpl2Only ];
57+
maintainers = with maintainers; [ govindsi ];
58+
platforms = [ "aarch64-linux" ];
59+
};
60+
}
61+
// (args.argsOverride or { })
62+
)
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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

Comments
 (0)