heads/modules/coreboot

186 lines
6.8 KiB
Makefile
Raw Normal View History

modules-$(CONFIG_COREBOOT) += coreboot
ifeq "$(CONFIG_COREBOOT)" "y"
CONFIG_COREBOOT_ROM ?= coreboot.rom
CONFIG_COREBOOT_BOOTBLOCK ?=
ifeq "$(CONFIG_TARGET_ARCH)" "x86"
COREBOOT_TARGET := i386
LINUX_IMAGE_FILE := bzImage
COREBOOT_TARGET_CROSS :=
else ifeq "$(CONFIG_TARGET_ARCH)" "ppc64"
COREBOOT_TARGET := ppc64
LINUX_IMAGE_FILE := zImage
# skiboot payload needs this to find the cross compiler, it can't find
# it from XGCCPATH. This uses the Heads toolchain for skiboot
COREBOOT_TARGET_CROSS := CROSS=$(CROSS)
else
$(error "$(CONFIG_TARGET_ARCH) target isn't supported by this module")
endif
ifeq "$(CONFIG_COREBOOT_VERSION)" "4.11"
Add new board: Purism Librem Server L1UM (#858) * modules/coreboot: add option to use coreboot 4.11 Port patches from coreboot 4.8.1 to 4.11: * 0000-measure-boot -> 0001 * 0010-cross-compiler-support All other patches for coreboot 4.8.1 have either already been integrated, or are for platforms which do not need to be migrated to coreboot 4.11 (they will move to 4.12 or newer). Signed-off-by: Matt DeVillier <matt.devillier@puri.sm> * patches/coreboot-4.11: Add Broadwell-DE platform patch Add a patch for FSP Broadwell-DE to make use of Heads' measured boot. Signed-off-by: Matt DeVillier <matt.devillier@puri.sm> * patches/coreboot-4.11: Add patch to read serial # from CBFS Will be used by multiple Librem boards. Signed-off-by: Matt DeVillier <matt.devillier@puri.sm> * patches/coreboot-4.11: add board support for Librem Server L1UM Signed-off-by: Matt DeVillier <matt.devillier@puri.sm> * Librem Server L1UM: add new board Add board config, coreboot config, kernel config files. Add conditional purism-blobs dependency to coreboot-4.11 module. Signed-off-by: Matt DeVillier <matt.devillier@puri.sm> * flash.sh: add special handling for librem_l1um board Add support for persisting PCIe config via PCHSTRP9 in flash descriptor. This is needed to support multiple variants of the L1UM server which use the same firmware but differ in PCIe lane configuration via the PCH straps configuration in the flash descriptor. Signed-off-by: Matt DeVillier <matt.devillier@puri.sm> * patches/coreboot-4.11: Add 'Use PRIxPTR to print uintptr_t' patch Cherry-picked from upstream coreboot (post-4.11), fixes compilation issue. Signed-off-by: Matt DeVillier <matt.devillier@puri.sm> * CircleCI: add target to build board librem_l1um Signed-off-by: Matt DeVillier <matt.devillier@puri.sm>
2020-10-18 13:48:25 -05:00
coreboot_version := 4.11
coreboot_hash := 97fd859b4c39a25534fe33c30eb86e54a233952e08a024c55858d11598a8ad87
coreboot-blobs_hash := aa7855c5bd385b3360dadc043ea6bc93f564e6e4840d9b3ee5b9e696bbd055db
else ifeq "$(CONFIG_COREBOOT_VERSION)" "4.19"
coreboot_version := 4.19
coreboot_hash := 65ccb2f46535b996e0066a1b76f81c8cf1ff3e27df84b3f97d8ad7b3e7cf0a43
coreboot-blobs_hash := 30214caed07b25f11e47bec022ff6234841376e36689eb674de2330a3e980cbc
else ifeq "$(CONFIG_COREBOOT_VERSION)" "talos_2"
coreboot_version = talos_2
coreboot_commit_hash = c8aed443c631042ad2b0326c35cd0b774752b924
coreboot_repo := https://github.com/Dasharo/coreboot
else ifeq "$(CONFIG_COREBOOT_VERSION)" "purism"
coreboot_version := purism
coreboot_repo := https://source.puri.sm/coreboot/coreboot
coreboot_commit_hash := a899f08d2789db1dd9b02cff34179c4d38e6d0e3
else
$(error "$(BOARD): does not specify coreboot version under CONFIG_COREBOOT_VERSION")
endif
coreboot_depends := $(if $(CONFIG_PURISM_BLOBS), purism-blobs)
coreboot_depends := $(if $(CONFIG_NITROKEY_BLOBS), nitrokey-blobs)
coreboot_base_dir := coreboot-$(coreboot_version)
coreboot_dir := $(coreboot_base_dir)/$(BOARD)
coreboot_tar := coreboot-$(coreboot_version).tar.xz
coreboot_url := https://www.coreboot.org/releases/$(coreboot_tar)
# coreboot builds are specialized on a per-target basis.
# The builds are done in a per-target subdirectory
CONFIG_COREBOOT_CONFIG ?= config/coreboot-$(BOARD).config
# Ensure that touching the config file will force a rebuild
$(build)/$(coreboot_dir)/.configured: $(CONFIG_COREBOOT_CONFIG)
EXTRA_FLAGS ?= -fdebug-prefix-map=$(pwd)=heads -gno-record-gcc-switches -Wno-error=packed-not-aligned -Wno-address-of-packed-member
coreboot_configure := \
2018-08-13 10:26:08 -04:00
mkdir -p "$(build)/$(coreboot_dir)" \
&& $(call install_config,$(pwd)/$(CONFIG_COREBOOT_CONFIG),$(build)/$(coreboot_dir)/.config) \
&& echo 'CONFIG_LOCALVERSION="$(BRAND_NAME)-$(HEADS_GIT_VERSION)"' >> $(build)/$(coreboot_dir)/.config \
&& echo 'CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME="$(BOARD)"' >> $(build)/$(coreboot_dir)/.config \
2018-08-13 10:26:08 -04:00
&& $(MAKE) olddefconfig \
-C "$(build)/$(coreboot_base_dir)" \
obj="$(build)/$(coreboot_dir)" \
DOTCONFIG="$(build)/$(coreboot_dir)/.config" \
BUILD_TIMELESS=1 \
CFLAGS_x86_32="$(EXTRA_FLAGS)" \
CFLAGS_x86_64="$(EXTRA_FLAGS)" \
coreboot_target := \
2018-08-13 10:26:08 -04:00
-C "$(build)/$(coreboot_base_dir)" \
obj="$(build)/$(coreboot_dir)" \
DOTCONFIG="$(build)/$(coreboot_dir)/.config" \
xcompile="$(build)/$(coreboot_base_dir)/.xcompile" \
$(COREBOOT_TARGET_CROSS) \
BUILD_TIMELESS=1 \
CFLAGS_x86_32="$(EXTRA_FLAGS)" \
CFLAGS_x86_64="$(EXTRA_FLAGS)" \
2017-03-21 14:29:07 -04:00
$(MAKE_JOBS)
coreboot_output := $(CONFIG_COREBOOT_ROM)
coreboot_output += $(CONFIG_COREBOOT_BOOTBLOCK)
coreboot_depend += linux initrd $(musl_dep)
modules/coreboot: Do not rebuild coreboot buildstack when built .xcompile was not found because it was quoted and shouldn't in coreboot module's makefile Prior: stat("\"/home/user/heads/build/x86/coreboot-4.13/.xcompile\"", 0x7ffe56e6cfd0) = -1 ENOENT (No such file or directory) pipe([3, 4]) = 0 fcntl(4, F_GETFD) = 0 fcntl(4, F_SETFD, FD_CLOEXEC) = 0 fcntl(3, F_GETFD) = 0 fcntl(3, F_SETFD, FD_CLOEXEC) = 0 prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=1024, rlim_max=1024*1024}) = 0 prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=1024, rlim_max=1024*1024}) = 0 stat("/usr/bin/env", {st_mode=S_IFREG|0755, st_size=48480, ...}) = 0 geteuid() = 1000 getegid() = 1000 getuid() = 1000 getgid() = 1000 access("/usr/bin/env", X_OK) = 0 mmap(NULL, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7ce2be6fd000 rt_sigprocmask(SIG_BLOCK, ~[], [CHLD], 8) = 0 clone(child_stack=0x7ce2be705ff0, flags=CLONE_VM|CLONE_VFORK|SIGCHLD) = 305342 munmap(0x7ce2be6fd000, 36864) = 0 rt_sigprocmask(SIG_SETMASK, [CHLD], NULL, 8) = 0 close(4) = 0 read(3, "2\n", 200) = 2 read(3, "", 198) = 0 close(3) = 0 wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 305342 fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0 write(1, "make -C \"/home/user/heads/build/"..., 74make -C "/home/user/heads/build/x86/coreboot-4.13" CPUS=2 "crossgcc-i386" ) = 74 rt_sigprocmask(SIG_BLOCK, [HUP INT QUIT TERM XCPU XFSZ], NULL, 8) = 0 stat("/usr/bin/env", {st_mode=S_IFREG|0755, st_size=48480, ...}) = 0 geteuid() = 1000 getegid() = 1000 getuid() = 1000 getgid() = 1000 access("/usr/bin/env", X_OK) = 0 mmap(NULL, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7ce2be6fd000 rt_sigprocmask(SIG_BLOCK, ~[], [HUP INT QUIT TERM CHLD XCPU XFSZ], 8) = 0 clone(child_stack=0x7ce2be705ff0, flags=CLONE_VM|CLONE_VFORK|SIGCHLD) = 305343 munmap(0x7ce2be6fd000, 36864) = 0 rt_sigprocmask(SIG_SETMASK, [HUP INT QUIT TERM CHLD XCPU XFSZ], NULL, 8) = 0 rt_sigprocmask(SIG_UNBLOCK, [HUP INT QUIT TERM XCPU XFSZ], NULL, 8) = 0 wait4(-1, make[1]: Entering directory '/home/user/heads/build/x86/coreboot-4.13' Welcome to the coreboot cross toolchain builder v () Building toolchain using 2 thread(s). Target architecture is i386-elf Found compatible Ada compiler, enabling Ada support by default. Downloading and verifying tarballs ... * gmp-6.2.0.tar.xz (cached)... hash verified (052a5411dc74054240eec58132d2cf41211d0ff6) * mpfr-4.1.0.tar.xz (cached)... hash verified (159c3a58705662bfde4dc93f2617f3660855ead6) * mpc-1.2.0.tar.gz (cached)... hash verified (0abdc94acab0c9bfdaa391347cdfd7bbdb1cf017) * binutils-2.35.tar.xz (cached)... hash verified (6bdd090ce268b6d6c3442516021c4e4b5019e303) * gcc-8.3.0.tar.xz (cached)... hash verified (c27f4499dd263fe4fb01bcc5565917f3698583b2) Downloaded tarballs ... ok Unpacking and patching ... * gmp-6.2.0.tar.xz o gmp-6.2.0_generic-build.patch * mpfr-4.1.0.tar.xz ^C0x7ffe56e6ef40, 0, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set) strace: Process 305153 detached After: stat("/home/user/heads/build/x86/coreboot-4.13/.xcompile", 0x7ffd0303c7f0) = -1 ENOENT (No such file or directory) pipe([3, 4]) = 0 fcntl(4, F_GETFD) = 0 fcntl(4, F_SETFD, FD_CLOEXEC) = 0 fcntl(3, F_GETFD) = 0 fcntl(3, F_SETFD, FD_CLOEXEC) = 0 prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=1024, rlim_max=1024*1024}) = 0 prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=1024, rlim_max=1024*1024}) = 0 stat("/usr/bin/env", {st_mode=S_IFREG|0755, st_size=48480, ...}) = 0 geteuid() = 1000 getegid() = 1000 getuid() = 1000 getgid() = 1000 access("/usr/bin/env", X_OK) = 0 mmap(NULL, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x740f6e370000 rt_sigprocmask(SIG_BLOCK, ~[], [CHLD], 8) = 0 clone(child_stack=0x740f6e378ff0, flags=CLONE_VM|CLONE_VFORK|SIGCHLD) = 306024 munmap(0x740f6e370000, 36864) = 0 rt_sigprocmask(SIG_SETMASK, [CHLD], NULL, 8) = 0 close(4) = 0 read(3, "2\n", 200) = 2 read(3, "", 198) = 0 close(3) = 0 wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 306024 fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0 write(1, "make -C \"/home/user/heads/build/"..., 74make -C "/home/user/heads/build/x86/coreboot-4.13" CPUS=2 "crossgcc-i386" ) = 74 rt_sigprocmask(SIG_BLOCK, [HUP INT QUIT TERM XCPU XFSZ], NULL, 8) = 0 stat("/usr/bin/env", {st_mode=S_IFREG|0755, st_size=48480, ...}) = 0 geteuid() = 1000 getegid() = 1000 getuid() = 1000 getgid() = 1000 access("/usr/bin/env", X_OK) = 0 mmap(NULL, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x740f6e370000 rt_sigprocmask(SIG_BLOCK, ~[], [HUP INT QUIT TERM CHLD XCPU XFSZ], 8) = 0 clone(child_stack=0x740f6e378ff0, flags=CLONE_VM|CLONE_VFORK|SIGCHLD) = 306025 munmap(0x740f6e370000, 36864) = 0 rt_sigprocmask(SIG_SETMASK, [HUP INT QUIT TERM CHLD XCPU XFSZ], NULL, 8) = 0 rt_sigprocmask(SIG_UNBLOCK, [HUP INT QUIT TERM XCPU XFSZ], NULL, 8) = 0 wait4(-1, make[1]: Entering directory '/home/user/heads/build/x86/coreboot-4.13' Welcome to the coreboot cross toolchain builder v () Building toolchain using 2 thread(s). Target architecture is i386-elf Found compatible Ada compiler, enabling Ada support by default. Downloading and verifying tarballs ... * gmp-6.2.0.tar.xz (cached)... hash verified (052a5411dc74054240eec58132d2cf41211d0ff6) * mpfr-4.1.0.tar.xz (cached)... hash verified (159c3a58705662bfde4dc93f2617f3660855ead6) * mpc-1.2.0.tar.gz (cached)... hash verified (0abdc94acab0c9bfdaa391347cdfd7bbdb1cf017) * binutils-2.35.tar.xz (cached)... hash verified (6bdd090ce268b6d6c3442516021c4e4b5019e303) * gcc-8.3.0.tar.xz (cached)... hash verified (c27f4499dd263fe4fb01bcc5565917f3698583b2) Downloaded tarballs ... ok Unpacking and patching ... * mpfr-4.1.0.tar.xz * mpc-1.2.0.tar.gz * binutils-2.35.tar.xz ^C0x7ffd0303e760, 0, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set) strace: Process 305835 detached So coreboot buildstack is built once per version and then reused on next board builds. Saves precious CI and local builds when developing with qemu/kvm.
2023-03-07 15:38:44 -05:00
COREBOOT_TOOLCHAIN=$(build)/$(coreboot_base_dir)/.xcompile
$(COREBOOT_TOOLCHAIN): $(build)/$(coreboot_base_dir)/.canary
$(MAKE) -C "$(build)/$(coreboot_base_dir)" CPUS=$(CPUS) "crossgcc-$(COREBOOT_TARGET)"
$(build)/$(coreboot_dir)/.configured: $(COREBOOT_TOOLCHAIN)
# Force a rebuild if the inputs have changed
$(build)/$(coreboot_dir)/.build: \
$(build)/$(BOARD)/$(LINUX_IMAGE_FILE) \
$(build)/$(BOARD)/initrd.cpio.xz \
# This produces a ROM image that is written with the flashrom program
ifneq ($(CONFIG_COREBOOT),)
$(build)/$(BOARD)/$(CB_OUTPUT_FILE): $(build)/$(coreboot_dir)/.build
# Use coreboot.rom, because custom output files might not be processed by cbfstool
"$(build)/$(coreboot_dir)/cbfstool" "$(dir $<)coreboot.rom" print
$(call do-copy,$(dir $<)$(CONFIG_COREBOOT_ROM),$@)
@touch $@ # update the time stamp
ifneq ($(CONFIG_COREBOOT_BOOTBLOCK),)
$(build)/$(BOARD)/$(CB_BOOTBLOCK_FILE): $(build)/$(coreboot_dir)/.build
$(call do-copy,$(dir $<)$(CONFIG_COREBOOT_BOOTBLOCK),$@)
@touch $@ # update the time stamp
endif
endif
2018-02-13 13:20:04 -05:00
#
# Helpful target for reconfiguring the coreboot target
#
coreboot.save_in_defconfig_format_in_place:
mkdir -p "$(build)/$(coreboot_dir)" && \
cp "$(pwd)/$(CONFIG_COREBOOT_CONFIG)" "$(build)/$(coreboot_dir)/.config" && \
2018-02-13 13:20:04 -05:00
$(MAKE) \
-C "$(build)/$(coreboot_base_dir)" \
2018-08-13 10:26:08 -04:00
DOTCONFIG="$(build)/$(coreboot_dir)/.config" \
olddefconfig && \
2018-08-13 10:26:08 -04:00
$(MAKE) \
-C "$(build)/$(coreboot_base_dir)" \
DOTCONFIG="$(build)/$(coreboot_dir)/.config" \
savedefconfig && \
mv "$(build)/$(coreboot_base_dir)/defconfig" "$(pwd)/$(CONFIG_COREBOOT_CONFIG)"
coreboot.save_in_oldconfig_format_in_place:
mkdir -p "$(build)/$(coreboot_dir)" && \
cp "$(pwd)/$(CONFIG_COREBOOT_CONFIG)" "$(build)/$(coreboot_dir)/.config" && \
$(MAKE) \
-C "$(build)/$(coreboot_base_dir)" \
DOTCONFIG="$(build)/$(coreboot_dir)/.config" \
olddefconfig \
&& mv "$(build)/$(coreboot_dir)/.config" "$(pwd)/$(CONFIG_COREBOOT_CONFIG)"
coreboot.modify_defconfig_in_place:
mkdir -p "$(build)/$(coreboot_dir)" && \
cp "$(pwd)/$(CONFIG_COREBOOT_CONFIG)" "$(build)/$(coreboot_dir)/.config" && \
$(MAKE) \
-C "$(build)/$(coreboot_base_dir)" \
DOTCONFIG="$(build)/$(coreboot_dir)/.config" \
menuconfig \
&& $(MAKE) \
-C "$(build)/$(coreboot_base_dir)" \
DOTCONFIG="$(build)/$(coreboot_dir)/.config" \
DEFCONFIG="$(pwd)/$(CONFIG_COREBOOT_CONFIG)" \
savedefconfig
coreboot.modify_and_save_oldconfig_in_place:
mkdir -p "$(build)/$(coreboot_dir)" && \
$(MAKE) menuconfig \
-C "$(build)/$(coreboot_base_dir)" \
obj="$(build)/$(coreboot_dir)" \
DOTCONFIG="$(pwd)/$(CONFIG_COREBOOT_CONFIG)"
# if we are not building from a git checkout,
# we must also download the coreboot-blobs tree
ifeq "$(coreboot_repo)" ""
coreboot_depends += coreboot-blobs
modules-y += coreboot-blobs
coreboot-blobs_version := $(coreboot_version)
coreboot-blobs_tar := coreboot-blobs-$(coreboot-blobs_version).tar.xz
coreboot-blobs_url := https://www.coreboot.org/releases/$(coreboot-blobs_tar)
ifeq "$(CONFIG_COREBOOT_VERSION)" "4.8.1"
coreboot-blobs_tar_opt := --strip 3
coreboot-blobs_dir := coreboot-$(coreboot-blobs_version)/3rdparty/blobs
else
coreboot-blobs_tar_opt := --strip 2
coreboot-blobs_dir := coreboot-$(coreboot-blobs_version)/3rdparty
endif
## there is nothing to build for the blobs, this should be
## made easier to make happen
coreboot-blobs_output := .built
coreboot-blobs_configure := echo -e 'all:\n\ttouch .built' > Makefile
endif
endif