Contents

  • Introduction and Source Code

  • Building EDKII Firmware on a Linux Host

  • Building EDKII Firmware on a Linux Host using uefi-tools

  • Building EDKII Firmware on a Windows host using Windows Subsystem for Linux

Introduction

The Tianocore EDKII project provides an implementation of UEFI firmware. This guide documents the steps to build the UEFI firmware for Arm FVP AEMv8A Models and Juno Development Platform.

Getting the Source Code

The following source repositories are required for building the UEFI firmware.

Project

Repository

Repository URL

Description 

 Tianocore

tianocore\edk2 

https://github.com/tianocore/edk2.git 

The edk2 repository contains the firmware development environment and required packages for buiding the UEFI firmware.

 Tianocore

tianocore\edk2-platforms

https://github.com/tianocore/edk2-platforms.git

The edk2-platforms repository contains the platform workspace and associated modules.

 ACPICA

acpica\acpica

https://github.com/acpica/acpica.git

The ACPI Component Architecture (ACPICA) tools provide an open-source implementation of the iASL compiler. 

Setting up the workspace

The first step towards building an edk2 image is to create a working directory.

  1. Launch a terminal window.
  2. Create a workspace folder on your development PC called 'source'.
  3. Set the WORKSPACE environment variable to point to this folder.

Example:

On a bash shell:

cd <Directory where you want to work>
mkdir source
cd source
export WORKSPACE=$PWD 

Cloning the source code repositories

Note: To clone the repositories you need 'git' to be installed on your development PC (see the Development Tools)

In the terminal window, change directory to your workspace ('source') folder and run the following commands.

git clone --recursive https://github.com/tianocore/edk2.git
git clone https://github.com/tianocore/edk2-platforms.git
git clone https://github.com/acpica/acpica.git

Building EDKII Firmware on a Linux host

Prerequisites

Check the Ubuntu version by typing the following in the terminal window.

$ uname -srvmpio
Linux 4.18.0-15-generic #16~18.04.1-Ubuntu SMP Thu Feb 7 14:06:04 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

 

Development Tools

The following development tools must be installed on the development PC.

Tool Description Install Instruction
Python 2.7 OR Python 2.3 Python interpreter. Python 2.7

$ sudo apt install python
$ python -V
Python 2.7.15rc1

Python 3

$ sudo apt install python3 python3-distutils

Git  Git source control tool.  

$ sudo apt install git
$ git --version
git version 2.17.1

 uuid-dev  Required for including uuid/uuid.h  $ sudo apt install uuid-dev
 build-essential  This package installs make, gcc, g++ etc.  

$ sudo apt install build-essential
$ make -v
GNU Make 4.1
$ gcc --version
gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
$ g++ --version
g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0

 bison  A parser generator required by acpica tools. $ sudo apt install bison
 flex  A fast lexical analyzer generator required by acpica tools.
 $ sudo apt install flex

Setting up the development tools

Install the required development tools by running the following commands in the terminal window.

$ sudo apt install bison build-essential flex git uuid-dev

Python 2.7 or Python 3

$ sudo apt install <python | python3 python3-distutils>

 
Arm cross compiler toolchain

The Arm toolchain to cross compile from x86_64-linux to aarch64-elf is available at: GNU Downloads

Select the latest toolchain to match the development PC architecture and the select the little-endian 'AArch64 ELF bare-metal target (aarch64-elf)' GCC cross compiler.

Example: For a x86_64 development PC, download gcc-arm-8.2-2019.01-x86_64-aarch64-elf.tar.xz

Create a folder called 'toolchain' under the workspace folder. e.g. source\toolchain and extract the toolchain to this folder.

$ mkdir $WORKSPACE/toolchain
$ cd $WORKSPACE/toolchain
$ wget https://developer.arm.com/-/media/Files/downloads/gnu-a/8.2-2019.01/gcc-arm-8.2-2019.01-x86_64-aarch64-elf.tar.xz
$ tar xf gcc-arm-8.2-2019.01-x86_64-aarch64-elf.tar.xz

Build the acpica tools

The acpica tools implement the latest iAsl compiler. To build the acpica tools run the following commands in the terminal window.

$ cd $WORKSPACE
$ make -C $WORKSPACE/acpica

Building edk2 firmware

To build the firmware image, follow the steps below and run the commands in the terminal window.

1. Setup up the environment variables.

