-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is the UEFI firmware for Raspberry Pi 4 implemented by tianocore. This allows raspbberrypi runs almost any OS with proper drivers, even Windows. However, it has some limitations, devices such as V3D Core and GPIO are not available currently, you can see its upstream for more info. We have disabled the 3GB limit by default because our kernel linux-aarch64 is new enough(>=5.8). This will allow OS uses full RAM on the models have RAM larger than 3GB. Signed-off-by: zhanghua000 <[email protected]>
- Loading branch information
1 parent
8446892
commit eded6bc
Showing
7 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.cer | ||
*.bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[Trigger] | ||
Type = File | ||
Operation = Install | ||
Operation = Upgrade | ||
Target = boot/Image | ||
Target = boot/Image.gz | ||
Target = boot/RPI_EFI.fd | ||
|
||
[Action] | ||
Description = Copying kernel binaries... | ||
When = PostTransaction | ||
Exec = /usr/share/libalpm/scripts/post-install-uefi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[Trigger] | ||
Type = File | ||
Operation = Remove | ||
Target = boot/RPI_EFI.fd | ||
|
||
[Action] | ||
Description = Removing copied files for UEFI... | ||
When = PreTransaction | ||
Exec = /usr/share/libalpm/scripts/pre-remove-uefi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
|
||
buildarch=8 # aarch64 | ||
|
||
pkgname="uefi-raspberrypi4" | ||
pkgver=1.33.r1.g02bc9ce | ||
pkgrel=1 | ||
backup=("boot/config.txt") | ||
pkgdesc="UEFI firmware for RaspberryPi 4B" | ||
url="https://github.com/pftf/RPi4" | ||
arch=("aarch64") | ||
license=("custom:BSD-2-Clause-Patent") | ||
makedepends=("git" "acpica" "openssl" "util-linux" "python" "clang" "llvm" "lld") | ||
source=( | ||
"git+https://github.com/pftf/RPi4" | ||
"ms_kek.cer::https://go.microsoft.com/fwlink/?LinkId=321185" | ||
"ms_db1.cer::https://go.microsoft.com/fwlink/?linkid=321192" | ||
"ms_db2.cer::https://go.microsoft.com/fwlink/?linkid=321194" | ||
"arm64_dbx.bin::https://uefi.org/sites/default/files/resources/dbxupdate_arm64.bin" | ||
"build.sh" | ||
"70-post-install-uefi.hook" | ||
"80-pre-remove-uefi.hook" | ||
"post-install-uefi" | ||
"pre-remove-uefi" | ||
) | ||
sha256sums=('SKIP' | ||
'a1117f516a32cefcba3f2d1ace10a87972fd6bbe8fe0d0b996e09e65d802a503' | ||
'e8e95f0733a55e8bad7be0a1413ee23c51fcea64b3c8fa6a786935fddcc71961' | ||
'48e99b991f57fc52f76149599bff0a58c47154229b9f8d603ac40d3500248507' | ||
'f42c187f8b01b497f81fb0459164b27d16ca2af0b95c7331a82c1a27a731a885' | ||
'b36edc417b1061ba926934f9e16bd2d35723e3db69b7879e854f4a8339cf45bf' | ||
'8e55eb4afdd6b572d2413e87b64219d2f9d3bd033de2dfd37e176e92d25d5821' | ||
'caa86b22a1452d8974e7bbecbb6d9fb591a58da928a06d5e13cee9592e785b12' | ||
'02a799c12e818c6a177df4a5c52454d177f3c8cea11584fcc19e392f08c7418c' | ||
'4052d07f78e0230406c311aab5dcd153c111fb72024d4afa33f2ea019eeb3a6a') | ||
|
||
pkgver(){ | ||
cd "${srcdir}/RPi4" | ||
git describe --tags | sed "s/v//;s/-/.r/;s/-/./g" | ||
} | ||
prepare(){ | ||
cd "${srcdir}/RPi4" | ||
git submodule update --init --recursive | ||
mkdir -p keys | ||
cp "${srcdir}"/{ms_kek.cer,ms_db1.cer,ms_db2.cer,arm64_dbx.bin} keys/ | ||
openssl req -new -x509 -newkey rsa:2048 -subj "/CN=Raspberry Pi Platform Key/" -keyout /dev/null -outform DER -out keys/pk.cer -days 7300 -nodes -sha256 | ||
cp "${srcdir}/build.sh" build.sh | ||
patch --binary -d edk2 -p1 -i ../0001-MdeModulePkg-UefiBootManagerLib-Signal-ReadyToBoot-o.patch | ||
patch --binary -d edk2-platforms -p1 -i ../0002-Check-for-Boot-Discovery-Policy-change.patch | ||
} | ||
build(){ | ||
cd "${srcdir}/RPi4" | ||
sed -i "s/%FIRMVER%/${pkgver}-${pkgrel}/g" build.sh | ||
MAKEFLAGS= make -C edk2/BaseTools CXX=llvm | ||
bash build.sh | ||
} | ||
package(){ | ||
conflicts=("uboot-raspberrypi") | ||
depends=("raspberrypi-overlays" "linux-aarch64>=5.8" "raspberrypi-bootloader") | ||
optdepends=( | ||
"firmware-raspberrypi: firmware for RaspberryPi 4B" | ||
"linux-firmware: firmware for RaspberryPi 4B") | ||
|
||
install -Dm644 "${srcdir}/RPi4/Build/RPi4/RELEASE_CLANG38/FV/RPI_EFI.fd" "${pkgdir}/boot/RPI_EFI.fd" | ||
install -Dm644 "${srcdir}/RPi4/config.txt" "${pkgdir}/boot/config.txt" | ||
install -Dm644 "${srcdir}/RPi4/License.txt" "${pkgdir}/usr/share/licenses/${pkgname}/License.txt" | ||
install -Dm644 "${srcdir}/70-post-install-uefi.hook" "${pkgdir}/usr/share/libalpm/hooks/70-post-install-uefi.hook" | ||
install -Dm644 "${srcdir}/80-pre-remove-uefi.hook" "${pkgdir}/usr/share/libalpm/hooks/80-pre-remove-uefi.hook" | ||
install -Dm755 "${srcdir}/post-install-uefi" "${pkgdir}/usr/share/libalpm/scripts/post-install-uefi" | ||
install -Dm755 "${srcdir}/pre-remove-uefi" "${pkgdir}/usr/share/libalpm/scripts/pre-remove-uefi" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
export WORKSPACE=$PWD | ||
export PACKAGES_PATH=$WORKSPACE/edk2:$WORKSPACE/edk2-platforms:$WORKSPACE/edk2-non-osi | ||
export CLANG38_AARCH64_PREFIX=llvm- | ||
export BUILD_FLAGS="-D SECURE_BOOT_ENABLE=TRUE -D INCLUDE_TFTP_COMMAND=TRUE -D NETWORK_ISCSI_ENABLE=TRUE -D SMC_PCI_SUPPORT=1" | ||
export DEFAULT_KEYS="-D DEFAULT_KEYS=TRUE -D PK_DEFAULT_FILE=$WORKSPACE/keys/pk.cer -D KEK_DEFAULT_FILE1=$WORKSPACE/keys/ms_kek.cer -D DB_DEFAULT_FILE1=$WORKSPACE/keys/ms_db1.cer -D DB_DEFAULT_FILE2=$WORKSPACE/keys/ms_db2.cer -D DBX_DEFAULT_FILE1=$WORKSPACE/keys/arm64_dbx.bin" | ||
source edk2/edksetup.sh | ||
# EDK2's 'build' command doesn't play nice with spaces in environmnent variables, so we can't move the PCDs there... | ||
build -a AARCH64 -t CLANG38 -p edk2-platforms/Platform/RaspberryPi/RPi4/RPi4.dsc -b RELEASE -n $(nproc) --pcd gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor=L"https://github.com/pftf/RPi4" --pcd gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString=L"UEFI Firmware %FIRMVER%" --pcd gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB=0 ${BUILD_FLAGS} ${DEFAULT_KEYS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "Copying /boot/Image to /boot/vmlinux-linux..." | ||
cp /boot/Image /boot/vmlinux-linux | ||
echo "Copying /boot/Image.gz to /boot/vmlinuz-linux..." | ||
cp /boot/Image.gz /boot/vmlinuz-linux | ||
echo "Copying device tree from kernel..." | ||
cp /boot/dtbs/broadcom/bcm2711-rpi-4-b.dtb /boot/bcm2711-rpi-4-b.dtb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "Removing /boot/vmlinux-linux..." | ||
rm -f /boot/vmlinux-linux | ||
echo "Removing /boot/vmlinuz-linux..." | ||
rm -f /boot/vmlinuz-linux | ||
echo "Removing /boot/bcm2711-rpi-4-b" | ||
rm -f /boot/bcm2711-rpi-4-b.dtb |