summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaximilian Brune <maximilian.brune@9elements.com>2023-06-26 20:04:47 +0200
committerLean Sheng Tan <sheng.tan@9elements.com>2023-07-23 18:24:39 +0000
commitc202be793fd483167ab25b60a3f4630137ca33ae (patch)
treefbf2a71b14847b5f33ebc81363511ccc2fbcd3eb
parent449c6d981c216e05d5238056f03c7794e43600ec (diff)
payloads/external/LinuxBoot: Clean up
There were some issues with the current Linuxboot Makefiles. - multithreaded compilation didn't work, because some prerequisites were missing - initramfs wasn't added for x86 qemu boot. - riscv support was incomplete It began with separate patches, but resulted in a clean up patch, that is hard to separate. The most important changes are the following: - Instead of phony targets, actual files are now used as prerequisites - riscv can now be used as target - initramfs works now also for x86 - instead of querying the most recent version from the internet, I set a known working version (because I tested it) that can be customized and/or upgraded in the future. The reasons: - querying the version from the internet requires a constant connection to the internet even after linux kernel is already build (aka subsequent builds). - one usually wants to use a known working version, but optionally still have the posibillity to choose a custom one. This patch introduces this possibility in its most simple form. - I removed as much ifeq statements as possible and moved that responsibility to Kconfig, because they tend to make the Makefile less readable. Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com> Change-Id: I25e757108e0dd473969fe5a192ad0733f1fe6286 Reviewed-on: https://review.coreboot.org/c/coreboot/+/76150 Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r--payloads/external/LinuxBoot/Kconfig116
-rw-r--r--payloads/external/LinuxBoot/Makefile81
-rw-r--r--payloads/external/LinuxBoot/arm64/kernel_fdt_lzma.its7
-rw-r--r--payloads/external/LinuxBoot/empty.dts4
-rw-r--r--payloads/external/LinuxBoot/i386/defconfig (renamed from payloads/external/LinuxBoot/x86/defconfig)0
-rw-r--r--payloads/external/LinuxBoot/riscv/defconfig-324
-rw-r--r--payloads/external/LinuxBoot/riscv/defconfig-642
-rw-r--r--payloads/external/LinuxBoot/riscv/kernel_fdt_lzma.its74
-rw-r--r--payloads/external/LinuxBoot/targets/linux.mk123
-rw-r--r--payloads/external/LinuxBoot/targets/u-root.mk72
-rw-r--r--payloads/external/Makefile.inc42
11 files changed, 246 insertions, 279 deletions
diff --git a/payloads/external/LinuxBoot/Kconfig b/payloads/external/LinuxBoot/Kconfig
index 4feb98b9db..24bfe3f112 100644
--- a/payloads/external/LinuxBoot/Kconfig
+++ b/payloads/external/LinuxBoot/Kconfig
@@ -19,6 +19,13 @@ config LINUXBOOT_X86
help
X86 kernel and initramfs
+config LINUXBOOT_ARM
+ bool "arm64"
+ depends on ARCH_ARM
+ select PAYLOAD_FIT_SUPPORT
+ help
+ arm kernel and initramfs
+
config LINUXBOOT_ARM64
bool "arm64"
depends on ARCH_ARM64
@@ -26,9 +33,16 @@ config LINUXBOOT_ARM64
help
AARCH64 kernel and initramfs
-config LINUXBOOT_RISCV
+config LINUXBOOT_RISCV_RV32
+ bool "RISC-V"
+ depends on ARCH_RISCV_RV32
+ select PAYLOAD_FIT_SUPPORT
+ help
+ RISC-V kernel and initramfs
+
+config LINUXBOOT_RISCV_RV64
bool "RISC-V"
- depends on ARCH_RISCV
+ depends on ARCH_RISCV_RV64
select PAYLOAD_FIT_SUPPORT
help
RISC-V kernel and initramfs
@@ -41,76 +55,38 @@ config LINUXBOOT_COMPILE_KERNEL
bool "Compile kernel"
default n
-if LINUXBOOT_COMPILE_KERNEL
-comment "parse linux crosscompiler with: LINUXBOOT_CROSS_COMPILE"
-endif
-
config LINUXBOOT_KERNEL_PATH
string "Path to kernel"
- default "Image"
- depends on !LINUXBOOT_COMPILE_KERNEL
-
-if LINUXBOOT_COMPILE_KERNEL
-
-choice
- prompt "Kernel release"
- default LINUXBOOT_KERNEL_STABLE
- help
- Choose the kernel release.
-
- Select 'custom' if your want to define the kernel version.
- For more information about the current 'mainline', 'stable' or 'longterm'
- version, visit: https://www.kernel.org/
-
-config LINUXBOOT_KERNEL_MAINLINE
- bool "mainline"
+ default "build/uImage" if LINUXBOOT_KERNEL_UIMAGE
+ default "build/bzImage" if LINUXBOOT_KERNEL_BZIMAGE
help
- Mainline kernel version
+ The kernel path is either and absolute path or relative to the
+ LinuxBoot directory
-config LINUXBOOT_KERNEL_STABLE
- bool "stable"
- help
- Stable kernel version
-
-config LINUXBOOT_KERNEL_LONGTERM
- bool "longterm"
- help
- Longterm (LTS) kernel version
+if LINUXBOOT_COMPILE_KERNEL
-config LINUXBOOT_KERNEL_CUSTOM
- bool "custom"
+config LINUXBOOT_CROSS_COMPILE
+ string "cross compiler"
+ default "" # e.g. "aarch64-linux-gnu-"
help
- Custom kernel version
+ Choose a custom cross compiler toolchain to use.
+ It can be useful if you don't want to use the coreboot toolchain
+ or experience problems using it.
-endchoice
-
-config LINUXBOOT_KERNEL_CUSTOM_VERSION
+config LINUXBOOT_KERNEL_VERSION
string "kernel version"
- default ""
- depends on LINUXBOOT_KERNEL_CUSTOM
+ default "6.3"
help
Choose the Linux kernel version number. (x.x.x)
Release candidate kernels (rc) are currently are not supported.
-choice
- prompt "Kernel configuration"
- default LINUXBOOT_KERNEL_ARCH_DEFAULT_CONFIG
-
-config LINUXBOOT_KERNEL_ARCH_DEFAULT_CONFIG
- bool "Default architecture configuration"
- help
- This option will use the default configuration for the
- selected architecture.
-
-config LINUXBOOT_KERNEL_CUSTOM_CONFIG
- bool "Custom (def)config file"
-
-endchoice
-
config LINUXBOOT_KERNEL_CONFIGFILE
string "Config file path"
- default "defconfig"
- depends on LINUXBOOT_KERNEL_CUSTOM_CONFIG
+ default "i386/defconfig" if LINUXBOOT_X86
+ default "x86_64/defconfig" if LINUXBOOT_X86_64
+ default "arm64/defconfig" if LINUXBOOT_ARM64
+ default "riscv/defconfig-32" if LINUXBOOT_RISCV_RV32
+ default "riscv/defconfig-64" if LINUXBOOT_RISCV_RV64
help
Path to the kernel configuration file.
@@ -119,7 +95,7 @@ config LINUXBOOT_KERNEL_CONFIGFILE
choice
prompt "Kernel binary format"
default LINUXBOOT_KERNEL_BZIMAGE if LINUXBOOT_X86 || LINUXBOOT_X86_64
- default LINUXBOOT_KERNEL_UIMAGE if LINUXBOOT_ARM64 || LINUXBOOT_RISCV
+ default LINUXBOOT_KERNEL_UIMAGE if LINUXBOOT_ARM64 || LINUXBOOT_RISCV_RV32 || LINUXBOOT_RISCV_RV64
config LINUXBOOT_KERNEL_BZIMAGE
bool "bzImage"
@@ -127,14 +103,14 @@ config LINUXBOOT_KERNEL_BZIMAGE
config LINUXBOOT_KERNEL_UIMAGE
bool "uImage"
- depends on LINUXBOOT_ARM64 || LINUXBOOT_RISCV
+ depends on LINUXBOOT_ARM64 || LINUXBOOT_RISCV_RV32 || LINUXBOOT_RISCV_RV64
endchoice
-config LINUXBOOT_DTB_FILE
+config LINUXBOOT_DTS_FILE
string "Compiled devicetree file"
- depends on LINUXBOOT_ARM64 || LINUXBOOT_RISCV
- default ""
+ depends on LINUXBOOT_ARM64 || LINUXBOOT_RISCV_RV32 || LINUXBOOT_RISCV_RV64
+ default "empty.dts"
endif #LINUXBOOT_COMPILE_KERNEL
@@ -145,9 +121,7 @@ config LINUX_COMMAND_LINE
Add your own kernel command-line arguments.
config PAYLOAD_FILE
- default "payloads/external/LinuxBoot/linuxboot/bzImage" if LINUXBOOT_COMPILE_KERNEL && ( LINUXBOOT_X86 || LINUXBOOT_X86_64 )
- default "payloads/external/LinuxBoot/linuxboot/uImage" if LINUXBOOT_COMPILE_KERNEL && (LINUXBOOT_ARM64 || LINUXBOOT_RISCV)
- default LINUXBOOT_KERNEL_PATH if !LINUXBOOT_COMPILE_KERNEL
+ default "payloads/external/LinuxBoot/build/Image"
comment "Linux initramfs"
@@ -157,16 +131,17 @@ config LINUXBOOT_BUILD_INITRAMFS
config LINUXBOOT_INITRAMFS_PATH
string "Path to initramfs"
- depends on !LINUXBOOT_BUILD_INITRAMFS
+ default "build/initramfs_u-root.cpio" if LINUXBOOT_UROOT
if LINUXBOOT_BUILD_INITRAMFS
choice
- prompt "Payload Mode"
+ prompt "Initramfs"
default LINUXBOOT_UROOT
config LINUXBOOT_UROOT
bool "u-root"
+ depends on !LINUXBOOT_RISCV_RV32 # not supported by u-root
help
Enable u-root linuxboot mode.
See http://u-root.tk/ for more information.
@@ -345,11 +320,6 @@ config LINUXBOOT_INITRAMFS_COMPRESSION_XZ
endchoice
-config LINUX_INITRD
- string
- default "payloads/external/LinuxBoot/linuxboot/initramfs_u-root.cpio" if LINUXBOOT_UROOT
- default LINUXBOOT_INITRAMFS_PATH if !LINUXBOOT_BUILD_INITRAMFS
-
config LINUXBOOT_INITRAMFS_SUFFIX
string
default "" if LINUXBOOT_INITRAMFS_COMPRESSION_NONE
diff --git a/payloads/external/LinuxBoot/Makefile b/payloads/external/LinuxBoot/Makefile
index cd9f7eaa0e..d12d323f5e 100644
--- a/payloads/external/LinuxBoot/Makefile
+++ b/payloads/external/LinuxBoot/Makefile
@@ -1,62 +1,51 @@
## SPDX-License-Identifier: GPL-2.0-only
-project_dir=linuxboot
-
unexport $(COREBOOT_EXPORTS)
-all: linuxboot
+DTC ?= dtc
-u-root:
- $(MAKE) -f targets/u-root.mk
+LINUX_ARCH-$(CONFIG_LINUXBOOT_X86_64) = x86_64
+LINUX_ARCH-$(CONFIG_LINUXBOOT_X86) = i386
+LINUX_ARCH-$(CONFIG_LINUXBOOT_ARM64) = arm64
+LINUX_ARCH-$(CONFIG_LINUXBOOT_RISCV_RV32) = riscv
+LINUX_ARCH-$(CONFIG_LINUXBOOT_RISCV_RV64) = riscv
-ifeq ($(CONFIG_LINUXBOOT_BUILD_INITRAMFS),y)
-ifeq ($(CONFIG_LINUXBOOT_UROOT),y)
-initramfs: u-root
-endif
-else
-ifneq ($(CONFIG_LINUXBOOT_INITRAMFS),)
-initramfs:
- if [[ ! -f "$(top)/$(CONFIG_LINUXBOOT_INITRAMFS)" ]]; then \
- echo "<< Linux initramfs '$(CONFIG_LINUXBOOT_INITRAMFS)' is missing. >>"; \
- exit 1; \
- fi
-endif
-endif
+build/Image: $(CONFIG_LINUXBOOT_KERNEL_PATH)
+ ln -s -r $< $@
+
+include targets/linux.mk targets/u-root.mk
-initramfs_compressed: initramfs
+build/initramfs: $(CONFIG_LINUXBOOT_INITRAMFS_PATH)
ifeq ($(CONFIG_LINUXBOOT_INITRAMFS_COMPRESSION_XZ),y)
- xz --keep --force --check=crc32 --lzma2=dict=1MiB $(top)/$(CONFIG_LINUXBOOT_INITRAMFS)
+ 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_COMPILE_KERNEL),y)
-ifeq ($(CONFIG_LINUXBOOT_ARCH),arm64)
-kernel: initramfs
- if [[ ! -f "$(top)/$(CONFIG_LINUXBOOT_DTB_FILE)" ]]; then \
- echo "<< Linux kernel devicetree is missing. >>"; \
- exit 1; \
- fi
- $(MAKE) -f targets/linux.mk
-else
-kernel:
- $(MAKE) -f targets/linux.mk
-endif
-else
-kernel:
- if [[ ! -f "$(top)/$(CONFIG_LINUXBOOT_KERNEL)" ]]; then \
- echo "<< Linux kernel '$(CONFIG_LINUXBOOT_KERNEL)' is missing. >>"; \
- exit 1; \
- fi
-endif
+ifeq ($(CONFIG_LINUXBOOT_KERNEL_BZIMAGE),y)
+
+build/bzImage: $(kernel_dir)/arch/x86/boot/bzImage | build
+ cp $< $@
+
+else ifeq ($(CONFIG_LINUXBOOT_KERNEL_UIMAGE),y)
+
+build/target.dtb: $(CONFIG_LINUXBOOT_DTS_FILE)
+ $(DTC) -o $@ $<
+
+build/uImage: 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
-linuxboot: kernel initramfs_compressed
+build:
+ mkdir build
clean:
- rm -rf $(project_dir)/kernel*
- rm -f $(project_dir)/u-root
- rm -f $(project_dir)/initramfs*
- rm -f $(project_dir)/bzImage
+ rm -rf build/kernel*
+ rm -f build/u-root
+ rm -f build/initramfs*
+ rm -f build/bzImage
distclean:
- rm -rf $(project_dir)
+ rm -rf build
-.PHONY: linuxboot kernel initramfs_compressed initramfs u-root clean distclean
+.PHONY: linuxboot clean distclean
diff --git a/payloads/external/LinuxBoot/arm64/kernel_fdt_lzma.its b/payloads/external/LinuxBoot/arm64/kernel_fdt_lzma.its
index 3087e69a74..46c43ac9dc 100644
--- a/payloads/external/LinuxBoot/arm64/kernel_fdt_lzma.its
+++ b/payloads/external/LinuxBoot/arm64/kernel_fdt_lzma.its
@@ -11,7 +11,7 @@
images {
kernel {
description = "Vanilla Linux kernel";
- data = /incbin/("vmlinux.bin.lzma");
+ data = /incbin/("../build/vmlinux.bin.lzma");
type = "kernel";
arch = "arm64";
os = "linux";
@@ -30,7 +30,7 @@
};
fdt-1 {
description = "Flattened Device Tree blob";
- data = /incbin/("target.dtb");
+ data = /incbin/("../build/target.dtb");
type = "flat_dt";
arch = "arm64";
compression = "none";
@@ -46,7 +46,7 @@
};
ramdisk-1 {
description = "Compressed Initramfs";
- data = /incbin/("initramfs");
+ data = /incbin/("../build/initramfs");
type = "ramdisk";
arch = "arm64";
os = "linux";
@@ -65,6 +65,7 @@
configurations {
default = "conf-1";
conf-1 {
+ compatible = "linuxboot";
description = "Boot Linux kernel with FDT blob";
kernel = "kernel";
fdt = "fdt-1";
diff --git a/payloads/external/LinuxBoot/empty.dts b/payloads/external/LinuxBoot/empty.dts
new file mode 100644
index 0000000000..e160dad6a6
--- /dev/null
+++ b/payloads/external/LinuxBoot/empty.dts
@@ -0,0 +1,4 @@
+/dts-v1/;
+
+/ {
+};
diff --git a/payloads/external/LinuxBoot/x86/defconfig b/payloads/external/LinuxBoot/i386/defconfig
index 6c20c145cd..6c20c145cd 100644
--- a/payloads/external/LinuxBoot/x86/defconfig
+++ b/payloads/external/LinuxBoot/i386/defconfig
diff --git a/payloads/external/LinuxBoot/riscv/defconfig-32 b/payloads/external/LinuxBoot/riscv/defconfig-32
new file mode 100644
index 0000000000..f6af0f708d
--- /dev/null
+++ b/payloads/external/LinuxBoot/riscv/defconfig-32
@@ -0,0 +1,4 @@
+CONFIG_ARCH_RV32I=y
+CONFIG_32BIT=y
+# CONFIG_PORTABLE is not set
+CONFIG_NONPORTABLE=y
diff --git a/payloads/external/LinuxBoot/riscv/defconfig-64 b/payloads/external/LinuxBoot/riscv/defconfig-64
new file mode 100644
index 0000000000..313edc554d
--- /dev/null
+++ b/payloads/external/LinuxBoot/riscv/defconfig-64
@@ -0,0 +1,2 @@
+CONFIG_ARCH_RV64I=y
+CONFIG_64BIT=y
diff --git a/payloads/external/LinuxBoot/riscv/kernel_fdt_lzma.its b/payloads/external/LinuxBoot/riscv/kernel_fdt_lzma.its
new file mode 100644
index 0000000000..6cbe484910
--- /dev/null
+++ b/payloads/external/LinuxBoot/riscv/kernel_fdt_lzma.its
@@ -0,0 +1,74 @@
+/*
+ * Simple U-Boot uImage source file containing a single kernel and FDT blob
+ */
+
+/dts-v1/;
+
+/ {
+ description = "Simple image with single Linux kernel and FDT blob";
+ #address-cells = <1>;
+
+ images {
+ kernel {
+ description = "Vanilla Linux kernel";
+ data = /incbin/("../build/vmlinux.bin.lzma");
+ type = "kernel";
+ arch = "riscv64";
+ os = "linux";
+ compression = "lzma";
+ load = <0x80000>;
+ entry = <0x80000>;
+ hash-1 {
+ algo = "crc32";
+ };
+ hash-2 {
+ algo = "sha1";
+ };
+ hash-3 {
+ algo = "sha256";
+ };
+ };
+ fdt-1 {
+ description = "Flattened Device Tree blob";
+ data = /incbin/("../build/target.dtb");
+ type = "flat_dt";
+ arch = "riscv64";
+ compression = "none";
+ hash-1 {
+ algo = "crc32";
+ };
+ hash-2 {
+ algo = "sha1";
+ };
+ hash-3 {
+ algo = "sha256";
+ };
+ };
+ ramdisk-1 {
+ description = "Compressed Initramfs";
+ data = /incbin/("../build/initramfs");
+ type = "ramdisk";
+ arch = "riscv64";
+ os = "linux";
+ compression = "none";
+ load = <00000000>;
+ entry = <00000000>;
+ hash-1 {
+ algo = "sha1";
+ };
+ hash-2 {
+ algo = "sha256";
+ };
+ };
+ };
+
+ configurations {
+ default = "conf-1";
+ conf-1 {
+ description = "Boot Linux kernel with FDT blob";
+ kernel = "kernel";
+ fdt = "fdt-1";
+ ramdisk = "ramdisk-1";
+ };
+ };
+};
diff --git a/payloads/external/LinuxBoot/targets/linux.mk b/payloads/external/LinuxBoot/targets/linux.mk
index 12f66f7049..4156e1ee74 100644
--- a/payloads/external/LinuxBoot/targets/linux.mk
+++ b/payloads/external/LinuxBoot/targets/linux.mk
@@ -1,41 +1,20 @@
## SPDX-License-Identifier: GPL-2.0-only
-SHELL := /bin/bash
+SHELL := /bin/sh
-ARCH-$(CONFIG_LINUXBOOT_X86_64)=x86_64
-ARCH-$(CONFIG_LINUXBOOT_X86)=x86
-ARCH-$(CONFIG_LINUXBOOT_ARM64)=arm64
-
-TAG-$(CONFIG_LINUXBOOT_KERNEL_MAINLINE)=mainline
-TAG-$(CONFIG_LINUXBOOT_KERNEL_STABLE)=stable
-TAG-$(CONFIG_LINUXBOOT_KERNEL_LONGTERM)=longterm
-
-pwd:=$(shell pwd)
-top:=../../..
-project_dir=linuxboot
-tarball_dir:=$(project_dir)/tarball
-decompress_flag=.done
-
-OBJCOPY:=$(LINUXBOOT_CROSS_COMPILE)objcopy
+OBJCOPY:=$(CONFIG_LINUXBOOT_CROSS_COMPILE)objcopy
KERNEL_MAKE_FLAGS = \
- ARCH=$(ARCH-y) \
+ CROSS_COMPILE=$(CONFIG_LINUXBOOT_CROSS_COMPILE) \
+ ARCH=$(LINUX_ARCH-y) \
KBUILD_BUILD_USER="coreboot" \
KBUILD_BUILD_HOST="reproducible" \
KBUILD_BUILD_TIMESTAMP="$(shell perl -e 'print scalar gmtime($(SOURCE_DATE_EPOCH))')" \
KBUILD_BUILD_VERSION="0"
-ifeq ($(CONFIG_LINUXBOOT_KERNEL_CUSTOM),y)
- kernel_version:=$(CONFIG_LINUXBOOT_KERNEL_CUSTOM_VERSION)
-else
- kernel_version:=$(shell curl -sS -k https://www.kernel.org/feeds/kdist.xml | \
- sed -n -e 's@.*<guid isPermaLink="false">\(.*\)</guid>.*@\1@p' | \
- awk -F ',' '/$(TAG-y)/{ print $$3 }' | \
- head -n 1)
-endif
-
-kernel_dir=$(project_dir)/kernel-$(subst .,_,$(kernel_version))
-kernel_tarball=linux-$(kernel_version).tar
-kernel_mirror=https://mirrors.edge.kernel.org/pub/linux/kernel
+kernel_version = $(CONFIG_LINUXBOOT_KERNEL_VERSION)
+kernel_dir = build/kernel-$(subst .,_,$(kernel_version))
+kernel_tarball = linux-$(kernel_version).tar
+kernel_mirror = https://mirrors.edge.kernel.org/pub/linux/kernel
ifeq ($(findstring x2.6.,x$(kernel_version)),x2.6.)
kernel_mirror_path := $(kernel_mirror)/v2.6
@@ -49,81 +28,35 @@ else ifeq ($(findstring x6.,x$(kernel_version)),x6.)
kernel_mirror_path := $(kernel_mirror)/v6.x
endif
-all: kernel
-
-lookup:
-ifeq ($(kernel_version),)
- $(error kernel version lookup failed for $(TAG-y) release)
-endif
- @echo " WWW Kernel [$(TAG-y)] $(kernel_version)"
-
-fetch:
-ifneq ($(shell [[ -d "$(kernel_dir)" && -f "$(kernel_dir)/$(decompress_flag)" ]];echo $$?),0)
- mkdir -p $(tarball_dir)
- if [[ ! -f $(tarball_dir)/$(kernel_tarball).xz && ! -f $(tarball_dir)/$(kernel_tarball).xz ]]; then \
- echo " WWW $(kernel_tarball).xz"; \
- cd $(tarball_dir); \
- curl -OLSs "$(kernel_mirror_path)/$(kernel_tarball).xz"; \
- cd $(pwd); \
- fi
-endif
+build/$(kernel_tarball).xz:
+ echo " Test $(kernel_version)"
+ echo " WWW $(kernel_mirror_path)/$(kernel_tarball).xz";
+ curl -OLSs --output-dir build "$(kernel_mirror_path)/$(kernel_tarball).xz";
-unpack: fetch
- if [[ -d "$(kernel_dir)" && ! -f "$(kernel_dir)/$(decompress_flag)" ]]; then \
- rm -rf $(kernel_dir); \
- fi
- if [[ ! -d "$(kernel_dir)" ]]; then \
- mkdir $(kernel_dir); \
- echo " XZ $(kernel_tarball).xz"; \
- tar xJf $(tarball_dir)/$(kernel_tarball).xz --strip 1 -C $(kernel_dir); \
- fi
- touch $(kernel_dir)/$(decompress_flag)
+$(kernel_dir): build/$(kernel_tarball).xz
+ echo " XZ $(kernel_tarball).xz";
+ mkdir $(kernel_dir);
+ tar xJf build/$(kernel_tarball).xz --strip 1 -C $(kernel_dir);
-$(kernel_dir)/.config: unpack
+$(kernel_dir)/.config: $(CONFIG_LINUXBOOT_KERNEL_CONFIGFILE) | $(kernel_dir)
@echo " CONFIG Linux $(kernel_version)"
-ifeq ($(CONFIG_LINUXBOOT_KERNEL_CUSTOM_CONFIG),y)
cp $(CONFIG_LINUXBOOT_KERNEL_CONFIGFILE) $(kernel_dir)/.config
-else
- cp $(ARCH-y)/defconfig $(kernel_dir)/.config
-endif
$(MAKE) -C $(kernel_dir) $(KERNEL_MAKE_FLAGS) olddefconfig
-build: $(kernel_dir)/.config
+$(kernel_dir)/vmlinux : $(kernel_dir)/.config | $(kernel_dir)
@echo " MAKE Linux $(kernel_version)"
-ifeq ($(CONFIG_LINUXBOOT_KERNEL_BZIMAGE),y)
- $(MAKE) -C $(kernel_dir) $(KERNEL_MAKE_FLAGS) CROSS_COMPILE=$(LINUXBOOT_CROSS_COMPILE) bzImage
-else
-ifeq ($(CONFIG_LINUXBOOT_KERNEL_UIMAGE),y)
- $(MAKE) -C $(kernel_dir) $(KERNEL_MAKE_FLAGS) CROSS_COMPILE=$(LINUXBOOT_CROSS_COMPILE) vmlinux
-endif
-endif
+ echo "$(MAKE) -j 4 -C $(kernel_dir) $(KERNEL_MAKE_FLAGS) vmlinux"
+ $(MAKE) -j 4 -C $(kernel_dir) $(KERNEL_MAKE_FLAGS) vmlinux
-ifeq ($(CONFIG_LINUXBOOT_KERNEL_BZIMAGE),y)
-$(top)/$(CONFIG_LINUXBOOT_KERNEL): build
- @echo " CP bzImage"
- cp $(kernel_dir)/arch/x86/boot/bzImage $@
-else
-ifeq ($(CONFIG_LINUXBOOT_KERNEL_UIMAGE),y)
-$(project_dir)/target.dtb: $(top)/$(CONFIG_LINUXBOOT_DTB_FILE)
- cp $< $@
-$(project_dir)/vmlinux.bin: $(kernel_dir)/vmlinux
+build/vmlinux.bin: $(kernel_dir)/vmlinux | build
$(OBJCOPY) -O binary $< $@
-$(project_dir)/vmlinux.bin.lzma: $(project_dir)/vmlinux.bin
+
+build/vmlinux.bin.lzma: build/vmlinux.bin
xz -c -k -f --format=lzma --lzma1=dict=1MiB,lc=3,lp=0,pb=3 $< > $@
-$(top)/$(CONFIG_LINUXBOOT_KERNEL): build $(project_dir)/vmlinux.bin.lzma $(project_dir)/target.dtb
- cp $(project_dir)/../arm64/kernel_fdt_lzma.its $(project_dir)
- cp $(top)/$(CONFIG_LINUXBOOT_INITRAMFS)$(CONFIG_LINUXBOOT_INITRAMFS_SUFFIX) $(project_dir)/initramfs
- mkimage -f $(project_dir)/kernel_fdt_lzma.its $@
-else
- $(error Kernel image format not found)
- exit 1
-endif
-endif
-ifneq ($(TAG-y),)
-kernel: lookup $(top)/$(CONFIG_LINUXBOOT_KERNEL)
-else
-kernel: $(top)/$(CONFIG_LINUXBOOT_KERNEL)
-endif
+$(kernel_dir)/arch/x86/boot/bzImage: $(kernel_dir)/.config
+ @echo " MAKE Linux $(kernel_version)"
+ echo "$(MAKE) -C $(kernel_dir) $(KERNEL_MAKE_FLAGS) bzImage"
+ $(MAKE) -C $(kernel_dir) $(KERNEL_MAKE_FLAGS) bzImage
-.PHONY: all kernel build unpack fetch check
+.PHONY: kernel
diff --git a/payloads/external/LinuxBoot/targets/u-root.mk b/payloads/external/LinuxBoot/targets/u-root.mk
index e673aabf11..fff79df0a1 100644
--- a/payloads/external/LinuxBoot/targets/u-root.mk
+++ b/payloads/external/LinuxBoot/targets/u-root.mk
@@ -1,29 +1,26 @@
## SPDX-License-Identifier: GPL-2.0-only
-project_dir=$(shell pwd)/linuxboot
-go_path_dir=$(project_dir)/go
-uroot_bin=$(project_dir)/u-root
-uroot_package=github.com/u-root/u-root
-
-ARCH-$(CONFIG_LIBUXBOOT_X86_64)=amd64
-ARCH-$(CONFIG_LINUXBOOT_X86)=i386
-ARCH-$(CONFIG_LINUXBOOT_ARM64)=arm64
-
-go_version=$(shell go version | sed -nr 's/.*go([0-9]+\.[0-9]+.?[0-9]?).*/\1/p' )
-go_version_major=$(shell echo $(go_version) | sed -nr 's/^([0-9]+)\.([0-9]+)\.?([0-9]*)$$/\1/p')
-go_version_minor=$(shell echo $(go_version) | sed -nr 's/^([0-9]+)\.([0-9]+)\.?([0-9]*)$$/\2/p')
-
-uroot_args+=-build=$(CONFIG_LINUXBOOT_UROOT_FORMAT)
-uroot_args+=-initcmd $(CONFIG_LINUXBOOT_UROOT_INITCMD)
-uroot_args+=-uinitcmd=$(CONFIG_LINUXBOOT_UROOT_UINITCMD)
-uroot_args+=-defaultsh $(CONFIG_LINUXBOOT_UROOT_SHELL)
+uroot_package = github.com/u-root/u-root
+uroot_build = build/go/src/$(uroot_package)
+
+UROOT_ARCH-$(CONFIG_LIBUXBOOT_X86_64) = amd64
+UROOT_ARCH-$(CONFIG_LINUXBOOT_X86) = 386
+UROOT_ARCH-$(CONFIG_LINUXBOOT_ARM64) = arm64
+UROOT_ARCH-$(CONFIG_LINUXBOOT_RISCV_RV64) = riscv64
+
+go_version = $(shell go version | sed -nr 's/.*go([0-9]+\.[0-9]+.?[0-9]?).*/\1/p' )
+go_version_major = $(shell echo $(go_version) | sed -nr 's/^([0-9]+)\.([0-9]+)\.?([0-9]*)$$/\1/p')
+go_version_minor = $(shell echo $(go_version) | sed -nr 's/^([0-9]+)\.([0-9]+)\.?([0-9]*)$$/\2/p')
+
+uroot_args += -build=$(CONFIG_LINUXBOOT_UROOT_FORMAT)
+uroot_args += -initcmd $(CONFIG_LINUXBOOT_UROOT_INITCMD)
+uroot_args += -uinitcmd=$(CONFIG_LINUXBOOT_UROOT_UINITCMD)
+uroot_args += -defaultsh $(CONFIG_LINUXBOOT_UROOT_SHELL)
ifneq (CONFIG_LINUXBOOT_UROOT_FILES,)
-uroot_args+=$(foreach file,$(CONFIG_LINUXBOOT_UROOT_FILES),-files $(PWD)/$(file))
+uroot_args += $(foreach file,$(CONFIG_LINUXBOOT_UROOT_FILES),-files $(PWD)/$(file))
endif
-uroot_cmds=$(CONFIG_LINUXBOOT_UROOT_COMMANDS)
-
-all: u-root
+uroot_cmds = $(CONFIG_LINUXBOOT_UROOT_COMMANDS)
version:
ifeq ("$(go_version)","")
@@ -38,27 +35,16 @@ ifeq ($(shell if [ $(go_version_minor) -lt 9 ]; then echo y; fi),y)
endif
endif
-get: version
- if [ -d "$(go_path_dir)/src/$(uroot_package)" ]; then \
- git -C $(go_path_dir)/src/$(uroot_package) checkout --quiet main; \
- git -C $(go_path_dir)/src/$(uroot_package) pull || \
- echo -e "\n<<Pulling u-root package from GitHub failed>>\n"; \
- else \
- git clone https://${uroot_package} ${go_path_dir}/src/${uroot_package} || \
- (echo -e "\n<<Failed to clone u-root package. Please check your internet access>>\n" && \
- exit 1); \
- fi
-
-checkout: get
- git -C $(go_path_dir)/src/$(uroot_package) checkout --quiet $(CONFIG_LINUXBOOT_UROOT_VERSION)
-
-build: checkout
- cd ${go_path_dir}/src/${uroot_package}; \
- go build -o ${uroot_bin} .
+$(uroot_build):
+ git clone https://$(uroot_package) $(uroot_build)
+ git -C $(uroot_build) checkout --quiet $(CONFIG_LINUXBOOT_UROOT_VERSION)
-u-root: build
- GOARCH=$(ARCH-y) $(uroot_bin) \
- -uroot-source ${go_path_dir}/src/${uroot_package} \
- $(uroot_args) -o $(project_dir)/initramfs_u-root.cpio $(uroot_cmds)
+$(uroot_build)/u-root: $(uroot_build)
+ cd $(uroot_build); \
+ go build -o u-root .
-.PHONY: all u-root build checkout get version
+#$(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)
diff --git a/payloads/external/Makefile.inc b/payloads/external/Makefile.inc
index 33df6fb46e..4d3799de89 100644
--- a/payloads/external/Makefile.inc
+++ b/payloads/external/Makefile.inc
@@ -26,8 +26,8 @@ ifneq ($(strip $(call strip_quotes,$(CONFIG_LINUX_COMMAND_LINE))),)
endif
ifneq ($(strip $(call strip_quotes,$(CONFIG_LINUX_INITRD))),)
ifneq ($(CONFIG_LINUXBOOT_ARM64),y)
- ADDITIONAL_PAYLOAD_CONFIG+=-I $(CONFIG_LINUX_INITRD)$(CONFIG_LINUXBOOT_INITRAMFS_SUFFIX)
- prebuilt-files += $(strip $(call strip_quotes,$(CONFIG_LINUX_INITRD)))
+ ADDITIONAL_PAYLOAD_CONFIG+=-I $(CONFIG_LINUX_INITRD)$(CONFIG_LINUXBOOT_INITRAMFS)$(CONFIG_LINUXBOOT_INITRAMFS_SUFFIX)
+ prebuilt-files += $(strip $(call strip_quotes,$(CONFIG_LINUX_INITRD)$(CONFIG_LINUXBOOT_INITRAMFS)))
endif
endif
endif
@@ -367,41 +367,45 @@ payloads/external/iPXE/ipxe/ipxe.rom ipxe: $(DOTCONFIG) $(PXE_CONFIG_SCRIPT)
MFLAGS= MAKEFLAGS=
# LinuxBoot
+LINUXBOOT_CROSS_COMPILE_ARCH-$(CONFIG_LINUXBOOT_X86) = x86_32
+LINUXBOOT_CROSS_COMPILE_ARCH-$(CONFIG_LINUXBOOT_X86_64) = x86_64
+LINUXBOOT_CROSS_COMPILE_ARCH-$(CONFIG_LINUXBOOT_ARM) = arm
+LINUXBOOT_CROSS_COMPILE_ARCH-$(CONFIG_LINUXBOOT_ARM64) = arm64
+LINUXBOOT_CROSS_COMPILE_ARCH-$(CONFIG_LINUXBOOT_RISCV_RV32) = riscv
+LINUXBOOT_CROSS_COMPILE_ARCH-$(CONFIG_LINUXBOOT_RISCV_RV64) = riscv
+ifeq ($(CONFIG_LINUXBOOT_CROSS_COMPILE),)
+ CONFIG_LINUXBOOT_CROSS_COMPILE=$(CROSS_COMPILE_$(LINUXBOOT_CROSS_COMPILE_ARCH-y))
+endif
.PHONY: linuxboot
-linuxboot:
+payloads/external/LinuxBoot/build/Image linuxboot:
$(MAKE) -C payloads/external/LinuxBoot \
CPUS=$(CPUS) \
CONFIG_LINUXBOOT_X86_64=$(CONFIG_LINUXBOOT_X86_64) \
CONFIG_LINUXBOOT_X86=$(CONFIG_LINUXBOOT_X86) \
+ CONFIG_LINUXBOOT_ARM=$(CONFIG_LINUXBOOT_ARM) \
CONFIG_LINUXBOOT_ARM64=$(CONFIG_LINUXBOOT_ARM64) \
- CONFIG_LINUXBOOT_KERNEL=$(CONFIG_PAYLOAD_FILE) \
- CONFIG_LINUXBOOT_INITRAMFS=$(CONFIG_LINUX_INITRD) \
+ CONFIG_LINUXBOOT_RISCV_RV32=$(CONFIG_LINUXBOOT_RISCV_RV32) \
+ CONFIG_LINUXBOOT_RISCV_RV64=$(CONFIG_LINUXBOOT_RISCV_RV64) \
+ CONFIG_LINUXBOOT_CROSS_COMPILE=$(CONFIG_LINUXBOOT_CROSS_COMPILE) \
+ 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_BUILD_INITRAMFS=$(CONFIG_LINUXBOOT_BUILD_INITRAMFS) \
- CONFIG_LINUXBOOT_KERNEL_MAINLINE=$(CONFIG_LINUXBOOT_KERNEL_MAINLINE) \
- CONFIG_LINUXBOOT_KERNEL_STABLE=$(CONFIG_LINUXBOOT_KERNEL_STABLE) \
- CONFIG_LINUXBOOT_KERNEL_LONGTERM=$(CONFIG_LINUXBOOT_KERNEL_LONGTERM) \
- CONFIG_LINUXBOOT_KERNEL_CUSTOM=$(CONFIG_LINUXBOOT_KERNEL_CUSTOM) \
- CONFIG_LINUXBOOT_KERNEL_CUSTOM_VERSION=$(CONFIG_LINUXBOOT_KERNEL_CUSTOM_VERSION) \
- CONFIG_LINUXBOOT_KERNEL_CUSTOM_CONFIG=$(CONFIG_LINUXBOOT_KERNEL_CUSTOM_CONFIG) \
+ CONFIG_LINUXBOOT_KERNEL_PATH=$(CONFIG_LINUXBOOT_KERNEL_PATH) \
+ CONFIG_LINUXBOOT_KERNEL_VERSION=$(CONFIG_LINUXBOOT_KERNEL_VERSION) \
CONFIG_LINUXBOOT_KERNEL_BZIMAGE=$(CONFIG_LINUXBOOT_KERNEL_BZIMAGE) \
CONFIG_LINUXBOOT_KERNEL_UIMAGE=$(CONFIG_LINUXBOOT_KERNEL_UIMAGE) \
CONFIG_LINUXBOOT_KERNEL_CONFIGFILE=$(CONFIG_LINUXBOOT_KERNEL_CONFIGFILE) \
- CONFIG_LINUXBOOT_INITRAMFS_COMPRESSION_XZ=$(CONFIG_LINUXBOOT_INITRAMFS_COMPRESSION_XZ) \
CONFIG_LINUXBOOT_UROOT=$(CONFIG_LINUXBOOT_UROOT) \
CONFIG_LINUXBOOT_UROOT_VERSION=$(CONFIG_LINUXBOOT_UROOT_VERSION) \
CONFIG_LINUXBOOT_UROOT_FORMAT=$(CONFIG_LINUXBOOT_UROOT_FORMAT) \
CONFIG_LINUXBOOT_UROOT_INITCMD=$(CONFIG_LINUXBOOT_UROOT_INITCMD) \
- CONFIG_LINUXBOOT_UROOT_UINITCMD=$(CONFIG_LINUXBOOT_UROOT_UINITCMD)\
+ CONFIG_LINUXBOOT_UROOT_UINITCMD=$(CONFIG_LINUXBOOT_UROOT_UINITCMD) \
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_DTB_FILE=$(CONFIG_LINUXBOOT_DTB_FILE)
-
-payloads/external/LinuxBoot/linuxboot/bzImage: linuxboot
-payloads/external/LinuxBoot/linuxboot/uImage: linuxboot
-payloads/external/LinuxBoot/linuxboot/initramfs_u-root.cpio: linuxboot
+ CONFIG_LINUXBOOT_DTS_FILE=$(CONFIG_LINUXBOOT_DTS_FILE)
# BOOTBOOT