-
Notifications
You must be signed in to change notification settings - Fork 6
Misc EDK2 build notes
Use Linux (or WSL2) to save you some time. While doing such with macOS is completely feasible (and that's what I sometimes do actually), either patching build definition to make XCode working or bootstrapping GCC toolchains (crosstool-ng
) will take a while. Working with Windows is technically possible but not recommended (my personal opinion.)
Assuming amd64/x64 host machine and Ubuntu 18.04, install gcc-aarch64-linux-gnu
toolchain for AArch64. Install gcc-arm-none-eabi
or gcc-arm-linux-gnueabihf
for ARM (32-bit). Linaro's pre-built toolchains are also acceptable. Clang 11 is also okay (still needs aarch64 binutils.) Additional dependencies such as bison flex libuuid-dev
and standard build tools (I just use build-essential
) are also required. This should be similar for other distributions.
Just go ahead and everything will be fine.
Using 32bit ARM with hardware float point support needs a EDK2 BaseTools patch, see the main repo of Yahallo (this one) for details.
Clang is stricter with your language style. Be prepared for more warnings. Also, if the linker reports errors, this is likely because Clang cannot find the proper linker to utilize. Invoke the command with strace
to find what it needs and make a symbolic link if needed.
Export required prefixes to your environment for convenience. Although here it said CLANG38
and GCC5
, the version doesn't necessarily have to match and therefore it can be higher. For instance, I am using GCC 8 and Clang 11.
Clang prefix is only used for binutils, since Clang is supports cross-compile by design.
# set for EDK2
export CLANG38_AARCH64_PREFIX=aarch64-linux-gnu-
export GCC5_AARCH64_PREFIX=aarch64-linux-gnu-
export CLANG38_ARM_PREFIX=arm-linux-gnueabihf-
export GCC5_ARM_PREFIX=arm-linux-gnueabihf-
You will also need a copy of ACPI tools. The ACPI tools from Ubuntu repo is a bit old, I recommend building them by yourself:
git clone https://github.com/acpica/acpica.git
cd acpica
make -j
sudo make install
Ensure you have Python 3 installed and PIP is available.
git clone https://github.com/tianocore/edk2
cd edk2
# Update submodules
git submodule init
git submodule update
# Install dependencies and make base tools
pip3 install -r pip-requirements.txt
# You might also want to patch tools like this repo if needed
make -C BaseTools
. edksetup.sh
You are now ready to build things.
Assuming environment is already sourced.
# Example ARM, GCC and Debug Config
build -a ARM -p YahalloPkg/YahalloPkg.dsc -t GCC5 -b DEBUG
# Example AARCH64, Clang and Release config
build -a ARM -p Lumia950XLPkg/Lumia950XL.dsc -t CLANG38 -b RELEASE
# Example AARCH64, Clang, Release and Multithread build config
build -a ARM -p Lumia950XLPkg/Lumia950XL.dsc -t CLANG38 -b RELEASE -n 0
You will find the build artifacts at the directory specified by the manifest, likely the Build
directory.
Standard C/C++ extension will mostly work, except sometimes it cannot correctly infer the include path and missing external fields populated by the autogenerate process. At this moment you need to manually populate the include path if needed (MdePkg, MdeModulePkg, and likely ArmPkg or whatever depends on the target.)
In the future I might really need to write an extension called "EDK2 Productivity for Visual Studio Code"...