payloads/tianocore: Rework Makefile

Rework edkii makefile so that the various build options are
unified between CorebootPayloadPkg, uefipayload_202107 and
upstream.

This sets the project directory based on the git repository name
i.e. https://github.com/mrchromebox/edk2 becomes mrchomebox

Also builds to $(obj)/UEFIPAYLOAD.fd and allows using a commit
ID without a branch.

Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Change-Id: I3cc274e7385dd71c2aae315162cc48444b7eaa5f
Reviewed-on: https://review.coreboot.org/c/coreboot/+/61620
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-by: Martin Roth - Personal <martinroth@google.com>
This commit is contained in:
Sean Rhodes 2022-02-04 07:41:16 +00:00 committed by Martin Roth - Personal
parent e0e6f07220
commit 0884f21042
4 changed files with 124 additions and 107 deletions

View File

@ -136,22 +136,23 @@ payloads/external/depthcharge/depthcharge/build/depthcharge.elf depthcharge: $(D
# Tianocore # Tianocore
payloads/external/tianocore/tianocore/Build/UEFIPAYLOAD.fd tianocore: $(DOTCONFIG) $(obj)/UEFIPAYLOAD.fd tianocore: $(DOTCONFIG)
$(MAKE) -C payloads/external/tianocore all \ $(MAKE) -C payloads/external/tianocore all \
HOSTCC="$(HOSTCC)" \ HOSTCC="$(HOSTCC)" \
CC="$(HOSTCC)" \ CC="$(HOSTCC)" \
CONFIG_TIANOCORE_REVISION_ID=$(CONFIG_TIANOCORE_REVISION_ID) \ CONFIG_TIANOCORE_REPOSITORY=$(CONFIG_TIANOCORE_REPOSITORY) \
CONFIG_TIANOCORE_DEBUG=$(CONFIG_TIANOCORE_DEBUG) \ CONFIG_TIANOCORE_TAG_OR_REV=$(CONFIG_TIANOCORE_TAG_OR_REV) \
CONFIG_TIANOCORE_TARGET_IA32=$(CONFIG_TIANOCORE_TARGET_IA32) \
CONFIG_TIANOCORE_BOOTSPLASH_FILE=$(CONFIG_TIANOCORE_BOOTSPLASH_FILE) \
CONFIG_TIANOCORE_UEFIPAYLOAD=$(CONFIG_TIANOCORE_UEFIPAYLOAD) \ CONFIG_TIANOCORE_UEFIPAYLOAD=$(CONFIG_TIANOCORE_UEFIPAYLOAD) \
CONFIG_TIANOCORE_UPSTREAM=$(CONFIG_TIANOCORE_UPSTREAM) \ CONFIG_TIANOCORE_UPSTREAM=$(CONFIG_TIANOCORE_UPSTREAM) \
CONFIG_ECAM_MMCONF_BASE_ADDRESS=$(CONFIG_ECAM_MMCONF_BASE_ADDRESS) \ CONFIG_TIANOCORE_COREBOOTPAYLOAD=$(CONFIG_TIANOCORE_COREBOOTPAYLOAD) \
CONFIG_TIANOCORE_DEBUG=$(CONFIG_TIANOCORE_DEBUG) \
CONFIG_TIANOCORE_RELEASE=$(CONFIG_TIANOCORE_RELEASE) \
CONFIG_TIANOCORE_ABOVE_4G_MEMORY=$(CONFIG_TIANOCORE_ABOVE_4G_MEMORY) \ CONFIG_TIANOCORE_ABOVE_4G_MEMORY=$(CONFIG_TIANOCORE_ABOVE_4G_MEMORY) \
CONFIG_TIANOCORE_BOOTSPLASH_FILE=$(CONFIG_TIANOCORE_BOOTSPLASH_FILE) \
CONFIG_TIANOCORE_BOOT_TIMEOUT=$(CONFIG_TIANOCORE_BOOT_TIMEOUT) \ CONFIG_TIANOCORE_BOOT_TIMEOUT=$(CONFIG_TIANOCORE_BOOT_TIMEOUT) \
CONFIG_TIANOCORE_CBMEM_LOGGING=$(CONFIG_TIANOCORE_CBMEM_LOGGING) \ CONFIG_TIANOCORE_CBMEM_LOGGING=$(CONFIG_TIANOCORE_CBMEM_LOGGING) \
CONFIG_TIANOCORE_COREBOOTPAYLOAD=$(CONFIG_TIANOCORE_COREBOOTPAYLOAD) \
CONFIG_TIANOCORE_USE_8254_TIMER=$(CONFIG_TIANOCORE_USE_8254_TIMER) \ CONFIG_TIANOCORE_USE_8254_TIMER=$(CONFIG_TIANOCORE_USE_8254_TIMER) \
CONFIG_ECAM_MMCONF_BASE_ADDRESS=$(CONFIG_ECAM_MMCONF_BASE_ADDRESS) \
GCC_CC_x86_32=$(GCC_CC_x86_32) \ GCC_CC_x86_32=$(GCC_CC_x86_32) \
GCC_CC_x86_64=$(GCC_CC_x86_64) \ GCC_CC_x86_64=$(GCC_CC_x86_64) \
GCC_CC_arm=$(GCC_CC_arm) \ GCC_CC_arm=$(GCC_CC_arm) \
@ -161,6 +162,7 @@ payloads/external/tianocore/tianocore/Build/UEFIPAYLOAD.fd tianocore: $(DOTCONFI
OBJCOPY_arm=$(OBJCOPY_arm) \ OBJCOPY_arm=$(OBJCOPY_arm) \
OBJCOPY_arm64=$(OBJCOPY_arm64) \ OBJCOPY_arm64=$(OBJCOPY_arm64) \
MFLAGS= MAKEFLAGS= MFLAGS= MAKEFLAGS=
mv payloads/external/tianocore/output/UEFIPAYLOAD.fd $@
# FILO # FILO

View File

@ -2,7 +2,7 @@ if PAYLOAD_TIANOCORE
config PAYLOAD_FILE config PAYLOAD_FILE
string "Tianocore binary" string "Tianocore binary"
default "payloads/external/tianocore/tianocore/Build/UEFIPAYLOAD.fd" default "$(obj)/UEFIPAYLOAD.fd"
help help
The result of a UefiPayloadPkg build The result of a UefiPayloadPkg build
@ -35,13 +35,30 @@ config TIANOCORE_COREBOOTPAYLOAD
Select this option to build using MrChromebox's older (now deprecated) Select this option to build using MrChromebox's older (now deprecated)
CorebootPayloadPkg-based Tianocore branch CorebootPayloadPkg-based Tianocore branch
config TIANOCORE_CUSTOM
bool "Custom"
help
Specify your own edk2 repository and branch to use.
endchoice endchoice
config TIANOCORE_REVISION_ID config TIANOCORE_REPOSITORY
string "Insert a commit's SHA-1 or a branch name" string "URL to git repository for edk2"
default "https://github.com/tianocore/edk2" if TIANOCORE_UPSTREAM
default "https://github.com/mrchromebox/edk2" if TIANOCORE_UEFIPAYLOAD || TIANOCORE_COREBOOTPAYLOAD
help help
The commit's SHA-1 or branch name of the revision to use. Choose "upstream/master" coreboot supports an array of build options which can be found below. These options
for master branch of Tianocore release on github. will only have an effect if the relevant options exist in the target repository.
config TIANOCORE_TAG_OR_REV
string "Insert a commit's SHA-1 or a branch name"
default "origin/uefipayload_202107" if TIANOCORE_UEFIPAYLOAD
default "origin/master" if TIANOCORE_UPSTREAM
default "origin/coreboot_fb" if TIANOCORE_COREBOOTPAYLOAD
help
The commit's SHA-1 or branch name of the revision to use. This must exist in
TIANOCORE_REPOSITORY, and in the case of a branch name, prefixed with origin i.e.
"origin/uefipayload_202202"
choice choice
prompt "Tianocore build" prompt "Tianocore build"
@ -64,32 +81,33 @@ endchoice
if TIANOCORE_UEFIPAYLOAD if TIANOCORE_UEFIPAYLOAD
config TIANOCORE_CBMEM_LOGGING config TIANOCORE_ABOVE_4G_MEMORY
bool "Enable Tianocore logging to CBMEM" bool "Enable above 4G memory"
default n
help help
Select this option if you want to enable Tianocore logging to CBMEM. Select this option to enable Above 4G Decode. This will allow the
You may want to increase the default cbmem buffer size when selecting payload to use all of the memory, rather than an maximum of 4G.
this option, especially if using a debug (vs release) build.
Selecting this option will increase the payload size in CBFS by ~220KB.
config TIANOCORE_BOOTSPLASH_IMAGE Disabling memory above 4G is useful for bootloaders that are not
bool "Use a custom bootsplash image" fully 64-bit aware such as Qubes R4.0.4 bootloader.
config TIANOCORE_BOOTSPLASH_FILE
string "Tianocore Bootsplash path and filename"
default "bootsplash.bmp"
help help
Select this option if you have a bootsplash image that you would Select this option if you have a bootsplash image that you would
like to be used. If this option is not selected, the default like to be used. If this option is not selected, the default
coreboot logo (European Brown Hare) will used. coreboot logo (European Brown Hare) will used.
config TIANOCORE_BOOTSPLASH_FILE
string "Tianocore Bootsplash path and filename"
depends on TIANOCORE_BOOTSPLASH_IMAGE
default "bootsplash.bmp"
help
The path and filename of the file to use as graphical bootsplash The path and filename of the file to use as graphical bootsplash
image. The file must be an uncompressed BMP. image. The file must be an uncompressed BMP, in BMP 3 format.
Linux can create these with the below command:
`convert splosh.bmp BMP3:splash.bmp`
This image will also be used as the BGRT boot image, which may This image will also be used as the BGRT boot image, which may
persist through your OS boot process, and will be displayed persist through your OS boot process.
vertically centered 38.2% from the top of the display.
See ACPI spec 6.3, 5.2.22 Boot Graphics Resource Table (BGRT), and See ACPI spec 6.3, 5.2.22 Boot Graphics Resource Table (BGRT), and
Microsoft's documentation on BGRT positioning: Microsoft's documentation on BGRT positioning:
@ -101,16 +119,21 @@ config TIANOCORE_BOOTSPLASH_FILE
If an absolute path is not given, the path will assumed to be If an absolute path is not given, the path will assumed to be
relative to the coreboot root directory. relative to the coreboot root directory.
config TIANOCORE_ABOVE_4G_MEMORY config TIANOCORE_BOOT_TIMEOUT
bool "Enable above 4G memory" int
default n default 2
help help
Select this option to enable Above 4G Decode. This will allow the The length of time in seconds for which the boot splash/menu prompt will be displayed.
payload to use all of the memory, rather than an maximum of 4G. For boards with an internal display, the default value of 2s is generally sufficient.
For boards with an external display, a value of 5s is generally sufficient.
Disabling this option, which will reserve memory above 4G, is config TIANOCORE_CBMEM_LOGGING
useful for bootloaders that are not fully 64-bit aware such as bool "Enable Tianocore logging to CBMEM"
Qubes R4.0.4 bootloader. help
Select this option if you want to enable Tianocore logging to CBMEM.
You may want to increase the default cbmem buffer size when selecting
this option, especially if using a debug (vs release) build.
Selecting this option will increase the payload size in CBFS by 0x10000.
endif endif
@ -123,12 +146,4 @@ config TIANOCORE_USE_8254_TIMER
endif endif
config TIANOCORE_BOOT_TIMEOUT
int
default 2
help
The length of time in seconds for which the boot splash/menu prompt will be displayed.
For boards with an internal display, the default value of 2s is generally sufficient.
For boards without an internal display, a value of 5s is generally sufficient.
endif endif

View File

@ -3,84 +3,84 @@
# force the shell to bash - the edksetup.sh script doesn't work with dash # force the shell to bash - the edksetup.sh script doesn't work with dash
export SHELL := env bash export SHELL := env bash
project_name=Tianocore project_name = Tianocore
project_dir=$(CURDIR)/tianocore project_dir = $(CURDIR)/$(word 3,$(subst /, ,$(CONFIG_TIANOCORE_REPOSITORY)))
project_git_repo=https://github.com/mrchromebox/edk2
project_git_branch=uefipayload_202107
upstream_git_repo=https://github.com/tianocore/edk2
build_flavor=-D BOOTLOADER=COREBOOT -D PCIE_BASE=$(CONFIG_ECAM_MMCONF_BASE_ADDRESS) -DPS2_KEYBOARD_ENABLE
BUILD_STR = -a IA32 -a X64 -t COREBOOT
ifeq ($(CONFIG_TIANOCORE_COREBOOTPAYLOAD),y) ifeq ($(CONFIG_TIANOCORE_COREBOOTPAYLOAD),y)
project_git_branch=coreboot_fb BUILD_STR += -p CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc
bootloader=CorebootPayloadPkg
else else
bootloader=UefiPayloadPkg BUILD_STR += -p UefiPayloadPkg/UefiPayloadPkg.dsc
endif
BUILD_STR += -D BOOTLOADER=COREBOOT -q
#
# EDK II has the following build options relevant to coreboot:
#
#
# OPTION = DEFAULT_VALUE
#
# ABOVE_4G_MEMORY = TRUE
ifneq ($(CONFIG_TIANOCORE_ABOVE_4G_MEMORY),y)
BUILD_STR += -D ABOVE_4G_MEMORY=FALSE
endif
# BOOTSPLASH_IMAGE = FALSE
ifneq ($(CONFIG_TIANOCORE_BOOTSPLASH_FILE),)
BUILD_STR += -D BOOTSPLASH_IMAGE=TRUE
endif
# BUILD_TARGETS = DEBUG
ifeq ($(CONFIG_TIANOCORE_RELEASE),y)
BUILD_STR += -b RELEASE
endif
# PLATFORM_BOOT_TIMEOUT = 3
ifneq ($(TIANOCORE_BOOT_TIMEOUT),)
BUILD_STR += -D PLATFORM_BOOT_TIMEOUT=$(CONFIG_TIANOCORE_BOOT_TIMEOUT)
endif
# USE_CBMEM_FOR_CONSOLE = FALSE
ifeq ($(CONFIG_TIANOCORE_CBMEM_LOGGING),y)
BUILD_STR += -D USE_CBMEM_FOR_CONSOLE=TRUE
endif
#
# The below are legacy options only available in CorebootPayloadPkg:
#
# PCIE_BASE = 0
ifneq ($(CONFIG_ECAM_MMCONF_BASE_ADDRESS),)
BUILD_STR += -D PCIE_BASE=$(CONFIG_ECAM_MMCONF_BASE_ADDRESS)
endif
# USE_HPET_TIMER = FALSE
ifeq ($(CONFIG_TIANOCORE_USE_8254_TIMER),y)
BUILD_STR += -D USE_HPET_TIMER=TRUE
endif endif
ifeq ($(CONFIG_TIANOCORE_UPSTREAM),y) bootloader = $(word 8,$(subst /, ,$(BUILD_STR)))
TAG=upstream/master
else
TAG=origin/$(project_git_branch)
endif
ifneq ($(CONFIG_TIANOCORE_REVISION_ID),)
TAG=$(CONFIG_TIANOCORE_REVISION_ID)
endif
export EDK_TOOLS_PATH=$(project_dir)/BaseTools export EDK_TOOLS_PATH=$(project_dir)/BaseTools
ifeq ($(CONFIG_TIANOCORE_DEBUG),y)
BUILD_TYPE=DEBUG
else
BUILD_TYPE=RELEASE
endif
ifeq ($(CONFIG_TIANOCORE_CBMEM_LOGGING),y)
CBMEM=-D USE_CBMEM_FOR_CONSOLE=TRUE
endif
ifeq ($(CONFIG_TIANOCORE_ABOVE_4G_MEMORY),y)
4G=-D ABOVE_4G_MEMORY=TRUE
else
4G=-D ABOVE_4G_MEMORY=FALSE
endif
TIMEOUT=-D PLATFORM_BOOT_TIMEOUT=$(CONFIG_TIANOCORE_BOOT_TIMEOUT)
ifneq ($(CONFIG_TIANOCORE_USE_8254_TIMER), y)
TIMER=-DUSE_HPET_TIMER
endif
ifeq ($(CONFIG_TIANOCORE_COREBOOTPAYLOAD),y)
BUILD_STR=-q -a IA32 -a X64 -p CorebootPayloadPkg/CorebootPayloadPkgIa32X64.dsc -t COREBOOT -b $(BUILD_TYPE) $(TIMER) -DPS2_KEYBOARD_ENABLE
else
BUILD_STR=-q -a IA32 -a X64 -p UefiPayloadPkg/UefiPayloadPkg.dsc -t COREBOOT -b $(BUILD_TYPE) $(TIMEOUT) $(build_flavor) $(CBMEM) $(4G)
endif
all: clean build all: clean build
$(project_dir): $(project_dir):
echo " Cloning $(project_name) from Git" echo " Cloning $(project_name) from $(CONFIG_TIANOCORE_REPOSITORY)"
git clone --branch $(project_git_branch) $(project_git_repo) $(project_dir); \ git clone $(CONFIG_TIANOCORE_REPOSITORY) $(project_dir); \
cd $(project_dir); \ cd $(project_dir);
git remote add upstream $(upstream_git_repo)
update: $(project_dir) update: $(project_dir)
if [ ! -d "$(project_dir)" ]; then \
git clone $(CONFIG_TIANOCORE_REPOSITORY) $(project_dir); \
fi
cd $(project_dir); \ cd $(project_dir); \
echo " Fetching new commits from the $(project_name) repo"; \ echo " Fetching new commits from $(CONFIG_TIANOCORE_REPOSITORY)"; \
git fetch --multiple origin upstream 2>/dev/null; \ git fetch origin 2>/dev/null; \
if ! git rev-parse --verify -q $(TAG) >/dev/null; then \ if ! git rev-parse --verify -q $(CONFIG_TIANOCORE_TAG_OR_REV) >/dev/null; then \
echo " $(TAG) is not a valid git reference"; \ echo " $(CONFIG_TIANOCORE_TAG_OR_REV) is not a valid git reference"; \
exit 1; \ exit 1; \
fi; \ fi; \
if git status --ignore-submodules=dirty | grep -qv clean; then \ if git status --ignore-submodules=dirty | grep -qv clean; then \
echo " Checking out $(project_name) revision $(TAG)"; \ echo " Checking out $(project_name) revision $(CONFIG_TIANOCORE_TAG_OR_REV)"; \
git checkout --detach $(TAG); \ git checkout --detach $(CONFIG_TIANOCORE_TAG_OR_REV) -f; \
else \ else \
echo " Working directory not clean; will not overwrite"; \ echo " Working directory not clean; will not overwrite"; \
fi; \ fi; \
git submodule update --init git submodule update --init --checkout
checktools: checktools:
echo "Checking uuid-dev..." echo "Checking uuid-dev..."
@ -94,8 +94,8 @@ checktools:
( echo " Not found."; echo "Error: Please install nasm."; exit 1 ) ( echo " Not found."; echo "Error: Please install nasm."; exit 1 )
build: update checktools build: update checktools
unset CC; $(MAKE) -C $(project_dir)/BaseTools unset CC; $(MAKE) -C $(project_dir)/BaseTools 2>&1
echo " build $(project_name) $(TAG)" echo " build $(project_name) $(CONFIG_TIANOCORE_TAG_OR_REV)"
if [ -n "$(CONFIG_TIANOCORE_BOOTSPLASH_FILE)" ]; then \ if [ -n "$(CONFIG_TIANOCORE_BOOTSPLASH_FILE)" ]; then \
echo " Copying custom bootsplash image"; \ echo " Copying custom bootsplash image"; \
case "$(CONFIG_TIANOCORE_BOOTSPLASH_FILE)" in \ case "$(CONFIG_TIANOCORE_BOOTSPLASH_FILE)" in \
@ -114,13 +114,14 @@ build: update checktools
cat ../tools_def.txt >> $(project_dir)/Conf/tools_def.txt; \ cat ../tools_def.txt >> $(project_dir)/Conf/tools_def.txt; \
fi; \ fi; \
build $(BUILD_STR); \ build $(BUILD_STR); \
mv $(project_dir)/Build/$(bootloader)*/*/FV/UEFIPAYLOAD.fd $(project_dir)/Build/UEFIPAYLOAD.fd; \ mkdir -p $(project_dir)/../output
mv $(project_dir)/Build/$(bootloader)*/*/FV/UEFIPAYLOAD.fd $(project_dir)/../output/UEFIPAYLOAD.fd; \
git checkout MdeModulePkg/Logo/Logo.bmp > /dev/null 2>&1 || true git checkout MdeModulePkg/Logo/Logo.bmp > /dev/null 2>&1 || true
clean: clean:
test -d $(project_dir) && (cd $(project_dir); rm -rf Build; rm -f Conf/tools_def.txt) || exit 0 test -d $(project_dir) && (cd $(project_dir); rm -rf Build; rm -f Conf/tools_def.txt) || exit 0
distclean: distclean:
rm -rf $(project_dir) rm -rf */
.PHONY: all update checktools config build clean distclean .PHONY: all update checktools config build clean distclean

View File

@ -81,7 +81,6 @@ config ME_BIN_PATH
config TIANOCORE_BOOTSPLASH_FILE config TIANOCORE_BOOTSPLASH_FILE
string string
depends on TIANOCORE_BOOTSPLASH_IMAGE
default "3rdparty/blobs/mainboard/starlabs/Logo.bmp" default "3rdparty/blobs/mainboard/starlabs/Logo.bmp"
config UART_FOR_CONSOLE config UART_FOR_CONSOLE