## page was renamed from UEFI-howto ||<>|| == Introduction == These are instructions for setting up EDK II build environment on Ubuntu, and building OVMF images for use with qemu. == Initial set up == Recent EDK2 checkouts (as of 2 Sept 2012) are known to build correctly on precise. === Install required packages === {{{sudo apt-get install build-essential git uuid-dev iasl nasm}}} === Get the latest source for EDKII === In a suitable working directory ({{{~/src/}}} in this case, but you can alter this) checkout the latest EDKII source: {{{ $ mkdir ~/src $ cd ~/src $ git clone git://github.com/tianocore/edk2.git $ cd edk2 $ git submodule update --init }}} Note, that you can choose a stable branch of edk2 before updating submodules. The following instructions assume that you remain in the {{{~/src/edk2}}} directory === Compile base tools === For MS Windows, prebuilt binaries of the base tools are shipped with the source; on Ubuntu the base tools required for building EDKII need to be built first. {{{ $ make -C BaseTools }}} === Set up build environment === You need to set EDK_TOOLS_PATH and set up the build environment by running the edksetup.sh script provided in the source. This script will copy template and configuration files to edk2/Conf directory. {{{ $ . edksetup.sh }}} === Set up build target === To set up the build target you need to modify the conf file Conf/target.txt. This will enable the firmware package to be built and set up the compiler version used. {{{ $ vi Conf/target.txt }}} Find {{{ ACTIVE_PLATFORM = Nt32Pkg/Nt32Pkg.dsc }}} and replace it with {{{ ACTIVE_PLATFORM = MdeModulePkg/MdeModulePkg.dsc }}} Find {{{ TOOL_CHAIN_TAG = MYTOOLS }}} and replace it with your version on GCC here for example GCC 4.6 will be used. {{{ TOOL_CHAIN_TAG = GCC46 }}} Find {{{ TARGET_ARCH = IA32 }}} and replace it with 'X64' for 64bit or 'IA32 X64' to build both architectures. {{{ TARGET_ARCH = X64 }}} == Building MdeModulePkg module package == This will build !MdeModulePkg and helloworld program that we can use later when we launch the UEFI shell from emulator. Just type build: {{{ $ build }}} On a Core i5 with 4GB of RAM the total build time is around two minutes. == Build a full system firmware image (OVMF) == The Open Virtual Machine Firmware (or "OVMF") can be used to enable UEFI within virtual machines. It provides libraries and drivers related to virtual machines. Currently OVMF support QEMU for emulating UEFI on IA32 and X86-64 based systems. You could also build OVMF with source level debugging enabled. === Set up build target === You can build OVMF for IA32 or X64 architechtures. In this example we will build OVMF for X64 architecture. You will need to modify Conf/target.txt and replace ACTIVE_PLATFORM with the right dsc file. {{{ $ vi Conf/target.txt }}} Find {{{ ACTIVE_PLATFORM = MdeModulePkg/MdeModulePkg.dsc }}} replace with {{{ ACTIVE_PLATFORM = OvmfPkg/OvmfPkgX64.dsc }}} This will set the Target Arch to X64, PEI code to X64 and DXE/UEFI code to X64. === Build OvmfPkg === {{{ $ build }}} On an i7 with 16GB RAM the total build time is less than 30 seconds. The firmware image produced will be located in {{{Build/OvmfX64/DEBUG_GCC46/FV/OVMF.fd}}}. If you'd like debug output on the serial console, use the {{{DEBUG_ON_SERIAL_PORT}}} option: {{{ $ build -DDEBUG_ON_SERIAL_PORT=TRUE }}} === Building OvmfPkg with Secure Boot support === If you wish to build OVMF with Secure Boot, you must follow the openssl installation instructions found in {{{CryptoPkg/Library/OpensslLib/Patch-HOWTO.txt}}}, and build with the {{{SECURE_BOOT_ENABLE}}} option: {{{ $ build -DSECURE_BOOT_ENABLE=TRUE }}} If you see an error that "the required fv image size exceeds the set fv image size" consult [[http://feishare.com/efimail/messages/20110324-1024-Re__edk2__Error_about_building_OVMF_on_Fedora_8-Bei_Guan.html|this mailing list post.]]. This issue has been fixed in recent builds. == Running UEFI in QEMU == See the [[UEFI/OVMF|OVMF]] page for running the OVMF images under qemu.