2021-05-12 20:36:15 +02:00
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# edk2
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
2023-08-27 16:59:54 +02:00
|
|
|
EDK2_VERSION = edk2-stable202308
|
2021-05-12 20:36:15 +02:00
|
|
|
EDK2_SITE = https://github.com/tianocore/edk2
|
|
|
|
EDK2_SITE_METHOD = git
|
2022-11-23 11:20:35 +01:00
|
|
|
EDK2_LICENSE = BSD-2-Clause-Patent
|
2022-08-26 22:57:55 +02:00
|
|
|
EDK2_LICENSE_FILES = License.txt
|
2021-06-12 16:38:35 +02:00
|
|
|
EDK2_CPE_ID_VENDOR = tianocore
|
2021-05-12 20:36:15 +02:00
|
|
|
EDK2_DEPENDENCIES = edk2-platforms host-python3 host-acpica host-util-linux
|
|
|
|
EDK2_INSTALL_TARGET = NO
|
|
|
|
EDK2_INSTALL_IMAGES = YES
|
|
|
|
|
|
|
|
ifeq ($(BR2_ENABLE_DEBUG),y)
|
|
|
|
EDK2_BUILD_TYPE = DEBUG
|
2023-07-21 22:27:57 +02:00
|
|
|
ifeq ($(BR2_TARGET_EDK2_OVMF_DEBUG_ON_SERIAL),y)
|
|
|
|
# DEBUG_ON_SERIAL_PORT is only tested to be set, so don't disable it, as
|
|
|
|
# it would still be set.
|
2023-07-24 19:24:26 +02:00
|
|
|
EDK2_BUILD_OPTS += -DDEBUG_ON_SERIAL_PORT
|
2023-07-21 22:27:57 +02:00
|
|
|
endif
|
2021-05-12 20:36:15 +02:00
|
|
|
else
|
|
|
|
EDK2_BUILD_TYPE = RELEASE
|
2023-07-21 22:27:57 +02:00
|
|
|
# DEBUG_ON_SERIAL_PORT is only valid in debug builds, so useless to set
|
|
|
|
# it (enabled or disabled) on a relase build.
|
2021-05-12 20:36:15 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Build system notes.
|
|
|
|
#
|
|
|
|
# The EDK2 build system is rather unique, so here are a few useful notes.
|
|
|
|
#
|
|
|
|
# First, builds rely heavily on Git submodules to fetch various dependencies
|
|
|
|
# into specific directory structures. It might be possible to work around this
|
|
|
|
# and rely on Buildroot's infrastructure, but using Git submodules greatly
|
|
|
|
# simplifies this already complicated build system.
|
|
|
|
#
|
|
|
|
# Second, the build system is spread across various commands and stages.
|
|
|
|
# Therefore, all build variables needs to be exported to be available
|
|
|
|
# accordingly. The first stage will build $(@D)/BaseTools which contains
|
|
|
|
# various tools and scripts for the host.
|
|
|
|
#
|
|
|
|
# Third, where applicable, the dependency direction between EDK2 and
|
|
|
|
# ARM Trusted Firmware (ATF) will go in different direction for different
|
|
|
|
# platforms. Most commonly, ATF will depend on EDK2 via the BL33 payload.
|
|
|
|
# But for some platforms (e.g. QEMU SBSA or DeveloperBox) EDK2 will package
|
|
|
|
# the ATF images within its own build system. In such cases, intermediary
|
|
|
|
# "EDK2 packages" will be built in $(EDK2_BUILD_PACKAGES) in order for EDK2
|
|
|
|
# to be able to use them in subsequent build stages.
|
|
|
|
#
|
|
|
|
# For more information about the build setup:
|
|
|
|
# https://edk2-docs.gitbook.io/edk-ii-build-specification/4_edk_ii_build_process_overview
|
|
|
|
|
|
|
|
EDK2_GIT_SUBMODULES = YES
|
|
|
|
EDK2_BUILD_PACKAGES = $(@D)/Build/Buildroot
|
2022-12-01 19:33:37 +01:00
|
|
|
EDK2_PACKAGES_PATHS = $(@D) $(EDK2_BUILD_PACKAGES) $(STAGING_DIR)/usr/share/edk2-platforms
|
2021-05-12 20:36:15 +02:00
|
|
|
|
2021-09-23 17:57:25 +02:00
|
|
|
ifeq ($(BR2_TARGET_EDK2_PLATFORM_OVMF_I386),y)
|
2021-10-04 15:27:40 +02:00
|
|
|
EDK2_ARCH = IA32
|
2021-09-23 17:57:25 +02:00
|
|
|
EDK2_DEPENDENCIES += host-nasm
|
|
|
|
EDK2_PACKAGE_NAME = OvmfPkg
|
|
|
|
EDK2_PLATFORM_NAME = OvmfPkgIa32
|
|
|
|
EDK2_BUILD_DIR = OvmfIa32
|
|
|
|
|
|
|
|
else ifeq ($(BR2_TARGET_EDK2_PLATFORM_OVMF_X64),y)
|
2021-10-04 15:27:40 +02:00
|
|
|
EDK2_ARCH = X64
|
2021-05-12 20:36:15 +02:00
|
|
|
EDK2_DEPENDENCIES += host-nasm
|
|
|
|
EDK2_PACKAGE_NAME = OvmfPkg
|
|
|
|
EDK2_PLATFORM_NAME = OvmfPkgX64
|
|
|
|
EDK2_BUILD_DIR = OvmfX64
|
|
|
|
|
|
|
|
else ifeq ($(BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU),y)
|
2021-10-04 15:27:40 +02:00
|
|
|
EDK2_ARCH = AARCH64
|
2021-05-12 20:36:15 +02:00
|
|
|
EDK2_PACKAGE_NAME = ArmVirtPkg
|
|
|
|
EDK2_PLATFORM_NAME = ArmVirtQemu
|
|
|
|
EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)-$(EDK2_ARCH)
|
|
|
|
|
|
|
|
else ifeq ($(BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU_KERNEL),y)
|
2021-10-04 15:27:40 +02:00
|
|
|
EDK2_ARCH = AARCH64
|
2021-05-12 20:36:15 +02:00
|
|
|
EDK2_PACKAGE_NAME = ArmVirtPkg
|
|
|
|
EDK2_PLATFORM_NAME = ArmVirtQemuKernel
|
|
|
|
EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)-$(EDK2_ARCH)
|
|
|
|
|
2022-11-22 17:05:44 +01:00
|
|
|
else ifeq ($(BR2_TARGET_EDK2_PLATFORM_ARM_SGI575),y)
|
|
|
|
EDK2_ARCH = AARCH64
|
|
|
|
EDK2_PACKAGE_NAME = Platform/ARM/SgiPkg/Sgi575
|
|
|
|
EDK2_PLATFORM_NAME = Sgi575
|
|
|
|
EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)
|
|
|
|
|
2021-05-12 20:36:15 +02:00
|
|
|
else ifeq ($(BR2_TARGET_EDK2_PLATFORM_ARM_VEXPRESS_FVP_AARCH64),y)
|
2021-10-04 15:27:40 +02:00
|
|
|
EDK2_ARCH = AARCH64
|
2021-05-12 20:36:15 +02:00
|
|
|
EDK2_PACKAGE_NAME = Platform/ARM/VExpressPkg
|
|
|
|
EDK2_PLATFORM_NAME = ArmVExpress-FVP-AArch64
|
|
|
|
EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)
|
|
|
|
|
|
|
|
else ifeq ($(BR2_TARGET_EDK2_PLATFORM_SOCIONEXT_DEVELOPERBOX),y)
|
2021-10-04 15:27:40 +02:00
|
|
|
EDK2_ARCH = AARCH64
|
2021-05-12 20:36:15 +02:00
|
|
|
EDK2_DEPENDENCIES += host-dtc arm-trusted-firmware
|
|
|
|
EDK2_PACKAGE_NAME = Platform/Socionext/DeveloperBox
|
|
|
|
EDK2_PLATFORM_NAME = DeveloperBox
|
|
|
|
EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)
|
|
|
|
EDK2_BUILD_ENV += DTC_PREFIX=$(HOST_DIR)/bin/
|
|
|
|
EDK2_BUILD_OPTS += -D DO_X86EMU=TRUE
|
|
|
|
EDK2_PRE_BUILD_HOOKS += EDK2_PRE_BUILD_SOCIONEXT_DEVELOPERBOX
|
|
|
|
|
|
|
|
define EDK2_PRE_BUILD_SOCIONEXT_DEVELOPERBOX
|
|
|
|
mkdir -p $(EDK2_BUILD_PACKAGES)/Platform/Socionext/DeveloperBox
|
|
|
|
$(ARM_TRUSTED_FIRMWARE_DIR)/tools/fiptool/fiptool create \
|
|
|
|
--tb-fw $(BINARIES_DIR)/bl31.bin \
|
|
|
|
--soc-fw $(BINARIES_DIR)/bl31.bin \
|
|
|
|
--scp-fw $(BINARIES_DIR)/bl31.bin \
|
|
|
|
$(EDK2_BUILD_PACKAGES)/Platform/Socionext/DeveloperBox/fip_all_arm_tf.bin
|
|
|
|
endef
|
|
|
|
|
|
|
|
else ifeq ($(BR2_TARGET_EDK2_PLATFORM_SOLIDRUN_ARMADA80X0MCBIN),y)
|
2021-10-04 15:27:40 +02:00
|
|
|
EDK2_ARCH = AARCH64
|
2022-12-01 19:33:37 +01:00
|
|
|
EDK2_DEPENDENCIES += host-dtc arm-trusted-firmware edk2-non-osi
|
2021-05-12 20:36:15 +02:00
|
|
|
EDK2_PACKAGE_NAME = Platform/SolidRun/Armada80x0McBin
|
|
|
|
EDK2_PLATFORM_NAME = Armada80x0McBin
|
|
|
|
EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)-$(EDK2_ARCH)
|
|
|
|
EDK2_BUILD_ENV += DTC_PREFIX=$(HOST_DIR)/bin/
|
|
|
|
EDK2_BUILD_OPTS += -D INCLUDE_TFTP_COMMAND
|
2022-12-01 19:33:37 +01:00
|
|
|
EDK2_PACKAGES_PATHS += $(STAGING_DIR)/usr/share/edk2-non-osi
|
2021-05-12 20:36:15 +02:00
|
|
|
|
|
|
|
else ifeq ($(BR2_TARGET_EDK2_PLATFORM_QEMU_SBSA),y)
|
2021-10-04 15:27:40 +02:00
|
|
|
EDK2_ARCH = AARCH64
|
2021-05-12 20:36:15 +02:00
|
|
|
EDK2_DEPENDENCIES += arm-trusted-firmware
|
|
|
|
EDK2_PACKAGE_NAME = Platform/Qemu/SbsaQemu
|
|
|
|
EDK2_PLATFORM_NAME = SbsaQemu
|
|
|
|
EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)
|
|
|
|
EDK2_PRE_BUILD_HOOKS += EDK2_PRE_BUILD_QEMU_SBSA
|
|
|
|
|
|
|
|
define EDK2_PRE_BUILD_QEMU_SBSA
|
|
|
|
mkdir -p $(EDK2_BUILD_PACKAGES)/Platform/Qemu/Sbsa
|
|
|
|
ln -srf $(BINARIES_DIR)/{bl1.bin,fip.bin} $(EDK2_BUILD_PACKAGES)/Platform/Qemu/Sbsa/
|
|
|
|
endef
|
|
|
|
|
boot/edk2: add support for RISC-V 64bit architecture
RISC-V 64bit qemu virt machine support has been added in edk2
version "stable202302". See [1].
Since edk2-stable202308, introduced in buildroot in commit 5c9f310
"boot/edk2: bump to version edk2-stable202308", it is now possible
to boot the edk2 UEFI shell in qemu.
This commit adds this early RISC-V support to edk2.
The RISC-V edk2 UEFI shell can be booted in Buildroot with the
following commands:
# Build EDK2 images
cat > .config <<EOF
BR2_riscv=y
BR2_RISCV_64=y
BR2_PACKAGE_HOST_QEMU=y
BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
BR2_TARGET_EDK2=y
EOF
make olddefconfig
make
# edk2 image size should fit the 32MB of qemu pflash memories
truncate -s 32M output/images/RISCV_VIRT_CODE.fd
truncate -s 32M output/images/RISCV_VIRT_VARS.fd
# Start qemu:
output/host/usr/bin/qemu-system-riscv64 \
-M virt,pflash0=pflash0,pflash1=pflash1,acpi=off \
-nographic \
-blockdev node-name=pflash0,driver=file,read-only=on,filename=output/images/RISCV_VIRT_CODE.fd \
-blockdev node-name=pflash1,driver=file,filename=output/images/RISCV_VIRT_VARS.fd
Note: a Qemu version >= 8.0.0 is needed to properly start edk2. A qemu
version on the host system might not be sufficient. This is why the
Buildroot host-qemu is built in this config example.
[1] https://github.com/tianocore/edk2/releases/tag/edk2-stable202302
Signed-off-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-12-22 11:56:55 +01:00
|
|
|
else ifeq ($(BR2_TARGET_EDK2_PLATFORM_OVMF_RISCV),y)
|
|
|
|
EDK2_ARCH = RISCV64
|
|
|
|
EDK2_PACKAGE_NAME = OvmfPkg/RiscVVirt
|
|
|
|
EDK2_PLATFORM_NAME = RiscVVirtQemu
|
|
|
|
EDK2_BUILD_DIR = $(EDK2_PLATFORM_NAME)
|
|
|
|
|
2021-05-12 20:36:15 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
EDK2_BASETOOLS_OPTS = \
|
|
|
|
EXTRA_LDFLAGS="$(HOST_LDFLAGS)" \
|
|
|
|
EXTRA_OPTFLAGS="$(HOST_CPPFLAGS)"
|
|
|
|
|
2022-12-01 19:33:37 +01:00
|
|
|
EDK2_PACKAGES_PATH = $(subst $(space),:,$(strip $(EDK2_PACKAGES_PATHS)))
|
|
|
|
|
boot/edk2: unset MAKEFLAGS in build environment
Yann reported in [1] that edk2 build could sometimes fail. The issue
can be reproduced when per-package directories is enabled, or also
when building on a system with GNU Make >= 4.4 using the
"--shuffle=reverse" option (such as Fedora 39). Those are pointing
toward a Makefile dependency issue.
The issue can be reproduced with commands:
cat > .config <<EOF
BR2_riscv=y
BR2_RISCV_64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TARGET_EDK2=y
EOF
make olddefconfig
Then, building either with:
make --shuffle=reverse
Or:
utils/config -e BR2_PER_PACKAGE_DIRECTORIES
make olddefconfig
make -j$(nproc)
It is interesting to mention that when using "make --shuffle=reverse"
to build, the build can be completed if restarted only with "make". It
will not pull any other Buildroot package. This fact hints toward a
Makefile dependency issue internal to the EDK2 build system, rather
than in the Buildroot recipe.
The EDK2 build system is quite unique. See [2]. It generates files,
makefiles and internally uses GNU Make to compile code. This system is
likely not tested as being a sub-Make process in a complex Makefile
such as Buildroot.
In order to prevent Buildroot to pass unexpected Make flags to the
EDK2 sub-Make, this commit unset the MAKEFLAGS variable in the EDK2
build environment. This will put the EDK2 build script in a more
common and tested state. See GNU Make documentation about recursive use
of Make, more specifically [3].
Note: as mentioned, the build failure is likely due to an internal
issue of the EDK2 build system. The failure points to a missing
dependency in the EDK2 generator itself. This commit does not fix this
issue, but rather put the EDK2 build system in a normalized
environment, avoiding Buildroot flags being passed to the internal
EDK2 sub-Make invocation. The upstream EDK2 build system most likely
need a fix too.
Fixes:
make[2]: *** No rule to make target '/buildroot/output/build/edk2-edk2-stable202308/Build/RiscVVirtQemu/RELEASE_GCC5/RISCV64/MdeModulePkg/Application/UiApp/UiApp/DEBUG/UiApp.efi', needed by '/buildroot/output/build/edk2-edk2-stable202308/Build/RiscVVirtQemu/RELEASE_GCC5/FV/Ffs/462CAA21-7614-4503-836E-8AB6F4662331UiApp/UiApp.offset'. Stop.
build.py...
: error 7000: Failed to execute command
make tbuild [/buildroot/output/build/edk2-edk2-stable202308/Build/RiscVVirtQemu/RELEASE_GCC5/RISCV64/MdeModulePkg/Application/UiApp/UiApp]
build.py...
: error F002: Failed to build module
/buildroot/output/build/edk2-edk2-stable202308/MdeModulePkg/Application/UiApp/UiApp.inf [RISCV64, GCC5, RELEASE]
[1] https://lists.buildroot.org/pipermail/buildroot/2023-December/681507.html
[2] https://tianocore-docs.github.io/edk2-BuildSpecification/draft/4_edk_ii_build_process_overview/42_build_process_overview.html
[3] https://www.gnu.org/software/make/manual/make.html#Options_002fRecursion
Reported-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-12-31 19:14:37 +01:00
|
|
|
# EDK2 "build" script internally uses and calls "make", which controls
|
|
|
|
# its own flags. It is mainly tested while not being a sub-make. In
|
|
|
|
# order to stay in that configuration, we avoid leaking top-level
|
|
|
|
# Buildroot make flags into EDK2 build by clearing the MAKEFLAGS
|
|
|
|
# environment variable.
|
2021-05-12 20:36:15 +02:00
|
|
|
EDK2_BUILD_ENV += \
|
boot/edk2: unset MAKEFLAGS in build environment
Yann reported in [1] that edk2 build could sometimes fail. The issue
can be reproduced when per-package directories is enabled, or also
when building on a system with GNU Make >= 4.4 using the
"--shuffle=reverse" option (such as Fedora 39). Those are pointing
toward a Makefile dependency issue.
The issue can be reproduced with commands:
cat > .config <<EOF
BR2_riscv=y
BR2_RISCV_64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TARGET_EDK2=y
EOF
make olddefconfig
Then, building either with:
make --shuffle=reverse
Or:
utils/config -e BR2_PER_PACKAGE_DIRECTORIES
make olddefconfig
make -j$(nproc)
It is interesting to mention that when using "make --shuffle=reverse"
to build, the build can be completed if restarted only with "make". It
will not pull any other Buildroot package. This fact hints toward a
Makefile dependency issue internal to the EDK2 build system, rather
than in the Buildroot recipe.
The EDK2 build system is quite unique. See [2]. It generates files,
makefiles and internally uses GNU Make to compile code. This system is
likely not tested as being a sub-Make process in a complex Makefile
such as Buildroot.
In order to prevent Buildroot to pass unexpected Make flags to the
EDK2 sub-Make, this commit unset the MAKEFLAGS variable in the EDK2
build environment. This will put the EDK2 build script in a more
common and tested state. See GNU Make documentation about recursive use
of Make, more specifically [3].
Note: as mentioned, the build failure is likely due to an internal
issue of the EDK2 build system. The failure points to a missing
dependency in the EDK2 generator itself. This commit does not fix this
issue, but rather put the EDK2 build system in a normalized
environment, avoiding Buildroot flags being passed to the internal
EDK2 sub-Make invocation. The upstream EDK2 build system most likely
need a fix too.
Fixes:
make[2]: *** No rule to make target '/buildroot/output/build/edk2-edk2-stable202308/Build/RiscVVirtQemu/RELEASE_GCC5/RISCV64/MdeModulePkg/Application/UiApp/UiApp/DEBUG/UiApp.efi', needed by '/buildroot/output/build/edk2-edk2-stable202308/Build/RiscVVirtQemu/RELEASE_GCC5/FV/Ffs/462CAA21-7614-4503-836E-8AB6F4662331UiApp/UiApp.offset'. Stop.
build.py...
: error 7000: Failed to execute command
make tbuild [/buildroot/output/build/edk2-edk2-stable202308/Build/RiscVVirtQemu/RELEASE_GCC5/RISCV64/MdeModulePkg/Application/UiApp/UiApp]
build.py...
: error F002: Failed to build module
/buildroot/output/build/edk2-edk2-stable202308/MdeModulePkg/Application/UiApp/UiApp.inf [RISCV64, GCC5, RELEASE]
[1] https://lists.buildroot.org/pipermail/buildroot/2023-December/681507.html
[2] https://tianocore-docs.github.io/edk2-BuildSpecification/draft/4_edk_ii_build_process_overview/42_build_process_overview.html
[3] https://www.gnu.org/software/make/manual/make.html#Options_002fRecursion
Reported-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-12-31 19:14:37 +01:00
|
|
|
MAKEFLAGS= \
|
2021-05-12 20:36:15 +02:00
|
|
|
WORKSPACE=$(@D) \
|
|
|
|
PACKAGES_PATH=$(EDK2_PACKAGES_PATH) \
|
|
|
|
PYTHON_COMMAND=$(HOST_DIR)/bin/python3 \
|
|
|
|
IASL_PREFIX=$(HOST_DIR)/bin/ \
|
|
|
|
NASM_PREFIX=$(HOST_DIR)/bin/ \
|
|
|
|
GCC5_$(EDK2_ARCH)_PREFIX=$(TARGET_CROSS)
|
|
|
|
|
|
|
|
EDK2_BUILD_OPTS += \
|
|
|
|
-t GCC5 \
|
|
|
|
-n $(BR2_JLEVEL) \
|
|
|
|
-a $(EDK2_ARCH) \
|
|
|
|
-b $(EDK2_BUILD_TYPE) \
|
|
|
|
-p $(EDK2_PACKAGE_NAME)/$(EDK2_PLATFORM_NAME).dsc
|
|
|
|
|
|
|
|
define EDK2_BUILD_CMDS
|
|
|
|
mkdir -p $(EDK2_BUILD_PACKAGES)
|
|
|
|
export $(EDK2_BUILD_ENV) && \
|
|
|
|
unset ARCH && \
|
|
|
|
source $(@D)/edksetup.sh && \
|
|
|
|
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/BaseTools $(EDK2_BASETOOLS_OPTS) && \
|
|
|
|
build $(EDK2_BUILD_OPTS) all
|
|
|
|
endef
|
|
|
|
|
|
|
|
define EDK2_INSTALL_IMAGES_CMDS
|
|
|
|
cp -f $(@D)/Build/$(EDK2_BUILD_DIR)/$(EDK2_BUILD_TYPE)_GCC5/FV/*.fd $(BINARIES_DIR)
|
|
|
|
endef
|
|
|
|
|
|
|
|
$(eval $(generic-package))
|