Install e2fsprogs, gmp, mpfr and gcc 4.3 from gentoo repositories (as root). Not all of these may bee needed (I did not need any of them):
~ # emerge -DuN sys-libs/glibc
~ # emerge -DuN sys-fs/e2fsprogs
~ # emerge -DuN dev-libs/gmp
~ # emerge -DuN dev-python/gmpy
~ # emerge -DuN dev-libs/mpfr
~ # emerge -DuN =sys-devel/gcc
And if you are going to be using the KVM OVMF virtual machine to test your code and also built the KVM kernel code as modules, execute the following two lines of code to install the kernel kvm code:
~ # modprobe kvm
~ # modprobe kvm-intel
Create a directory for edk2 code (from here on, as a user):
~ $ mkdir -p ~/bios
bios $ cd ~/bios
Download the edk2 source tree trunk (r12958)
bios $ svn co https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2
Set up the script files and native executables that will be used in builds:
bios $ make -C edk2/BaseTools
Set up the environment declarations and run edksetup.sh
bios $ WORKSPACE=~/bios/edk2
bios $ EDK_TOOLS_PATH=~/bios/edk2/BaseTools
bios $ cd edk2
edk2 $ ./edksetup.sh
Build the gcc cross compiler tool chains to used build .EFI files. You will need to edit mingw-gcc-build.py to fix up the sites and checksums for the source code for binutils and gcc. First the edits (as a universal diff):
--- mingw-gcc-build.py.bak 2012-01-27 15:28:25.000000000 -0600
+++ mingw-gcc-build.py 2012-01-27 15:28:25.000000000 -0600
@@ -208,10 +208,10 @@
source_files_common = {
'binutils': {
- 'url': 'http://www.kernel.org/pub/linux/devel/binutils/' + \
+ 'url': 'http://ftp.gnu.org/gnu/binutils/' + \
'binutils-$version.tar.bz2',
- 'version': '2.20.51.0.5',
- 'md5': '6d2de7cdf7a8389e70b124e3d73b4d37',
+ 'version': '2.22',
+ 'md5': 'ee0f10756c84979622b992a4a61ea3f5',
},
}
Now enter these commands to build a gcc 4.3 cross compiler:
edk2 $ cd BaseTools/gcc
gcc $ sudo ./mingw-gcc-build.py --arch x64
gcc $ cd ../..
Edit Conf/target.txt
ACTIVE_PLATFORM = Nt32Pkg/Nt32Pkg.dsc
TOOL_CHAIN_TAG = MYTOOLS
TARGET_ARCH = IA32
to
ACTIVE_PLATFORM = MdeModulePkg/MdeModulePkg.dsc
TOOL_CHAIN_TAG = GCC46
TARGET_ARCH = IA32 X64
[Note that the GCC version on your system can be 4.3, 4.4, 4.5 or 4.6 and the corresponding values for TOOL_CHAIN_TAG should be GCC42, GCC44, GCC45 or GCC46. Use "gcc --version" to display the version information.]
[Note that you may get errors building gcc 4.3. I worked around this by downloading and installing (following the INSTALL file directions) mpfr 3.1.0 from the mpfr web site. Then the mingw-gcc-build.py file ran without a hitch.]
Now, build the MdeModulePkg to make sure everything is working.
edk2 $ build
This shoudl create a complete set of 32-bit and 64-bit EFI files for the applications from MdeModulePkg in bios/edk2/Build/MdeModule/Debug_GCC46/IA32 and bios/edk2/Build/MdeModule/Debug_GCC46/X64.
As a final test, build the OVMF target.
edk2 $ build -p OvmfPkg/OvmfPkgIa32X64.dsc
If successful, this will build an image located at:
Then execute the following commands to set up the OVMF runtime environment:
edk2 $ cd ..
bios $ mkdir run-ovmf
bios $ cd run-ovmf
run-ovmf $ ln -s ~/bios/edk2/Build/Ovmf3264/DEBUG_GCC46/FV/OVMF.fd bios.bin
run-ovmf $ ln -s ~/bios/edk2/Build/Ovmf3264/DEBUG_GCC46/FV/OvmfVideo.rom vgabios-cirrus.bin
run-ovmf $ mkdir hda-contents
run-ovmf $ qemu-system-x86_64 -L . -hda fat:hda-contents
run-ovmf $ ln -s ~/bios/edk2/Build/MdeModule/DEBUG_GCC46/X64/HelloWorld.efi hda-contents/HelloWorld.efi
You can use 'cp' to copy the files in the instructions above, but by using symbolic links, while you are debugging the code you are writing, each build is 'magically' already there in the QEMU simulated drive, so you don't need to copy it over again. Later, after editing your source code in MdeModulePkg, you just need to execute the following commands to update your executables and start the next test:
~ $ cd ~/bios/edk2
~ edk2 $ build
~ edk2 $ qemu-system-x86_64 -L ../run-ovmf -hda fat:../run-ovmf/hda-contents