Skip to content

Commit

Permalink
Platform/RPi4: Allocate more space for UEFI image
Browse files Browse the repository at this point in the history
The Pi's UEFI image was sized without thought for much future growth,
and its become apparent that its largely outgrown the allocated space
when various debug options or edk2 features are enabled. Since these
images tend to exist on disks which are usually in the GB+ ranges
doubling the size of the RPI_EFI.fd image shouldn't be a problem.

This change must be accompanied by build edk2-non-osi changes to TFA
which update the RPI3_PRELOADED_DTB_BASE=0x3e0000 and config.txt
changes as documented in the README being patched.

Since we are adjusting the image size, lets also increase the DTB
reservation to 128K and reserve a 64k block for future PCC channel
data structures that are shared between TFA and ACPI as well
immediately before the DTB.

Signed-off-by: Jeremy Linton <[email protected]>
  • Loading branch information
jlintonarm authored and leiflindholm committed Sep 24, 2024
1 parent 6947602 commit 991b802
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
13 changes: 9 additions & 4 deletions Platform/RaspberryPi/RPi4/RPi4.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@
gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|1
gEfiMdePkgTokenSpaceGuid.PcdPostCodePropertyMask|0
gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|320
#
# Follows right after the FD image. (bump the size again)
#
gRaspberryPiTokenSpaceGuid.PcdFdtBaseAddress|0x003e0000


# DEBUG_ASSERT_ENABLED 0x01
# DEBUG_PRINT_ENABLED 0x02
Expand Down Expand Up @@ -397,14 +402,14 @@
gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x04000000
#
# 0x00000000 - 0x001F0000 FD (PcdFdBaseAddress, PcdFdSize)
# 0x001F0000 - 0x00200000 DTB (PcdFdtBaseAddress, PcdFdtSize)
# 0x00200000 - ... RAM (PcdSystemMemoryBase, PcdSystemMemorySize)
# 0x003E0000 - 0x00400000 DTB (PcdFdtBaseAddress, PcdFdtSize)
# 0x00400000 - ... RAM (PcdSystemMemoryBase, PcdSystemMemorySize)
#
# This matches PcdFvBaseAddress, since everything less is the FD, and
# will be reserved away.
#
gArmTokenSpaceGuid.PcdSystemMemoryBase|0x00200000
gArmTokenSpaceGuid.PcdSystemMemorySize|0x3fe00000
gArmTokenSpaceGuid.PcdSystemMemoryBase|0x00400000
gArmTokenSpaceGuid.PcdSystemMemorySize|0x3fc00000

#
# Device specific addresses
Expand Down
20 changes: 12 additions & 8 deletions Platform/RaspberryPi/RPi4/RPi4.fdf
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

[FD.RPI_EFI]
BaseAddress = 0x00000000|gArmTokenSpaceGuid.PcdFdBaseAddress
Size = 0x001f0000|gArmTokenSpaceGuid.PcdFdSize
Size = 0x003e0000|gArmTokenSpaceGuid.PcdFdSize
ErasePolarity = 1

BlockSize = 0x00001000|gRaspberryPiTokenSpaceGuid.PcdFirmwareBlockSize
NumBlocks = 0x1f0
NumBlocks = 0x3e0

################################################################################
#
Expand All @@ -56,7 +56,7 @@ FILE = $(TFA_BUILD_BL31)
#
# UEFI image
#
0x00020000|0x001b0000
0x00020000|0x00390000
gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize
FV = FVMAIN_COMPACT

Expand All @@ -70,7 +70,7 @@ FV = FVMAIN_COMPACT
#

# NV_VARIABLE_STORE
0x001d0000|0x0000e000
0x003b0000|0x0000e000
gRaspberryPiTokenSpaceGuid.PcdNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize

DATA = {
Expand Down Expand Up @@ -113,11 +113,11 @@ DATA = {
}

# NV_EVENT_LOG
0x001de000|0x00001000
0x003be000|0x00001000
gRaspberryPiTokenSpaceGuid.PcdNvStorageEventLogBase|gRaspberryPiTokenSpaceGuid.PcdNvStorageEventLogSize

# NV_FTW_WORKING header
0x001df000|0x00001000
0x003bf000|0x00001000
gRaspberryPiTokenSpaceGuid.PcdNvStorageFtwWorkingBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize

DATA = {
Expand All @@ -132,14 +132,18 @@ DATA = {
}

# NV_FTW_WORKING data
0x001e0000|0x00010000
0x003c0000|0x00010000
gRaspberryPiTokenSpaceGuid.PcdNvStorageFtwSpareBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize

# reserve some future RAM for the ACPI PCC channel structures, immediately before the DTB
# 0x003d0000|0x00010000
# gRaspberryPiTokenSpaceGuid.PcdPccBaseAddress|gRaspberryPiTokenSpaceGuid.PcdPccSize

#
# This is just for documentation purposes! The DTB reserved space is not part of the FD,
# but this is exactly where it is expected to be.
#
# 0x001f0000|0x10000
# 0x003e0000|0x20000
# gRaspberryPiTokenSpaceGuid.PcdFdtBaseAddress|gRaspberryPiTokenSpaceGuid.PcdFdtSize
#

Expand Down
10 changes: 5 additions & 5 deletions Platform/RaspberryPi/RPi4/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ Build instructions from the top level edk2-platforms Readme.md apply.
enable_gic=1
armstub=RPI_EFI.fd
disable_commandline_tags=2
device_tree_address=0x1f0000
device_tree_end=0x200000
device_tree_address=0x3e0000
device_tree_end=0x400000
```
Additionally, if you want to use PL011 instead of the miniUART, you can add the lines:
```
Expand Down Expand Up @@ -91,12 +91,12 @@ the SD or USB, and then edit your `config.txt` so that it looks like:
```
(...)
disable_commandline_tags=2
device_tree_address=0x1f0000
device_tree_end=0x200000
device_tree_address=0x3e0000
device_tree_end=0x400000
device_tree=your_fdt_file.dtb
```

Note: the address range **must** be `[0x1f0000:0x200000]`. `dtoverlay` and `dtparam` parameters are also supported.
Note: the address range **must** be `[0x3e0000:0x400000]`. `dtoverlay` and `dtparam` parameters are also supported.

## Custom `bootargs`

Expand Down

0 comments on commit 991b802

Please sign in to comment.