From f9b1f6f0a521d9c8c073bcff5e9a1c3e7de2d107 Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Sun, 18 Oct 2020 13:25:08 -0500 Subject: [PATCH 1/4] config/coreboot-*: drop CONFIG_LOCALVERSION Will be injected as part of the build using $(HEADS_GIT_VERSION) Signed-off-by: Matt DeVillier --- config/coreboot-kgpe-d16.config | 1 - config/coreboot-librem_13v2.config | 1 - config/coreboot-librem_13v4.config | 1 - config/coreboot-librem_15v3.config | 1 - config/coreboot-librem_15v4.config | 1 - config/coreboot-librem_mini.config | 1 - config/coreboot-qemu-fbwhiptail.config | 1 - config/coreboot-qemu.config | 1 - config/coreboot-t420.config | 1 - config/coreboot-t430-flash.config | 1 - config/coreboot-t430.config | 1 - config/coreboot-x220.config | 1 - config/coreboot-x230-flash.config | 1 - config/coreboot-x230-hotp-verification.config | 1 - config/coreboot-x230.config | 1 - 15 files changed, 15 deletions(-) diff --git a/config/coreboot-kgpe-d16.config b/config/coreboot-kgpe-d16.config index 01cf91ee6..3c341acd1 100644 --- a/config/coreboot-kgpe-d16.config +++ b/config/coreboot-kgpe-d16.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y CONFIG_USE_OPTION_TABLE=y # CONFIG_COLLECT_TIMESTAMPS is not set diff --git a/config/coreboot-librem_13v2.config b/config/coreboot-librem_13v2.config index d7c899877..5c30393dc 100644 --- a/config/coreboot-librem_13v2.config +++ b/config/coreboot-librem_13v2.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="4.8.1-Purism-1-heads-beta" CONFIG_ANY_TOOLCHAIN=y CONFIG_USE_BLOBS=y CONFIG_MEASURED_BOOT=y diff --git a/config/coreboot-librem_13v4.config b/config/coreboot-librem_13v4.config index 66fd6aa07..d3c019898 100644 --- a/config/coreboot-librem_13v4.config +++ b/config/coreboot-librem_13v4.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="4.8.1-Purism-1-heads-beta" CONFIG_ANY_TOOLCHAIN=y CONFIG_USE_BLOBS=y CONFIG_MEASURED_BOOT=y diff --git a/config/coreboot-librem_15v3.config b/config/coreboot-librem_15v3.config index 7be32773d..a813b5eac 100644 --- a/config/coreboot-librem_15v3.config +++ b/config/coreboot-librem_15v3.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="4.8.1-Purism-1-heads-beta" CONFIG_ANY_TOOLCHAIN=y CONFIG_USE_BLOBS=y CONFIG_MEASURED_BOOT=y diff --git a/config/coreboot-librem_15v4.config b/config/coreboot-librem_15v4.config index a2afb1ceb..46298edaf 100644 --- a/config/coreboot-librem_15v4.config +++ b/config/coreboot-librem_15v4.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="4.8.1-Purism-1-heads-beta" CONFIG_ANY_TOOLCHAIN=y CONFIG_USE_BLOBS=y CONFIG_MEASURED_BOOT=y diff --git a/config/coreboot-librem_mini.config b/config/coreboot-librem_mini.config index 699affbeb..6abec5691 100644 --- a/config/coreboot-librem_mini.config +++ b/config/coreboot-librem_mini.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y CONFIG_VENDOR_PURISM=y CONFIG_INTEL_GMA_VBT_FILE="3rdparty/purism-blobs/mainboard/purism/librem_whl/vbt.bin" diff --git a/config/coreboot-qemu-fbwhiptail.config b/config/coreboot-qemu-fbwhiptail.config index a1a6f4323..bd1a924f8 100644 --- a/config/coreboot-qemu-fbwhiptail.config +++ b/config/coreboot-qemu-fbwhiptail.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="-heads" CONFIG_ANY_TOOLCHAIN=y # CONFIG_INCLUDE_CONFIG_FILE is not set CONFIG_CBFS_SIZE=0x700000 diff --git a/config/coreboot-qemu.config b/config/coreboot-qemu.config index 87d0f64a2..8a3fd6d28 100644 --- a/config/coreboot-qemu.config +++ b/config/coreboot-qemu.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="-heads" CONFIG_ANY_TOOLCHAIN=y # CONFIG_INCLUDE_CONFIG_FILE is not set CONFIG_CBFS_SIZE=0x700000 diff --git a/config/coreboot-t420.config b/config/coreboot-t420.config index 793ff17d6..59a91b8b0 100644 --- a/config/coreboot-t420.config +++ b/config/coreboot-t420.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y # CONFIG_INCLUDE_CONFIG_FILE is not set # CONFIG_COLLECT_TIMESTAMPS is not set diff --git a/config/coreboot-t430-flash.config b/config/coreboot-t430-flash.config index c44c75375..092bd8bcd 100644 --- a/config/coreboot-t430-flash.config +++ b/config/coreboot-t430-flash.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y # CONFIG_INCLUDE_CONFIG_FILE is not set # CONFIG_COLLECT_TIMESTAMPS is not set diff --git a/config/coreboot-t430.config b/config/coreboot-t430.config index 405e0bba1..1607172c7 100644 --- a/config/coreboot-t430.config +++ b/config/coreboot-t430.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y CONFIG_MEASURED_BOOT=y CONFIG_VENDOR_LENOVO=y diff --git a/config/coreboot-x220.config b/config/coreboot-x220.config index 01a66302e..88167453a 100644 --- a/config/coreboot-x220.config +++ b/config/coreboot-x220.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y # CONFIG_INCLUDE_CONFIG_FILE is not set # CONFIG_COLLECT_TIMESTAMPS is not set diff --git a/config/coreboot-x230-flash.config b/config/coreboot-x230-flash.config index 6461d02be..9ad545e08 100644 --- a/config/coreboot-x230-flash.config +++ b/config/coreboot-x230-flash.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y # CONFIG_INCLUDE_CONFIG_FILE is not set # CONFIG_COLLECT_TIMESTAMPS is not set diff --git a/config/coreboot-x230-hotp-verification.config b/config/coreboot-x230-hotp-verification.config index 092064afa..865a04fe8 100644 --- a/config/coreboot-x230-hotp-verification.config +++ b/config/coreboot-x230-hotp-verification.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y CONFIG_MEASURED_BOOT=y CONFIG_VENDOR_LENOVO=y diff --git a/config/coreboot-x230.config b/config/coreboot-x230.config index ac344588a..4d3c569bf 100644 --- a/config/coreboot-x230.config +++ b/config/coreboot-x230.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y CONFIG_MEASURED_BOOT=y CONFIG_VENDOR_LENOVO=y From ffd449cb27eab2a38a0f52988b10c12cb149d6d2 Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Sun, 18 Oct 2020 13:47:09 -0500 Subject: [PATCH 2/4] modules/coreboot: inject $(HEADS_GIT_VERSION) as CONFIG_LOCALVERSION Needed for fwupd to handle board updates Signed-off-by: Matt DeVillier --- Makefile | 1 + modules/coreboot | 1 + 2 files changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 7817f5f64..4deebe571 100644 --- a/Makefile +++ b/Makefile @@ -109,6 +109,7 @@ GIT_STATUS := $(shell \ else \ echo dirty ; \ fi) +HEADS_GIT_VERSION := $(shell git describe --tags --dirty) # record the build date / git hashes and other files here HASHES := $(build)/$(BOARD)/hashes.txt diff --git a/modules/coreboot b/modules/coreboot index 7e3b7f1e4..c7f91e84a 100644 --- a/modules/coreboot +++ b/modules/coreboot @@ -37,6 +37,7 @@ EXTRA_FLAGS := -fdebug-prefix-map=$(pwd)=heads -gno-record-gcc-switches -Wno-err coreboot_configure := \ mkdir -p "$(build)/$(coreboot_dir)" \ && cp "$(pwd)/$(CONFIG_COREBOOT_CONFIG)" "$(build)/$(coreboot_dir)/.config" \ + && echo 'CONFIG_LOCALVERSION="Heads-$(HEADS_GIT_VERSION)"' >> $(build)/$(coreboot_dir)/.config \ && $(MAKE) olddefconfig \ -C "$(build)/$(coreboot_base_dir)" \ obj="$(build)/$(coreboot_dir)" \ From b2e1a587eda2410882f5a72374db9597c8b89d04 Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Sun, 18 Oct 2020 14:13:20 -0500 Subject: [PATCH 3/4] modules/coreboot: override SMBIOS ProductName with $(BOARD) Signed-off-by: Matt DeVillier --- modules/coreboot | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/coreboot b/modules/coreboot index c7f91e84a..f26888309 100644 --- a/modules/coreboot +++ b/modules/coreboot @@ -38,6 +38,7 @@ coreboot_configure := \ mkdir -p "$(build)/$(coreboot_dir)" \ && cp "$(pwd)/$(CONFIG_COREBOOT_CONFIG)" "$(build)/$(coreboot_dir)/.config" \ && echo 'CONFIG_LOCALVERSION="Heads-$(HEADS_GIT_VERSION)"' >> $(build)/$(coreboot_dir)/.config \ + && echo 'CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME="$(BOARD)"' >> $(build)/$(coreboot_dir)/.config \ && $(MAKE) olddefconfig \ -C "$(build)/$(coreboot_base_dir)" \ obj="$(build)/$(coreboot_dir)" \ From 7d3c04843cc10d03e98adee3eef5a7aa5d2a1a7a Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Sun, 18 Oct 2020 13:55:10 -0500 Subject: [PATCH 4/4] Use $(BOARD)-$(HEADS_GIT_VERSION) as basis for output filename makes builds uniquely identifiable based on board and version. Signed-off-by: Matt DeVillier --- Makefile | 33 ++++++++++--------- .../qemu-coreboot-fbwhiptail.config | 2 +- boards/qemu-coreboot/qemu-coreboot.config | 2 +- boards/t430-flash/t430-flash.config | 2 +- boards/x230-flash/x230-flash.config | 2 +- modules/coreboot | 4 ++- modules/linuxboot | 6 ++-- 7 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 4deebe571..44023aed6 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,17 @@ +# Need to set CB_OUTPUT_FILE before board .config included so +# that target overrides in x230/x430-flash (eg) are properly handled +GIT_HASH := $(shell git rev-parse HEAD) +GIT_STATUS := $(shell \ + if git diff --exit-code >/dev/null ; then \ + echo clean ; \ + else \ + echo dirty ; \ + fi) +HEADS_GIT_VERSION := $(shell git describe --tags --dirty) + +CB_OUTPUT_FILE := heads-$(BOARD)-$(HEADS_GIT_VERSION).rom +LB_OUTPUT_FILE := linuxboot-$(BOARD)-$(HEADS_GIT_VERSION).rom + all: -include .config @@ -100,17 +114,6 @@ include $(CONFIG) # Unless otherwise specified, we are building for heads CONFIG_HEADS ?= y -# Some things want usernames, we use the current checkout -# so that they are reproducible -GIT_HASH := $(shell git rev-parse HEAD) -GIT_STATUS := $(shell \ - if git diff --exit-code >/dev/null ; then \ - echo clean ; \ - else \ - echo dirty ; \ - fi) -HEADS_GIT_VERSION := $(shell git describe --tags --dirty) - # record the build date / git hashes and other files here HASHES := $(build)/$(BOARD)/hashes.txt @@ -187,10 +190,10 @@ CROSS_TOOLS := \ -ifeq "$(CONFIG_COREBOOT)" "y" -all: $(build)/$(BOARD)/coreboot.rom -else ifeq "$(CONFIG_LINUXBOOT)" "y" -all: $(build)/$(BOARD)/linuxboot.rom +ifeq ($(CONFIG_COREBOOT), y) +all: $(build)/$(BOARD)/$(CB_OUTPUT_FILE) +else ifeq ($(CONFIG_LINUXBOOT), y) +all: $(build)/$(BOARD)/$(LB_OUTPUT_FILE) else $(error "$(BOARD): neither CONFIG_COREBOOT nor CONFIG_LINUXBOOT is set?") endif diff --git a/boards/qemu-coreboot-fbwhiptail/qemu-coreboot-fbwhiptail.config b/boards/qemu-coreboot-fbwhiptail/qemu-coreboot-fbwhiptail.config index b6210ca77..83ba5cd9e 100644 --- a/boards/qemu-coreboot-fbwhiptail/qemu-coreboot-fbwhiptail.config +++ b/boards/qemu-coreboot-fbwhiptail/qemu-coreboot-fbwhiptail.config @@ -48,7 +48,7 @@ export CONFIG_BOOT_DEV="/dev/sda1" run: qemu-system-x86_64 \ --machine q35 \ - --bios $(build)/$(BOARD)/coreboot.rom \ + --bios $(build)/$(BOARD)/$(CB_OUTPUT_FILE) \ -object rng-random,filename=/dev/urandom,id=rng0 \ -device virtio-rng-pci,rng=rng0 \ -netdev user,id=u1 -device e1000,netdev=u1 \ diff --git a/boards/qemu-coreboot/qemu-coreboot.config b/boards/qemu-coreboot/qemu-coreboot.config index dce3583ed..79643a5e1 100644 --- a/boards/qemu-coreboot/qemu-coreboot.config +++ b/boards/qemu-coreboot/qemu-coreboot.config @@ -58,7 +58,7 @@ run: qemu-system-x86_64 \ --machine q35 \ --serial /dev/tty \ - --bios $(build)/$(BOARD)/coreboot.rom \ + --bios $(build)/$(BOARD)/$(CB_OUTPUT_FILE) \ -object rng-random,filename=/dev/urandom,id=rng0 \ -device virtio-rng-pci,rng=rng0 \ -netdev user,id=u1 -device e1000,netdev=u1 \ diff --git a/boards/t430-flash/t430-flash.config b/boards/t430-flash/t430-flash.config index 43be7cb21..897eb6418 100644 --- a/boards/t430-flash/t430-flash.config +++ b/boards/t430-flash/t430-flash.config @@ -21,6 +21,6 @@ export CONFIG_FLASHROM_OPTIONS="--force --noverify-all -p internal --ifd --image # allow the board to boot into a minimal Heads and read the full # ROM from an external USB media. all: $(build)/$(BOARD)/$(BOARD).rom -$(build)/$(BOARD)/$(BOARD).rom: $(build)/$(BOARD)/coreboot.rom +$(build)/$(BOARD)/$(BOARD).rom: $(build)/$(BOARD)/$(CB_OUTPUT_FILE) dd of=$@ if=$< bs=65536 count=64 skip=128 sha256sum $@ diff --git a/boards/x230-flash/x230-flash.config b/boards/x230-flash/x230-flash.config index edb417ea7..283c8fbf8 100644 --- a/boards/x230-flash/x230-flash.config +++ b/boards/x230-flash/x230-flash.config @@ -26,6 +26,6 @@ export CONFIG_FLASHROM_OPTIONS="--force --noverify-all -p internal --ifd --image # allow the board to boot into a minimal Heads and read the full # ROM from an external USB media. all: $(build)/$(BOARD)/$(BOARD).rom -$(build)/$(BOARD)/$(BOARD).rom: $(build)/$(BOARD)/coreboot.rom +$(build)/$(BOARD)/$(BOARD).rom: $(build)/$(BOARD)/$(CB_OUTPUT_FILE) dd of=$@ if=$< bs=65536 count=64 skip=128 sha256sum $@ diff --git a/modules/coreboot b/modules/coreboot index f26888309..a4664e94e 100644 --- a/modules/coreboot +++ b/modules/coreboot @@ -78,10 +78,12 @@ $(build)/$(coreboot_dir)/.build: \ $(build)/$(BOARD)/initrd.cpio.xz \ # This produces a ROM image that is written with the flashrom program -$(build)/$(BOARD)/coreboot.rom: $(build)/$(coreboot_dir)/.build +ifneq ($(CONFIG_COREBOOT),) +$(build)/$(BOARD)/$(CB_OUTPUT_FILE): $(build)/$(coreboot_dir)/.build "$(build)/$(coreboot_dir)/cbfstool" "$(dir $<)coreboot.rom" print $(call do-copy,$(dir $<)coreboot.rom,$@) @touch $@ # update the time stamp +endif # # Helpful target for reconfiguring the coreboot target diff --git a/modules/linuxboot b/modules/linuxboot index 57ea31a23..19edcc4e6 100644 --- a/modules/linuxboot +++ b/modules/linuxboot @@ -59,9 +59,11 @@ endif linuxboot_output := build/$(linuxboot_board)/linuxboot.rom linuxboot_rom := $(build)/$(linuxboot_dir)/$(linuxboot_output) -$(build)/$(BOARD)/linuxboot.rom: $(build)/$(linuxboot_dir)/.build +ifneq ($(CONFIG_LINUXBOOT),) +$(build)/$(BOARD)/$(LB_OUTPUT_FILE): $(build)/$(linuxboot_dir)/.build $(call do-copy,$(dir $<)linuxboot.rom,$@) @touch $@ +endif # Also force a rebuild if any of the input files are updated $(build)/$(linuxboot_dir)/.build: \ @@ -70,7 +72,7 @@ $(build)/$(linuxboot_dir)/.build: \ $(build)/$(BOARD)/initrd.cpio.xz \ -linuxboot.run: $(build)/$(BOARD)/linuxboot.rom +linuxboot.run: $(build)/$(BOARD)/$(LB_OUTPUT_FILE) $(MAKE) -C $(build)/$(linuxboot_base_dir) \ BOARD:=$(linuxboot_board) \ KERNEL=$(build)/$(BOARD)/bzImage \