Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inject Heads version string into coreboot LOCALVERSION... #859

Merged
merged 4 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -100,16 +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)

# record the build date / git hashes and other files here
HASHES := $(build)/$(BOARD)/hashes.txt

Expand Down Expand Up @@ -186,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion boards/qemu-coreboot/qemu-coreboot.config
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion boards/t430-flash/t430-flash.config
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@
2 changes: 1 addition & 1 deletion boards/x230-flash/x230-flash.config
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@
1 change: 0 additions & 1 deletion config/coreboot-kgpe-d16.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_LOCALVERSION="heads"
CONFIG_ANY_TOOLCHAIN=y
CONFIG_USE_OPTION_TABLE=y
# CONFIG_COLLECT_TIMESTAMPS is not set
Expand Down
1 change: 0 additions & 1 deletion config/coreboot-librem_13v2.config
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion config/coreboot-librem_13v4.config
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion config/coreboot-librem_15v3.config
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion config/coreboot-librem_15v4.config
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion config/coreboot-librem_mini.config
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
1 change: 0 additions & 1 deletion config/coreboot-qemu-fbwhiptail.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_LOCALVERSION="-heads"
CONFIG_ANY_TOOLCHAIN=y
# CONFIG_INCLUDE_CONFIG_FILE is not set
CONFIG_CBFS_SIZE=0x700000
Expand Down
1 change: 0 additions & 1 deletion config/coreboot-qemu.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_LOCALVERSION="-heads"
CONFIG_ANY_TOOLCHAIN=y
# CONFIG_INCLUDE_CONFIG_FILE is not set
CONFIG_CBFS_SIZE=0x700000
Expand Down
1 change: 0 additions & 1 deletion config/coreboot-t420.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_LOCALVERSION="heads"
CONFIG_ANY_TOOLCHAIN=y
# CONFIG_INCLUDE_CONFIG_FILE is not set
# CONFIG_COLLECT_TIMESTAMPS is not set
Expand Down
1 change: 0 additions & 1 deletion config/coreboot-t430-flash.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_LOCALVERSION="heads"
CONFIG_ANY_TOOLCHAIN=y
# CONFIG_INCLUDE_CONFIG_FILE is not set
# CONFIG_COLLECT_TIMESTAMPS is not set
Expand Down
1 change: 0 additions & 1 deletion config/coreboot-t430.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_LOCALVERSION="heads"
CONFIG_ANY_TOOLCHAIN=y
CONFIG_MEASURED_BOOT=y
CONFIG_VENDOR_LENOVO=y
Expand Down
1 change: 0 additions & 1 deletion config/coreboot-x220.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_LOCALVERSION="heads"
CONFIG_ANY_TOOLCHAIN=y
# CONFIG_INCLUDE_CONFIG_FILE is not set
# CONFIG_COLLECT_TIMESTAMPS is not set
Expand Down
1 change: 0 additions & 1 deletion config/coreboot-x230-flash.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_LOCALVERSION="heads"
CONFIG_ANY_TOOLCHAIN=y
# CONFIG_INCLUDE_CONFIG_FILE is not set
# CONFIG_COLLECT_TIMESTAMPS is not set
Expand Down
1 change: 0 additions & 1 deletion config/coreboot-x230-hotp-verification.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_LOCALVERSION="heads"
CONFIG_ANY_TOOLCHAIN=y
CONFIG_MEASURED_BOOT=y
CONFIG_VENDOR_LENOVO=y
Expand Down
1 change: 0 additions & 1 deletion config/coreboot-x230.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CONFIG_LOCALVERSION="heads"
CONFIG_ANY_TOOLCHAIN=y
CONFIG_MEASURED_BOOT=y
CONFIG_VENDOR_LENOVO=y
Expand Down
6 changes: 5 additions & 1 deletion modules/coreboot
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ 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 \
&& echo 'CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME="$(BOARD)"' >> $(build)/$(coreboot_dir)/.config \
&& $(MAKE) olddefconfig \
-C "$(build)/$(coreboot_base_dir)" \
obj="$(build)/$(coreboot_dir)" \
Expand Down Expand Up @@ -76,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
Expand Down
6 changes: 4 additions & 2 deletions modules/linuxboot
Original file line number Diff line number Diff line change
Expand Up @@ -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: \
Expand All @@ -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 \
Expand Down