refactor(nxp): parameterize i.MX platform builders to reduce duplication
This refactoring reduces code duplication across i.MX93, i.MX8MP, and i.MX8MQ platforms by extracting common build logic into parameterized shared builders. This makes it easier to maintain and add new i.MX platforms while ensuring consistency across all platforms.
This commit is contained in:
parent
8b405e9c6d
commit
688ee555de
14 changed files with 398 additions and 598 deletions
|
|
@ -1,56 +1,20 @@
|
|||
{ pkgs, ... }@args:
|
||||
with pkgs;
|
||||
buildLinux (
|
||||
args
|
||||
// rec {
|
||||
version = "6.12.20";
|
||||
name = "imx8mp-linux";
|
||||
(pkgs.callPackage ../../common/bsp/imx-linux-builder.nix args) {
|
||||
pname = "imx8mp-linux";
|
||||
version = "6.12.20";
|
||||
|
||||
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
|
||||
modDirVersion = version;
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "nxp-imx";
|
||||
repo = "linux-imx";
|
||||
# tag: lf-6.12.20-2.0.0
|
||||
rev = "dfaf2136deb2af2e60b994421281ba42f1c087e0";
|
||||
sha256 = "sha256-ITrmj3a5YfXh/PSRTi+Rlto5uEBIAWFWtkTsO1ATXIo=";
|
||||
};
|
||||
|
||||
defconfig = "imx_v8_defconfig";
|
||||
# Platform-specific configuration (if any)
|
||||
extraConfig = "";
|
||||
|
||||
# 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 = "nxp-imx";
|
||||
repo = "linux-imx";
|
||||
# tag: lf-6.12.20-2.0.0
|
||||
rev = "dfaf2136deb2af2e60b994421281ba42f1c087e0";
|
||||
sha256 = "sha256-ITrmj3a5YfXh/PSRTi+Rlto5uEBIAWFWtkTsO1ATXIo=";
|
||||
};
|
||||
}
|
||||
// (args.argsOverride or { })
|
||||
)
|
||||
# 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,69 +1,13 @@
|
|||
{ 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 {
|
||||
pkgs.callPackage ../../common/bsp/imx-optee-builder.nix {
|
||||
pname = "imx8mp-optee-os";
|
||||
version = "lf-6.12.20-2.0.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 = "87964807d80baf1dcfd89cafc66de34a1cf16bf3";
|
||||
sha256 = "sha256-AMZUMgmmyi5l3BMT84uubwjU0lwNObs9XW6ZCbqfhmc=";
|
||||
};
|
||||
|
||||
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 '/usr/bin/env bash' '${pkgs.bash}/bin/bash'
|
||||
substituteInPlace ta/pkcs11/scripts/dump_ec_curve_params.sh \
|
||||
--replace '/usr/bin/env 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=mx8mpevk"
|
||||
"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
|
||||
'';
|
||||
platformFlavor = "mx8mpevk";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,93 +1,17 @@
|
|||
{
|
||||
stdenv,
|
||||
lib,
|
||||
bison,
|
||||
dtc,
|
||||
fetchgit,
|
||||
flex,
|
||||
gnutls,
|
||||
libuuid,
|
||||
ncurses,
|
||||
openssl,
|
||||
which,
|
||||
perl,
|
||||
buildPackages,
|
||||
efitools,
|
||||
}:
|
||||
let
|
||||
ubsrc = fetchgit {
|
||||
{ pkgs, fetchgit }:
|
||||
pkgs.callPackage ../../common/bsp/imx-uboot-builder.nix {
|
||||
pname = "imx8mp-uboot";
|
||||
version = "2025.04";
|
||||
|
||||
src = fetchgit {
|
||||
url = "https://github.com/nxp-imx/uboot-imx.git";
|
||||
# tag: lf-6.12.20-2.0.0
|
||||
rev = "9383f8387dc76524524da69992db96c22195a57c";
|
||||
sha256 = "sha256-httRSwN8NiKOdL7fZEvN/4AbypGQfegYtJgxKIea+Zg=";
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "imx8mp-uboot";
|
||||
version = "2025.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 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
|
||||
'';
|
||||
|
||||
passAsFile = [ "extraConfig" ];
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
|
||||
make imx8mp_evk_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 ./dts/upstream/src/arm64/freescale/imx8mp-evk.dtb $out
|
||||
cp .config $out
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
dontStrip = true;
|
||||
defconfig = "imx8mp_evk_defconfig";
|
||||
ramdiskAddr = "0x45000000";
|
||||
fdtAddr = "0x44000000";
|
||||
dtbPath = "./dts/upstream/src/arm64/freescale/imx8mp-evk.dtb";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue