Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ArmPkg Profiling

We will take the ARM Versatile Express TC2 (big.LITTLE test chip) as an example in this page.

1. Build UEFI in Release build & Copy the binary to the board. See the instructions in this wiki page

2. Identify the start and end point of your trace. Example on TC2, we want to measure from the start of UEFI at 0xB0000000 - defined into ArmVExpress-CTA15-A7.fdf

[FD.ARM_VEXPRESS_CTA15A7_EFI]
BaseAddress   = 0xB0000000|gArmTokenSpaceGuid.PcdFdBaseAddress  # The base address of the Firmware in remapped DRAM.
Size          = 0x000B0000|gArmTokenSpaceGuid.PcdFdSize         # The size in bytes of the FLASH Device

... until the start of Linux. To identfy where we will start Linux we need to load the symbol of the BDS. So start UEFI a first time on the target up to the Boot menu.

Load all the symbols with DS-5 (symbols for Pre-EFI and UEFI phases):

source "/home/olivier/tianocore/ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py" -f (0xB0000000,0x000B0000) -m (0x80000000,0x40000000) -v -a

Save the output into a file and replace the entry line to make DS-5 command line. Example:

From:

Add symbols of /home/olivier/tianocore/Build/ArmVExpress-CTA15-A7/RELEASE_GCC48/ARM/ArmPlatformPkg/PrePi/PeiMPCore/DEBUG/ArmPlatformPrePiMPCore.dll at 0xb0000180 Add symbols of /home/olivier/tianocore/Build/ArmVExpress-CTA15-A7/RELEASE_GCC48/ARM/MdeModulePkg/Core/Dxe/DxeMain/DEBUG/DxeCore.dll at 0xbfd62240 Add symbols of /home/olivier/tianocore/Build/ArmVExpress-CTA15-A7/RELEASE_GCC48/ARM/ArmPkg/Drivers/CpuDxe/CpuDxe/DEBUG/ArmCpuDxe.dll at 0xbfd14240 (...)

To:

add-symbol-file /home/olivier/tianocore/Build/ArmVExpress-CTA15-A7/RELEASE_GCC48/ARM/ArmPlatformPkg/PrePi/PeiMPCore/DEBUG/ArmPlatformPrePiMPCore.dll 0xb0000180 add-symbol-file /home/olivier/tianocore/Build/ArmVExpress-CTA15-A7/RELEASE_GCC48/ARM/MdeModulePkg/Core/Dxe/DxeMain/DEBUG/DxeCore.dll 0xbfd62240 add-symbol-file /home/olivier/tianocore/Build/ArmVExpress-CTA15-A7/RELEASE_GCC48/ARM/ArmPkg/Drivers/CpuDxe/CpuDxe/DEBUG/ArmCpuDxe.dll 0xbfd14240 (...)

Save the file into symbols.ds

Go to the assembly view of 'StartLinux'. Find where we start Linux and set a hardware breakpoint at this location.

Set a hardware breakpoint at the start of UEFI:

hbreak -p *S:0xB0000000

4. After disconnecting the debugger, restart the ARM Versatile Express.

5. Setting up DS-5 for DSTREAM trace with UEFI This tutorial assumes you have already set up DS-5 for hardware debugging UEFI. If you haven't, help can be found here.

Ensure that your DSTREAM's debug probe is connected via a Mictor-38 to the target's trace port. This is in addition to the JTAG connection.

6. Open the Debug Configurations menu and from there open the DTSL Options window: In the Trace Capture tab, select "DSTREAM 4GB Trace Buffer". The other settings are optional.

In the Core Trace tab, select "Enable core trace", "Enable core trace", for each core you want to trace, and optionally "Cycle accurate trace".

On TC2, you should now be in the ARM Boot Monitor Menu.

7. Connect the debugger.

8. Enable your two hardware breakpoints (the start and stop of your trace).

9. Load all the symbols (ie: 'source symbols.ds'). Symbols must be loaded before starting the acquisition.

10. Resume the execution. Start UEFI by typing:

flash run uefi

Program execution should stop at address 0xB0000000.

11. Clear the trace and resume the execution.

UEFI will now boot. As soon as you enter into the Boot Menu press the boot entry (another alternative would be to automatically start Linux by setting PcdTimeout... to 0). Program execution should stop again when reaching the breakpoint you added in stop address.

Results

After some post-processing here are the list of the 20 functions that consume the more cycles on the UEFI Firmware of the ARM Versatile Express TC2.

Module Name / Function NameCyclePercentageCount
ArmPlatformPrePiMPCore.dll/LzmaDec_DecodeReal153839701933%9
ArmCpuDxe.dll/ArmCleanInvalidateDataCacheEntryBySetWay121011291426%18487296
ArmPlatformBds.dll/InternalMemCopyMem55755279212%99
DxeCore.dll/InternalMemCopyMem3721824348%26152
ArmPlatformPrePiMPCore.dll/InternalMemCopyMem1582596343%65
ArmCpuDxe.dll/ArmV7AllDataCachesOperation1560043793%18489420
VariableRuntimeDxe.dll/__aeabi_uread4677013111%68442
SerialDxe.dll/MmioRead32496574811%167543
DxeCore.dll/InternalMemCompareMem484891551%70456
HdLcdGraphicsDxe.dll/MmioRead32283378350%95824
DxeCore.dll/FwVolBlockReadBlock277519500%45740
HiiDatabase.dll/InternalMemCopyMem211792850%8105
ArmVeNorFlashDxe.dll/InternalMemCopyMem141684620%281
DxeCore.dll/FvCheck129615740%23193
DxeCore.dll/ReadUnaligned16123971480%27832
ArmCpuDxe.dll/UpdatePageEntries117856910%20544
DxeCore.dll/ProduceFVBProtocolOnBuffer115222080%14
HiiDatabase.dll/__aeabi_memcpy93412750%20710
DxeCore.dll/CoreSetInterruptState83324360%32373
ArmPlatformPrePiMPCore.dll/MmioRead3282615300%27246
Function NameCyclePercentageCOunt
LzmaDec_DecodeReal153839701933%9
ArmCleanInvalidateDataCacheEntryBySetWay121599557126%18504704
InternalMemCopyMem113375405824%36242
ArmV7AllDataCachesOperation1600284083%18515535
MmioRead32867177191%292770
__aeabi_uread4677073031%68453
InternalMemCompareMem525674071%76317
FwVolBlockReadBlock277519500%45740
ReadUnaligned16132717900%29780
FvCheck129615740%23193
UpdatePageEntries117856910%20544
ProduceFVBProtocolOnBuffer115222080%14
__aeabi_memcpy93996290%20814
CoreSetInterruptState83324360%32373
VariableWriteServiceInitialize70585480%64019
CompareGuid66851260%141296
IsErasedFlashBuffer65509330%1
InternalMemSetMem3264509100%1800
CoreRestoreTpl60727180%15192
NarrowGlyphToBlt58921730%20809

This is based on SVN rev15539 (2014-05-19).