Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added references to PetaLinux tips

This page provides information related to the Zynq UltraScale+ MPSoC Platform Management Unit (PMU). The PMU controls the power-up, reset, and monitoring of resources within the system. 

Table of Contents

Table of Contents
excludeTable of Contents|What\'s new.*


Overview of PMU Firmware

The Platform Management Unit (PMU) in Zynq MPSoC has a Microblaze with 32 KB of ROM and 128 KB of RAM. The ROM is pre-loaded with PMU Boot ROM (PBR) which performs pre-boot tasks and enters a service mode. For more details on PMU, PBR and PMUFW load sequence, refer to Platform Management Unit (Chapter-6) in Zynq MPSoC TRM (UG1085). PMU RAM can be loaded with a firmware (PMU Firmware) at run-time and can be used to extend or customize the functionality of PMU. Some part of the RAM is reserved for PBR, leaving around 125.7 KB for PMU Firmware.

Here is the memory layout of PMU RAM:

The PMU Firmware provided in Vitis, comes with a default linker script which aligns with this memory layout and there is no specific customization required from user.

Modules

PMU Firmware is designed to be modular and enables adding new functionality in the form of modules. Each functionally distinct feature is designed in as a module, so that PMUFW can be configured to include only the required functionality for a user application. This type of modular design allows easy addition of new features and as well as optimizes memory footprint by disabling unused modules.

All the common functions that may be required by the modules are organized as separate libraries in PMUFW with APIs clearly specified. The included APIs in PMU Firmware are given below:
  1. ROM Services API
  2. Reset Services API
  3. BSP/Utility API

These APIs can be used by the modules in PMUFW to perform the specified actions as required.

