nxp imx8m quad evaluation platform support

Signed-off-by: Ganga Ram <Ganga.Ram@tii.ae>
This commit is contained in:
Ganga Ram 2024-02-24 08:01:59 +04:00 committed by mergify[bot]
parent 5c2a5c00a0
commit 53e2a96a9e
12 changed files with 329 additions and 3 deletions

View file

@ -184,6 +184,7 @@
msi-gs60 = import ./msi/gs60;
msi-gl62 = import ./msi/gl62;
nxp-imx8mp-evk = import ./nxp/imx8mp-evk;
nxp-imx8mq-evk = import ./nxp/imx8mq-evk;
nxp-imx8qm-mek = import ./nxp/imx8qm-mek;
hardkernel-odroid-hc4 = import ./hardkernel/odroid-hc4;
hardkernel-odroid-h3 = import ./hardkernel/odroid-h3;

View file

@ -1,12 +1,12 @@
{
pkgs,
enable-tee ? false,
enable-tee ? true,
}:
with pkgs; let
fw-ver = "202006";
cp-tee =
if enable-tee
then "install -m 0644 ${optee-os}/tee.bin ./iMX8M/tee.bin"
then "install -m 0644 ${imx8mp-optee-os}/tee.bin ./iMX8M/tee.bin"
else "";
imx8mp-atf = pkgs.callPackage ./imx8mp-atf.nix {

View file

@ -51,7 +51,7 @@ in
makeFlags = [
"PLATFORM=imx"
"PLATFORM_FLAVOR=mx8qmmek"
"PLATFORM_FLAVOR=mx8mpevk"
"CFG_ARM64_core=y"
"CFG_TEE_TA_LOG_LEVEL=0"
"CFG_TEE_CORE_LOG_LEVEL=0"

View file

@ -0,0 +1,34 @@
{
lib,
pkgs,
buildArmTrustedFirmware,
fetchgit,
enable-tee,
}:
with pkgs; let
opteedflag =
if enable-tee
then "SPD=opteed"
else "";
target-board = "imx8mq";
in
buildArmTrustedFirmware rec {
pname = "imx8mq-atf";
platform = target-board;
enableParallelBuilding = true;
extraMeta.platforms = ["aarch64-linux"];
src = fetchgit {
url = "https://github.com/nxp-imx/imx-atf.git";
#lf6.1.55_2.2.0
rev = "08e9d4eef2262c0dd072b4325e8919e06d349e02";
sha256 = "sha256-96EddJXlFEkP/LIGVgNBvUP4IDI3BbDE/c9Yub22gnc=";
};
extraMakeFlags = lib.concatLists [
(lib.optional (lib.versionAtLeast pkgs.binutils.version "2.39") "LDFLAGS=--no-warn-rwx-segments")
["PLAT=${platform}" "bl31" "${opteedflag}"]
];
filesToInstall = ["build/${target-board}/release/bl31.bin"];
}

View file

@ -0,0 +1,78 @@
{
pkgs,
enable-tee ? false,
}:
with pkgs; let
cp-tee =
if enable-tee
then "install -m 0644 ${imx8mq-optee-os}/tee.bin ./iMX8M/tee.bin"
else "";
imx8mq-atf = pkgs.callPackage ./imx8mq-atf.nix {
inherit (pkgs) buildArmTrustedFirmware;
inherit enable-tee;
};
imx8mq-firmware = pkgs.callPackage ./imx8mq-firmware.nix {};
imx8mq-uboot = pkgs.callPackage ./imx8mq-uboot.nix {};
imx8mq-optee-os = pkgs.callPackage ./imx8mq-optee-os.nix {};
in {
imx8m-boot = pkgs.stdenv.mkDerivation rec {
name = "imx8mq-mkimage";
version = "lf-6.1.55-2.2.0";
src = pkgs.fetchgit {
url = "https://github.com/nxp-imx/imx-mkimage.git";
rev = "c4365450fb115d87f245df2864fee1604d97c06a";
sha256 = "sha256-xycEaWKVM63BlDyBKNN0OefyK6iX/fQOTvv4fRVM55U=";
leaveDotGit = true;
};
postPatch = ''
substituteInPlace Makefile \
--replace 'CC = gcc' 'CC = clang'
patchShebangs scripts
'';
nativeBuildInputs = [
clang
git
dtc
];
buildInputs = [
git
glibc.static
zlib
zlib.static
];
buildPhase = ''
runHook preBuild
make bin
make SOC=iMX8M mkimage_imx8
cp -v ${pkgs.ubootTools}/bin/mkimage ./iMX8M/mkimage_uboot
install -m 0644 ${imx8mq-uboot}/u-boot-spl.bin ./iMX8M/u-boot-spl.bin
install -m 0644 ${imx8mq-uboot}/u-boot-nodtb.bin ./iMX8M/u-boot-nodtb.bin
install -m 0644 ${imx8mq-uboot}/imx8mq-evk.dtb ./iMX8M/imx8mq-evk.dtb
install -m 0644 ${imx8mq-firmware}/firmware/ddr/synopsys/lpddr4_pmu_train_1d_dmem.bin ./iMX8M/lpddr4_pmu_train_1d_dmem.bin
install -m 0644 ${imx8mq-firmware}/firmware/ddr/synopsys/lpddr4_pmu_train_1d_imem.bin ./iMX8M/lpddr4_pmu_train_1d_imem.bin
install -m 0644 ${imx8mq-firmware}/firmware/ddr/synopsys/lpddr4_pmu_train_2d_dmem.bin ./iMX8M/lpddr4_pmu_train_2d_dmem.bin
install -m 0644 ${imx8mq-firmware}/firmware/ddr/synopsys/lpddr4_pmu_train_2d_imem.bin ./iMX8M/lpddr4_pmu_train_2d_imem.bin
install -m 0644 ${imx8mq-firmware}/firmware/hdmi/cadence/signed_hdmi_imx8m.bin ./iMX8M/signed_hdmi_imx8m.bin
install -m 0644 ${imx8mq-atf}/bl31.bin ./iMX8M/bl31.bin
${cp-tee}
make SOC=iMX8M flash_evk
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/image
install -m 0644 ./iMX8M/flash.bin $out/image
runHook postInstall
'';
};
}

View file

@ -0,0 +1,19 @@
{pkgs, ...}:
with pkgs;
stdenv.mkDerivation rec {
pname = "imx8mq-firmware";
version = "8.22";
src = pkgs.fetchurl {
url = "https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-${version}.bin";
sha256 = "sha256-lMi86sVuxQPCMuYU931rvY4Xx9qnHU5lHqj9UDTDA1A=";
};
dontUnpack = true;
dontStrip = true;
installPhase = ''
${pkgs.bash}/bin/bash $src --auto-accept --force
mv firmware-imx-${version} $out
'';
}

View file

@ -0,0 +1,50 @@
{pkgs, ...} @ args:
with pkgs;
buildLinux (args
// rec {
version = "6.1.55";
name = "imx8mq-linux";
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
modDirVersion = version;
defconfig = "imx_v8_defconfig";
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 = "nxp-imx";
repo = "linux-imx";
# tag: lf-6.1.55-2.2.0
rev = "770c5fe2c1d1529fae21b7043911cd50c6cf087e";
sha256 = "sha256-tIWt75RUrjB6KmUuAYBVyAC1dmVGSUAgqV5ROJh3xU0=";
};
}
// (args.argsOverride or {}))

View file

@ -0,0 +1,66 @@
{pkgs}: let
python3 = pkgs.buildPackages.python3;
toolchain = pkgs.gcc9Stdenv.cc;
binutils = pkgs.gcc9Stdenv.cc.bintools.bintools_bin;
cpp = pkgs.gcc;
in
pkgs.stdenv.mkDerivation rec {
pname = "imx8mq-optee-os";
version = "lf-6.1.55-2.2.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 = "a303fc80f7c4bd713315687a1fa1d6ed136e78ee";
sha256 = "sha256-OpyG812DX0c06bRZPKWB2cNu6gtZCOvewDhsKgrGB+s=";
};
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"
"PLATFORM_FLAVOR=mx8mqevk"
"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
'';
}

