cancel
Showing results for 
Search instead for 
Did you mean: 

stlink v2 & ITM trace

bernd
Associate II
Posted on November 07, 2013 at 19:02

Hi,

I am currently stuck with stlink v2 and ITM trace on a STM32F103RB. I am using CMSIS debug support by simply calling ITM_SendChar(). This is the only trace specific code than I am using. I used SWV in the stlink tool as well as st-trace but I don't see any data. When debugging I can also see that I can reach and execute

ITM->PORT[0].u8 = (uint8_t)ch;

I have not found a single hint on certain startup-code or device, clock or other activation code that needs to be used. Anything I am potentially missing? I think I saw somewhere that trace is only working when connected with a debugger but that sounds too odd to me. I am not debugging and tracing at the same time. Physically I am only using GND, VREF, SW CLK, SW DATA IO, SWO and RST of the stlink - works well for debugging and flashing. SWCLK and TRACESWO show some activity on the oscilloscope and only when activated - so something is happening. Thanks, Bernd
9 REPLIES 9
Posted on November 07, 2013 at 20:02

It is critical that the SWV/ITM tool understands exactly what frequency you are running the core.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
bernd
Associate II
Posted on November 07, 2013 at 20:37

That was already set wrong. Now I set to 72MHz and SWV Frequency is auto-set to 2MHz. Does that make sense?

But still no data.
Posted on November 07, 2013 at 21:44

I haven't played with a stand-alone ST-LINK, mainly the Discovery boards, and via U-LINK and J-LINK. What firmware do you have on the ST-LINK? Confirm not in JTAG mode. If you have a serial port perhaps you'd want to display the APB/AHB clocks, and ITM registers.

RCC_ClocksTypeDef RCC_ClockFreq;
RCC_GetClocksFreq(&RCC_ClockFreq);
printf(''SYS:%d H:%d, P1:%d, P2:%d
'',
RCC_ClockFreq.SYSCLK_Frequency,
RCC_ClockFreq.HCLK_Frequency, // AHB
RCC_ClockFreq.PCLK1_Frequency, // APB1
RCC_ClockFreq.PCLK2_Frequency); // APB2
printf(''%08X %08X %08X %08X %08
X'',
*(volatile unsigned int *)0xE0000E00,
*(volatile unsigned int *)0xE0000E80,
*(volatile unsigned int *)0xE000EDF0,
*(volatile unsigned int *)0xE000EDFC,
*(volatile unsigned int *)0xE0042004);

For several of the Discovery boards you have to solder one of the SB (solder bridge) to get PB3 (SWO) to the F103 implementing the ST-LINK
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
bernd
Associate II
Posted on November 07, 2013 at 22:17

{SYSCLK_Frequency = 72000000, HCLK_Frequency = 72000000, PCLK1_Frequency = 36000000, PCLK2_Frequency = 72000000, ADCCLK_Frequency = 36000000}
ITM_TER = 0xFFFFFFFF
ITM_TCR = 0x1000D
0xE000EDF0 = 0x30003
0xE000EDFC = 0x1000001
0xE0042004 = 0x27

cmantunes
Associate II
Posted on December 05, 2013 at 15:04

Have you been able to solve the problem? I am having the same issue with ST Link Utility Serial WIre Viewer... Thanks!

Posted on December 05, 2013 at 16:00

Have you been able to solve the problem? I am having the same issue with ST Link Utility Serial WIre Viewer...

The same issue? Can you be a little bit more specific about your set up and tool chain, and such?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
cmantunes
Associate II
Posted on December 05, 2013 at 17:04

I am using Em::Blocks IDE, which doesn't support ITM viewing, together with with ST-Link V2/ISOL for programming and debugging. This config works fine. For serial wire viewing, I am just using the STM32 STLink Utility. 

Posted on December 05, 2013 at 17:21

And what board/chip is this with? Do you have a schematic?

The critical connection is PB3 SWO.

The critical setting is that of the speed.

The other setting should be the defaults for ITM_SendChar(), the ST-Link can let you mess with the channel setting, but not much else.

Pay attention to the connectivity, and firmware version.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
cmantunes
Associate II
Posted on December 06, 2013 at 17:31

Well, it's always a stupid mistake, like connecting to the wrong pin!

It is working now. Thank you for your interest.