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>
This commit is contained in:
parent
449c6d981c
commit
c202be793f
|
@ -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
|
||||
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_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
|
||||
default "build/uImage" if LINUXBOOT_KERNEL_UIMAGE
|
||||
default "build/bzImage" if LINUXBOOT_KERNEL_BZIMAGE
|
||||
help
|
||||
The kernel path is either and absolute path or relative to the
|
||||
LinuxBoot directory
|
||||
|
||||
if LINUXBOOT_COMPILE_KERNEL
|
||||
|
||||
choice
|
||||
prompt "Kernel release"
|
||||
default LINUXBOOT_KERNEL_STABLE
|
||||
config LINUXBOOT_CROSS_COMPILE
|
||||
string "cross compiler"
|
||||
default "" # e.g. "aarch64-linux-gnu-"
|
||||
help
|
||||
Choose the kernel release.
|
||||
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.
|
||||
|
||||
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"
|
||||
help
|
||||
Mainline kernel version
|
||||
|
||||
config LINUXBOOT_KERNEL_STABLE
|
||||
bool "stable"
|
||||
help
|
||||
Stable kernel version
|
||||
|
||||
config LINUXBOOT_KERNEL_LONGTERM
|
||||
bool "longterm"
|
||||
help
|
||||
Longterm (LTS) kernel version
|
||||
|
||||
config LINUXBOOT_KERNEL_CUSTOM
|
||||
bool "custom"
|
||||
help
|
||||
Custom kernel version
|
||||
|
||||
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
|
||||
|
|
|
@ -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 $< $@
|
||||
|
||||
initramfs_compressed: initramfs
|
||||
include targets/linux.mk targets/u-root.mk
|
||||
|
||||
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)
|
||||
|
||||
linuxboot: kernel initramfs_compressed
|
||||
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
|
||||
|
||||
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
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
/dts-v1/;
|
||||
|
||||
/ {
|
||||
};
|
|
@ -0,0 +1,4 @@
|
|||
CONFIG_ARCH_RV32I=y
|
||||
CONFIG_32BIT=y
|
||||
# CONFIG_PORTABLE is not set
|
||||
CONFIG_NONPORTABLE=y
|
|
@ -0,0 +1,2 @@
|
|||
CONFIG_ARCH_RV64I=y
|
||||
CONFIG_64BIT=y
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
};
|
|
@ -1,39 +1,18 @@
|
|||
## 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_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
|
||||
|
||||
|
@ -49,81 +28,35 @@ else ifeq ($(findstring x6.,x$(kernel_version)),x6.)
|
|||
kernel_mirror_path := $(kernel_mirror)/v6.x
|
||||
endif
|
||||
|
||||
all: kernel
|
||||
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";
|
||||
|
||||
lookup:
|
||||
ifeq ($(kernel_version),)
|
||||
$(error kernel version lookup failed for $(TAG-y) release)
|
||||
endif
|
||||
@echo " WWW Kernel [$(TAG-y)] $(kernel_version)"
|
||||
$(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);
|
||||
|
||||
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
|
||||
|
||||
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)/.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
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
## 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
|
||||
uroot_build = build/go/src/$(uroot_package)
|
||||
|
||||
ARCH-$(CONFIG_LIBUXBOOT_X86_64)=amd64
|
||||
ARCH-$(CONFIG_LINUXBOOT_X86)=i386
|
||||
ARCH-$(CONFIG_LINUXBOOT_ARM64)=arm64
|
||||
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')
|
||||
|
@ -23,8 +22,6 @@ endif
|
|||
|
||||
uroot_cmds = $(CONFIG_LINUXBOOT_UROOT_COMMANDS)
|
||||
|
||||
all: u-root
|
||||
|
||||
version:
|
||||
ifeq ("$(go_version)","")
|
||||
printf "\n<<Please install Golang >= 1.9 for u-root mode>>\n\n"
|
||||
|
@ -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
|
||||
$(uroot_build):
|
||||
git clone https://$(uroot_package) $(uroot_build)
|
||||
git -C $(uroot_build) checkout --quiet $(CONFIG_LINUXBOOT_UROOT_VERSION)
|
||||
|
||||
checkout: get
|
||||
git -C $(go_path_dir)/src/$(uroot_package) checkout --quiet $(CONFIG_LINUXBOOT_UROOT_VERSION)
|
||||
$(uroot_build)/u-root: $(uroot_build)
|
||||
cd $(uroot_build); \
|
||||
go build -o u-root .
|
||||
|
||||
build: checkout
|
||||
cd ${go_path_dir}/src/${uroot_package}; \
|
||||
go build -o ${uroot_bin} .
|
||||
|
||||
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)
|
||||
|
||||
.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)
|
||||
|
|
|
@ -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,28 +367,36 @@ 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_INITRAMFS_SUFFIX=$(CONFIG_LINUXBOOT_INITRAMFS_SUFFIX) \
|
||||
CONFIG_LINUXBOOT_COMPILE_KERNEL=$(CONFIG_LINUXBOOT_COMPILE_KERNEL) \
|
||||
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_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_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) \
|
||||
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) \
|
||||
|
@ -397,11 +405,7 @@ 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_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
|
||||
|
||||
|
|
Loading…
Reference in New Issue