Skip to content

Common instructions

Brian Richardson edited this page Feb 28, 2017 · 13 revisions

Common instructions for Linux

A significant portion of the steps are common on the various UNIX-like platforms. You should start with the instructions for the operating system that most closely matches your platform, and it will direct you here at the appropriate time.

Get the edk2 source tree using Git

bash$ mkdir ~/src
bash$ cd ~/src
bash$ git clone https://github.com/tianocore/edk2

Compile build tools

bash$ cd ~/src/edk2
bash$ make -C BaseTools
bash$ . edksetup.sh

When the above steps are done, you can work in the edk2 directory for code development.

For FatPkg Developers (optional)

  • Create a workspace directory
  • Change to the workspace directory
  • Clone the EDK II project repository
  • Clone the edk2-FatPkg repository to “FatPkg”
  • Build the tools
    • make -C edk2/BaseTools
  • Set environment variables
    • WORKSPACE – The workspace directory created above
    • PACKAGES_PATH – Set it to $WORKSPACE/edk2
Example:
  export WORKSPACE=/Sample/Path
  export PACKAGES_PATH=$WORKSPACE/edk2
  • Run the edksetup.sh script
    • . edk2/edksetup.sh
When the above steps are done, the directory structure will look like:
  Sample
    └───Path (WORKSPACE)
       ├───edk2
       └───FatPkg

Modify Conf Files

Running edksetup.sh populates the edk2/Conf directory with default configuration files. You will need to edit the Conf/target.txt file to set the build platform, target architecture, tool chain, and multi-threading options. The example below is based on building the MdeModulePkg using GCC5.

Set Build Target Information

For the Conf/target.txt file, find the following lines:

ACTIVE_PLATFORM       = Nt32Pkg/Nt32Pkg.dsc
TOOL_CHAIN_TAG        = MYTOOLS

And change the corresponding lines to match these:

ACTIVE_PLATFORM       = MdeModulePkg/MdeModulePkg.dsc
TOOL_CHAIN_TAG        = GCC5
Note: The gcc --version command can be used to find out your GCC version. Use the GCC45 toolchain for gcc 4.5.* and the GCC46 toolchain for gcc 4.6.*.
Note: for GCC5 please install the gcc-5 package. Example for Ubuntu: sudo apt-get install gcc-5
Locate the TARGET_ARCH setting:
TARGET_ARCH           = IA32

Change this reflect the build architecture for the final UEFI binary.

Example: X64, IA32 X64 (which will build both architectures).
Optional: enable multi-threaded build. The default value for MAX_CONCURRENT_THREAD_NUMBER is 1, which disables multi-threaded build. Change this value based on your system's multi-threading capabilities. The formula is '1 + (2 x processor threads)'.
Example: for an Intel Core i5 (two processor cores w/ hyperthreading), the value is 9.

Build Hello World! (and the rest of MdeModulePkg)

Now you should be able to simply run the build command to compile MdeModulePkg.

bash$ build

One result of the build is that you should have the HelloWorld UEFI application:

bash$ ls Build/MdeModule/DEBUG_*/*/HelloWorld.efi

Build OVMF

Once your build environment is set up you might be interested in building the OVMF platform which is included in the main EDK II source tree. Since OVMF builds a full system firmware image this may be of interest to UEFI system firmware developers.

Clone this wiki locally