EDK2: Difference between revisions
[unchecked revision] | [unchecked revision] |
Content deleted Content added
m made top-level section H2, as is standard |
m Bot: Replace deprecated source tag with syntaxhighlight |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 24:
===Building without edk2-platforms===
If you only want the UEFI library or virtual machine firmware, then this guide will suffice. Make sure you have all the dependencies installed first:
<
sudo apt install build-essential git python2 uuid-dev nasm acpica-tools # Or whatever your package manager is
</syntaxhighlight>
First, we must clone EDK2
<
git clone https://github.com/tianocore/edk2.git
</syntaxhighlight>
Note that this is the latest non-stable source. If you want the stable source then run:
<
git clone https://github.com/tianocore/edk2.git -b"stable/202011"
</syntaxhighlight>
or whatever is appropriate at the time you are reading this. After that, we now must clone the submodules
<
cd edk2
git submodule update --init
</syntaxhighlight>
Then, we need to setup the environment for EDK2
<
export EDK_TOOLS_PATH=$PWD/BaseTools
# If you are compiling for ARM, then this is needed
Line 51:
# Run this no matter what you are compiling for
source edksetup.sh
</syntaxhighlight>
The last step generates various configuration files and sets up some variables. Note that edksetup.sh must be sourced, as its variables must persist.
Now we need to build the base tools
<
make -C BaseTools
</syntaxhighlight>
And lastly, we must actually build EDK2 using its Python build script.
<
build -a YOUR_ARCH -t GCC5 -p YOUR_PACKAGE
</syntaxhighlight>
YOUR_ARCH can be IA32, X64, AARCH64, ARM, or RISCV64. Note that not all packages compile for all architectures. YOUR_PACKAGE must point to a package in the source tree. Further guides in this article will tell you what -p option to pass to EDK2's build script
===Building with edk2-platforms===
Line 66:
First, we need to create our workspace folder
<
mkdir edk2 && cd edk2
export WORKSPACE=$PWD
</syntaxhighlight>
Now we need to clone the source to all repos. edk2-non-osi is optional depending on the platform you are building for, but I would recommend downloading it anyway
<
git clone https://github.com/tianocore/edk2.git -b"stable/202011"
git clone https://github.com/tianocore/edk2-platforms.git
Line 77:
cd edk2 && git submodule update --init
cd ../edk2-platforms && git submodule update --init && cd ..
</syntaxhighlight>
We need to let EDK2's build system know where these folders are. We'll also setup a couple other variables as well
<
export EDK_TOOLS_PATH="$PWD/BaseTools"
export PACKAGES_PATH="$PWD/edk2:$PWD/edk2-platforms:$PWD/edk2-non-osi"
</syntaxhighlight>
We now must setup the environment now
<
. edk2/edksetup.sh
make -C edk2/BaseTools
</syntaxhighlight>
After that, building is exactly like before. To build for a certain platform in edk2-platforms, simply find the relevant .dsc file.
==Building an EDK2 UEFI application==
Line 93:
First, we must create a directory that contains our application. We'll create it inside of the main EDK2 directory, like this
<
cd edk2
mkdir MyEfiApp
</syntaxhighlight>
Now, create a file named MyEfiApp.inf in the MyEfiApp directory. Give it the following contents
<
[Defines]
INF_VERSION = 1.25
Line 127:
[Pcd]
</syntaxhighlight>
Create a file called UefiMain.c in the same directory MyEfiApp.inf, and give it the following contents
<
#include <Uefi.h>
#include <Library/UefiLib.h>
Line 152:
return EFI_SUCCESS;
}
</syntaxhighlight>
Now run edksetup.sh if need be. After that, find a "Components" section MdeModulePkg/MdeModulePkg.dsc, and add this to it
<
[Components]
...
MyEfiApp/MyEfiApp.inf
</syntaxhighlight>
After that, call EDK2's build system like this to build MyEfiApp
<
build -a YOUR_ARCH -t GCC5 -p MdeModulePkg/MdeModulePkg.dsc
</syntaxhighlight>
Finally, in the folder Build/MdeModule/DEBUG_GCC5/YOUR_ARCH, there should be a file named MyEfiApp.efi.
==Building OVMF and ArmVirt==
Building OVMF and ArmVirtPkg is easy, after setting up EDK2, run the following for OVMF:
<
build -a YOUR_ARCH -t GCC5 -p OvmfPkg/OvmfPkgYOUR_ARCH.dsc
</syntaxhighlight>
YOUR_ARCH can only be IA32 or X64 for OVMF. For ArmVirtPkg, run this instead:
<
build -a YOUR_ARCH -t GCC5 -p ArmVirtPkg/ArmVirtQemu.dsc
</syntaxhighlight>
YOUR_ARCH can only be ARM or AARCH64. After this,, the firmware will be output in for OVMF Build/OvmfYOUR_ARCH/DEBUG_GCC5/FV, or for ArmVirtPkg Build/ArmVirtQemu-YOUR_ARCH/DEBUG_GCC5/FV
[[Category:UEFI]]
[[Category:Firmware]]
|