Skip to content

Instantly share code, notes, and snippets.

@jdek
Last active February 21, 2020 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdek/92bffc4003da2a73450eeb39ca2acdcc to your computer and use it in GitHub Desktop.
Save jdek/92bffc4003da2a73450eeb39ca2acdcc to your computer and use it in GitHub Desktop.
Easily build UEFI module for the Raspberry Pi 4, also fetches fixup4.dat, start4.elf. Resulting firmware is in ./uefi/output/
[rpi4]
## enable 64bit
arm_64bit=1
enable_gic=1
## load UEFI
armstub=RPI_EFI.fd
## load device tree
# device_tree_address=0x20000
# device_tree_end=0x30000
# device_tree=bcm2711-rpi-4-b.dtb
# dtoverlay=miniuart-bt
## setup hdmi
hdmi_group=2
hdmi_mode=85
config_hdmi_boost=11
disable_overscan=1
#!/bin/bash
# Notes:
# - You need an aarch64 toolchain. Set the GCC5_AARCH64_PREFIX variable below.
function clone_git_repo
{
host=$1; user=$2; repo=$3; branch=${4:-master}
OLDPWD=$PWD
[ -d $repo/.git ] && { cd $repo && git pull; } || rm -rf $OLDPWD/$repo
cd $OLDPWD
[ -d $repo ] || SSH_ASKPASS=false git clone --recursive -b $branch git@$host:$user/$repo.git $repo < /dev/null || SSH_ASKPASS=false git clone --recursive -b $branch https://$host/$user/$repo.git $repo < /dev/null || return 1
}
mkdir -p uefi
export WORKSPACE="$PWD/uefi"
cd "$WORKSPACE"
clone_git_repo github.com tianocore edk2
clone_git_repo github.com tianocore edk2-platforms
clone_git_repo github.com tianocore edk2-non-osi
export PACKAGES_PATH=$WORKSPACE/edk2:$WORKSPACE/edk2-platforms:$WORKSPACE/edk2-non-osi
clone_git_repo github.com acpica acpica
make -C acpica
export IASL_PREFIX=$WORKSPACE/acpica/generate/unix/bin/
source edk2/edksetup.sh
make -C edk2/BaseTools
mkdir -p "$WORKSPACE/output"
cd "$WORKSPACE/output"
[ -f fixup4.dat ] || curl -LO "https://github.com/raspberrypi/firmware/raw/master/boot/fixup4.dat"
[ -f start4.elf ] || curl -LO "https://github.com/raspberrypi/firmware/raw/master/boot/start4.elf"
cd -
export GCC5_AARCH64_PREFIX=aarch64-unknown-linux-gnu-
build -n 8 -a AARCH64 -t GCC5 -p Platform/RaspberryPi/RPi4/RPi4.dsc
cp Build/RPi4/DEBUG_GCC5/FV/RPI_EFI.fd "$WORKSPACE/output/"
ls "$WORKSPACE/output"
@jdek
Copy link
Author

jdek commented Feb 21, 2020

My ESP (fat32) partition look like this:

esp/EFI/BOOT/bootaa64.efi
esp/config.txt
esp/fixup4.dat
esp/start4.elf
esp/RPI_EFI.fd

The esp/EFI/BOOT/bootaa64.efi comes from NetBSD current (as of 2020-02-21).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment