Lab Setup Linux for Ubuntu 16.04

  1. Download the UEFI Training Materials .zip (accept any security notifications)
  2. 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
  3. 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
    
  4. Create a directory “src”
    bash$ mkdir ~src
  5. From the ~.../FW folder, copy and paste folder “~.../FW/edk2” to ~src
  6. Rename or mv the directory “~src/edk2/BaseTools” to something else
    bash$ cd ~src/edk2
    bash$ mv BaseTools BaseToolsX
  7. Extract the file ~FW/edk2Linux/BaseTools.tar.gz to ~src/edk2
    bash$ cd ~src/edk2
  8. Make the BaseTools and setup the environment
    bash$ make –C BaseTools
    bash$ . edksetup.sh
  9. Open the file Conf/target.txt
    bash$ gedit Conf/target.txt
  10. Update the following:
ACTIVE_PLATFORM       = OvmfPkg/OvmfPkgX64.dsc
TARGET_ARCH           = X64
TOOL_CHAIN_TAG        = GCC5

  1. Save and Exit target.txt
  2. To build OvmfPkg Type
    bash$ build
  3. 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:

  1. Edit ~/src/edk2/tools_def.txt
  2. Find DEFINE GCC44_ALL_CC_FLAGS remove 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
  3. Save tools_def.txt
  4. Build again Type
    bash$ build


Invoke QEMU to run UEFI Shell

  1. Create a run-ovmf directory under the home directory
    bash$ cd ~
    bash$ mkdir ~run-ovmf
    bash$ cd run-ovmf
    
  2. Create a directory hda-contents to use as a hard disk image
    bash$ mkdir hda-contents
  3. Copy the OVMF.fd BIOS image created from the build to the run-ovmf directory naming it bios.bin
    bash$ cp ~/src/edk2/Build/OvmfX64/DEBUG_GCC5/FV/OVMF.fd bios.bin
  4. 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

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

End of Lab Setup for Linux