Emulating a arm32 UEFI device is useful for developing Linux and debugging it.
In the GDB Debugging page you can find instructions on how to compile Linux for this virtual machine.
Run the following commands to install the required packages.
sudo apt install python python3 python3-distutilssudo apt install gcc-arm-none-eabisudo apt install uuid-devsudo apt install build-essentialsudo apt install bisonsudo apt install flex
You will need other stuff too, but that is probably already installed. (e.g. git)
You need the source code of edk2 and acpica.
# Go to the directory you want to work inexport WORKSPACE=$PWD# Download edk2 and acpicagit clone https://github.com/acpica/acpica.gitgit clone https://github.com/tianocore/edk2.git# Download submodulescd edk2git submodule update --initcd ..
Go to your source directory and run the following commands.
# Compile acpica toolsmake -C $WORKSPACE/acpica -j$(nproc)# Set environment variablesexport GCC5_ARM_PREFIX=arm-none-eabi-export IASL_PREFIX=$WORKSPACE/acpica/generate/unix/bin/export PYTHON_COMMAND=/usr/bin/python3# Configure the edk2 environmentsource edk2/edksetup.sh# Compile edk2 BaseToolsmake -C edk2/BaseTools -j$(nproc)# Compile OVMFbuild -a ARM -t GCC5 -p ArmVirtPkg/ArmVirtQemu.dsc -b RELEASE -j$(nproc)
Your output OVMF firmware file for qemu is
Create a directory, where you want your files to be in. Put your
QEMU_EFI.fd firmware file in this directory, compiled in the previous section. Now run the following commands to create some disk images:
rm -f flash0.img flash1.imgdd if=/dev/zero bs=1M count=64 of=flash0.imgdd if=/dev/zero bs=1M count=64 of=flash1.imgdd if=QEMU_EFI.fd bs=1M of=flash0.img conv=notrunc
Now create a directory named
boot. This will be your EFI partition. You can now easily place your EFI files in there.
To start your virtual machine run the following command, and make sure
qemu-system-arm is installed.
qemu-system-arm \-m 1024 \-cpu cortex-a15 \-M virt \-pflash flash0.img \-pflash flash1.img \-nographic \-drive \file=fat:rw:boot/ \-smp '4'
This will run qemu with 4 virtual CPU cores. They are Coretx-A15 cores. Used because it works.
The following ZIP includes all files setup in their proper location. In addition its EFI partition folder has a UEFI shell in it. To run it either execute the
run.sh file or enter the command described in Run qemu.
Links where the above compiling information is from: