2020-11-25 14:43:07 +01:00
i f e q "$(CONFIG_COREBOOT)" "y"
2021-07-20 23:48:08 +03:00
CONFIG_COREBOOT_ROM ?= coreboot.rom
CONFIG_COREBOOT_BOOTBLOCK ?=
2021-07-18 20:34:20 +03:00
i f e q "$(CONFIG_TARGET_ARCH)" "x86"
COREBOOT_TARGET := i386
LINUX_IMAGE_FILE := bzImage
2023-08-10 14:01:02 -04:00
COREBOOT_TARGET_CROSS :=
2021-07-18 20:34:20 +03:00
e l s e i f e q "$(CONFIG_TARGET_ARCH)" "ppc64"
COREBOOT_TARGET := ppc64
LINUX_IMAGE_FILE := zImage
2023-08-11 13:03:58 -04:00
# skiboot payload needs the Heads toolchain as it is little-endian (like
# Linux), but coreboot is big-endian on PPC64.
2023-08-10 14:01:02 -04:00
COREBOOT_TARGET_CROSS := CROSS = $( CROSS)
2021-07-18 20:34:20 +03:00
e l s e
2024-01-08 14:05:03 -05:00
$( error " $( CONFIG_TARGET_ARCH) target is not supported by this module " )
2021-07-18 20:34:20 +03:00
e n d i f
2023-08-10 16:48:05 -04:00
# Each coreboot version is defined as a separate module, but only the needed
# modules become dependencies of the current board. One coreboot version is
# selected for the toolchain build and firmware build. These can be the same
# (when using a coreboot release) or different (when using a fork that reuses a
# release's toolchain).
# Define a coreboot module. Parameters:
# $1 - module version
# $2 - toolchain coreboot version - if nonempty, uses the toolchain from this
# version (use for forks to avoid building extra copies of the same
# toolchain)
#
# For a coreboot release:
# - the version is the coreboot release version
# - set coreboot-<version>_hash to the tarball hash
# - set coreboot-blobs-<version>_hash to the blobs tarball hash
#
# For a git fork:
# - the version is the name of the fork (just controls the build directory used)
# - set coreboot-<version>_repo to the git repo address
# - set coreboot-<version>_commit_hash to the git commit
d e f i n e coreboot_module =
coreboot-$( 1) _version := $( 1)
coreboot-$( 1) _module_file := coreboot
coreboot-$( 1) _base_dir := coreboot-$( 1)
coreboot-$( 1) _dir := coreboot-$( 1) /$( BOARD)
coreboot-$( 1) _toolchain := $( 2)
# These are ignored if this version is a git fork
coreboot-$( 1) _tar := coreboot-$( 1) .tar.xz
coreboot-$( 1) _url := https://www.coreboot.org/releases/coreboot-$( 1) .tar.xz
# These are only used for releases, git forks don't use upstream blobs
coreboot-blobs-$( 1) _version := $( 1)
coreboot-blobs-$( 1) _module_file := coreboot
coreboot-blobs-$( 1) _dir := coreboot-$( 1) /3rdparty
coreboot-blobs-$( 1) _tar := coreboot-blobs-$( 1) .tar.xz
coreboot-blobs-$( 1) _url := https://www.coreboot.org/releases/coreboot-blobs-$( 1) .tar.xz
coreboot-blobs-$( 1) _tar_opt := --strip 2
e n d e f
# coreboot releases
coreboot-4.11_hash := 97fd859b4c39a25534fe33c30eb86e54a233952e08a024c55858d11598a8ad87
coreboot-blobs-4.11_hash := aa7855c5bd385b3360dadc043ea6bc93f564e6e4840d9b3ee5b9e696bbd055db
$( eval $ ( call coreboot_module ,4.11,) )
2024-01-05 15:11:21 -05:00
# The coreboot 4.11 toolchain disables the Ada compiler. None of the 4.11 boards need
# libgfxinit, and the old Ada compiler no longer compiles with the Debian 12 host toolchain.
coreboot-4.11_toolchain_build_args := BUILD_LANGUAGES = c
2023-08-10 16:48:05 -04:00
coreboot-4.20.1_hash := b41539a8c2eab2fec752157eb4acbd0e2a637a7203530c12e66b43a5c3c3a931
coreboot-blobs-4.20.1_hash := 30f9d8618e78d483d0903976982485e70825ca3469efd17902c9246aaefd7c4a
$( eval $ ( call coreboot_module ,4.20.1,) )
2024-02-05 11:06:11 -05:00
coreboot-4.22.01_hash := 3d1a36dfb2a654133c7f36cf4da436f0d79f535644069adfe7cdcad962532c3f
coreboot-blobs-4.22.01_hash := 4bb98f1a1cc8b3c7004a1d720462bfff0fe34a9106163df2708b952bddfc5203
$( eval $ ( call coreboot_module ,4.22.01,) )
2024-07-10 12:14:14 -04:00
coreboot-24.02.01_hash := e56f5c0c9008bfdec1c4be6409ac093680140f9441efd3d5e47bdeffcbf77e50
coreboot-blobs-24.02.01_hash := 8d03b82cd2b2593473d4cd511c7bef7fdd43839237f6c37a8383161660c14427
$( eval $ ( call coreboot_module ,24.02.01,) )
2023-08-10 16:48:05 -04:00
# coreboot git forks
2023-08-11 13:03:58 -04:00
# talos_2 could use the 4.20.1 toolchain, but it's the only ppc64 fork, so
2023-08-11 09:32:30 -04:00
# there is no point preparing another coreboot module that won't be shared with
# anything.
2023-08-10 16:48:05 -04:00
coreboot-talos_2_repo := https://github.com/Dasharo/coreboot
2023-11-16 16:36:16 -05:00
coreboot-talos_2_commit_hash := fc47236e9877f4113dfcce07fa928f52d4d2c8ee
2023-08-11 09:32:30 -04:00
$( eval $ ( call coreboot_module ,talos_ 2,) )
2023-08-10 16:48:05 -04:00
2024-07-19 09:27:11 -04:00
# coreboot-purism is based on 24.02.01 - reuse that toolchain.
2023-08-10 16:48:05 -04:00
coreboot-purism_repo := https://source.puri.sm/firmware/coreboot.git
2024-10-18 17:22:03 -04:00
coreboot-purism_commit_hash := bea9947a1279be7d4a72b38a601d0288d10d1cb8
2024-07-19 09:27:11 -04:00
$( eval $ ( call coreboot_module ,purism ,24.02.01) )
2023-08-10 16:48:05 -04:00
2025-01-15 15:13:38 +01:00
# MSI and NovaCustom NV4xPZ, NS5xPU, V560TU boards are based on Dasharo
2024-11-29 18:50:45 +01:00
# coreboot fork, based on upstream coreboot version 24.02
2024-02-14 16:57:05 +01:00
coreboot-dasharo_repo := https://github.com/dasharo/coreboot
2025-01-17 18:32:11 -05:00
coreboot-dasharo_commit_hash := 94e5f5d5b808cf8d8fd5c70d4ef6a08a054f8986
2024-12-02 12:22:11 +01:00
$( eval $ ( call coreboot_module ,dasharo ,24.02.01) )
2025-01-15 12:20:20 +01:00
#coreboot-dasharo_patch_version := unreleased
2023-08-18 11:39:48 -04:00
2025-02-12 13:33:15 -05:00
# T480 is based on coreboot ~24.12 release
# coreboot 24.12 doesn't include t480 support which is still under review at https://review.coreboot.org/c/coreboot/+/83274
# TODO: track upstream WiP and switch to later upstream release containing patchset without relaying on libreboot downstream maintained patchset
# Therefore, patches/coreboot-2412 includes libreboot patches applied to 24.12 release
# patches/coreboot-2412 also includes PR0 patchset, minus xeon support which don't apply to 24.12 as per https://review.coreboot.org/c/coreboot/+/85278
# TODO: @miczyg1 rebase of patchset so that doenstream don't have to maintain, adapt work
2025-02-14 12:11:57 -05:00
coreboot-24.12_repo := https://review.coreboot.org/coreboot.git
coreboot-24.12_commit_hash := 2f1e4e5e8515dd350cc9d68b48d32a5b6b02ae6a
2025-02-11 11:13:14 -05:00
#Don't reuse any coreboot buildstack for now since nothing else is based on 24.12
2025-02-14 12:11:57 -05:00
$( eval $ ( call coreboot_module ,24.12,) )
2025-02-03 22:33:20 +01:00
2023-08-10 16:48:05 -04:00
# Check that the board configured the coreboot version correctly
i f e q "$(CONFIG_COREBOOT_VERSION)" ""
2020-08-20 15:15:46 -04:00
$( error " $( BOARD) : does not specify coreboot version under CONFIG_COREBOOT_VERSION " )
2023-08-10 16:48:05 -04:00
e l s e i f e q "$(coreboot-$(CONFIG_COREBOOT_VERSION)_dir)" ""
2024-01-08 14:05:03 -05:00
$( error " $( BOARD) : coreboot version $( CONFIG_COREBOOT_VERSION) not known " )
2024-02-13 15:21:49 +01:00
e n d i f
2020-07-10 09:44:01 -04:00
2023-08-10 16:48:05 -04:00
coreboot_module := coreboot-$( CONFIG_COREBOOT_VERSION)
modules-y += $( coreboot_module)
# Don't make everyone type $($(coreboot_module)_dir)
coreboot_dir := $( $( coreboot_module) _dir)
coreboot_base_dir := $( $( coreboot_module) _base_dir)
2023-08-10 13:35:04 -04:00
2023-08-11 10:51:59 -04:00
$(coreboot_module)_depends += $( if $( CONFIG_PURISM_BLOBS) , purism-blobs)
2016-08-19 11:31:07 -04:00
2020-01-08 17:08:15 +01:00
# coreboot builds are specialized on a per-target basis.
2016-11-23 12:11:08 -05:00
# The builds are done in a per-target subdirectory
2018-02-05 11:56:15 -05:00
CONFIG_COREBOOT_CONFIG ?= config/coreboot-$( BOARD) .config
2024-02-16 15:25:54 +01:00
CONFIG_COREBOOT_LOCALVERSION ?= " $( BRAND_NAME) - $( HEADS_GIT_VERSION) "
2024-02-09 10:50:33 +01:00
CONFIG_COREBOOT_SMBIOS_PRODUCT_NAME ?= $( BOARD)
2016-11-23 12:11:08 -05:00
2018-05-03 16:47:09 -04:00
# Ensure that touching the config file will force a rebuild
$(build)/$(coreboot_dir)/.configured : $( CONFIG_COREBOOT_CONFIG )
2023-08-10 16:49:58 -04:00
# Select the coreboot version to use for the toolchain
i f e q "$($(coreboot_module)_toolchain)" ""
2024-07-15 16:53:59 -04:00
# Use the same module
coreboot_toolchain_module := $( coreboot_module)
2023-08-10 16:49:58 -04:00
e l s e
2024-07-15 16:53:59 -04:00
# Use a different module
coreboot_toolchain_module := coreboot-$( $( coreboot_module) _toolchain)
modules-y += $( coreboot_toolchain_module)
# The toolchain module won't build anything for this board, we just need
# the module prepped so we can hook up the toolchain target
$(coreboot_toolchain_module)_output := .nobuild
$(coreboot-toolchain_module)_configure := echo -e 'all:\n\ttouch .nobuild' > Makefile.nobuild
$(coreboot-toolchain_module)_target := -f Makefile.nobuild
2023-08-10 16:49:58 -04:00
e n d i f
2023-08-10 16:48:05 -04:00
$(coreboot_module)_configure := \
2024-02-13 17:29:46 +01:00
mkdir -p " $( build) / $( coreboot_dir) " ; \
$( call install_config,$( pwd ) /$( CONFIG_COREBOOT_CONFIG) ,$( build) /$( coreboot_dir) /.config) ; \
2024-02-16 14:01:09 +01:00
sed -i '/^CONFIG_LOCALVERSION/d' $( build) /$( coreboot_dir) /.config; \
2024-02-16 15:25:54 +01:00
echo 'CONFIG_LOCALVERSION=$(CONFIG_COREBOOT_LOCALVERSION)' >> $( build) /$( coreboot_dir) /.config; \
2024-02-16 14:01:09 +01:00
sed -i '/^CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME/d' $( build) /$( coreboot_dir) /.config; \
2024-02-13 17:29:46 +01:00
echo 'CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME="$(CONFIG_COREBOOT_SMBIOS_PRODUCT_NAME)"' >> $( build) /$( coreboot_dir) /.config; \
if [ ! -z " $( CONFIG_COREBOOT_SMBIOS_MANUFACTURER) " ] ; then \
2024-02-16 14:01:09 +01:00
sed -i '/^CONFIG_MAINBOARD_SMBIOS_MANUFACTURER/d' $( build) /$( coreboot_dir) /.config; \
2024-02-13 17:29:46 +01:00
echo 'CONFIG_MAINBOARD_SMBIOS_MANUFACTURER="$(CONFIG_COREBOOT_SMBIOS_MANUFACTURER)"' >> $( build) /$( coreboot_dir) /.config; \
fi ; \
$( MAKE) olddefconfig \
2018-08-13 10:26:08 -04:00
-C " $( build) / $( coreboot_base_dir) " \
obj = " $( build) / $( coreboot_dir) " \
2018-10-27 14:03:45 -07:00
DOTCONFIG = " $( build) / $( coreboot_dir) /.config " \
2017-02-01 13:39:56 -05:00
BUILD_TIMELESS = 1 \
2016-11-23 12:11:08 -05:00
2023-08-10 17:14:42 -04:00
# Create a dependency from coreboot to the toolchain. Use .heads-toolchain to
# mark that the toolchain was built.
2024-01-08 14:05:03 -05:00
COREBOOT_TOOLCHAIN_DIR = $( build) /$( $( coreboot_toolchain_module) _base_dir)
$(COREBOOT_TOOLCHAIN_DIR)/.heads-toolchain : $( COREBOOT_TOOLCHAIN_DIR ) /.canary
2024-01-05 15:11:21 -05:00
$( MAKE) -C " $( build) / $( $( coreboot_toolchain_module) _base_dir) " CPUS = $( CPUS) " crossgcc- $( COREBOOT_TARGET) " \
$( $( coreboot_toolchain_module) _toolchain_build_args)
2023-08-10 17:14:42 -04:00
touch " $@ "
2023-08-10 16:49:58 -04:00
2024-01-08 14:05:03 -05:00
$(build)/$(coreboot_dir)/.configured : $( COREBOOT_TOOLCHAIN_DIR ) /.heads -toolchain
## Toolchain packages ##
# coreboot likes to download its own toolchain packages, but these sources can
# go down or move also. Download them ahead of the toolchain build with
# fetch_source_archive.sh to leverage our mirrors.
#
# Create a task for each package.
# $1 - package name (binutils/gcc/gmp/etc. - check coreboot/util/crossgcc/sum/)
d e f i n e coreboot-toolchain-pkg =
# The package versions and digests aren't duplicated here, we get them
# from the coreboot source. This means downloading all packages
# requires unpacking the coreboot source, but that's preferred over
# maintaining a duplicate list here for each coreboot version.
# Rule to download the source archive for $1 and place it in the
# cooreboot directory. Although there is a specific file produced here
# (the package), we can't use it as the rule target because we don't
# know the filename until coreboot is unpacked.
$(COREBOOT_TOOLCHAIN_DIR)/.heads-crossgcc-pkg-$(1) : $( COREBOOT_TOOLCHAIN_DIR ) /.canary
WGET = " $( WGET) " bin/fetch_coreboot_crossgcc_archive.sh \
" $( COREBOOT_TOOLCHAIN_DIR) " " $( 1) " " $( packages) "
touch " $$ @ "
# The toolchain build requires this package
$(COREBOOT_TOOLCHAIN_DIR)/.heads-toolchain : $( COREBOOT_TOOLCHAIN_DIR ) /.heads -crossgcc -pkg -$( 1)
# The "packages" target depends on this target, so 'make packages' will
# include these packages for seeding a mirror.
packages : $( COREBOOT_TOOLCHAIN_DIR ) /.heads -crossgcc -pkg -$( 1)
e n d e f
$( eval $ ( call coreboot -toolchain -pkg ,gmp ) )
$( eval $ ( call coreboot -toolchain -pkg ,mpfr ) )
$( eval $ ( call coreboot -toolchain -pkg ,mpc ) )
$( eval $ ( call coreboot -toolchain -pkg ,binutils ) )
$( eval $ ( call coreboot -toolchain -pkg ,gcc ) )
$( eval $ ( call coreboot -toolchain -pkg ,nasm ) )
$( eval $ ( call coreboot -toolchain -pkg ,iasl ) )
2023-08-10 16:49:58 -04:00
# Build with the cross toolchain from the toolchain module (which might be the
# same coreboot module or a different one).
2023-08-10 16:48:05 -04:00
$(coreboot_module)_target := \
2018-08-13 10:26:08 -04:00
-C " $( build) / $( coreboot_base_dir) " \
obj = " $( build) / $( coreboot_dir) " \
2018-10-27 14:03:45 -07:00
DOTCONFIG = " $( build) / $( coreboot_dir) /.config " \
2023-08-10 16:49:58 -04:00
XGCCPATH = " $( build) / $( $( coreboot_toolchain_module) _base_dir) /util/crossgcc/xgcc/bin/ " \
2023-08-10 14:01:02 -04:00
$( COREBOOT_TARGET_CROSS) \
2017-02-01 13:39:56 -05:00
BUILD_TIMELESS = 1 \
2017-03-21 14:29:07 -04:00
$( MAKE_JOBS)
2016-11-23 12:11:08 -05:00
2023-08-10 16:48:05 -04:00
$(coreboot_module)_output := $( CONFIG_COREBOOT_ROM)
$(coreboot_module)_output += $( CONFIG_COREBOOT_BOOTBLOCK)
2018-09-18 15:59:48 -04:00
2018-05-02 11:38:39 -04:00
# Force a rebuild if the inputs have changed
$(build)/$(coreboot_dir)/.build : \
2021-07-18 20:34:20 +03:00
$( build) /$( BOARD) /$( LINUX_IMAGE_FILE) \
2018-05-02 11:38:39 -04:00
$( build) /$( BOARD) /initrd.cpio.xz \
2018-05-02 14:53:54 -04:00
# This produces a ROM image that is written with the flashrom program
2020-10-21 10:04:27 -05:00
i f n e q ( $( CONFIG_COREBOOT ) , )
2021-07-20 23:48:08 +03:00
2020-10-21 10:04:27 -05:00
$(build)/$(BOARD)/$(CB_OUTPUT_FILE) : $( build ) /$( coreboot_dir ) /.build
2021-07-20 23:48:08 +03:00
# Use coreboot.rom, because custom output files might not be processed by cbfstool
2018-05-02 14:53:54 -04:00
" $( build) / $( coreboot_dir) /cbfstool " " $( dir $<) coreboot.rom " print
2021-07-20 23:48:08 +03:00
$( call do -copy,$( dir $<) $( CONFIG_COREBOOT_ROM) ,$@ )
@touch $@ # update the time stamp
i f n e q ( $( CONFIG_COREBOOT_BOOTBLOCK ) , )
$(build)/$(BOARD)/$(CB_BOOTBLOCK_FILE) : $( build ) /$( coreboot_dir ) /.build
$( call do -copy,$( dir $<) $( CONFIG_COREBOOT_BOOTBLOCK) ,$@ )
2018-05-02 14:53:54 -04:00
@touch $@ # update the time stamp
2020-10-21 10:04:27 -05:00
e n d i f
2016-08-14 16:03:11 -04:00
2021-07-20 23:48:08 +03:00
e n d i f
2018-02-13 13:20:04 -05:00
#
# Helpful target for reconfiguring the coreboot target
#
2023-04-19 10:04:53 -04:00
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) \
2018-05-02 11:38:39 -04:00
-C " $( build) / $( coreboot_base_dir) " \
2018-08-13 10:26:08 -04:00
DOTCONFIG = " $( build) / $( coreboot_dir) /.config " \
2023-04-19 10:04:53 -04:00
olddefconfig && \
2018-08-13 10:26:08 -04:00
$( MAKE) \
-C " $( build) / $( coreboot_base_dir) " \
2023-04-19 10:04:53 -04:00
DOTCONFIG = " $( build) / $( coreboot_dir) /.config " \
savedefconfig && \
mv " $( build) / $( coreboot_base_dir) /defconfig " " $( pwd ) / $( CONFIG_COREBOOT_CONFIG) "
2024-02-13 15:21:49 +01:00
2023-04-19 10:04:53 -04:00
coreboot.save_in_oldconfig_format_in_place :
mkdir -p " $( build) / $( coreboot_dir) " && \
cp " $( pwd ) / $( CONFIG_COREBOOT_CONFIG) " " $( build) / $( coreboot_dir) /.config " && \
2023-04-19 10:04:53 -04:00
$( MAKE) \
-C " $( build) / $( coreboot_base_dir) " \
2023-04-19 10:04:53 -04:00
DOTCONFIG = " $( build) / $( coreboot_dir) /.config " \
olddefconfig \
&& mv " $( build) / $( coreboot_dir) /.config " " $( pwd ) / $( CONFIG_COREBOOT_CONFIG) "
2023-04-19 10:04:53 -04:00
2023-04-19 10:04:53 -04:00
coreboot.modify_defconfig_in_place :
mkdir -p " $( build) / $( coreboot_dir) " && \
cp " $( pwd ) / $( CONFIG_COREBOOT_CONFIG) " " $( build) / $( coreboot_dir) /.config " && \
2023-04-19 10:04:53 -04:00
$( MAKE) \
-C " $( build) / $( coreboot_base_dir) " \
2023-04-19 10:04:53 -04:00
DOTCONFIG = " $( build) / $( coreboot_dir) /.config " \
2023-04-19 10:04:53 -04:00
menuconfig \
&& $( MAKE) \
-C " $( build) / $( coreboot_base_dir) " \
2023-04-19 10:04:53 -04:00
DOTCONFIG = " $( build) / $( coreboot_dir) /.config " \
2023-04-19 10:04:53 -04:00
DEFCONFIG = " $( pwd ) / $( CONFIG_COREBOOT_CONFIG) " \
2023-04-19 10:04:53 -04:00
savedefconfig
2023-04-19 10:04:53 -04:00
coreboot.modify_and_save_oldconfig_in_place :
2023-04-19 10:04:53 -04:00
mkdir -p " $( build) / $( coreboot_dir) " && \
2023-04-19 10:04:53 -04:00
$( MAKE) menuconfig \
-C " $( build) / $( coreboot_base_dir) " \
obj = " $( build) / $( coreboot_dir) " \
DOTCONFIG = " $( pwd ) / $( CONFIG_COREBOOT_CONFIG) "
2017-02-01 11:50:52 -05:00
# if we are not building from a git checkout,
# we must also download the coreboot-blobs tree
2023-08-10 16:48:05 -04:00
i f e q "$($(coreboot_module)_repo)" ""
2018-02-05 11:56:15 -05:00
2023-08-10 16:48:05 -04:00
coreboot-blobs_module := coreboot-blobs-$( CONFIG_COREBOOT_VERSION)
2017-02-01 11:50:52 -05:00
2023-08-10 16:48:05 -04:00
$(coreboot_module)_depends += $( coreboot-blobs_module)
modules-y += $( coreboot-blobs_module)
2017-02-01 11:50:52 -05:00
2016-08-14 16:03:11 -04:00
## there is nothing to build for the blobs, this should be
## made easier to make happen
2023-08-10 16:48:05 -04:00
$(coreboot-blobs_module)_output := .built
$(coreboot-blobs_module)_configure := echo -e 'all:\n\ttouch .built' > Makefile
2016-08-14 16:03:11 -04:00
2017-02-01 11:50:52 -05:00
e n d i f
2020-11-25 14:43:07 +01:00
e n d i f