How-To: Compile EDK2/OVMF From Source on Linux 
EDK2 is a development environment to create firmware implementations that follows the UEFI specification. It is part of tianocore project. which is the reference implemenation for UEFI. Multiple “packages”, which are the sources to build tianocore for different platforms (x86, ARM, QEMU), are located inside the git repository of “EDK2”. OVMF, which stands for Open Virtual Machine Firmware, is one of these packages. It enables UEFI inside virtual machines, like in QEMU environments. This is useful to test UEFI applications (hello world, bootloaders, graphical user interfaces to configure your processor/GPU) inside a VM without the need of booting a real machine.
In my case I wanted to compile OVMF from source but the existing how-to’s were not satisfying, such as “How to build OVMF”. It took me a while to figure everything out and after all it is quite easy. Here is how I’ve done it [in May 2021 on Ubuntu 21.04]. I think it should work on all Linux/UNIX-systems the same way. Depending on your system, you may need to install other-named packages or use another package manager.
# all essential packages $ sudo apt update $ sudo apt install -y git nasm iasl build-essential uuid-dev $ git clone https://github.com/tianocore/edk2.git $ cd ./edk2 $ git submodule update --init $ make -C BaseTools
<edk2-root>/Conf/target.txt and make sure the keys (which will already exist in the file) have the following values
# taken from https://github.com/tianocore/tianocore.github.io/wiki/How-to-build-OVMF ACTIVE_PLATFORM = OvmfPkg/OvmfPkgX64.dsc TARGET_ARCH = X64 TOOL_CHAIN_TAG = GCC5
Now execute the following commands:
$ cd <edk2-root>/OvmfPkg $ ./build.sh
That’s it, it should work! The files that you probably want now after the build (to boot this inside QEMU) are located in “
PS: Here are some interesting comments about OVMF: https://www.linux-kvm.org/downloads/lersek/ovmf-whitepaper-c770f8c.txt
- “python” is missing (happened to me on Ubuntu 21.04).): It’s okay to use python3. If you already have python3 available, execute the following command:
$ ln -s /usr/bin/python3 /usr/bin/python