Skip to content

Commit 695e034

Browse files
committed
PoC against linuxboot#1462 and what should become linuxboot#1417
1 parent 42f7e4d commit 695e034

File tree

3 files changed

+131
-95
lines changed

3 files changed

+131
-95
lines changed

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ define define_module =
278278
# if they have not defined a separate base dir, define it
279279
# as the same as their build dir.
280280
$(eval $1_base_dir = $(or $($1_base_dir),$($1_dir)))
281+
# Dynamically defined modules must tell us what module file defined them
282+
$(eval $1_module_file = $(or $($1_module_file),$1))
281283

282284
ifneq ("$($1_repo)","")
283285
$(eval $1_patch_name = $1$(if $($1_patch_version),-$($1_patch_version),))
@@ -328,8 +330,11 @@ define define_module =
328330
touch "$(build)/$($1_base_dir)/.patched"; \
329331
fi
330332
else
331-
$(eval $1_patch_version ?= $($1_version))
332-
$(eval $1_patch_name = $1-$($1_patch_version))
333+
# Versioned modules (each version a separate module) don't need to include
334+
# the version a second time. (The '-' separator is also omitted then.)
335+
# $1_patch_version can still be defined manually.
336+
$(eval $1_patch_version ?= $(if $(filter %-$($1_version),$1),,$($1_version)))
337+
$(eval $1_patch_name = $1$(if $($1_patch_version),-,)$($1_patch_version))
333338
# Fetch and verify the source tar file
334339
# wget creates it early, so we have to cleanup if it fails
335340
$(packages)/$($1_tar):
@@ -394,7 +399,7 @@ define define_module =
394399
$(build)/$($1_base_dir)/.canary \
395400
$(foreach d,$($1_config_wait),$(build)/$($d_dir)/.build) \
396401
$($1_config_file_path) \
397-
modules/$1
402+
modules/$($1_module_file)
398403
@echo "$(DATE) CONFIG $1"
399404
@( \
400405
cd "$(build)/$($1_dir)" ; \

modules/coreboot

Lines changed: 123 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
modules-$(CONFIG_COREBOOT) += coreboot
2-
31
ifeq "$(CONFIG_COREBOOT)" "y"
42

53
CONFIG_COREBOOT_ROM ?= coreboot.rom
@@ -8,65 +6,103 @@ CONFIG_COREBOOT_BOOTBLOCK ?=
86
ifeq "$(CONFIG_TARGET_ARCH)" "x86"
97
COREBOOT_TARGET := i386
108
LINUX_IMAGE_FILE := bzImage
9+
COREBOOT_TARGET_CROSS :=
1110
else ifeq "$(CONFIG_TARGET_ARCH)" "ppc64"
1211
COREBOOT_TARGET := ppc64
1312
LINUX_IMAGE_FILE := zImage
13+
# skiboot payload needs the Heads toolchain as it is little-endian (like
14+
# Linux), but coreboot is big-endian on PPC64.
15+
COREBOOT_TARGET_CROSS := CROSS=$(CROSS)
1416
else
1517
$(error "$(CONFIG_TARGET_ARCH) target isn't supported by this module")
1618
endif
1719

18-
ifeq "$(CONFIG_COREBOOT_VERSION)" "4.8.1"
19-
coreboot_version := 4.8.1
20-
coreboot_hash := f0ddf4db0628c1fe1e8348c40084d9cbeb5771400c963fd419cda3995b69ad23
21-
coreboot-blobs_hash := 18aa509ae3af005a05d7b1e0b0246dc640249c14fc828f5144b6fd20bb10e295
22-
else ifeq "$(CONFIG_COREBOOT_VERSION)" "4.11"
23-
coreboot_version := 4.11
24-
coreboot_hash := 97fd859b4c39a25534fe33c30eb86e54a233952e08a024c55858d11598a8ad87
25-
coreboot-blobs_hash := aa7855c5bd385b3360dadc043ea6bc93f564e6e4840d9b3ee5b9e696bbd055db
26-
coreboot_depends := $(if $(CONFIG_PURISM_BLOBS), purism-blobs)
27-
else ifeq "$(CONFIG_COREBOOT_VERSION)" "4.13"
28-
coreboot_version := 4.13
29-
coreboot_hash := 4779da645a25ddebc78f1bd2bd0b740fb1e6479572648d4650042a2b9502856a
30-
coreboot-blobs_hash := 060656b46a7859d038ddeec3f7e086e85f146a50b280c4babec23c1188264dc8
31-
coreboot_depends := $(if $(CONFIG_PURISM_BLOBS), purism-blobs)
32-
else ifeq "$(CONFIG_COREBOOT_VERSION)" "4.17"
33-
coreboot_version := 4.17
34-
coreboot_hash := 95da11d1c6a450385101a68799258a398ce965f4e46cce6fe8d5ebd74e50c125
35-
coreboot-blobs_hash := a2277fe7a2b2aab5da0aa335158460e00b852382f6736f2179992805702eb607
36-
coreboot_depends := $(if $(CONFIG_PURISM_BLOBS), purism-blobs)
37-
EXTRA_FLAGS := -fdebug-prefix-map=$(pwd)=heads -gno-record-gcc-switches -Wno-error=packed-not-aligned -Wno-error=address-of-packed-member
38-
else ifeq "$(CONFIG_COREBOOT_VERSION)" "4.19"
39-
coreboot_version := 4.19
40-
coreboot_hash := 65ccb2f46535b996e0066a1b76f81c8cf1ff3e27df84b3f97d8ad7b3e7cf0a43
41-
coreboot-blobs_hash := 30214caed07b25f11e47bec022ff6234841376e36689eb674de2330a3e980cbc
42-
coreboot_depends := $(if $(CONFIG_PURISM_BLOBS), purism-blobs)
43-
EXTRA_FLAGS := -fdebug-prefix-map=$(pwd)=heads -gno-record-gcc-switches -Wno-error=packed-not-aligned -Wno-error=address-of-packed-member
44-
else ifeq "$(CONFIG_COREBOOT_VERSION)" "talos_2"
45-
coreboot_version = git
46-
coreboot_patch_version = talos_2
47-
coreboot_commit_hash = c8aed443c631042ad2b0326c35cd0b774752b924
48-
coreboot_repo := https://github.com/Dasharo/coreboot
49-
else ifeq "$(CONFIG_COREBOOT_VERSION)" "nitrokey"
50-
coreboot_version = git
51-
coreboot_patch_version = clevo_release
52-
coreboot_commit_hash = ae10b20f5c6abc9c23f709b65c46be6525da8c13
53-
coreboot_repo := https://github.com/dasharo/coreboot
54-
coreboot_depends := $(if $(CONFIG_NITROKEY_BLOBS), nitrokey-blobs)
55-
else ifeq "$(CONFIG_COREBOOT_VERSION)" "purism"
56-
coreboot_version := git
57-
coreboot_repo := https://source.puri.sm/coreboot/coreboot
58-
coreboot_commit_hash := a899f08d2789db1dd9b02cff34179c4d38e6d0e3
59-
EXTRA_FLAGS := -fdebug-prefix-map=$(pwd)=heads -gno-record-gcc-switches -Wno-error=packed-not-aligned -Wno-error=address-of-packed-member
60-
else
20+
# Each coreboot version is defined as a separate module, but only the needed
21+
# modules become dependencies of the current board. One coreboot version is
22+
# selected for the toolchain build and firmware build. These can be the same
23+
# (when using a coreboot release) or different (when using a fork that reuses a
24+
# release's toolchain).
25+
26+
# Define a coreboot module. Parameters:
27+
# $1 - module version
28+
# $2 - toolchain coreboot version - if nonempty, uses the toolchain from this
29+
# version (use for forks to avoid building extra copies of the same
30+
# toolchain)
31+
#
32+
# For a coreboot release:
33+
# - the version is the coreboot release version
34+
# - set coreboot-<version>_hash to the tarball hash
35+
# - set coreboot-blobs-<version>_hash to the blobs tarball hash
36+
#
37+
# For a git fork:
38+
# - the version is the name of the fork (just controls the build directory used)
39+
# - set coreboot-<version>_repo to the git repo address
40+
# - set coreboot-<version>_commit_hash to the git commit
41+
define coreboot_module =
42+
coreboot-$(1)_version := $(1)
43+
coreboot-$(1)_module_file := coreboot
44+
coreboot-$(1)_base_dir := coreboot-$(1)
45+
coreboot-$(1)_dir := coreboot-$(1)/$(BOARD)
46+
coreboot-$(1)_toolchain := $(2)
47+
# These are ignored if this version is a git fork
48+
coreboot-$(1)_tar := coreboot-$(1).tar.xz
49+
coreboot-$(1)_url := https://www.coreboot.org/releases/coreboot-$(1).tar.xz
50+
# These are only used for releases, git forks don't use upstream blobs
51+
coreboot-blobs-$(1)_version := $(1)
52+
coreboot-blobs-$(1)_module_file := coreboot
53+
coreboot-blobs-$(1)_dir := coreboot-$(1)/3rdparty
54+
coreboot-blobs-$(1)_tar := coreboot-blobs-$(1).tar.xz
55+
coreboot-blobs-$(1)_url := https://www.coreboot.org/releases/coreboot-blobs-$(1).tar.xz
56+
coreboot-blobs-$(1)_tar_opt := --strip 2
57+
endef
58+
59+
# coreboot releases
60+
61+
coreboot-4.11_hash := 97fd859b4c39a25534fe33c30eb86e54a233952e08a024c55858d11598a8ad87
62+
coreboot-blobs-4.11_hash := aa7855c5bd385b3360dadc043ea6bc93f564e6e4840d9b3ee5b9e696bbd055db
63+
$(eval $(call coreboot_module,4.11,))
64+
65+
coreboot-4.19_hash := 65ccb2f46535b996e0066a1b76f81c8cf1ff3e27df84b3f97d8ad7b3e7cf0a43
66+
coreboot-blobs-4.19_hash := 30214caed07b25f11e47bec022ff6234841376e36689eb674de2330a3e980cbc
67+
$(eval $(call coreboot_module,4.19,))
68+
69+
coreboot-4.20.1_hash := b41539a8c2eab2fec752157eb4acbd0e2a637a7203530c12e66b43a5c3c3a931
70+
coreboot-blobs-4.20.1_hash := 30f9d8618e78d483d0903976982485e70825ca3469efd17902c9246aaefd7c4a
71+
$(eval $(call coreboot_module,4.20.1,))
72+
73+
# coreboot git forks
74+
75+
# talos_2 could use the 4.20.1 toolchain, but it's the only ppc64 fork, so
76+
# there is no point preparing another coreboot module that won't be shared with
77+
# anything.
78+
coreboot-talos_2_repo := https://github.com/Dasharo/coreboot
79+
coreboot-talos_2_commit_hash := c8aed443c631042ad2b0326c35cd0b774752b924
80+
$(eval $(call coreboot_module,talos_2,))
81+
82+
coreboot-purism_repo := https://source.puri.sm/firmware/coreboot.git
83+
coreboot-purism_commit_hash := a899f08d2789db1dd9b02cff34179c4d38e6d0e3
84+
$(eval $(call coreboot_module,purism,4.20.1))
85+
86+
coreboot-nitrokey_repo := https://github.com/dasharo/coreboot
87+
coreboot-nitrokey_commit_hash := ae10b20f5c6abc9c23f709b65c46be6525da8c13
88+
coreboot-nitrokey_patch_version := clevo_release
89+
$(eval $(call coreboot_module,nitrokey,4.19))
90+
91+
# Check that the board configured the coreboot version correctly
92+
ifeq "$(CONFIG_COREBOOT_VERSION)" ""
6193
$(error "$(BOARD): does not specify coreboot version under CONFIG_COREBOOT_VERSION")
94+
else ifeq "$(coreboot-$(CONFIG_COREBOOT_VERSION)_dir)" ""
95+
$(error "$(BOARD): coreboot version $(CONFIG_COREBOOT_VERSION) not known"
6296
endif
6397

64-
#coreboot_version := git
65-
#coreboot_repo := https://github.com/osresearch/coreboot
66-
coreboot_base_dir := coreboot-$(coreboot_version)
67-
coreboot_dir := $(coreboot_base_dir)/$(BOARD)
68-
coreboot_tar := coreboot-$(coreboot_version).tar.xz
69-
coreboot_url := https://www.coreboot.org/releases/$(coreboot_tar)
98+
coreboot_module := coreboot-$(CONFIG_COREBOOT_VERSION)
99+
modules-y += $(coreboot_module)
100+
# Don't make everyone type $($(coreboot_module)_dir)
101+
coreboot_dir := $($(coreboot_module)_dir)
102+
coreboot_base_dir := $($(coreboot_module)_base_dir)
103+
104+
$(coreboot_module)_depends += $(if $(CONFIG_PURISM_BLOBS), purism-blobs)
105+
$(coreboot_module)_depends += $(if $(CONFIG_NITROKEY_BLOBS), nitrokey-blobs)
70106

71107
# coreboot builds are specialized on a per-target basis.
72108
# The builds are done in a per-target subdirectory
@@ -77,7 +113,22 @@ $(build)/$(coreboot_dir)/.configured: $(CONFIG_COREBOOT_CONFIG)
77113

78114
EXTRA_FLAGS ?= -fdebug-prefix-map=$(pwd)=heads -gno-record-gcc-switches -Wno-error=packed-not-aligned -Wno-address-of-packed-member
79115

80-
coreboot_configure := \
116+
# Select the coreboot version to use for the toolchain
117+
ifeq "$($(coreboot_module)_toolchain)" ""
118+
# Use the same module
119+
coreboot_toolchain_module := $(coreboot_module)
120+
else
121+
# Use a different module
122+
coreboot_toolchain_module := coreboot-$($(coreboot_module)_toolchain)
123+
modules-y += $(coreboot_toolchain_module)
124+
# The toolchain module won't build anything for this board, we just need
125+
# the module prepped so we can hook up the toolchain target
126+
$(coreboot_toolchain_module)_output := .nobuild
127+
$(coreboot-toolchain_module)_configure := echo -e 'all:\n\ttouch .nobuild' > Makefile.nobuild
128+
$(coreboot-toolchain_module)_target := -f Makefile.nobuild
129+
endif
130+
131+
$(coreboot_module)_configure := \
81132
mkdir -p "$(build)/$(coreboot_dir)" \
82133
&& $(call install_config,$(pwd)/$(CONFIG_COREBOOT_CONFIG),$(build)/$(coreboot_dir)/.config) \
83134
&& echo 'CONFIG_LOCALVERSION="$(BRAND_NAME)-$(HEADS_GIT_VERSION)"' >> $(build)/$(coreboot_dir)/.config \
@@ -90,40 +141,30 @@ coreboot_configure := \
90141
CFLAGS_x86_32="$(EXTRA_FLAGS)" \
91142
CFLAGS_x86_64="$(EXTRA_FLAGS)" \
92143

93-
COREBOOT_IASL="$(build)/$(coreboot_base_dir)/util/crossgcc/xgcc/bin/iasl"
144+
# Create a dependency from coreboot to the toolchain. Use .heads-toolchain to
145+
# mark that the toolchain was built.
146+
COREBOOT_TOOLCHAIN=$(build)/$($(coreboot_toolchain_module)_base_dir)/.heads-toolchain
147+
$(COREBOOT_TOOLCHAIN): $(build)/$($(coreboot_toolchain_module)_base_dir)/.canary
148+
$(MAKE) -C "$(build)/$($(coreboot_toolchain_module)_base_dir)" CPUS=$(CPUS) "crossgcc-$(COREBOOT_TARGET)"
149+
touch "$@"
94150

95-
# coreboot for x86 is built with the 32-bit compiler; ideally we could use the
96-
# same x86_64-linux-musl -m32 to build it, but this causes some link errors that
97-
# need to be tracked down.
98-
# CROSS="$(CROSS)" \
99-
100-
ifeq "$(CONFIG_TARGET_ARCH)" "x86"
101-
COREBOOT_CROSS := $(dir $(CROSS))i386-linux-musl-
102-
else
103-
COREBOOT_CROSS := $(CROSS)
104-
endif
151+
$(build)/$(coreboot_dir)/.configured: $(COREBOOT_TOOLCHAIN)
105152

106-
coreboot_target := \
153+
# Build with the cross toolchain from the toolchain module (which might be the
154+
# same coreboot module or a different one).
155+
$(coreboot_module)_target := \
107156
-C "$(build)/$(coreboot_base_dir)" \
108157
obj="$(build)/$(coreboot_dir)" \
109-
CROSS="$(COREBOOT_CROSS)" \
110-
IASL="$(COREBOOT_IASL)" \
111158
DOTCONFIG="$(build)/$(coreboot_dir)/.config" \
112-
xcompile="$(build)/$(coreboot_base_dir)/.xcompile" \
159+
XGCCPATH="$(build)/$($(coreboot_toolchain_module)_base_dir)/util/crossgcc/xgcc/bin/" \
160+
$(COREBOOT_TARGET_CROSS) \
113161
BUILD_TIMELESS=1 \
114162
CFLAGS_x86_32="$(EXTRA_FLAGS)" \
115163
CFLAGS_x86_64="$(EXTRA_FLAGS)" \
116164
$(MAKE_JOBS)
117165

118-
coreboot_output := $(CONFIG_COREBOOT_ROM)
119-
coreboot_output += $(CONFIG_COREBOOT_BOOTBLOCK)
120-
coreboot_depend += linux initrd $(musl_dep)
121-
122-
COREBOOT_TOOLCHAIN=$(build)/$(coreboot_base_dir)/.xcompile
123-
$(COREBOOT_TOOLCHAIN): $(build)/$(coreboot_base_dir)/.canary
124-
$(MAKE) -C "$(build)/$(coreboot_base_dir)" CPUS=$(CPUS) "crossgcc-$(COREBOOT_TARGET)"
125-
126-
$(build)/$(coreboot_dir)/.configured: $(COREBOOT_TOOLCHAIN)
166+
$(coreboot_module)_output := $(CONFIG_COREBOOT_ROM)
167+
$(coreboot_module)_output += $(CONFIG_COREBOOT_BOOTBLOCK)
127168

128169
# Force a rebuild if the inputs have changed
129170
$(build)/$(coreboot_dir)/.build: \
@@ -194,27 +235,17 @@ coreboot.modify_and_save_oldconfig_in_place:
194235

195236
# if we are not building from a git checkout,
196237
# we must also download the coreboot-blobs tree
197-
ifneq "$(coreboot_version)" "git"
198-
199-
coreboot_depends += coreboot-blobs
200-
modules-y += coreboot-blobs
238+
ifeq "$($(coreboot_module)_repo)" ""
201239

202-
coreboot-blobs_version := $(coreboot_version)
203-
coreboot-blobs_tar := coreboot-blobs-$(coreboot-blobs_version).tar.xz
204-
coreboot-blobs_url := https://www.coreboot.org/releases/$(coreboot-blobs_tar)
240+
coreboot-blobs_module := coreboot-blobs-$(CONFIG_COREBOOT_VERSION)
205241

206-
ifeq "$(CONFIG_COREBOOT_VERSION)" "4.8.1"
207-
coreboot-blobs_tar_opt := --strip 3
208-
coreboot-blobs_dir := coreboot-$(coreboot-blobs_version)/3rdparty/blobs
209-
else
210-
coreboot-blobs_tar_opt := --strip 2
211-
coreboot-blobs_dir := coreboot-$(coreboot-blobs_version)/3rdparty
212-
endif
242+
$(coreboot_module)_depends += $(coreboot-blobs_module)
243+
modules-y += $(coreboot-blobs_module)
213244

214245
## there is nothing to build for the blobs, this should be
215246
## made easier to make happen
216-
coreboot-blobs_output := .built
217-
coreboot-blobs_configure := echo -e 'all:\n\ttouch .built' > Makefile
247+
$(coreboot-blobs_module)_output := .built
248+
$(coreboot-blobs_module)_configure := echo -e 'all:\n\ttouch .built' > Makefile
218249

219250
endif
220251
endif

patches/coreboot-clevo_release/0001-change_acpica-unix2_location_to_a_mirror.patch renamed to patches/coreboot-nitrokey-clevo_release/0001-change_acpica-unix2_location_to_a_mirror.patch

File renamed without changes.

0 commit comments

Comments
 (0)