compulab: ucm-imx95: fix cross-build of mkimage host tools

imx-mkimage runs on the build machine, but ucm-imx95-boot used target stdenv
and forced clang. Cross-building the SD image from x86_64 then failed building
mkimage_imx8 with "stdio.h not found", blocking flash.bin.

Build mkimage with buildPackages; keep firmware blobs from target pkgs.
This commit is contained in:
Govind Singh 2026-06-05 15:20:26 +04:00
parent d66213a72e
commit 307a84fc96
3 changed files with 23 additions and 34 deletions

View file

@ -1,24 +1,17 @@
{ {
callPackage, pkgs,
fetchFromGitHub,
stdenv,
clang,
git,
dtc,
glibc,
zlib,
vim,
}: }:
let let
bp = pkgs.buildPackages;
imx95-atf = callPackage ./ucm-imx95-atf.nix { }; imx95-atf = pkgs.callPackage ./ucm-imx95-atf.nix { };
imx95-firmware = callPackage ./ucm-imx95-firmware.nix { }; imx95-firmware = pkgs.callPackage ./ucm-imx95-firmware.nix { };
imx95-uboot = callPackage ./ucm-imx95-uboot.nix { }; imx95-uboot = pkgs.callPackage ./ucm-imx95-uboot.nix { };
imx95-optee-os = callPackage ./ucm-imx95-optee-os.nix { }; imx95-optee-os = pkgs.callPackage ./ucm-imx95-optee-os.nix { };
imx95-sm-fw = callPackage ./ucm-imx95-sm-fw.nix { }; imx95-sm-fw = pkgs.callPackage ./ucm-imx95-sm-fw.nix { };
imx95-oei-ddr = callPackage ./ucm-imx95-oei-ddr.nix { }; imx95-oei-ddr = pkgs.callPackage ./ucm-imx95-oei-ddr.nix { };
imx95-oei-tcm = callPackage ./ucm-imx95-oei-tcm.nix { }; imx95-oei-tcm = pkgs.callPackage ./ucm-imx95-oei-tcm.nix { };
src = fetchFromGitHub { src = pkgs.fetchFromGitHub {
owner = "nxp-imx"; owner = "nxp-imx";
repo = "imx-mkimage"; repo = "imx-mkimage";
#tag: lf-6.6.52-2.2.1 #tag: lf-6.6.52-2.2.1
@ -28,7 +21,8 @@ let
shortRev = builtins.substring 0 8 src.rev; shortRev = builtins.substring 0 8 src.rev;
in in
{ {
imx95-boot = stdenv.mkDerivation rec { # mkimage runs on the build machine; use buildPackages when cross-compiling.
imx95-boot = bp.stdenv.mkDerivation {
inherit src; inherit src;
name = "imx95-mkimage"; name = "imx95-mkimage";
version = "lf-6.6.52-2.2.1"; version = "lf-6.6.52-2.2.1";
@ -36,27 +30,22 @@ in
postPatch = '' postPatch = ''
substituteInPlace Makefile \ substituteInPlace Makefile \
--replace-fail 'git rev-parse --short=8 HEAD' 'echo ${shortRev}' --replace-fail 'git rev-parse --short=8 HEAD' 'echo ${shortRev}'
substituteInPlace Makefile \
--replace-fail 'CC = gcc' 'CC = clang'
substituteInPlace iMX95/soc.mak \ substituteInPlace iMX95/soc.mak \
--replace-fail 'xxd' "${vim.xxd}/bin/xxd" --replace-fail 'xxd' "${bp.vim.xxd}/bin/xxd"
substituteInPlace scripts/fspi_fcb_gen.sh \ substituteInPlace scripts/fspi_fcb_gen.sh \
--replace-fail 'xxd' "${vim.xxd}/bin/xxd" --replace-fail 'xxd' "${bp.vim.xxd}/bin/xxd"
substituteInPlace scripts/fspi_packer.sh \ substituteInPlace scripts/fspi_packer.sh \
--replace-fail 'xxd' "${vim.xxd}/bin/xxd" --replace-fail 'xxd' "${bp.vim.xxd}/bin/xxd"
patchShebangs scripts patchShebangs scripts
''; '';
nativeBuildInputs = [ nativeBuildInputs = [
clang bp.stdenv.cc
git bp.git
dtc bp.dtc
]; bp.glibc.static
bp.zlib
buildInputs = [ bp.zlib.static
glibc.static
zlib
zlib.static
]; ];
buildPhase = '' buildPhase = ''

View file

@ -1,3 +1,3 @@
final: _prev: { final: _prev: {
inherit (final.callPackage ./bsp/ucm-imx95-boot.nix { }) imx95-boot; inherit (final.callPackage ./bsp/ucm-imx95-boot.nix { pkgs = final; }) imx95-boot;
} }

View file

@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
(fetchpatch { (fetchpatch {
name = "imx93-trdc-header-guard.patch"; name = "imx93-trdc-header-guard.patch";
url = "https://github.com/nxp-imx/imx-atf/commit/e194a14ec55f13386babc80c90098874367ab3d6.patch"; url = "https://github.com/nxp-imx/imx-atf/commit/e194a14ec55f13386babc80c90098874367ab3d6.patch";
sha256 = "sha256-uXRgeyFmxDww93nJe04aoOLml2R7IbABZLhywyYmePk="; sha256 = "sha256-K1JECateo4mUrOaV41PUmCXHn7DfmgRQXx4KdcIALqE=";
}) })
]; ];