Skip to content

Commit

Permalink
Platform/RPi4: Enable the use of DualSerialPortLib
Browse files Browse the repository at this point in the history
With DualSerialPortLib available, we can remove the PL011_ENABLE
option and use this library instead of being tied to selecting only
one of PL011SerialPortLib or BaseSerialPortLib16550.

Note that, for the time being, we choose to default to selecting the
PL011 based TF-A binary, since we have to pick one and we expect that
most usage of the firmware will be for a PL011 configuration (we of
course validated that the only drawback of using PL011 with a miniUART
configuration the loss of the 2 lines of serial debug output from TF-A
on startup and that there was no other issue besides that), but work
is underway to add runtime UART detection to TF-A, after which we will
revert to using a single TF-A binary that supports both UARTs.

Also note that this patch currently enforces the use of PL011 for the
ACPI tables, as we also have to pick one until we can switch to using
DynamicTablesPkg/ConfigurationManagerDxe for ACPI generation, which
we should do in a future update, and which will enable us to update
the ACPI tables at runtime according to the user-selected UART.

Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
  • Loading branch information
pbatard authored and Ard Biesheuvel committed Feb 14, 2020
1 parent 2fc6eb4 commit 41c1d9b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 43 deletions.
7 changes: 7 additions & 0 deletions Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,10 @@
gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress

# The following is a stopgap solution to default to PL011
# usage in ACPI (most common case), until we can switch
# to using DynamicTablesPkg/ConfigurationManagerDxe.
[BuildOptions]
GCC:*_*_*_ASLPP_FLAGS = -DPL011_ENABLE
GCC:*_*_*_ASLCC_FLAGS = -DPL011_ENABLE
26 changes: 3 additions & 23 deletions Platform/RaspberryPi/RPi4/RPi4.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
DEFINE SECURE_BOOT_ENABLE = FALSE
DEFINE INCLUDE_TFTP_COMMAND = FALSE
DEFINE DEBUG_PRINT_ERROR_LEVEL = 0x8000004F
DEFINE PL011_ENABLE = FALSE
DEFINE ACPI_BASIC_MODE_ENABLE = FALSE

################################################################################
Expand Down Expand Up @@ -118,16 +117,10 @@
ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf
ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf

!if $(PL011_ENABLE) == TRUE
# Dual serial port library
PL011UartClockLib|ArmPlatformPkg/Library/PL011UartClockLib/PL011UartClockLib.inf
PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf
SerialPortLib|ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.inf
!else
PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf
SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
!endif
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf

# Cryptographic libraries
IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
Expand Down Expand Up @@ -239,12 +232,6 @@
GCC:*_*_AARCH64_DLINK_FLAGS = -Wl,--fix-cortex-a53-843419
GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG -DNDEBUG

!if $(PL011_ENABLE) == TRUE
GCC:*_*_*_CC_FLAGS = -DPL011_ENABLE
GCC:*_*_*_ASLPP_FLAGS = -DPL011_ENABLE
GCC:*_*_*_ASLCC_FLAGS = -DPL011_ENABLE
!endif

[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
GCC:*_*_AARCH64_DLINK_FLAGS = -z common-page-size=0x10000

Expand Down Expand Up @@ -410,22 +397,15 @@
gBcm27xxTokenSpaceGuid.PcdBcm27xxPciBusMmioLen|0x3ffffff
gBcm27xxTokenSpaceGuid.PcdBcm27xxPciCpuMmioAdr|0x600000000

!if $(PL011_ENABLE) == TRUE
## PL011 UART
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0xfe201000
# UARTs
gArmPlatformTokenSpaceGuid.PL011UartInteger|0
gArmPlatformTokenSpaceGuid.PL011UartFractional|0
gArmPlatformTokenSpaceGuid.PL011UartClkInHz|48000000
!else
## NS16550 compatible UART
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0xfe215040
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|4
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|500000000
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|0x27
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|8
!endif

gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0

Expand Down
4 changes: 0 additions & 4 deletions Platform/RaspberryPi/RPi4/RPi4.fdf
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ NumBlocks = 0x200
# ATF primary boot image
#
0x00000000|0x00020000
!if $(PL011_ENABLE) == TRUE
FILE = Platform/RaspberryPi/$(PLATFORM_NAME)/TrustedFirmware/bl31_pl011.bin
!else
FILE = Platform/RaspberryPi/$(PLATFORM_NAME)/TrustedFirmware/bl31_miniuart.bin
!endif

#
# DTB.
Expand Down
21 changes: 5 additions & 16 deletions Platform/RaspberryPi/RPi4/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ following __major__ limitations:
missing/incomplete ACPI tables as well as other factors. For Linux, using
the `ACPI_BASIC_MODE_ENABLE` build option may help.
- Serial I/O from the OS may not work due to CPU throttling affecting the
miniUART baudrate. This can be worked around by using the `PL011_ENABLE`
compilation option.
miniUART baudrate. This can be worked around by using the PL011 UART
through the device tree overlays.

# Building

Expand All @@ -32,11 +32,6 @@ The following additional build options are also available:
ACPI (by disabling the Device Tree driver altogether). This may be required
to boot Operating Systems such as Linux on account of the current PCIe/xHCI
limitations.
- `-D PL011_ENABLE=1`: Selects PL011 for the serial console instead of the
miniUART (default). This doesn't change the GPIO pinout for the UART but
can be useful if you find that the miniUART baud rate changes when the
OS throttles the CPU. Note that this requires one of `disable-bt.dtbo` or
`miniuart-bt.dtbo` overlays to have been applied (see below).

# Booting the firmware

Expand All @@ -48,27 +43,21 @@ The following additional build options are also available:
- `start4.elf`
- `overlays/miniuart-bt.dbto` or `overlays/disable-bt.dtbo` (Optional)
4. Create a `config.txt` with the following content:
- For a firmware **without** the `PL011_ENABLE` build option:
```
arm_64bit=1
enable_uart=1
core_freq=250
enable_gic=1
armstub=RPI_EFI.fd
disable_commandline_tags=1
```
- For a firmware **with** the `PL011_ENABLE` build option:
Additionally, if you want to use PL011 instead of the miniUART, you can add the lines:
```
arm_64bit=1
enable_gic=1
armstub=RPI_EFI.fd
disable_commandline_tags=1
device_tree_address=0x20000
device_tree_end=0x30000
device_tree=bcm2711-rpi-4-b.dtb
dtoverlay=miniuart-bt
```
The above also requires `miniuart-bt.dbto` to have been copied into an `overlays/`
Note that doing so requires `miniuart-bt.dbto` to have been copied into an `overlays/`
directory on the uSD card. Alternatively, you may use `disable-bt` instead of
`miniuart-bt` if you don't require BlueTooth.
5. Insert the uSD card and power up the Pi.
Expand All @@ -80,7 +69,7 @@ The following additional build options are also available:
The TF-A binaries were compiled from a TF-A source over which 2 serial-output related
patches were applied, the first one to fix the miniUART baud rate not being properly
set to 115200 bauds with recent versions of `start4.elf` and the second one to allow
swicthing between miniUART and PL011 at build time.
the use of the PL011 UART.
No other alterations to the official source have been applied.
Expand Down

0 comments on commit 41c1d9b

Please sign in to comment.