Skip to content

Commit

Permalink
feat: initial release
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Riegler <[email protected]>
  • Loading branch information
xvzf committed Jan 5, 2024
1 parent a993504 commit c85c122
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 206 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Readme.md
Makefile
.github/
.git/
.git*
dist
dist.zip
out/
31 changes: 31 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build and Release

on:
push:
tags:
- '*'


jobs:
release:
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build
run: make dist
- uses: sigstore/[email protected]
with:
inputs: dist.zip
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist.zip*
file_glob: true
tag: ${{ github.ref }}
overwrite: true
107 changes: 0 additions & 107 deletions .github/workflows/linux_edk2.yml

This file was deleted.

15 changes: 15 additions & 0 deletions 0003-No3GbMemLimit.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
index e04c764..63b400c 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -511,8 +511,8 @@
#
# Supporting > 3GB of memory.
#
- gRaspberryPiTokenSpaceGuid.PcdRamMoreThan3GB|L"RamMoreThan3GB"|gConfigDxeFormSetGuid|0x0|0
- gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB|L"RamLimitTo3GB"|gConfigDxeFormSetGuid|0x0|1
+ gRaspberryPiTokenSpaceGuid.PcdRamMoreThan3GB|L"RamMoreThan3GB"|gConfigDxeFormSetGuid|0x0|1
+ gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB|L"RamLimitTo3GB"|gConfigDxeFormSetGuid|0x0|0

#
# Device Tree and ACPI selection.
13 changes: 13 additions & 0 deletions 0004-systemtable-devicetree.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
index e04c764..6b64c7a 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -521,7 +521,7 @@
# 1 - SYSTEM_TABLE_MODE_BOTH
# 2 - SYSTEM_TABLE_MODE_DT
#
- gRaspberryPiTokenSpaceGuid.PcdSystemTableMode|L"SystemTableMode"|gConfigDxeFormSetGuid|0x0|0
+ gRaspberryPiTokenSpaceGuid.PcdSystemTableMode|L"SystemTableMode"|gConfigDxeFormSetGuid|0x0|2

#
# Enable a fan in the ACPI thermal zone on GPIO pin #
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
FROM ubuntu:22.04 AS builder

ARG VERSION=dev
ENV VERSION=${VERSION}

RUN apt-get update && apt-get install -y \
build-essential \
Expand All @@ -19,7 +17,11 @@ COPY . .

RUN patch --binary -d edk2 -p1 -i ../0001-MdeModulePkg-UefiBootManagerLib-Signal-ReadyToBoot-o.patch
RUN patch --binary -d edk2-platforms -p1 -i ../0002-Check-for-Boot-Discovery-Policy-change.patch
RUN patch --binary -d edk2-platforms -p1 -i ../0003-No3GbMemLimit.patch
RUN patch --binary -d edk2-platforms -p1 -i ../0004-systemtable-devicetree.patch

