payloads/Linuxboot: Fix u-root build

Currently u-root doesn't build for various reasons.

1. The boot cmds have changed. Some have been removed and the default
   has changed to the 'boot' cmd for loading an OS.
2. The elvish shell has been removed as default shell. The gosh is now
   the default.
3. For some reason the -uroot-source parameter doesn't exist anymore? So
   instead we just cd into the u-root directory and build the initramfs
   there.

Build tested:
| CONFIG_LINUXBOOT_COMPILE_KERNEL | CONFIG_LINUXBOOT_BUILD_INITRAMFS |
----------------------------------------------------------------------
|                 n               |                 n                |
|                 n               |                 y                |
|                 y               |                 n                |
|                 y               |                 y                |
----------------------------------------------------------------------

Change-Id: If66238cec248deb3594de82f3adbc608516a2fc5
Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/84119
Reviewed-by: Alicja Michalska <ahplka19@gmail.com>
Reviewed-by: Frans Hendriks <fhendriks@eltan.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Maximilian Brune 2024-08-20 16:17:06 +02:00 committed by Felix Singer
commit 84347d0b45
4 changed files with 40 additions and 48 deletions

View file

@ -57,8 +57,8 @@ config LINUXBOOT_COMPILE_KERNEL
config LINUXBOOT_KERNEL_PATH
string "Path to kernel"
default "build/uImage" if LINUXBOOT_KERNEL_UIMAGE
default "build/bzImage" if LINUXBOOT_KERNEL_BZIMAGE
default ""
depends on !LINUXBOOT_COMPILE_KERNEL
help
The kernel path is either and absolute path or relative to the
LinuxBoot directory
@ -142,7 +142,7 @@ config LINUXBOOT_BUILD_INITRAMFS
config LINUXBOOT_INITRAMFS_PATH
string "Path to initramfs"
default "build/initramfs_u-root.cpio" if LINUXBOOT_UROOT
default "payloads/external/LinuxBoot/build/initramfs" if LINUXBOOT_UROOT
if LINUXBOOT_BUILD_INITRAMFS
@ -248,7 +248,7 @@ config LINUXBOOT_UROOT_INITCMD
config LINUXBOOT_UROOT_SHELL
string "default shell"
default "elvish"
default "gosh"
help
Default shell.
Can be an absolute path or a u-root command name. (default "elvish")
@ -264,10 +264,10 @@ if LINUXBOOT_UROOT_MAIN
choice
prompt "Choose a specific bootloader"
default SPECIFIC_BOOTLOADER_SYSTEMBOOT
default SPECIFIC_BOOTLOADER_BOOT
help
Specify a bootloader which starts after u-root init. It will be a symlink
to /bin/uinit. Default: systemboot
to /bin/uinit. Default: boot
config SPECIFIC_BOOTLOADER_NONE
bool "none"
@ -275,21 +275,14 @@ config SPECIFIC_BOOTLOADER_NONE
Leave u-root to decide which bootloaders to load first after init, if
any at all. Most likely u-root will start into the defined u-root shell.
config SPECIFIC_BOOTLOADER_SYSTEMBOOT
bool "systemboot"
help
If systemboot has been used as a bootloader wrapper in the past,
enable this option. It will invoke -uinitcmd=systemboot and result in
a BIOS/UEFI BDS boot behavior.
config SPECIFIC_BOOTLOADER_BOOT2
bool "boot2"
config SPECIFIC_BOOTLOADER_BOOT
bool "boot"
config SPECIFIC_BOOTLOADER_PXEBOOT
bool "pxeboot"
config SPECIFIC_BOOTLOADER_STBOOT
bool "stboot"
config SPECIFIC_BOOTLOADER_FITBOOT
bool "fitboot"
config SPECIFIC_BOOTLOADER_CUSTOM
bool "custom"
@ -307,10 +300,9 @@ config SPECIFIC_BOOTLOADER_CUSTOM_CMD
config LINUXBOOT_UROOT_UINITCMD
string
default "" if SPECIFIC_BOOTLOADER_NONE
default "systemboot" if SPECIFIC_BOOTLOADER_SYSTEMBOOT
default "boot2" if SPECIFIC_BOOTLOADER_BOOT2
default "boot" if SPECIFIC_BOOTLOADER_BOOT
default "pxeboot" if SPECIFIC_BOOTLOADER_PXEBOOT
default "stboot" if SPECIFIC_BOOTLOADER_STBOOT
default "fitboot" if SPECIFIC_BOOTLOADER_FITBOOT
default SPECIFIC_BOOTLOADER_CUSTOM_CMD if SPECIFIC_BOOTLOADER_CUSTOM
endif #LINUXBOOT_UROOT_MAIN
@ -328,6 +320,7 @@ config LINUXBOOT_INITRAMFS_COMPRESSION_NONE
config LINUXBOOT_INITRAMFS_COMPRESSION_XZ
bool "xz compression"
depends on LINUXBOOT_BUILD_INITRAMFS
endchoice