Each module can be provided with three handlers which are called in during the respective phases as described below:
Module HandlerPurposeAPI for Registering the Handlerexecution context
InitCalled during the init of the core to configure the module, register for events or add scheduler tasks. This can be used to load the configuration data into the module if required.XPfw_CoreSetCfgHandler(const XPfw_Module_t *ModPtr, XPfwModCfgInitHandler_t CfgHandler);StartUp
Event HandlerCalled when an event occurs (module should have registered for this event, preferably during the init phaseXPfw_CoreSetEventHandler(const XPfw_Module_t *ModPtr, XPfwModEventHandler_t EventHandler);Interrupt
IPI HandlerCalled when an IPI message with respective module-id arrivesXPfw_CoreSetIpiHandler(const XPfw_Module_t *ModPtr, XPfwModIpiHandler_t IpiHandler, u16 IpiId);Interrupt
PMUFW has a default set of modules which address most of the common use case for Power Management and Error Management. these modules can be taken as references for implementation of custom modules.

Inter-Processor Interrupts(IPI) Handling in PMUFW

PMU has 4 Inter-Processor Interrupts(IPI) assigned to it and one set of buffers. By default, PMUFW uses IPI-0 and associated buffers for all message exchange with other processors on the SoC. PMUFW uses IPI driver to send and receive messages. An IPI manager layer is implemented over the driver and it takes care of dispatching the IPI message to the registered module handlers based on IPI ID in the first word of the message. The message format for IPI is given below:
WordContentDescription
0Header<target_module_id, api_id>
1PAYLOADModule dependent payload
2
3
4
5
6RESERVEDRESERVED – for future use
7Checksum

IPI-1 is used for the callbacks from PMU to other masters and for communication initiated by PMUFW.

Currently, PM and EM modules use IPIs and this can be taken as reference for implementing custom modules which require IPI messaging.

Building PMU Firmware using Vitis


Info

For tips configuring PMU firmware builds in PetaLinux see PetaLinux Yocto Tips.


  1. Open Vitis
  2. Create a new application with File->New→Application Project...:
    1. Enter project name and click on Next. Eg: pmufw
    2. Select platform as "zcu102" from "Create a new platform from hardware (XSA)" tab options. Click on Next
    3. Now select the domain option as below and click on next
      1. CPU: psu_pmu_0
      2. OS: standalone
      3. Language: C
    4. Select "ZynqMP PMU Firmware" template from Templates list and click on Finish.
    5. After this, PMU project will be created. Right click on the project and select "Build Project" to build PMU Firmware.
  3. Connect to the local board and test the connection. You should see a pop up showing that the connection was established successfully.
  4. Connect to the COM port on the terminal to view the UART prints.
    Note:
    - PMUFW uses psu_uart_0 as default STDOUT. This can be changed to other UARTs using the "Modify BSP Settings" dialogue.
    To enable debug prints from PMUFW, add DEBUG_MODE to the defined symbols list in build settings dialog.- [Important] When PMUFW logging is enabled, power management for the logging UART port will be disabled. Because of that, some system-wide power management operations will also be affected (e.g. suspend/resume operations may not work properly.) Therefore, PMUFW logging should be enabled only when necessary.
  5. On XSCT Console, Connect to the board and Run the PMU firmware.
  6. View the PMU firmware prints on the Terminal console

Debugging PMU FW using Vitis


Info

PMU FW will be built with -Os and LTO optimizations by default.


If the user need to disable the optimization (for debugging), two things need to be done:
Since removing optimization results in increase of code size and can result in not being able to build PMU FW, some of the features that the user don’t use, need to be disabled by removing build flags from project settings. And to further disable some features, it can be disabled in xpfw_config.h file of PMU FW
To disable/modify Optimizations, below changes need to be done:
PMU FW application: In "Miscellaneous" section, need to remove/modify highlighted options below:

...

Adding a Custom Module

Creating a New Module

Each set of user defined routines performing a specific functionality should be designed to be a module in PMUFW. These files should be self contained and can use APIs from xpfw_core.h to call in FW routines. Each module should support the following interfaces:
1. Config Handler : Called during Init.
2. Event Handler: When a registered event is triggered
3. IPI Handler: When an IPI Message arrives with the registered IPI ID
To create a module, in the user_startup routine:
Code Block
themeMidnight
PmModPtr = XPfw_CoreCreateMod();
(void)XPfw_CoreSetCfgHandler(PmModPtr, PmCfgInit);
(void)XPfw_CoreSetEventHandler(PmModPtr, PmEventHandler);
(void)XPfw_CoreSetIpiHandler(PmModPtr, PmIpiHandler,0U)

Adding a Task to Scheduler

Tasks are functions which take void args and return void. Currently PMU Firmware has no way to check that the task returns in a pre-determined time, so this needs to be ensured by the task design. Let us consider a task which prints out a message:
Code Block
themeMidnight
void TaskPrintMsg(void)
{
    xil_printf("Task has been triggered\r\n");
}
 
If we want to schedule the above task to occur every 500ms, the following code can be used:
Code Block
themeMidnight
Status = XPfw_CoreScheduleTask(TaskModPtr, 500U, TaskPrintMsg);
if(XST_SUCCESS == Status) {
    xil_printf("Task has been added successfully !\r\n");
}
else {
    xil_printf(Ërror: Failed to add Task.!\r\n");
}
 

Registering for an Event

All interrupts that come into PMU are exposed to user as Events with specific EVENTIDs defined in xpfwevents.h; Any module can register for an event (usually in CfgInitHandler) and the module's EventHandler will be called when an event is triggered. To register for an RTC Event:
Code Block
themeMidnight
Status = XPfw_CoreRegisterEvent(ModPtr,XPFW_EV_RTC_SECONDS);

Example of an EventHandler

Code Block
themeMidnight
void RtcEventHandler(const XPfw_Module_t *ModPtr, u32 EventId)
{
    xil_printf("MOD%d:EVENTID: %d\r\n", ModPtr->ModId, EventId);
    if(XPFW_EV_RTC_SECONDS == EventId){
            /* Ack the Int in RTC Module */
            Xil_Out32(RTC_RTC_INT_STATUS,1U);
            xil_printf("RTC: %d \r\n", Xil_In32(RTC_CURRENT_TIME));
    }
}

PMU Firmware Memory Footprint

This section contains the approximate details of PMU Firmware Memory Footprint with various modules enabled.
In PMU Firmware,
  • PM and FPGA modules are enabled by default. FPGA block in PMU Firmware does the xilfpga and xilsecure functionality which performs loading of bitstream to PL, loading of secure image to memory and reading FPGA status. FPGA block does not have a separate build flag for itself and is part of PM module.
  • Error Management and Restart modules are not enabled by default
Refer to PMU Firmware Build Flags for module default setting information

Note: All of the metrics are with compilation optimized for size -Os. This optimization setting is enabled by default in Vitis. To disable the same, user need to follow the steps mentioned in Debugging PMU FW using Vitis section above
S.NoFeature/ComponentSize occupied (KB)Free space (KB)Additional NotesRemarks
1PMU Firmware without detailed debug prints enabled112.515.5This is with base PMU Firmware, PM module and FPGA block
2PMU Firmware with detailed debug prints enabled1235Detailed debug prints are enabled when XPFW_DEBUG_DETAILED and DEBUG_MODE flags are definedThis estimation is with combination of (1) and (2)
3PMU Firmware with Error Management Module enabled115.412.6Error Management module is enabled when ENABLE_EM and ENABLE_SCHEDULER flags are definedThis estimation is with combination of (1) and (3)
4PMU Firmware with Restart Module enabled117.510.5Restart module is enabled when ENABLE_RECOVERY, ENABLE_ESCALATION and CHECK_HEALTHY_BOOT flags are defined along with ENABLE_EM and ENABLE_SCHEDULER flagsThis estimation is with combination of (1) and (4)

Examples to enable/disable modules

  1. PM module is enabled by default with ENABLE_PM build flag. This build flag is defined in <PMU Firmware Application>/src/xpfw_config.h file. To disable PM Module, user need to make changes to xpfw_config.h file by removing/commenting defined ENABLE_PM flag.
  2. All other build flags can be enabled by following the below steps.
    1. Right click on the PMU Firmware project and select "C/C++ Build Settings" option. Properties window appears
    2. Select "Settings" from "C/C++ Build" options. In "Tool Settings" tab, select "Symbols" from "Microblaze gcc compiler" option
    3. Click on "Add" under "Defined symbols (-D)"
    4. Enter flag name to define and click "Ok"
    5. Again click "Ok" on properties window and the application will start building with the new compile flags defined

Registers reserved for PMU Firmware

Following are the general storage registers used by PMU Firmware
  1. 0xFFD80034 (PMU_GLOBAL_GLOBAL_GEN_STORAGE2) → Since 2018.1 if POS is enabled, FSBL waits till PMU has finished resuming by polling this register. Users are free to use this register after reset so it can still be considered as "reserved for customers".
  2. 0xFFD80038 (PMU_GLOBAL_GLOBAL_GEN_STORAGE3) → Since 2018.1 if POS is enabled, PMU waits till FSBL has finished reading the boot type. This additional handshake step is required in boot scenarios where FSBL is started by CSU. PFW must wait for CSU to trigger FSBL start otherwise there may be race condition where PFW is trying to restore state of processor as part of resume from Power Off Suspend sequence while CSU is trying to run FSBL on that same processor. Users are free to use this register after reset so it can still be considered as "reserved for customers".
  3. 0xFFD80040 (PMU_GLOBAL_GLOBAL_GEN_STORAGE4 - bit 0) → This register bit needs to be written by upper layer APU applications. So that, in case of FPD WDT error (and when ENABLE_RECOVERY and CHECK_HEALTHY_BOOT macros are defined), PMU checks this register to find out if previous boot was successful and does subsystem restart only if last boot was successful.
  4. 0xFFD80040 (PMU_GLOBAL_GLOBAL_GEN_STORAGE4 - bits 1 and 2) → Since 2018.3, these bits are used to know the status of RPU 0 and RPU 1 usage which will be updated by FSBL. Based on this information, PMU will decide whether to shutdown the unused RPU cores or not.
  5. 0xFFD80040 (PMU_GLOBAL_GLOBAL_GEN_STORAGE4 - bits 3 and 4) → Since 2018.3, these bits are used to set the restart scope to ATF in case of WDT restart.
  6. 0XFFD80040 (PMU_GLOBAL_GLOBAL_GEN_STORAGE4 - bit 16) → Written by PMU Firmware, FSBL uses this register bit to know if reset is APU only reset.
  7. 0XFFD80044 (PMU_GLOBAL_GLOBAL_GEN_STORAGE5 - bit 0) → Written by FSBL, PMU Firmware uses this register to know if FSBL has completed its execution. Since 2018.1, this check is performed to initialize and start the CSU WDT timer when ENABLE_WDT macro is defined.
  8. 0XFFD80044 (PMU_GLOBAL_GLOBAL_GEN_STORAGE5 - bits 1 and 2) → Written by FSBL. PMU Firmware uses these bits to know if FSBL is running on which processor. 01: APU, 10: RPU0, 11: RPU LS
  9. 0xFFD80044 (PMU_GLOBAL_GLOBAL_GEN_STORAGE5 - bits 16 to 23) → Since 2018.3, XilFPGA library in PMU uses these bits to store the PL state to know whether secure bit-stream or non-secure bit-stream or no bit-stream loaded. This information is used by XilFPGA Readback feature to dis-allow readback in case secure bit-stream is loaded.
  10. 0xFFD8006C (PMU_GLOBAL_PERS_GLOBAL_GEN_STORAGE7 - bit 3) → Since 2018.3, PMU is using this bit to indicate FSBL whether DDR is in self-refresh mode or not. PMU will set this bit if DDR is in self-refresh during warm-restart and clears after the restart.

And 0xFFD8004C (PMU_GLOBAL_GLOBAL_GEN_STORAGE7) is used by PMU_ROM. This register is used in case we encounter problems with the PL Power Up routine in which ROM does not wait long enough for the PL to come out of reset. The time ROM waits can be extended by increasing the value of this register.


FSBL also uses few general storage registers. Please refer to this link in FSBL wiki for the list of registers reserved for FSBL. 

...

  1. Implement idle hook for node NAND to be called before applying soft reset to NAND
  2. Keep PL power ON during APU/RPU subsystem restart
  3. Add support for idling GPU and GPU_PP nodes
  4. Implement HW exception handler for PMU
  5. Enable SLVERR for peripherals used by PMU
  6. Provide build option to disable FSBL copy to DDR feature
  7. Skip copying FSBL to DDR if FSBL image is encrypted
  8. Add new module to monitor RPU run mode

What's new in 2019.2 release

Following are the new features added in PMU Firmware in 2019.2 release:

  1. Change power state of power domain or island only if it is powered up by checking PWR_STATUS register
  2. Change WDT timeout when performing secure operations which take more time
  3. Added power down permission check for processor and PLL nodes in PmForcePowerDown()
  4. Added support for RPU only subsystem restart case

What's new in 2019.1 release

Following are the new features added in PMU Firmware in 2019.1 release:

  1. Idle nodes only once even if they are assigned to multiple masters
  2. Add support to idle and reset all twelve TTCs
  3. Support for APU only reset even if secure bitstream loading via OCM feature is executed
  4. Updates to XilFPGA APIs to support latest 5.0 version
  5. Add checksum support for IPI messages
  6. Add permission check for modifying error actions over IPI
  7. Bypass DDR related code if DDR is not present in the design
  8. Register handler and trigger FW error when Assert occurs
  9. Add hook for custom module in PMU Firmware
  10. Add handler for EMIO get reset status
  11. Add PMU RAM ECC error injection STL during PMU startup
  12. Add check for number of users for vpll
  13. Add support for Ultra96 power button

What's new in 2018.3 release

Following are the new features added in PMU Firmware in 2018.3 release:
  1. PMU Firmware support for PL Configuration Readback
  2. PMU Firmware support for AES encryption and decryption
  3. Put DDR in self refresh before warm-restart
  4. Implementation of clock EEMI APIs
  5. Addition of CSU/PMU global register access via MMIO calls
  6. Support to set restart scope during WDT restart
  7. PMU Firmware support for eFUSE access
  8. Implementation of pin mux functionality in PMU Firmware

What's new in 2018.2 release

Following are the new features added in PMU Firmware in 2018.2 release:
  1. Provide read/write access to AFI configuration registers through MMIO call
  2. While configuring PLL lock errors and its actions in EM module, wait for FSBL to complete psu_init to avoid initial PLL lock errors that occurs during FSBL initialization

What's new in 2018.1 release

Following are the new features added in PMU Firmware in 2018.1 release:
  1. PMU fail safe mechanism with CSU WDT is added
  2. Implemented idle hooks for nodes USB, DP and SATA
  3. Added suppoort for graceful force powerdown of PU
    1. This is to prevent any mid-flight AXI transactions from locking up the interconnect and hanging the device
  4. Added wake on USB support to wakeup all masters for which USB is set as wakeup source
  5. Added GPO section to config object to get the initial state of PMU GPO's and configure them in PMU Firmware
  6. Added modularity of xilfpga and xilsecure features using compiler switches
  7. Added Power Off Suspend to RAM feature
  8. Added support for resetting GPIO5 resets going to PL
  9. Added API to support secure single partition image

What's new in 2017.4 release

Following are the new features added in PMU Firmware in 2017.4 release:
  1. Exported efuse IP disable as part of version string in PmGetChipid to recognize eg/cg/ev devices

What's new in 2017.3 release

Following are the new features added in PMU Firmware in 2017.3 release:
  1. Added three level debug prints support in PMU Firmware application
  2. Added support to PMU EM module to set/remove the error action for any error at run time using IPI
  3. Added support to log EM errors that come to PMU and send when the target requests over IPI
  4. Added SRST support for FPD WDT
  5. Added xilsecure API calls to support xilsecure functionality from Linux

Related Links