From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=Tk6jUihA; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.221.42, mailfrom: pete@akeo.ie) Received: by mail-wr1-f42.google.com with SMTP id d16so16964660wre.10 for ; Tue, 28 Jan 2020 09:20:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j308IYV3zxYGfMMf7yyHAbF3CTWlLRzadz+8/Wy3mxA=; b=Tk6jUihAkHGhi/kR86OzxUVkZr/6bk705RkjhL3v4rFm5dziipKQLeULG7bBmu0SUN 6zLF7mH8F8wEXuJwOPF4Zb4dNdG5txjrmDs2yvBQVsczvoZGk4mJYheG81RH4vcbn0Lf PqzcnglnEV5ahf5WsB5p1sht6zYOOZSDLJjm4hFpmJVE5RUMhNJMnk7pMmiwU8qMN8mV diY9qjTDIhg0Zbw3wb+uAC2D56nHRuAj4Cbk+e7cq/vCRueLM8n+ZeEcuhW3uC4bU5gB K4VckMiGiFX8uc9nn2Q+QK3ewMRCRD8soNpvhA4iNhltFqkhaLAfbdhAGLilfjOtK118 MnLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j308IYV3zxYGfMMf7yyHAbF3CTWlLRzadz+8/Wy3mxA=; b=p+Xt9EI1wubevK2ziDhmo0iMfxsKe/uMLVtRKYe3Gh3cUWXVoqwkdEMbPspa5O0nyh 48R3VDJ673iIHzhTDhmmwjKEOzrFfDQ3H85u64W4i9+F6Dl/AHbuPFPZCdz4Bxvy6TGM d5yKsrFwkurLjxmykicvGcXd7G1mr+4wZWlqmdyNqOgvxGYbthcMNUnz0BAND2oVQg59 JED31hr3g6oVaoO2BH7ZphRtL+Fo74YD4rQEON+z0ikB34yumHgEnEYNZUvQITC/wSgF lFNHVoDDlSN8Or6UjbuWZAawtzEfvcYQupZZmMd3hJib9Icai8iIb+PHjvBS+SGo/H/v e5bg== X-Gm-Message-State: APjAAAXg7WxrYeWBhXkLepiuYsPKpNUkneA9LJio8FDtdD4ZnH/P/Kar LSWOI2u34l6rqu1dsyNWheYLe5h3aSA= 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) Return-Path: 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-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> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20200128171956.9680-1-pete@akeo.ie> References: <20200128171956.9680-1-pete@akeo.ie> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 = -DPL011_ENABLE + GCC:*_*_*_ASLCC_FLAGS = -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 = FALSE DEFINE INCLUDE_TFTP_COMMAND = FALSE DEFINE DEBUG_PRINT_ERROR_LEVEL = 0x8000004F - DEFINE PL011_ENABLE = FALSE DEFINE ACPI_BASIC_MODE_ENABLE = FALSE ################################################################################ @@ -118,16 +117,10 @@ [LibraryClasses.common] 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 @@ -239,12 +232,6 @@ [BuildOptions] 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 @@ -410,22 +397,15 @@ [PcdsFixedAtBuild.common] 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 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) == TRUE FILE = Platform/RaspberryPi/$(PLATFORM_NAME)/TrustedFirmware/bl31_pl011.bin -!else -FILE = Platform/RaspberryPi/$(PLATFORM_NAME)/TrustedFirmware/bl31_miniuart.bin -!endif # # DTB. diff --git a/Platform/RaspberryPi/RPi4/Readme.md b/Platform/RaspberryPi/RPi4/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. # Building @@ -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 @@ -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. @@ -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. -- 2.21.0.windows.1