As per https://github.com/raspberrypi/firmware/issues/1376 we found two issues with recent versions of the Raspberry Pi Foundation's start.elf on the Pi 3:
1. Our timeout delay for mbox reply was too short, leading to loss of USB due to USB mbox power state request not being applied. 2. The MiniUART baudrate shifted from the expected value due to the Raspberry Pi Foundation deviating from their official documentation and increasing the default core clock (which the MiniUART bases its baudrate divisor on) to 400 MHz, instead using a fixed 250 MHz, when 'enable_uart=1' is in effect. Fixing the first issue is fairly straightforward, and is done in patch 1/3, where we also take this opportunity to improve the overall mbox code. Fixing the second issue requires a little more involvement as we want to ensure that we no longer depend on a fixed PCD clock rate to derive the MiniUART baudrate divisor, but instead use the actual core clock frequency retreived from mbox. However, because there basically exists two instances of DualSerialLib in the firmware (one in PEI phase and one in DXE) and the serial initialization is done very early, we have to use the following process: 1. ArmPlatformPeiBootAction set the core clock of the PEI instance of DualSerialLib, which enables the PEI serial instance to be set with a proper baudrate. 2. A newly introduced PlatformPeiLib provides a PlatformPeim () call that reads the global value from the PEI serial instance and stores it into a GUID Hob. 3. In DXE phase, when the DXE instance of DualSerialLib attempts to read the core clock value for the first time, it detects that it has not been set and sets its value from the GUID Hob. It needs to be pointed out however that we can't use HobLib helper functions such as GetFirstGuidHob () or even GetHobList () directly because DualSerialLib gets instantiated before the DXE version of HobLib. However we work around that by using PrePeiGetHobList (). This serial baudrate fixup is accomplished in patch 2/3. We also take this opportunity to improve the Pi 4 code, which currently doesn't use the core clock frequency at all, andt instead applies a variable 12.12 fixed divisor (which we can always access without mbox transactions) onto a 1 GHz fixed clock. It should be noted that, with 2/3 applied, users of the Pi firmware have the new capability of being able to override the core frequency to whichever value they like (by adding 'core_freq=###' in their 'config.txt') without losing MiniUART baudrate, as was the case without this patch. Finally, considering that the knowing the actual core frequency the system booted with can be useful during early init, we add patch 3/3 to display this value for DEBUG builds. Andrei Warkentin (2): Platform/RPi: Fortify mailbox code Platform/RPi/DualSerialPortLib: Fix miniUART serial divisor computation Pete Batard (1): Platform/RPi: Report core clock frequency during early init Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 11 +- Platform/RaspberryPi/Include/Guid/DualSerialPortLibHobGuid.h | 22 ++++ Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h | 11 +- Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c | 106 +++++++++++++++++--- Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf | 6 ++ Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S | 83 ++++++++------- Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c | 8 +- Platform/RaspberryPi/Library/PlatformPeiLib/PlatformPeiLib.c | 33 ++++++ Platform/RaspberryPi/Library/PlatformPeiLib/PlatformPeiLib.inf | 47 +++++++++ Platform/RaspberryPi/RPi3/RPi3.dsc | 8 +- Platform/RaspberryPi/RPi4/RPi4.dsc | 9 +- Platform/RaspberryPi/RaspberryPi.dec | 1 + 12 files changed, 278 insertions(+), 67 deletions(-) create mode 100644 Platform/RaspberryPi/Include/Guid/DualSerialPortLibHobGuid.h create mode 100644 Platform/RaspberryPi/Library/PlatformPeiLib/PlatformPeiLib.c create mode 100644 Platform/RaspberryPi/Library/PlatformPeiLib/PlatformPeiLib.inf -- 2.21.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#58539): https://edk2.groups.io/g/devel/message/58539 Mute This Topic: https://groups.io/mt/73972537/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-