Lab Setup Linux for Ubuntu 16.04
- Download the UEFI Training Materials .zip (accept any security notifications)
Click “Open” and Extract the file to HOME which will take a few minutes
Note: It is highly important that you unzip the file correctly to this location because all the file locations in this training guide follow that format. The Default will be in/FW/...Directory~/Lab_Material_FW/FW- Documentation
- DriverWizard
- edk2
- edk2Linux
- LabSampleCode
Install the Ubuntu Linux tools:
bash$ sudo apt-get install build-essential uuid-dev iasl git bash$ sudo apt-get install gcc-5 nasm bash$ sudo apt-get install qemu- Create a directory “src”
bash$ mkdir ~src - From the
~.../FWfolder, copy and paste folder “~.../FW/edk2” to~src - Rename or mv the directory “
~src/edk2/BaseTools” to something else
bash$ cd ~src/edk2
bash$ mv BaseTools BaseToolsX - Extract the file
~FW/edk2Linux/BaseTools.tar.gzto~src/edk2
bash$ cd ~src/edk2 - Make the BaseTools and setup the environment
bash$ make –C BaseTools
bash$ . edksetup.sh - Open the file Conf/target.txt
bash$ gedit Conf/target.txt - Update the following:
ACTIVE_PLATFORM = OvmfPkg/OvmfPkgX64.dsc
TARGET_ARCH = X64
TOOL_CHAIN_TAG = GCC5
- Save and Exit target.txt
- To build OvmfPkg Type
bash$ build - The file OVMF.fd should be in the Build directory:
~/src/edk2/Build/OvmfX64/DEBUG_GCC5/FV/OVMF.fd
Build errors
For build errors the Build option for GCC5 may need to be updated:
- Edit ~/src/edk2/tools_def.txt
- Find
DEFINE GCC44_ALL_CC_FLAGSremove the "-Werror" flag because it will treat warnings as errors.
DEFINE GCC44_ALL_CC_FLAGS = -g -fshort-wchar -fno-builtin -fno-strict-aliasing -Wall -Wno-array-bounds -ffunction-sections -fdata-sections -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings - Save tools_def.txt
- Build again Type
bash$ build
Invoke QEMU to run UEFI Shell
- Create a run-ovmf directory under the home directory
bash$ cd ~ bash$ mkdir ~run-ovmf bash$ cd run-ovmf - Create a directory hda-contents to use as a hard disk image
bash$ mkdir hda-contents - Copy the
OVMF.fdBIOS image created from thebuildto the run-ovmf directory naming itbios.bin
bash$ cp ~/src/edk2/Build/OvmfX64/DEBUG_GCC5/FV/OVMF.fd bios.bin - Create a Linux shell script to run the QEMU from the run-ovmf directory
bash$ gedit RunQemu.sh
Add the following:
qemu-system-x86_64 -pflash bios.bin -hda fat:rw:hda-contents -net none -debugcon file:debug.log -global isa-debugcon.iobase=0x402

- Save RunQemu.sh and exit
- Run the RunQemu.sh Linux Shell Script:
bash$ . RunQemu.sh