From d148d3136ad22b78ba17cf2791e882943a6c244f Mon Sep 17 00:00:00 2001 From: Jonathon Hall Date: Mon, 28 Nov 2022 15:15:38 -0500 Subject: [PATCH] init: Add optional board-specific init script Boards can place a file in $(board)/initrd/bin/board-init.sh to perform board-specific initialization. If present, the board's $(board)/initrd directory is included in the initrd via board.initrd. Signed-off-by: Jonathon Hall --- Makefile | 12 ++++++++++++ initrd/init | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/Makefile b/Makefile index e7e078b8..f6567227 100644 --- a/Makefile +++ b/Makefile @@ -555,6 +555,7 @@ $(COREBOOT_UTIL_DIR)/superiotool/superiotool: \ initrd-y += $(pwd)/blobs/dev.cpio initrd-y += $(build)/$(initrd_dir)/modules.cpio initrd-y += $(build)/$(initrd_dir)/tools.cpio +initrd-y += $(build)/$(initrd_dir)/board.cpio initrd-$(CONFIG_HEADS) += $(build)/$(initrd_dir)/heads.cpio #$(build)/$(initrd_dir)/.build: $(build)/$(initrd_dir)/initrd.cpio.xz @@ -583,6 +584,17 @@ $(build)/$(initrd_dir)/initrd.cpio.xz: $(initrd-y) bundle-$(CONFIG_LINUX_BUNDLED) += $(board_build)/$(LINUX_IMAGE_FILE).bundled all: $(bundle-y) +# The board.cpio is built from the board's initrd/ directory. It contains +# board-specific support scripts. + +ifeq ($(wildcard $(pwd)/boards/$(BOARD)/initrd),) +$(build)/$(initrd_dir)/board.cpio: + cpio -H newc -o "$@" +else +$(build)/$(initrd_dir)/board.cpio: FORCE + $(call do-cpio,$@,$(pwd)/boards/$(BOARD)/initrd) +endif + # # The heads.cpio is built from the initrd directory in the # Heads tree. diff --git a/initrd/init b/initrd/init index 18d0bd55..8f41d813 100755 --- a/initrd/init +++ b/initrd/init @@ -151,6 +151,11 @@ if [ "$CONFIG_PUREBOOT_BASIC" = "y" ]; then export CONFIG_HOTPKEY=n fi +# Perform board-specific init if present +if [ -x /bin/board-init.sh ]; then + /bin/board-init.sh +fi + if [ ! -x "$CONFIG_BOOTSCRIPT" -a ! -x "$CONFIG_BOOTSCRIPT_NETWORK" ]; then recovery 'Boot script missing? Entering recovery shell' else