From 0832a9abc7bbe137bb6465ecb7fbd36c0a6a41fb Mon Sep 17 00:00:00 2001 From: Mohamed-nour Toumi Date: Fri, 31 Oct 2025 12:22:15 +0100 Subject: [PATCH] image: integrate the secure initramfs generator This change wires the secure initramfs generator into the image pipeline. It also introduces a load address for the initrd in FITs and aligns kernel config handling for initramfs compression. - include/image.mk: * Rewrite Image/SecureInitramfs as a traced shell block with clearer variables and debug output. * Add explicit `secure-initramfs` phony target and run it before `kernel_prepare`. * Keep existing initramfs kernel/ramdisk artifacts flow intact. Closes: PCF-1893 Tracked-by: FEAT-29 Signed-off-by: Mohamed-nour Toumi --- include/image.mk | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/include/image.mk b/include/image.mk index 800d8f033b..75e587af7b 100644 --- a/include/image.mk +++ b/include/image.mk @@ -158,12 +158,26 @@ define prepare_generic_squashfs endef define Image/SecureInitramfs - UNSTRIPPED_FOLDER=$(STAGING_DIR_ROOT) \ - BINARIES_PATH=$(CONFIG_TARGET_INIT_PATH) \ - $(TOPDIR)/scripts/gen-secure-initramfs.sh build \ - $(call get_initramfs_compression,CONFIG_TARGET_SECURE_INITRAMFS_COMPRESSION_) \ - $(BIN_DIR)/$(IMG_SECURE_INITRAMFS) \ - $(STAGING_DIR_IMAGE)/initramfs $(TARGET_DIR) + @{ \ + set -eu; \ + comp="$(call get_initramfs_compression,CONFIG_TARGET_SECURE_INITRAMFS_COMPRESSION_)"; \ + out="$(BIN_DIR)/$(IMG_SECURE_INITRAMFS)"; \ + initramfs_dir="$(STAGING_DIR_IMAGE)/initramfs"; \ + rootfs_dir="$(TARGET_DIR)"; \ + echo "[SecureInitramfs] UNSTRIPPED_FOLDER=$(STAGING_DIR_ROOT)"; \ + echo "[SecureInitramfs] BINARIES_PATH=$(CONFIG_TARGET_INIT_PATH)"; \ + printf '[SecureInitramfs] COMPRESSION => %q\n' "$$$$comp"; \ + printf '[SecureInitramfs] OUTPUT => %q\n' "$$$$out"; \ + printf '[SecureInitramfs] INITRAMFS => %q\n' "$$$$initramfs_dir"; \ + printf '[SecureInitramfs] ROOTFS => %q\n' "$$$$rootfs_dir"; \ + PS4='+ [SecureInitramfs] $${0##*/}:$${LINENO}: '; set -x; \ + UNSTRIPPED_FOLDER="$(STAGING_DIR_ROOT)" \ + BINARIES_PATH="$(CONFIG_TARGET_INIT_PATH)" \ + "$(TOPDIR)/scripts/gen-secure-initramfs.sh" build \ + "$$$$comp" \ + "$$$$out" \ + "$$$$initramfs_dir" "$$$$rootfs_dir"; \ + } endef define Image/BuildKernel/Initramfs @@ -956,7 +970,7 @@ define BuildImage image_prepare: ifeq ($(IB),) - .PHONY: download prepare compile compile-dtb clean image_prepare kernel_prepare install install-images + .PHONY: download prepare compile compile-dtb clean image_prepare kernel_prepare install install-images secure-initramfs compile: $(call Build/Compile) @@ -975,13 +989,16 @@ define BuildImage mkdir -p $(BIN_DIR) $(KDIR)/tmp endif - kernel_prepare: image_prepare + secure-initramfs: +ifeq ($(CONFIG_TARGET_SECURE_INITRAMFS),y) + $(call Image/SecureInitramfs) +endif + kernel_prepare: secure-initramfs image_prepare $(call Image/Build/targz) $(call Image/Build/cpiogz) $(call Image/BuildKernel) $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(if $(IB),,$(call Image/BuildKernel/Initramfs))) $(call Image/InstallKernel) - $(if $(CONFIG_TARGET_SECURE_INITRAMFS),$(call Image/SecureInitramfs)) $(foreach device,$(TARGET_DEVICES),$(call Device,$(device)))