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 <jonathon.hall@puri.sm>
This commit is contained in:
Jonathon Hall 2022-11-28 15:15:38 -05:00
parent 6e0d241913
commit d148d3136a
No known key found for this signature in database
GPG Key ID: 1E9C3CA91AE25114
2 changed files with 17 additions and 0 deletions

View File

@ -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 </dev/null >"$@"
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.

View File

@ -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