ZU＋ PM Software Tips - UART Usage
ZU+ PM Software Tips - UART Usage
UART Usage Considerations
The Zynq UltraScale+ MPSoC (ZU+) has 2 UART ports (UART0 and UART1). Once configured, any processor can write to the UART. It can be conveniently used as a general purpose logging port for all processors running on the ZU+. However, care must be taken when power management features are enabled. Otherwise, there could be unexpected side effects, including system crash.
Default PetaLinux Configuration
The default PetaLinux configuration for the ZCU102 board comes with a device tree (DT) that contains both UART0 and UART1 in their own generic power domains. In addition, Linux uses UART0 as the console port. This means that Linux is actively managing the power state of both UART0 and UART1. Since Linux is not using UART1, it will attempt to power down UART1, which means:
- Stopping UART FIFO and interrupts.
- Clock gating UART1.
- Power gating UART1.
If another processor (e.g. RPU) needs to use UART1, then UART1 must be removed from the DT.
PMU logging is disabled by default, but can be enabled by adding some compile flags. On the ZCU102, the PMU logs will be sent to UART1 if logging is enabled. However, the PMU itself is not a "PM Master", and cannot request the UART1 to be powered up for its own use. Therefore, there is no way to guarantee that UART1 is running whenever the PMU tries to print logs.
The problem is actually worst than missing PMU logs. That is because the PMU will block if the UART1 FIFO is full. So if UART1 is not running, the PMU will hang, and the entire system will hang.
It is for this reason that PMU logging should be used sparingly and must be used with extreme care.
The discussions above is focused on PetaLinux running on the ZCU102, where UART0 is used as the Linux console and UART1 is not used. In another board, their roles could be reversed, or only one of the UARTs would be available. There is no inherit difference between UART0 and UART1.
The UART is a somewhat unique device in a sense that it can be used concurrently by multiple processors (for transmitting data.) However, if the UART is present in the DT, Linux will assume it is the only user of the UART and fully control its clocks, power supply and operating mode. That in itself may or may not be a problem. It all depends on the purpose of the user's application.