payloads: Add LinuxBoot payload in u-root mode
* Add LinuxBoot support * Add u-root mode * Download kernel and u-root from upstream sources. * Add customization options * Clean kernel only if directory exists Change-Id: I3a25ff6812e046acc688cbbb203cf262ad751659 Signed-off-by: Philipp Deppenwiese <zaolin@das-labor.org> Reviewed-on: https://review.coreboot.org/23071 Reviewed-by: Ronald G. Minnich <rminnich@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
a892cde653
commit
0f0e4e6c66
|
@ -64,7 +64,7 @@ config PAYLOAD_FILE
|
|||
choice
|
||||
prompt "Payload compression algorithm"
|
||||
default COMPRESSED_PAYLOAD_LZMA
|
||||
depends on !PAYLOAD_NONE && !PAYLOAD_LINUX
|
||||
depends on !PAYLOAD_NONE && !PAYLOAD_LINUX && !PAYLOAD_LINUXBOOT
|
||||
help
|
||||
Choose the compression algorithm for the chosen payloads.
|
||||
You can choose between LZMA and LZ4.
|
||||
|
|
|
@ -35,6 +35,7 @@ payloads/external/iPXE \
|
|||
payloads/external/tint \
|
||||
payloads/external/tianocore \
|
||||
payloads/external/GRUB2 \
|
||||
payloads/external/LinuxBoot \
|
||||
|
||||
payloads/coreinfo/build/coreinfo.elf coreinfo:
|
||||
$(MAKE) -C payloads/coreinfo defaultbuild
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
## This file is part of the coreboot project.
|
||||
##
|
||||
## Copyright (C) 2017 Facebook Inc.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; version 2 of the License.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
|
||||
if PAYLOAD_LINUXBOOT
|
||||
|
||||
choice
|
||||
prompt "Architecture"
|
||||
default LINUXBOOT_X86_64
|
||||
|
||||
config LINUXBOOT_X86_64
|
||||
bool "x86_64"
|
||||
help
|
||||
AMD64 kernel and initramfs
|
||||
|
||||
config LINUXBOOT_X86
|
||||
bool "x86"
|
||||
help
|
||||
X86 kernel and initramfs
|
||||
endchoice
|
||||
|
||||
config LINUXBOOT_ARCH
|
||||
string
|
||||
default "amd64" if LINUXBOOT_X86_64
|
||||
default "386" if LINUXBOOT_X86
|
||||
|
||||
choice
|
||||
prompt "Kernel version"
|
||||
default LINUXBOOT_KERNEL_STABLE
|
||||
|
||||
config LINUXBOOT_KERNEL_STABLE
|
||||
bool "4.15.3"
|
||||
help
|
||||
Stable kernel version
|
||||
endchoice
|
||||
|
||||
config LINUXBOOT_KERNEL_VERSION
|
||||
string
|
||||
default "4.15.3" if LINUXBOOT_KERNEL_STABLE
|
||||
|
||||
config LINUXBOOT_KERNEL_CONFIGFILE
|
||||
string "Kernel config file"
|
||||
default ""
|
||||
help
|
||||
Add your own kernel configuration file. Otherwise a default
|
||||
minimal defconfig is used.
|
||||
|
||||
config LINUXBOOT_KERNEL_COMMANDLINE
|
||||
string "Kernel command-line"
|
||||
default ""
|
||||
help
|
||||
Add your own kernel command-line arguments.
|
||||
|
||||
config PAYLOAD_FILE
|
||||
default "payloads/external/LinuxBoot/linuxboot/kernel-image"
|
||||
|
||||
choice
|
||||
prompt "Payload Mode"
|
||||
default LINUXBOOT_UROOT
|
||||
|
||||
config LINUXBOOT_UROOT
|
||||
bool "u-root"
|
||||
help
|
||||
Enable u-root linuxboot mode.
|
||||
See http://u-root.tk/ for more information.
|
||||
endchoice
|
||||
|
||||
if LINUXBOOT_UROOT
|
||||
|
||||
choice
|
||||
prompt "U-root version"
|
||||
default LINUXBOOT_UROOT_MASTER
|
||||
|
||||
config LINUXBOOT_UROOT_MASTER
|
||||
bool "master"
|
||||
help
|
||||
Latest u-root version
|
||||
endchoice
|
||||
|
||||
config LINUXBOOT_UROOT_VERSION
|
||||
string
|
||||
default "master" if LINUXBOOT_UROOT_MASTER
|
||||
|
||||
config LINUXBOOT_UROOT_COMMANDS
|
||||
string "Select u-root commands"
|
||||
default ""
|
||||
help
|
||||
Comma separated list of additional modules to include. Otherwise all modules
|
||||
of u-root are included.
|
||||
|
||||
config LINUXBOOT_UROOT_FILES
|
||||
string "Add files to u-root base"
|
||||
default ""
|
||||
help
|
||||
Path to directory containing root structure for embedding into the
|
||||
initramfs.
|
||||
|
||||
config PAYLOAD_USERSPACE
|
||||
string ""
|
||||
default "payloads/external/LinuxBoot/linuxboot/initramfs.cpio.xz"
|
||||
|
||||
endif
|
||||
endif
|
|
@ -0,0 +1,23 @@
|
|||
## This file is part of the coreboot project.
|
||||
##
|
||||
## Copyright (C) 2017 Facebook Inc.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; version 2 of the License.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
|
||||
config PAYLOAD_LINUXBOOT
|
||||
bool "LinuxBoot"
|
||||
depends on ARCH_X86
|
||||
help
|
||||
Select this option if you want to build a coreboot image
|
||||
with a LinuxBoot payload. If you don't know what this is
|
||||
about, just leave it enabled.
|
||||
|
||||
See https://coreboot.org/Payloads for more information.
|
|
@ -0,0 +1,63 @@
|
|||
## This file is part of the coreboot project.
|
||||
##
|
||||
## Copyright (C) 2017 Facebook Inc.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; version 2 of the License.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
|
||||
kernel_tarball=https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-$(CONFIG_LINUXBOOT_KERNEL_VERSION).tar.xz
|
||||
project_dir=linuxboot
|
||||
kernel_dir=$(project_dir)/kernel
|
||||
|
||||
unexport $(COREBOOT_EXPORTS)
|
||||
|
||||
all: payload
|
||||
|
||||
$(kernel_dir)/.config:
|
||||
echo " WWW Download Linux $(CONFIG_LINUXBOOT_KERNEL_VERSION)"
|
||||
mkdir -p $(kernel_dir)
|
||||
ifeq ("$(wildcard $(kernel_dir)/README)","")
|
||||
wget -qO- $(kernel_tarball) | tar xJ -C $(kernel_dir) --strip 1
|
||||
endif
|
||||
|
||||
config: $(kernel_dir)/.config
|
||||
echo " CONFIG Linux $(CONFIG_LINUXBOOT_KERNEL_VERSION)"
|
||||
ifneq ($(CONFIG_LINUXBOOT_KERNEL_CONFIGFILE),)
|
||||
cp $(CONFIG_LINUXBOOT_KERNEL_CONFIGFILE) $(kernel_dir)/.config
|
||||
endif
|
||||
ifeq ($(CONFIG_LINUXBOOT_ARCH),386)
|
||||
cp x86/defconfig $(kernel_dir)/.config
|
||||
else ifeq ($(CONFIG_LINUXBOOT_ARCH),amd64)
|
||||
cp x86_64/defconfig $(kernel_dir)/.config
|
||||
endif
|
||||
|
||||
$(project_dir)/kernel-image: config
|
||||
echo " MAKE Kernel $(CONFIG_LINUXBOOT_KERNEL_VERSION)"
|
||||
$(MAKE) -C $(kernel_dir) olddefconfig
|
||||
$(MAKE) -C $(kernel_dir) -j $(CPUS)
|
||||
ifeq ($(CONFIG_LINUXBOOT_ARCH),386)
|
||||
cp $(kernel_dir)/arch/x86/boot/bzImage $(project_dir)/kernel-image
|
||||
else ifeq ($(CONFIG_LINUXBOOT_ARCH),amd64)
|
||||
cp $(kernel_dir)/arch/x86/boot/bzImage $(project_dir)/kernel-image
|
||||
endif
|
||||
|
||||
payload: $(project_dir)/kernel-image
|
||||
ifeq ($(CONFIG_LINUXBOOT_UROOT),y)
|
||||
$(MAKE) -f targets/u-root.mk
|
||||
endif
|
||||
|
||||
clean:
|
||||
if [ -d "$(kernel_dir)" ]; then make -C $(kernel_dir) clean; fi
|
||||
rm -f $(project_dir)/initramfs.cpio.xz
|
||||
|
||||
distclean:
|
||||
rm -rf $(project_dir)
|
||||
|
||||
.PHONY: config patch payload clean distclean clone fetch all
|
|
@ -0,0 +1,80 @@
|
|||
## This file is part of the coreboot project.
|
||||
##
|
||||
## Copyright (C) 2017 Facebook Inc.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; version 2 of the License.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
|
||||
uroot_git_repo=https://github.com/u-root/u-root.git
|
||||
uroot_dir=$(project_dir)/go/src/github.com/u-root/u-root
|
||||
go_check=$(shell command -v go 1>/dev/null 2>&1 && echo go)
|
||||
project_dir=$(shell pwd)/linuxboot
|
||||
project_name=u-root
|
||||
go_path_dir=$(shell pwd)/linuxboot/go
|
||||
|
||||
all: build
|
||||
|
||||
check:
|
||||
ifneq ($(go_check),go)
|
||||
printf "\n<<Please install Golang >= 1.9 for u-root mode>>\n\n"
|
||||
exit 1
|
||||
endif
|
||||
mkdir -p $(project_dir)/go/src/github.com/u-root
|
||||
|
||||
$(uroot_dir)/.git:
|
||||
echo " Git Cloning u-root $(CONFIG_LINUXBOOT_UROOT_VERSION)"
|
||||
git clone $(uroot_git_repo) $(uroot_dir)
|
||||
|
||||
fetch: check $(uroot_dir)/.git
|
||||
-cd "$(uroot_dir)" && git fetch origin
|
||||
|
||||
checkout: fetch
|
||||
cd "$(uroot_dir)" && \
|
||||
if ! git diff --quiet _cb_checkout "$(CONFIG_LINUXBOOT_UROOT_VERSION)" -- 2>/dev/null; \
|
||||
then \
|
||||
printf " CHECKOUT $(project_name) [$(CONFIG_LINUXBOOT_UROOT_VERSION)]\n"; \
|
||||
git checkout $$(git rev-parse HEAD) >/dev/null 2>&1; \
|
||||
git branch -f _cb_checkout "$(CONFIG_LINUXBOOT_UROOT_VERSION)" && \
|
||||
git checkout _cb_checkout && \
|
||||
$(if $(project_patches), \
|
||||
for patch in $(project_patches); do \
|
||||
printf " PATCH $$patch\n"; \
|
||||
git am --keep-cr "$$patch" || \
|
||||
( printf "Error when applying patches.\n"; \
|
||||
git am --abort; exit 1; ); \
|
||||
done;,true;) \
|
||||
fi
|
||||
|
||||
$(project_dir)/initramfs.cpio.xz: checkout
|
||||
cd $(uroot_dir); GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) go build u-root.go
|
||||
echo " MAKE u-root $(CONFIG_LINUXBOOT_UROOT_VERSION)"
|
||||
ifneq ($(CONFIG_LINUXBOOT_UROOT_COMMANDS),)
|
||||
ifneq ($(CONFIG_LINUXBOOT_UROOT_FILES),)
|
||||
cd $(uroot_dir); GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) ./u-root \
|
||||
-build=bb -files $(CONFIG_LINUXBOOT_UROOT_FILES) -o $(project_dir)/initramfs.cpio \
|
||||
./cmds/{$(CONFIG_LINUXBOOT_UROOT_COMMANDS)}
|
||||
else
|
||||
cd $(uroot_dir); GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) ./u-root \
|
||||
-build=bb -o $(project_dir)/initramfs.cpio ./cmds/{$(CONFIG_LINUXBOOT_UROOT_COMMANDS)}
|
||||
endif
|
||||
else
|
||||
ifneq ($(CONFIG_LINUXBOOT_UROOT_FILES),)
|
||||
cd $(uroot_dir); GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) ./u-root \
|
||||
-build=bb -files $(CONFIG_LINUXBOOT_UROOT_FILES) -o $(project_dir)/initramfs.cpio
|
||||
else
|
||||
cd $(uroot_dir); GOARCH=$(CONFIG_LINUXBOOT_ARCH) GOPATH=$(go_path_dir) ./u-root \
|
||||
-build=bb -o $(project_dir)/initramfs.cpio
|
||||
endif
|
||||
endif
|
||||
xz -f --check=crc32 -9 --lzma2=dict=1MiB --threads=$(CPUS) $(project_dir)/initramfs.cpio
|
||||
|
||||
build: $(project_dir)/initramfs.cpio.xz
|
||||
|
||||
.PHONY: build checkout fetch all check
|
|
@ -4,6 +4,7 @@
|
|||
##
|
||||
## Copyright (C) 2009-2010 coresystems GmbH
|
||||
## Copyright (C) 2015 Google Inc.
|
||||
## Copyright (C) 2017 Facebook Inc.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
|
@ -31,6 +32,13 @@ $(PAYLOAD_CONFIG): payloads/external/depthcharge/depthcharge/build/depthcharge.e
|
|||
#TODO: Figure out version
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_PAYLOAD_LINUXBOOT),y)
|
||||
ifneq ($(strip $(call strip_quotes,$(CONFIG_LINUXBOOT_KERNEL_COMMANDLINE))),)
|
||||
ADDITIONAL_PAYLOAD_CONFIG+=-C $(CONFIG_LINUXBOOT_KERNEL_COMMANDLINE)
|
||||
endif
|
||||
ADDITIONAL_PAYLOAD_CONFIG+=-I $(CONFIG_PAYLOAD_USERSPACE)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_PAYLOAD_LINUX),y)
|
||||
ifneq ($(strip $(call strip_quotes,$(CONFIG_LINUX_COMMAND_LINE))),)
|
||||
ADDITIONAL_PAYLOAD_CONFIG+=-C $(CONFIG_LINUX_COMMAND_LINE)
|
||||
|
@ -240,3 +248,32 @@ payloads/external/iPXE/ipxe/ipxe.rom ipxe: $(DOTCONFIG)
|
|||
IPXE_UART=$(IPXE_UART) \
|
||||
CONFIG_TTYS0_BAUD=$(CONFIG_TTYS0_BAUD) \
|
||||
MFLAGS= MAKEFLAGS=
|
||||
|
||||
# LinuxBoot
|
||||
|
||||
linuxboot:
|
||||
$(MAKE) -C payloads/external/LinuxBoot \
|
||||
HOSTCC="$(HOSTCC)" \
|
||||
CC="$(HOSTCC)" \
|
||||
GCC_CC_x86_32=$(GCC_CC_x86_32) \
|
||||
GCC_CC_x86_64=$(GCC_CC_x86_64) \
|
||||
GCC_CC_arm=$(GCC_CC_arm) \
|
||||
GCC_CC_arm64=$(GCC_CC_arm64) \
|
||||
OBJCOPY_x86_32=$(OBJCOPY_x86_32) \
|
||||
OBJCOPY_x86_64=$(OBJCOPY_x86_64) \
|
||||
OBJCOPY_arm=$(OBJCOPY_arm) \
|
||||
OBJCOPY_arm64=$(OBJCOPY_arm64) \
|
||||
CPUS=$(CPUS) \
|
||||
CONFIG_LINUXBOOT_KERNEL_VERSION=$(CONFIG_LINUXBOOT_KERNEL_VERSION) \
|
||||
CONFIG_LINUXBOOT_KERNEL_CONFIGFILE=$(CONFIG_LINUXBOOT_KERNEL_CONFIGFILE) \
|
||||
CONFIG_LINUXBOOT_KERNEL_COMMANDLINE=$(CONFIG_LINUXBOOT_KERNEL_COMMANDLINE) \
|
||||
CONFIG_LINUXBOOT_UROOT_VERSION=$(CONFIG_LINUXBOOT_UROOT_VERSION) \
|
||||
CONFIG_LINUXBOOT_UROOT_COMMANDS="$(CONFIG_LINUXBOOT_UROOT_COMMANDS)" \
|
||||
CONFIG_LINUXBOOT_ARCH=$(CONFIG_LINUXBOOT_ARCH) \
|
||||
CONFIG_LINUXBOOT_UROOT=$(CONFIG_LINUXBOOT_UROOT) \
|
||||
CONFIG_LINUXBOOT_UROOT_FILES=$(CONFIG_LINUXBOOT_UROOT_FILES)
|
||||
|
||||
payloads/external/LinuxBoot/linuxboot/kernel-image: linuxboot
|
||||
payloads/external/LinuxBoot/linuxboot/initramfs.cpio.xz: linuxboot
|
||||
payloads/external/LinuxBoot/linuxboot/kernel/.config: linuxboot
|
||||
payloads/external/LinuxBoot/linuxboot/go/src/github.com/u-root/u-root/.git: linuxboot
|
||||
|
|
|
@ -267,6 +267,7 @@ function update_config
|
|||
echo "# CONFIG_PAYLOAD_GRUB2 is not set"
|
||||
echo "# CONFIG_PAYLOAD_OPENBIOS is not set"
|
||||
echo "# CONFIG_PAYLOAD_DEPTHCHARGE is not set"
|
||||
echo "# CONFIG_PAYLOAD_LINUXBOOT is not set"
|
||||
echo "# CONFIG_PAYLOAD_UBOOT is not set"
|
||||
echo "# CONFIG_PAYLOAD_TIANOCORE is not set"
|
||||
echo "# CONFIG_PXE is not set"
|
||||
|
|
Loading…
Reference in New Issue