$ export GCC5_AARCH64_PREFIX=$WORKSPACE/toolchain/gcc-arm-8.2-2019.01-x86_64-aarch64-elf/bin/aarch64-elf-
$ export PACKAGES_PATH=$WORKSPACE/edk2:$WORKSPACE/edk2-platforms
$ export IASL_PREFIX=$WORKSPACE/acpica/generate/unix/bin/

       Select the python version you wish to use and set the PYTHON_COMMAND environment variable.

For Python 2.7:

$ export PYTHON_COMMAND=/usr/bin/python

For Python 3:

$ export PYTHON_COMMAND=/usr/bin/python3

2. Configure the edk2 development environment by running the edk2setup bash script.

$ source edk2/edksetup.sh

3. Build the BaseTools.

$ make -C edk2/BaseTools

Build the firmware for Arm FVP AEMv8A Model platform

Run the following command to build the firmware for FVP AEMv8A platform.

$ build -a AARCH64 -t GCC5 -p Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc -b DEBUG

$ build -a AARCH64 -t GCC5 -p Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc -b RELEASE

The firmware binaries can be found at the following location:

$WORKSPACE/Build/ArmVExpress-FVP-AArch64/<DEBUG|RELEASE>_GCC5/FV/FVP_AARCH64_EFI.fd

Build the firmware for Arm Juno platform

Run the following command to build the firmware for Arm Juno platform.

$ build -a AARCH64 -t GCC5 -p Platform/ARM/JunoPkg/ArmJuno.dsc -b DEBUG

$ build -a AARCH64 -t GCC5 -p Platform/ARM/JunoPkg/ArmJuno.dsc -b RELEASE

The firmware binaries can be found at the following location:

$ WORKSPACE/Build/ArmJuno/<DEBUG|RELEASE>_GCC5/FV/BL33_AP_UEFI.fd

Building EDKII Firmware on a Linux host using uefi-tools

Linaro provides a set of useful tools/scripts to build the tianocore\edk2 UEFI firmware on a Linux development PC.

The following sections outline the additional steps required for building firmware using the uefi-tools from Linaro. 

Cloning the uefi-tools source code repository

In a terminal window, change directory to your workspace ('source') folder and run the following commands.

$ git clone https://git.linaro.org/uefi/uefi-tools.git

Prerequisites

Development Tools

Setting up the development tools

The scripts in the uefi-tools package require Python 2.7 while edk2 defaults to use Python3.

Install Python 2.7 & Python 3 by running the following command

$ sudo apt install python python3 python3-distutils

Arm cross compiler toolchain

The uefi-tools use the gcc-aarch64-linux-gnu toolchain. Install the toolchain by running the following command.

$ sudo apt install gcc-aarch64-linux-gnu

Install the acpica tools

The uefi-tools use the the iAsl compiler that is packaged with the acpica-tools. Install the acpica-tools by running the following command.

$ sudo apt install acpica-tools

Building edk2 firmware

To build the firmware image, follow the steps below.

Launch a terminal window and change directory to the workspace folder.

$ cd $WORKSPACE

Build the firmware for Arm FVP AEMv8A Model platform

Run the following command to build the firmware for FVP AEMv8A platform.

$ ./uefi-tools/edk2-build.sh -b DEBUG fvp -v

$ ./uefi-tools/edk2-build.sh -b RELEASE fvp -v

The UEFI binary is available at:

$WORKSPACE/Build/ArmVExpress-FVP-AArch64/<DEBUG|RELEASE>_GCC5/FV/BL33_AP_UEFI.fd

Build the firmware for Arm Juno platform

Run the following command to build the firmware for Arm Juno platform.

$ ./uefi-tools/edk2-build.sh -b DEBUG juno -v

$ ./uefi-tools/edk2-build.sh -b RELEASE juno -v

The UEFI binary is available at:

$WORKSPACE/Build/ArmJuno/<DEBUG|RELEASE>_GCC5/FV/BL33_AP_UEFI.fd

Note: The uefi-tools have additional options that can be provided for building firmware. To view these additional options type the following command in a terminal window.

$ ./uefi-tools/edk2-build.sh -h

    Building EDKII Firmware on a Windows host using Windows Subsystem for Linux (WSL)

    The instructions for building the firmware using WSL are similar to that for a Linux host. The prerequisites for setting up the Windows Subsystem for Linux environment are listed below.

    Prerequisites

    Check the Ubuntu version by typing the following on the console.

    $ uname -srvmpio
    Linux 4.4.0-17763-Microsoft #253-Microsoft Mon Dec 31 17:49:00 PST 2018 x86_64 x86_64 x86_64 GNU/Linux

    The remaining instructions for installing the development tools, configuring the development environment and building the firmware are exactly similar to that for a Linux host.