ARG VERSION=dev
ENV VERSION=${VERSION}
ENV WORKSPACE=/build
ENV PACKAGES_PATH=$WORKSPACE/edk2:$WORKSPACE/edk2-platforms:$WORKSPACE/edk2-non-osi
ENV GCC5_AARCH64_PREFIX=aarch64-linux-gnu-
Expand Down
110 changes: 14 additions & 96 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,102 +1,20 @@
Raspberry Pi 4 UEFI Firmware Images
===================================
# ComputeBlade/CM4 optimized UEFI Firmware Images
> [!CAUTION]
> ** THE CONFIGURATION IS PROBABLY NOT SANE FOR ALL USERS **
[![Build status](https://img.shields.io/github/actions/workflow/status/pftf/RPi4/linux_edk2.yml?style=flat-square)](https://github.com/pftf/RPi4/actions)
[![Github stats](https://img.shields.io/github/downloads/pftf/RPi4/total.svg?style=flat-square)](https://github.com/pftf/RPi4/releases)
[![Release](https://img.shields.io/github/release-pre/pftf/RPi4?style=flat-square)](https://github.com/pftf/RPi4/releases)
This is a fork of the amazing [pftf/RPi4](https://github.com/pftf/RPi4) project, which brings a UEFI images for the RaspberryPi 4 Model B.

# Summary
# Adaptations compared to the pftf/RPi4 proejct

This repository contains installable builds of the official
[EDK2 Raspberry Pi 4 UEFI firmware](https://github.com/tianocore/edk2-platforms/tree/master/Platform/RaspberryPi/RPi4).
## Ease of use improvements
- Allow easy local builds using `make dist`

# Initial Notice
## Firmware specific configuration
- Configure features for the [ComputeBlade](http://computeblade.com)
- **Disable SD Card** (avoids modifying the UEFI image from the operating system)
- Additional device-tree overlays

__PLEASE READ THE FOLLOWING:__
🔻🔻🔻🔻🔻🔻🔻🔻🔻

* Ethernet networking support in Linux requires a recent enough kernel (version 5.7 or
later)

* SD or wireless support in Linux also requires a recent enough kernel (version 5.12 or
later).
Still, your mileage may vary as to whether these peripherals will actually be usable.

* Many drivers (GPIO, VPU, etc) are still likely to be missing from your OS, and will
have to be provided by a third party. Please do not ask for them here, as they fall
outside of the scope of this project.

* A 3 GB RAM limit is enforced __by default__, even if you are using a Raspberry Pi 4
model that has 4 GB or 8 GB of RAM, on account that the OS **must** patch DMA access,
to work around a hardware bug that is present in the Broadcom SoC.
For Linux this usually translates to using a recent kernel (version 5.8 or later) and
for Windows this requires the installation of a filter driver.
If you are running an OS that has been adequately patched, you can disable the 3 GB
limit by going to `Device Manager``Raspberry Pi Configuration``Advanced Settings`
in the UEFI settings.

* This firmware is built from the
[official EDK2 repository](https://github.com/tianocore/edk2-platforms/tree/master/Platform/RaspberryPi/RPi4),
with the following extra patch applied:
* `0001-MdeModulePkg-UefiBootManagerLib-Signal-ReadyToBoot-o.patch`, so that the
Graphical console is set as default.

🔺🔺🔺🔺🔺🔺🔺🔺🔺

# Installation

* Download the latest archive from the [Releases](https://github.com/pftf/RPi4/releases)
repository.

* Create an SD card or a USB drive, with at least one partition (it can be a regular
partition or an [ESP](https://en.wikipedia.org/wiki/EFI_system_partition)) and format
it to FAT16 or FAT32.

__Note:__ Booting from USB or from ESP requires a recent-enough version of the Pi
EEPROM (as well as a recent version of the UEFI firmware). If you are using the latest
UEFI firmware and find that booting from USB or from ESP doesn't work, please visit
https://github.com/raspberrypi/rpi-eeprom/releases to update your EEPROM.

* Extract all the files from the archive onto the partition you created above.
Note that outside of this `Readme.md`, which you can safely remove, you should not
change the names of the extracted files and directories.

# Usage

Insert the SD card/plug the USB drive and power up your Raspberry Pi. You should see a
multicoloured screen (which indicates that the CPU-embedded bootloader is reading the
data from the SD/USB partition) and then the Raspberry Pi black and white logo once the
UEFI firmware is ready.

At this stage, you can press <kbd>Esc</kbd> to enter the firmware setup, <kbd>F1</kbd>
to launch the UEFI Shell, or, provided you also have an UEFI bootloader on the SD
card or on a USB drive in `efi/boot/bootaa64.efi`, you can let the UEFI system run that
(which will be the default if no action is taken).

# Additional Notes

The firmware provided in the zip archive is the `RELEASE` version but you can also find
a `DEBUG` build of the firmware in the
[GitHub CI artifacts](https://github.com/pftf/RPi4/actions).

The provided firmwares should be able to auto-detect the UART being used (PL011 or mini
UART) according to whether `config.txt` contains the relevant overlay or not. The default
baudrate for serial I/O is `115200` and the console device to use under Linux is either
`/dev/ttyAMA0` when using PL011 or `/dev/ttyS0` when using miniUART.

At the moment, the published firmwares default to enforcing ACPI as well as a 3 GB RAM
limit, which is done to ensure Linux boot. These settings can be changed by going to
`Device Manager` &rarr; `Raspberry Pi Configuration` &rarr; `Advanced Configuration`.

Please visit https://rpi4-uefi.dev/ for more information.

# License

The firmware (`RPI_EFI.fd`) is licensed under the current EDK2 license, which is
[BSD-2-Clause-Patent](https://github.com/tianocore/edk2/blob/master/License.txt).

The other files from the zip archives are licensed under the terms described in the
[Raspberry Pi boot files README](https://github.com/raspberrypi/firmware/blob/master/README.md).

The binary blobs in the `firmware/` directory are licensed under the Cypress wireless driver
license that is found there.
## EDK2/UEFI specific changes
- Remove the default 3GB memory limit (**WARNING: this reduces compatibility**)
- Use device tree as system table by default (Required for exposing the PCIe bus to Linux)
3 changes: 2 additions & 1 deletion config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dtoverlay=uart5
dtoverlay=dwc2,dr_mode=host
dtoverlay=vc4-kms-v3d-pi4
dtparam=spi=on
dtparam=i2c_arm=on
dtoverlay=tpm-slb9670
dtparam=i2c_arm=on
dtoverlay=i2c-rtc,ds3231
dtparam=sd=off

0 comments on commit c85c122

Please sign in to comment.