From nobody Mon Feb 9 19:30:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53511+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53511+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1580232020856790.6643210835844; Tue, 28 Jan 2020 09:20:20 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZAtNYY1788612xpAyJ4n7HCl; Tue, 28 Jan 2020 09:20:19 -0800 X-Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by mx.groups.io with SMTP id smtpd.web09.245.1580232018852493702 for ; Tue, 28 Jan 2020 09:20:19 -0800 X-Received: by mail-wr1-f42.google.com with SMTP id d16so16964660wre.10 for ; Tue, 28 Jan 2020 09:20:18 -0800 (PST) X-Gm-Message-State: fqNs2vpScsFwAEYUUCUWpvqPx1787277AA= X-Google-Smtp-Source: APXvYqzz87WJuQWEwRhcWvfcOI6BXYmwGT83IYD3jr7pIhwyldemIOI1Eb4XB17ULfEGStjuCeuLOw== X-Received: by 2002:a05:6000:11c9:: with SMTP id i9mr31202688wrx.164.1580232017038; Tue, 28 Jan 2020 09:20:17 -0800 (PST) X-Received: from localhost.localdomain ([84.203.49.247]) by smtp.gmail.com with ESMTPSA id 205sm4000853wmd.42.2020.01.28.09.20.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jan 2020 09:20:16 -0800 (PST) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif@nuviainc.com, philmd@redhat.com Subject: [edk2-devel] [edk2-platforms][PATCH 4/4] Platform/RPi4: Enable the use of DualSerialPortLib Date: Tue, 28 Jan 2020 17:19:56 +0000 Message-Id: <20200128171956.9680-5-pete@akeo.ie> In-Reply-To: <20200128171956.9680-1-pete@akeo.ie> References: <20200128171956.9680-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1580232019; bh=xl56bb0TJNAUax/7mg5QuNKStvp2n5wmdo0GXLCpAuM=; h=Cc:Date:From:Reply-To:Subject:To; b=XAbTnLdoKZxaJhQ0Q9O6aWNrFsWedy5hDLtPYbQJRwywYf97jhYkTEK6e+f2kV0VNRa MkeTf7zJXH+ZmwaM/WbPCQLi/lsZdjPptH8748DMLzbfEr12bTiUFLD8WHZwB8vk1BOm3 Ns8oDyyQppPujtAF2tSPDA7zBzDD4BaYGqo= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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 --- Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf | 7 ++++++ Platform/RaspberryPi/RPi4/RPi4.dsc | 26 +++--------------= --- Platform/RaspberryPi/RPi4/RPi4.fdf | 4 --- Platform/RaspberryPi/RPi4/Readme.md | 21 ++++------------ 4 files changed, 15 insertions(+), 43 deletions(-) diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf b/Platform= /RaspberryPi/RPi4/AcpiTables/AcpiTables.inf index 5ce4c0b52b32..aa8f67dec95e 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf +++ b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf @@ -54,3 +54,10 @@ [FixedPcd] 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 =3D -DPL011_ENABLE + GCC:*_*_*_ASLCC_FLAGS =3D -DPL011_ENABLE diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4= /RPi4.dsc index bd3800c1d653..7c1937672597 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.dsc +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc @@ -38,7 +38,6 @@ [Defines] DEFINE SECURE_BOOT_ENABLE =3D FALSE DEFINE INCLUDE_TFTP_COMMAND =3D FALSE DEFINE DEBUG_PRINT_ERROR_LEVEL =3D 0x8000004F - DEFINE PL011_ENABLE =3D FALSE DEFINE ACPI_BASIC_MODE_ENABLE =3D FALSE =20 ##########################################################################= ###### @@ -118,16 +117,10 @@ [LibraryClasses.common] ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/Ar= mGenericTimerPhyCounterLib.inf =20 -!if $(PL011_ENABLE) =3D=3D TRUE + # Dual serial port library PL011UartClockLib|ArmPlatformPkg/Library/PL011UartClockLib/PL011UartCloc= kLib.inf PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf - SerialPortLib|ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortL= ib.inf -!else - PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf - PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf - PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatfor= mHookLibNull.inf - SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPort= Lib16550.inf -!endif + SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialP= ortLib.inf =20 # Cryptographic libraries IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf @@ -239,12 +232,6 @@ [BuildOptions] GCC:*_*_AARCH64_DLINK_FLAGS =3D -Wl,--fix-cortex-a53-843419 GCC:RELEASE_*_*_CC_FLAGS =3D -DMDEPKG_NDEBUG -DNDEBUG =20 -!if $(PL011_ENABLE) =3D=3D TRUE - GCC:*_*_*_CC_FLAGS =3D -DPL011_ENABLE - GCC:*_*_*_ASLPP_FLAGS =3D -DPL011_ENABLE - GCC:*_*_*_ASLCC_FLAGS =3D -DPL011_ENABLE -!endif - [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER] GCC:*_*_AARCH64_DLINK_FLAGS =3D -z common-page-size=3D0x10000 =20 @@ -410,22 +397,15 @@ [PcdsFixedAtBuild.common] gBcm27xxTokenSpaceGuid.PcdBcm27xxPciBusMmioLen|0x3ffffff gBcm27xxTokenSpaceGuid.PcdBcm27xxPciCpuMmioAdr|0x600000000 =20 -!if $(PL011_ENABLE) =3D=3D 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 =20 diff --git a/Platform/RaspberryPi/RPi4/RPi4.fdf b/Platform/RaspberryPi/RPi4= /RPi4.fdf index db393d47bcea..52ae1e5b65cb 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.fdf +++ b/Platform/RaspberryPi/RPi4/RPi4.fdf @@ -51,11 +51,7 @@ [FD.RPI_EFI] # ATF primary boot image # 0x00000000|0x00020000 -!if $(PL011_ENABLE) =3D=3D TRUE FILE =3D Platform/RaspberryPi/$(PLATFORM_NAME)/TrustedFirmware/bl31_pl011.= bin -!else -FILE =3D Platform/RaspberryPi/$(PLATFORM_NAME)/TrustedFirmware/bl31_miniua= rt.bin -!endif =20 # # DTB. diff --git a/Platform/RaspberryPi/RPi4/Readme.md b/Platform/RaspberryPi/RPi= 4/Readme.md index 74afc0f89451..758d0124a6cf 100644 --- a/Platform/RaspberryPi/RPi4/Readme.md +++ b/Platform/RaspberryPi/RPi4/Readme.md @@ -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. =20 # Building =20 @@ -32,11 +32,6 @@ The following additional build options are also availabl= e: ACPI (by disabling the Device Tree driver altogether). This may be requi= red to boot Operating Systems such as Linux on account of the current PCIe/x= HCI limitations. -- `-D PL011_ENABLE=3D1`: Selects PL011 for the serial console instead of t= he - 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). =20 # Booting the firmware =20 @@ -48,27 +43,21 @@ The following additional build options are also availab= le: - `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=3D1 enable_uart=3D1 - core_freq=3D250 enable_gic=3D1 armstub=3DRPI_EFI.fd disable_commandline_tags=3D1 ``` - - For a firmware **with** the `PL011_ENABLE` build option: + Additionally, if you want to use PL011 instead of the miniUART, you ca= n add the lines: ``` - arm_64bit=3D1 - enable_gic=3D1 - armstub=3DRPI_EFI.fd - disable_commandline_tags=3D1 device_tree_address=3D0x20000 device_tree_end=3D0x30000 device_tree=3Dbcm2711-rpi-4-b.dtb dtoverlay=3Dminiuart-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 int= o an `overlays/` directory on the uSD card. Alternatively, you may use `disable-bt` ins= tead of `miniuart-bt` if you don't require BlueTooth. 5. Insert the uSD card and power up the Pi. @@ -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-out= put related patches were applied, the first one to fix the miniUART baud rate not bein= g properly set to 115200 bauds with recent versions of `start4.elf` and the second on= e to allow -swicthing between miniUART and PL011 at build time. +the use of the PL011 UART. =20 No other alterations to the official source have been applied. =20 --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53511): https://edk2.groups.io/g/devel/message/53511 Mute This Topic: https://groups.io/mt/70222632/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-