UEFI support GCC build, so we can build it under linux system. This post try to show how to build it in Ubuntu12.10(64bit). lastest UDK version by now is UDK2014, it should also work.

Prepare

  • Install required packages
sudo apt-get install build-essential git uuid-dev iasl
  • Download UDK2010 unzip to folder such as ~/src/MyWorkSpace
  • Unzip BaseTools(Unix) to this folder

GCC47 configuration

Due to my UDK version don’t have GCC47 support, and my Ubuntu12.10 use GCC47, please notice that latest UDK should already fix this, but if you meet upper GCC version lack of support like this, you can refer to this link to add support.

Complie base tools

For MS windows system, prebuilt binaries of the base tools are packaged with the source. In linux, the base tools need to be built first, without this you may meet build FAIL!

$make -C BaseTools

Build

  • set EDK_TOOLS_PATH and build environment by edksetup.sh, this script will copy template and configuration files to /Conf folder.
$. edksetup.sh
  • build package sample
Build -a X64 -p MdeModulePkg\MdeModulePkg.dsc

After this build success, your files will be in folder “Build\MdeModule\DEBUG_GCC47\X64”

Set up a Shell Emulator

By use QEMU, a 64bit UEFI shell envrionment can be used to test your UEFI app.

  • install qemu
$ sudo apt-get install qemu
  • download bios.bin which include x64 UEFI shell
  • open terminal, switch to folder which contain the bios.bin, and start up qemu by below command.the ‘-L .’ option tells qemu to look for bios.bin in current folder.
qemu-system-x86_64 -L .

  • notice that the shell emulator don’t have any HDD, you can not run your EFI applications.

  • create folder as disk, put your uefi app into the folder, load it as fs0: in emulator.below example load folder ‘hda1’ as hdd, some .efi files are in this folder

qemu-system-x86_64 -L . -hda fat:hda1

  • UEFI shell emulator and enjoy yourself

Refer

Ubuntu EDK2 wiki
Ubuntu OVMF wiki