Take this article as the entry of my technical blog. It is embarrassing that the Chinese language support is broken on Ubuntu, so I may have to use English for recording purpose before it can be fixed.
(1) Dependencies of EDKII Environment
The guidance on Tianocore HomePage
`https://github.com/tianocore/tianocore.github.io/wiki/Common-instructions`
To set up the environment in Unix-like OS. Take Ubuntu 16.04LTS as host:
sudo apt-get install build-essential uuid-dev iasl git gcc-5 nasm
sudo apt-get install libuuid1=2.27.1-6ubuntu3.3 ### if any version issue
Then build the BaseTool of EDKII and setup the environment variable:
make -C BaseTools
export EDK_TOOLS_PATH=/home/ubuntu/Desktop/Tiano/edk2/BaseTools
cd .. && source edksetup.sh BaseTools
(2) Build OVMF Pkg and run with QEMU
Example of building specific module with target architecture of IA32 && X64.
Note that we pass the TPM device into QEMU with the CLI parameter.
build -p OvmfPkg/OvmfPkgIa32X64.dsc -t GCC5 -b RELEASE -a IA32 -a X64
sudo apt-get install -y qemu
qemu-img create -f qcow2 ./test.img 30G
qemu-system-x86_64 -display sdl -enable-kvm \
-m 1024 -boot c -bios Build/OVMF.fd -boot menu=on -tpmdev \
cuse-tpm,id=tpm0,path=/dev/vtpm0 \
-device tpm-tis,tpmdev=tpm0 ./test.img
Another thing to mention is that with a variant of Native GCC, the building process may crush.
/tmp/portage/sys-firmware/edk2-9999/work/Build/MdeModule/RELEASE_GCC44/X64/MdeModulePkg/Application/HelloWorld/HelloWorld/DEBUG/HelloWorld.dll unsupported ELF EM_X86_64 relocation 0x18.
GenFw: ERROR 3000: Invalid
/tmp/portage/sys-firmware/edk2-9999/work/Build/MdeModule/RELEASE_GCC44/X64/MdeModulePkg/Application/HelloWorld/HelloWorld/DEBUG/HelloWorld.dll unsupported ELF EM_X86_64 relocation 0x18.
GenFw: ERROR 3000: Invalid
if this happens, please make sure the version of your GCC is compatible (4.6 or 5). More details please see
https://sourceforge.net/p/edk2-buildtools/mailman/message/31144986/
(3) Run OVMF with QEMU
we may just assign the bios parameter to unter UEFI shell.
PS: Gnome Sreenshot shortcut of "Alt + Print Screen" is convenient the that of MacroHard.