This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Record trace on-chip with ETM on STM32H7 (Cortex M7)

Every now and then, as a side project, I try to setup the ETM on my STM32H7 to record the execution trace on-chip in circular buffer mode. The goal is really to record the trace ON CHIP and in some particular cases output this trace to the external world, but there is no specific tools like Lauterbach or ULink Pro involved. I don't need to filter the instructions, I want to record every instruction.

I've read plenty of ARM documentation (ETMv4 architecture spec, Coresight ref manual, amrV7 arch manual and of course STM32 ref manual) but still couldn't understand exactly how it works. In particular what is not clear is the relationship between the different components : ETM, ETF, DWT, Trace Funnel.

Here is the code I've got right now.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#define ETM_PRGCTRL ( (volatile uint32_t *)(0xE0041000 + 4))
#define ETM_LAR ( (volatile uint32_t *)(0xE0041000 + 0xFB0))
#define ETM_STAT ( (volatile uint32_t *)(0xE0041000 + 0xC))
#define ETM_CONFIG ( (volatile uint32_t *)(0xE0041000 + 0x10))
#define ETM_EVENTCTRL0 ( (volatile uint32_t *)(0xE0041000 + 0x20))
#define ETM_EVENTCTRL1 ( (volatile uint32_t *)(0xE0041000 + 0x24))
#define ETM_STALLCTRL ( (volatile uint32_t *)(0xE0041000 + 0x2C))
#define ETM_SYNCPR ( (volatile uint32_t *)(0xE0041000 + 0x34))
#define ETM_TRACEIDR ( (volatile uint32_t *)(0xE0041000 + 0x40))
#define ETM_TSCTRL ( (volatile uint32_t *)(0xE0041000 + 0x30))
#define ETM_VICTRL ( (volatile uint32_t *)(0xE0041000 + 0x80))
#define ETM_VIIECTRL ( (volatile uint32_t *)(0xE0041000 + 0x84))
#define ETM_VISSCTRL ( (volatile uint32_t *)(0xE0041000 + 0x88))
#define CSTF_BASE_ADDR 0x5C013000
#define CSTF_LAR ( (volatile uint32_t *)(CSTF_BASE_ADDR + 0xFB0))
#define CSTF_CTRL ( (volatile uint32_t *)(CSTF_BASE_ADDR + 0))
#define ETF_BASE_ADDR 0x5C014000
#define ETF_RRD ( (volatile uint32_t *)(ETF_BASE_ADDR + 0x10))
#define ETF_CTL ( (volatile uint32_t *)(ETF_BASE_ADDR + 0x20))
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The status bit of ETF never raises (ETF FIFO apparently remains empty all the time).

Any idea ?

0