View file

@ -0,0 +1,41 @@
{pkgs}:
with pkgs; let
inherit buildUBoot;
in
(buildUBoot {
pname = "imx8mq-uboot";
version = "2023.04";
src = fetchgit {
url = "https://github.com/nxp-imx/uboot-imx.git";
# tag: "lf-6.1.55-2.2.0"
rev = "49b102d98881fc28af6e0a8af5ea2186c1d90a5f";
sha256 = "sha256-1j6X82DqezEizeWoSS600XKPNwrQ4yT0vZuUImKAVVA=";
};
extraConfig = ''
CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="setenv ramdisk_addr_r 0x45000000; setenv fdt_addr_r 0x44000000; 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
'';
enableParallelBuilding = true;
defconfig = "imx8mq_evk_defconfig";
extraMeta.platforms = ["aarch64-linux"];
filesToInstall = [
"./u-boot-nodtb.bin"
"./spl/u-boot-spl.bin"
"./arch/arm/dts/imx8mq-evk.dtb"
".config"
];
})
.overrideAttrs (old: {
nativeBuildInputs = old.nativeBuildInputs ++ [pkgs.perl];
})

View file

@ -0,0 +1,18 @@
{pkgs, ...}: {
nixpkgs.overlays = [
(import ./overlay.nix)
];
imports = [
./modules.nix
];
boot.loader.grub.extraFiles = {
"imx8mq-evk.dtb" = "${pkgs.callPackage ./bsp/imx8mq-linux.nix {}}/dtbs/freescale/imx8mq-evk.dtb";
};
hardware.deviceTree = {
filter = "imx8mq-*.dtb";
name = "imx8mq-evk.dtb";
};
}

View file

@ -0,0 +1,16 @@
{
pkgs,
lib,
...
}: {
nixpkgs.hostPlatform = "aarch64-linux";
boot = {
kernelPackages = pkgs.linuxPackagesFor (pkgs.callPackage ./bsp/imx8mq-linux.nix {});
initrd.includeDefaultModules = lib.mkForce false;
};
disabledModules = ["profiles/all-hardware.nix"];
hardware.deviceTree.enable = true;
}

View file

@ -0,0 +1,3 @@
final: prev: {
inherit (final.callPackage ./bsp/imx8mq-boot.nix {pkgs = final;}) imx8m-boot;
}