2018-06-06 01:25 AM
Good morning,
I am trying to add some trace capabilities to my system: UART is obviously too slow so I would like to use ITM. I report my situation:
I use a STM32F3DISCO board, FreeRTOS, Eclipse with Jlink debugger plugin and AC6 plugin as IDE and JLink when I need it (I don't have a physical JLink probe but I reflash the micro).
I have implemented the code but nothing works: probably I didn't understand everything. The code I use is:
&sharpdefine DEMCRx (*((unsigned long *) 0xe000edfc))&sharpdefine TRCENA 0x01000000 // enable trace&sharpdefine ITM_STIM0 (*((unsigned long *) 0xe0000000))&sharpdefine ITM_STIM1 (*((unsigned long *) 0xe0000004))&sharpdefine ITM_STIM2 (*((unsigned long *) 0xe0000008))&sharpdefine ITM_STIM3 (*((unsigned long *) 0xe000000c))&sharpdefine ITM_TER (*((unsigned long *) 0xe0000e00))&sharpdefine ITM_TPR (*((unsigned long *) 0xe0000e40))&sharpdefine ITM_TCR (*((unsigned long *) 0xe0000e80))&sharpdefine ITM_LAR (*((unsigned long *) 0xe0000fb0))&sharpdefine ITM_LAR_ACCESS 0xc5acce55&sharpdefine DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE)void itm_init(void) {
uint32_t SWOSpeed = 3000000; uint32_t SWOPrescaler = (48000000 / SWOSpeed) - 1; // SWOSpeed in HzCoreDebug->DEMCR = 1 << CoreDebug_DEMCR_TRCENA_Pos;
DBGMCU->CR = 0x00000027;
*((volatile unsigned *) 0xE00400F0) = 0x00000002; *((volatile unsigned *) 0xE0040010) = SWOPrescaler; *((volatile unsigned *) 0xE0000FB0) = 0xC5ACCE55; *((volatile unsigned *) 0xE0000E80) = 0x0001000D; *((volatile unsigned *) 0xE0000E40) = 0x0000000F; *((volatile unsigned *) 0xE0000E00) = 0x00000001; *((volatile unsigned *) 0xE0001000) = 0x400003FE; *((volatile unsigned *) 0xE0040304) = 0x00000100;}int SWO_PrintChar(int ch){
(void) ITM_SendChar(ch);return(ch);
}void SWO_PrintString(const char *s) {
while (*s!='\0') { SWO_PrintChar(*s++); }}ITM_SendChar() is already defined in core_cm4.c
I have connected PB3 to pin6 of CN3 because SB10 is not soldered...which utility may I use to see the output of my SWO_PrintString calls?
Thank you in advance.
Best regards
#itm #swd #jlink #freertos #debug #trace #swo2018-06-06 01:48 AM
I have tried in this way just now: I reflashed the firmware stlink->jlink, then using the Jlink SWO viewer i have tried to get data, but nothing happens, no message is shown (PB3 is connected to pin6 of CN3, always with SB10 not connected).
2018-06-06 05:35 AM
The debugger should do the ITM initialization. The core clock must match SystemCoreClock. For stand alone operation the ST-LINK Utilities SWV Window should work with standard firmware.
I tend to use solder on the bridge rather than attempt to jumper.
2018-06-06 06:04 AM
https://community.st.com/0D50X00009Xkho5SAB
2018-06-06 07:15 AM
Ok then, I'm working on a system where I don't have admin credentials so I have to wait before I can install stlink utility. In the meantime I have tried the solution of Jlink (SEGGER RTT) and it works good: Now I would like to know if there is a way to reduce as much as I can the overhead due to tracing: in fact I have noted that when I add the tracing features the system is slowed down in a visible manner (less than UART but still slowed)...
The solution I want investigate so far are:
UART:really bad, slow but always available and simple to configure
ITM+SWO: to be tried
SEGGER RTT: much faster but requires ram overhead and still affects the system
Thanks for the answer and the help.
Best regards.