Skip to content

Commit 2379bc4

Browse files
authored
Merge pull request #1649 from govindsi/feat/imx93-evk-platform
Add support for i.MX93-EVK platform
2 parents 46f9982 + 688ee55 commit 2379bc4

22 files changed

+654
-392
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
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Parameterized Linux kernel builder for i.MX platforms
2+
# This builder is used across i.MX93, i.MX8MP, i.MX8MQ and similar platforms
3+
{ lib, pkgs, ... }@args:
4+
let
5+
inherit (pkgs) buildLinux;
6+
7+
# Import common kernel configuration
8+
kernelConfig = import ../lib/kernel-config.nix;
9+
in
10+
# Platform-specific parameters
11+
{
12+
pname,
13+
version,
14+
src,
15+
defconfig ? "imx_v8_defconfig",
16+
# Optional parameters
17+
extraConfig ? "",
18+
kernelPatches ? [ ],
19+
autoModules ? false,
20+
ignoreConfigErrors ? true,
21+
extraMeta ? { },
22+
}:
23+
let
24+
# Combine common i.MX kernel config with platform-specific config
25+
finalExtraConfig = kernelConfig.imxCommonKernelConfig + extraConfig;
26+
in
27+
buildLinux (
28+
args
29+
// rec {
30+
inherit
31+
version
32+
defconfig
33+
kernelPatches
34+
autoModules
35+
ignoreConfigErrors
36+
;
37+
name = pname;
38+
39+
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
40+
modDirVersion = version;
41+
42+
extraConfig = finalExtraConfig;
43+
44+
inherit src;
45+
46+
meta =
47+
with lib;
48+
{
49+
homepage = "https://github.com/nxp-imx/linux-imx";
50+
license = [ licenses.gpl2Only ];
51+
platforms = [ "aarch64-linux" ];
52+
}
53+
// extraMeta;
54+
}
55+
// (args.argsOverride or { })
56+
)
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Parameterized OP-TEE OS builder for i.MX platforms
2+
# This builder is used across i.MX93, i.MX8MP, i.MX8MQ and similar platforms
3+
{
4+
lib,
5+
pkgs,
6+
# Platform-specific parameters
7+
pname,
8+
version,
9+
platformFlavor,
10+
src,
11+
# Optional parameters
12+
meta ? { },
13+
}:
14+
let
15+
inherit (pkgs.buildPackages) python3;
16+
toolchain = pkgs.gccStdenv.cc;
17+
binutils = pkgs.gccStdenv.cc.bintools.bintools_bin;
18+
cpp = pkgs.gcc;
19+
20+
# Determine PLATFORM and PLATFORM_FLAVOR from platformFlavor
21+
# Format can be either "imx-mx93evk" (full platform string) or "mx8mpevk" (just flavor, platform is "imx")
22+
# Check if it starts with "imx-" to determine if it's a full platform string or just a flavor
23+
hasFullPlatform = lib.hasPrefix "imx-" platformFlavor;
24+
platform = if hasFullPlatform then platformFlavor else "imx";
25+
flavor = if hasFullPlatform then null else platformFlavor;
26+
in
27+
pkgs.stdenv.mkDerivation {
28+
inherit pname version src;
29+
30+
nativeBuildInputs = [
31+
python3
32+
];
33+
34+
enableParallelBuilding = true;
35+
36+
propagatedBuildInputs = with python3.pkgs; [
37+
pycryptodomex
38+
pyelftools
39+
cryptography
40+
];
41+
42+
# Common postPatch for all i.MX platforms
43+
# This is the major source of code duplication - ~60 lines of identical substitutions
44+
postPatch = ''
45+
# Patch all script shebangs automatically
46+
patchShebangs scripts/
47+
patchShebangs ta/
48+
49+
# Patch toolchain paths in mk/gcc.mk
50+
substituteInPlace mk/gcc.mk \
51+
--replace "\$(CROSS_COMPILE_\$(sm))objcopy" ${binutils}/bin/${toolchain.targetPrefix}objcopy
52+
substituteInPlace mk/gcc.mk \
53+
--replace "\$(CROSS_COMPILE_\$(sm))objdump" ${binutils}/bin/${toolchain.targetPrefix}objdump
54+
substituteInPlace mk/gcc.mk \
55+
--replace "\$(CROSS_COMPILE_\$(sm))nm" ${binutils}/bin/${toolchain.targetPrefix}nm
56+
substituteInPlace mk/gcc.mk \
57+
--replace "\$(CROSS_COMPILE_\$(sm))readelf" ${binutils}/bin/${toolchain.targetPrefix}readelf
58+
substituteInPlace mk/gcc.mk \
59+
--replace "\$(CROSS_COMPILE_\$(sm))ar" ${binutils}/bin/${toolchain.targetPrefix}ar
60+
substituteInPlace mk/gcc.mk \
61+
--replace "\$(CROSS_COMPILE_\$(sm))cpp" ${cpp}/bin/cpp
62+
'';
63+
64+
makeFlags =
65+
[
66+
"PLATFORM=${platform}"
67+
]
68+
++ lib.optionals (!hasFullPlatform) [
69+
"PLATFORM_FLAVOR=${flavor}"
70+
]
71+
++ [
72+
"CFG_ARM64_core=y"
73+
"CFG_TEE_TA_LOG_LEVEL=0"
74+
"CFG_TEE_CORE_LOG_LEVEL=0"
75+
"CROSS_COMPILE=${toolchain}/bin/${toolchain.targetPrefix}"
76+
"CROSS_COMPILE64=${toolchain}/bin/${toolchain.targetPrefix}"
77+
];
78+
79+
installPhase = ''
80+
mkdir -p $out
81+
cp ./out/arm-plat-imx/core/tee-raw.bin $out/tee.bin
82+
'';
83+
84+
meta = {
85+
homepage = "https://github.com/nxp-imx/imx-optee-os";
86+
license = [ lib.licenses.bsd2 ];
87+
platforms = [ "aarch64-linux" ];
88+
} // meta;
89+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Parameterized U-Boot builder for i.MX platforms
2+
# This builder is used across i.MX93, i.MX8MP, i.MX8MQ and similar platforms
3+
{
4+
lib,
5+
stdenv,
6+
buildPackages,
7+
# Required dependencies
8+
bison,
9+
dtc,
10+
flex,
11+
gnutls,
12+
libuuid,
13+
ncurses,
14+
openssl,
15+
perl,
16+
efitools,
17+
which,
18+
# Platform-specific parameters
19+
pname,
20+
version,
21+
src,
22+
defconfig,
23+
ramdiskAddr,
24+
fdtAddr,
25+
dtbPath,
26+
# Optional parameters
27+
extraConfig ? "",
28+
extraNativeBuildInputs ? [ ],
29+
}:
30+
let
31+
# Import common U-Boot configuration
32+
ubootConfig = import ../lib/uboot-config.nix;
33+
34+
# Generate the common config with platform-specific memory addresses
35+
commonConfig = ubootConfig.imxCommonUbootConfig {
36+
inherit ramdiskAddr fdtAddr;
37+
};
38+
39+
# Combine common config with any platform-specific extra config
40+
finalExtraConfig = commonConfig + extraConfig;
41+
in
42+
stdenv.mkDerivation {
43+
inherit pname version src;
44+
45+
postPatch = ''
46+
patchShebangs tools
47+
patchShebangs scripts
48+
'';
49+
50+
nativeBuildInputs = [
51+
bison
52+
flex
53+
openssl
54+
which
55+
ncurses
56+
libuuid
57+
gnutls
58+
perl
59+
efitools
60+
] ++ extraNativeBuildInputs;
61+
62+
depsBuildBuild = [ buildPackages.stdenv.cc ];
63+
hardeningDisable = [ "all" ];
64+
enableParallelBuilding = true;
65+
66+
makeFlags = [
67+
"DTC=${lib.getExe buildPackages.dtc}"
68+
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
69+
];
70+
71+
extraConfig = finalExtraConfig;
72+
73+
passAsFile = [ "extraConfig" ];
74+
75+
configurePhase = ''
76+
runHook preConfigure
77+
78+
make ${defconfig}
79+
cat $extraConfigPath >> .config
80+
81+
runHook postConfigure
82+
'';
83+
84+
installPhase = ''
85+
runHook preInstall
86+
87+
mkdir -p $out
88+
cp ./u-boot-nodtb.bin $out
89+
cp ./spl/u-boot-spl.bin $out
90+
cp ${dtbPath} $out
91+
cp .config $out
92+
93+
runHook postInstall
94+
'';
95+
96+
dontStrip = true;
97+
}

nxp/common/lib/kernel-config.nix

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Shared kernel configuration for i.MX platforms
2+
# This configuration is used across i.MX93, i.MX8MP, i.MX8MQ and similar platforms
3+
{
4+
# Common kernel extra configuration for i.MX platforms
5+
# Includes: virtualization support, EFI boot, RAID, USB/IP, framebuffer settings
6+
imxCommonKernelConfig = ''
7+
CRYPTO_TLS m
8+
TLS y
9+
MD_RAID0 m
10+
MD_RAID1 m
11+
MD_RAID10 m
12+
MD_RAID456 m
13+
DM_VERITY m
14+
LOGO y
15+
FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER n
16+
FB_EFI n
17+
EFI_STUB y
18+
EFI y
19+
VIRTIO y
20+
VIRTIO_PCI y
21+
VIRTIO_BLK y
22+
DRM_VIRTIO_GPU y
23+
EXT4_FS y
24+
USBIP_CORE m
25+
USBIP_VHCI_HCD m
26+
USBIP_HOST m
27+
USBIP_VUDC m
28+
'';
29+
}

nxp/common/lib/uboot-config.nix

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Shared U-Boot configuration for i.MX platforms
2+
# This configuration is used across i.MX93, i.MX8MP, i.MX8MQ and similar platforms
3+
{
4+
# Generate common U-Boot extra configuration for i.MX platforms
5+
# ramdiskAddr and fdtAddr are platform-specific memory addresses
6+
imxCommonUbootConfig =
7+
{ ramdiskAddr, fdtAddr }:
8+
''
9+
CONFIG_USE_BOOTCOMMAND=y
10+
CONFIG_BOOTCOMMAND="setenv ramdisk_addr_r ${ramdiskAddr}; setenv fdt_addr_r ${fdtAddr}; run distro_bootcmd; "
11+
CONFIG_CMD_BOOTEFI_SELFTEST=y
12+
CONFIG_CMD_BOOTEFI=y
13+
CONFIG_EFI_LOADER=y
14+
CONFIG_BLK=y
15+
CONFIG_PARTITIONS=y
16+
CONFIG_DM_DEVICE_REMOVE=n
17+
CONFIG_CMD_CACHE=y
18+
'';
19+
20+
# Common U-Boot native build inputs for i.MX platforms
21+
imxCommonUbootNativeBuildInputs = [
22+
"bison"
23+
"flex"
24+
"openssl"
25+
"which"
26+
"ncurses"
27+
"libuuid"
28+
"gnutls"
29+
"openssl"
30+
"perl"
31+
"efitools"
32+
];
33+
}

0 commit comments

Comments
 (0)