I want to run this on my phone. And I want to port it by myself!
Firstly, follow this useful flowchart before proceeding forward with the porting process.
This flowchart will guide you through and help you decide if you really want to port UEFI or Windows to your device.
Thanks to Gustave Monce (@gus33000) for the original flowchart idea!
Here are some important things you need during porting:
Make sure you have everything above, then proceed to install some packages (assume you are using Arch Linux):
sudo pacman -Syu
sudo pacman -Sy git base-devel gcc aarch64-linux-gnu-binutils aarch64-linux-gnu-gcc aarch64-linux-gnu-glibc python clang llvm dtc android-tools --needed
Make sure you have everything above, then proceed to install some packages (assume you are using Ubuntu):
sudo apt update
sudo apt install build-essential uuid-dev iasl git nasm python-is-python3 gettext gcc-aarch64-linux-gnu clang llvm device-tree-compiler adb fastboot
Some files found in Android can be useful for porting:
Device tree from Android can be very useful, especially when you don’t have the schematic diagram of your device. It also describes reserved memory regions on your device which can’t be touched by the UEFI.
You can get it from:
/sys/firmware/fdt on your device. A simple copy will work.
Then decompile it on your computer:
dtc -I dtb -O dts fdt -o output.dts
It has some useful information for generating UEFI image.
You can get it either from:
Then unpack the image on your computer:
unpack_bootimg --boot_img boot.img --format info
You will see something like:
os version: 9.0.0
os patch level: 2020-09
/proc/iomem to your computer
Clone the repo and build any device to fetch submodules
git clone --recursive email@example.com:edk2-porting/edk2-msm.git
./build.sh -d DEVICECODENAME
If everything goes well, you should see something like
Build done: /path/to/boot-DEVICECODENAME.img
You should add
--skip-rootfs-genin subsequent builds. This avoids rebuilding SimpleInit and reduces build time significantly.