View file

@ -10,10 +10,6 @@ LINUX_ARCH-$(CONFIG_LINUXBOOT_ARM64) = arm64
LINUX_ARCH-$(CONFIG_LINUXBOOT_RISCV_RV32) = riscv
LINUX_ARCH-$(CONFIG_LINUXBOOT_RISCV_RV64) = riscv
build/Image: $(CONFIG_LINUXBOOT_KERNEL_PATH) | build
ln -s -r $< $@
ifeq ($(CONFIG_LINUXBOOT_COMPILE_KERNEL),y)
include targets/linux.mk
endif
@ -21,30 +17,32 @@ ifeq ($(CONFIG_LINUXBOOT_UROOT),y)
include targets/u-root.mk
endif
ifeq ($(CONFIG_LINUXBOOT_BUILD_INITRAMFS),y)
build/initramfs: $(CONFIG_LINUXBOOT_INITRAMFS_PATH) | build
else
build/initramfs:
endif
ifeq ($(CONFIG_LINUXBOOT_INITRAMFS_COMPRESSION_XZ),y)
xz --keep --force --check=crc32 --lzma2=dict=1MiB $(CONFIG_LINUXBOOT_INITRAMFS_PATH)
endif
cp $(CONFIG_LINUXBOOT_INITRAMFS_PATH)$(CONFIG_LINUXBOOT_INITRAMFS_SUFFIX) $@
ifeq ($(CONFIG_LINUXBOOT_KERNEL_BZIMAGE),y)
build/bzImage: $(kernel_dir)/arch/x86/boot/bzImage build/initramfs | build
build/Image: $(kernel_dir)/arch/x86/boot/bzImage | build
cp $< $@
else ifeq ($(CONFIG_LINUXBOOT_KERNEL_UIMAGE),y)
build/target.dtb: $(CONFIG_LINUXBOOT_DTS_FILE)
build/target.dtb: $(CONFIG_LINUXBOOT_DTS_FILE) | build
$(DTC) -o $@ $<
build/uImage: build/vmlinux.bin.lzma build/initramfs build/target.dtb $(LINUX_ARCH-y)/kernel_fdt_lzma.its | build
build/Image: build/vmlinux.bin.lzma build/initramfs build/target.dtb $(LINUX_ARCH-y)/kernel_fdt_lzma.its | build
mkimage -f $(LINUX_ARCH-y)/kernel_fdt_lzma.its $@
endif # CONFIG_LINUXBOOT_KERNEL_BZIMAGE
else ifneq ($(CONFIG_LINUXBOOT_COMPILE_KERNEL),y)
build/Image: $(CONFIG_LINUXBOOT_KERNEL_PATH) | build
cp $< $@
endif
build/initramfs: build/initramfs_u-root.cpio | build
ifeq ($(CONFIG_LINUXBOOT_INITRAMFS_COMPRESSION_XZ),y)
xz --stdout --keep --force --check=crc32 --lzma2=dict=1MiB $< > $@
else
cp $< $@
endif
build:
mkdir build

View file

@ -39,12 +39,13 @@ $(uroot_build):
git clone https://$(uroot_package) $(uroot_build)
git -C $(uroot_build) checkout --quiet $(CONFIG_LINUXBOOT_UROOT_VERSION)
$(uroot_build)/u-root: $(uroot_build)
$(uroot_build)/u-root: | $(uroot_build)
cd $(uroot_build); \
go build -o u-root .
#$(CONFIG_LINUXBOOT_INITRAMFS_PATH)
build/initramfs_u-root.cpio: $(uroot_build)/u-root
GOARCH=$(UROOT_ARCH-y) $(uroot_build)/u-root \
-uroot-source $(uroot_build) \
$(uroot_args) -o build/initramfs_u-root.cpio $(uroot_cmds)
cd $(uroot_build); \
echo "GOARCH=$(UROOT_ARCH-y) ./u-root $(uroot_args) -o initramfs_u-root.cpio $(uroot_cmds)"
cd $(uroot_build); \
GOARCH=$(UROOT_ARCH-y) ./u-root $(uroot_args) -o initramfs_u-root.cpio $(uroot_cmds)
cp $(uroot_build)/initramfs_u-root.cpio $@

View file

@ -26,8 +26,8 @@ ifneq ($(strip $(call strip_quotes,$(CONFIG_LINUX_COMMAND_LINE))),)
endif
ifneq ($(strip $(call strip_quotes,$(CONFIG_LINUX_INITRD)$(CONFIG_LINUXBOOT_INITRAMFS_PATH))),)
ifneq ($(CONFIG_LINUXBOOT_ARM64),y)
ADDITIONAL_PAYLOAD_CONFIG+=-I $(CONFIG_LINUX_INITRD)$(CONFIG_LINUXBOOT_INITRAMFS_PATH)$(CONFIG_LINUXBOOT_INITRAMFS_SUFFIX)
prebuilt-files += $(strip $(call strip_quotes,$(CONFIG_LINUX_INITRD)$(CONFIG_LINUXBOOT_INITRAMFS)))
ADDITIONAL_PAYLOAD_CONFIG+=-I $(CONFIG_LINUX_INITRD)$(CONFIG_LINUXBOOT_INITRAMFS_PATH)
prebuilt-files += $(strip $(call strip_quotes,$(CONFIG_LINUX_INITRD)$(CONFIG_LINUXBOOT_INITRAMFS_PATH)))
endif
endif
endif
@ -399,7 +399,7 @@ else # CONFIG_LINUXBOOT_CROSS_COMPILE
$(warning "Using host toolchain to build Linuxboot")
endif # CONFIG_LINUXBOOT_CROSS_COMPILE
.PHONY: linuxboot
payloads/external/LinuxBoot/build/Image linuxboot:
payloads/external/LinuxBoot/build/Image payloads/external/LinuxBoot/build/initramfs linuxboot:
$(MAKE) -C payloads/external/LinuxBoot \
CPUS=$(CPUS) \
CONFIG_LINUXBOOT_X86_64=$(CONFIG_LINUXBOOT_X86_64) \
@ -411,7 +411,6 @@ payloads/external/LinuxBoot/build/Image linuxboot:
CONFIG_LINUXBOOT_CROSS_COMPILE_PATH=$(CONFIG_LINUXBOOT_CROSS_COMPILE_PATH) \
CONFIG_LINUXBOOT_BUILD_INITRAMFS=$(CONFIG_LINUXBOOT_BUILD_INITRAMFS) \
CONFIG_LINUXBOOT_INITRAMFS_PATH=$(CONFIG_LINUXBOOT_INITRAMFS_PATH) \
CONFIG_LINUXBOOT_INITRAMFS_SUFFIX=$(CONFIG_LINUXBOOT_INITRAMFS_SUFFIX) \
CONFIG_LINUXBOOT_INITRAMFS_COMPRESSION_XZ=$(CONFIG_LINUXBOOT_INITRAMFS_COMPRESSION_XZ) \
CONFIG_LINUXBOOT_COMPILE_KERNEL=$(CONFIG_LINUXBOOT_COMPILE_KERNEL) \
CONFIG_LINUXBOOT_KERNEL_PATH=$(CONFIG_LINUXBOOT_KERNEL_PATH) \
@ -427,7 +426,8 @@ payloads/external/LinuxBoot/build/Image linuxboot:
CONFIG_LINUXBOOT_UROOT_SHELL=$(CONFIG_LINUXBOOT_UROOT_SHELL) \
CONFIG_LINUXBOOT_UROOT_COMMANDS=$(CONFIG_LINUXBOOT_UROOT_COMMANDS) \
CONFIG_LINUXBOOT_UROOT_FILES=$(CONFIG_LINUXBOOT_UROOT_FILES) \
CONFIG_LINUXBOOT_DTS_FILE=$(CONFIG_LINUXBOOT_DTS_FILE)
CONFIG_LINUXBOOT_DTS_FILE=$(CONFIG_LINUXBOOT_DTS_FILE) \
$(subst payloads/external/LinuxBoot/,,$@)
# BOOTBOOT