How to use ETM to trace PMU events?

According to the manual, we can select PMU events as external input resource of ETM. However, the manual does not describe it in detail, and my attempts also failed.

To perform the experiment, i configure the following registers,

TRCCONFIGR -> 0x18c1      // Enable the return stack, global timestamping, Context ID, and Virtual context identifier tracing

TRCSYNCPR -> 0x8             // Enable trace synchronization every 256 bytes of trace.

TRCTSCTLR -> 0x0              // Disable the timestamp event

TRCTRACEIDR -> some id   // set trace id

TRCVICTLR -> 0x6b201       // trace only non-secure EL0

TRCVIIECTLR -> 0x0            // no address range filter

TRCVIPCSSCTLR -> 0x0     // no start or stop points for ViewInst

TRCEXTINSELR -> 0x8        // select PMU event "INST_RETIRED" as external input 1

TRCRSCTLR2  -> 0x1          // select external input 1 for resource selector 2

TRCEVENTCTL0R -> 0x2    // select resource selector 2 to fire event 0

TRCEVENTCTL1R -> 0x1    // enable event 0 to generate event elements in the trace

However, the output of trace does not contain any event element. Did i misconfigured any register? Moreover, according to the manual of Cortex-A57, the PMU event "INST_RETIRED" has four different event number to trace, i.e. [11:8]. Is that mean i can select any of them as the external input for ETM?

Thanks for any help!

Regards,

Zhenyu

Parents
  • Hi Zhenyu,

    I actually looked into this last week

    The trick is that the PMUEVENT pin numbering and the ETM input selection numbering are not the same! The decode for these event numbers is essentially that 0, 1, 2, 3 in TRCEXTINSELR correspond to the ETM external input bus (EXTIN[3:0]) which are usually wired to the CTIs. The PMU events are what used to be called the Extended Input in ETMv3 and is a wholly different resource selector there, but in ETMv4 they're combined into a single group. We recommend this layout in G.1 Recommended connection layout in the ETMv4 Architecture Specification.

    So, add four - tracking PMUEVENT[8] is TRCEXTINSELR[SELn] = 12, for example. PMUEVENT[25] is TRCEXTINSELR[SELn] = 29.

    You can only select 4 inputs (let us not call them events!) at a time through TRCEXTINSELR, and then map them to resources (TRCRSCTLRn with GROUP 0b0000 and SELECT being the extin selector number) - along with using TRCEVENTCTL0R.EVENTn (which maps the resource to an EVENTn) and TRCEVENTCTRL1R.INSTEN (enable by setting (1 << n)) fields, too, to make them visible in trace - one bit for each (see 6.4.10 Event tracing instruction trace packet). If you don't enable the packet with TRCEVENTCTRL1R.INSTEN or DATAEN, then you can still cause decrement counters, toggle the ViewInst function, and insert timestamps (TRCTSCTLR).

    Don't forget that the PMUEVENT bus doesn't export signals unless enabled - PMCR_EL0.X=1 (0xE04 in the memory mapped view) will enable the bus so that the selected event signals will actually do something.

    Ta,

    Matt

Reply
  • Hi Zhenyu,

    I actually looked into this last week

    The trick is that the PMUEVENT pin numbering and the ETM input selection numbering are not the same! The decode for these event numbers is essentially that 0, 1, 2, 3 in TRCEXTINSELR correspond to the ETM external input bus (EXTIN[3:0]) which are usually wired to the CTIs. The PMU events are what used to be called the Extended Input in ETMv3 and is a wholly different resource selector there, but in ETMv4 they're combined into a single group. We recommend this layout in G.1 Recommended connection layout in the ETMv4 Architecture Specification.

    So, add four - tracking PMUEVENT[8] is TRCEXTINSELR[SELn] = 12, for example. PMUEVENT[25] is TRCEXTINSELR[SELn] = 29.

    You can only select 4 inputs (let us not call them events!) at a time through TRCEXTINSELR, and then map them to resources (TRCRSCTLRn with GROUP 0b0000 and SELECT being the extin selector number) - along with using TRCEVENTCTL0R.EVENTn (which maps the resource to an EVENTn) and TRCEVENTCTRL1R.INSTEN (enable by setting (1 << n)) fields, too, to make them visible in trace - one bit for each (see 6.4.10 Event tracing instruction trace packet). If you don't enable the packet with TRCEVENTCTRL1R.INSTEN or DATAEN, then you can still cause decrement counters, toggle the ViewInst function, and insert timestamps (TRCTSCTLR).

    Don't forget that the PMUEVENT bus doesn't export signals unless enabled - PMCR_EL0.X=1 (0xE04 in the memory mapped view) will enable the bus so that the selected event signals will actually do something.

    Ta,

    Matt

Children
More questions in this forum