cancel
Showing results for 
Search instead for 
Did you mean: 

M4 Core ITM trace

K.Ata15
Associate III

Hi,

Looking at the reference manual, en.DM00327659.pdf, page 3929 it seems the simple way of debugging previous M4 processors using printf() redirect to the ITM and then using the SWO pin/STLINK interface could be used on the MP1 M4 core as well.

But there isn't simple mention of the ITM functions in the STM32Cube_FW_MP1_V1.0.0 release, and there is not even a single declaration of the ITM HW in the stm32mp157cxx_cm4.h file(not even the 0xE0000000 base address).

Can you provide some code example please, it will be much better starting point than the vague description of the ITM operation in the reference manual. Thank you!

Edit: ST-Link utility connected to the STM32MP157C-DK2 dev board seems not able to connect (loaded with latest V2.J34.M25 firmware) to the MP1. It does reset it though, so printf in the SWO viewer is out of the question. Maybe there is a way to redirect ITM to the M4 core ?

Second, seems the M4 ITM hw is loosely based on the STM32F469/479 ITM core(at least register addresses match). But the CubeF4 also do not supply 469 example, and ITM register also seems to be not declared in the include files.

I have working code ITM print code for F4, F7 and H7 devices, but the 469/MP1 hardware seems bit different.

K.

1 ACCEPTED SOLUTION

Accepted Solutions
OlivierK
ST Employee

Hello K,

You are correct, I tried STLink Utility which connects in JTAG/SWD via STLINK but this tool was primarily designed for STM32MCUs and not been upgraded yet to STM32MP1, therefore you won't be able to use SWV window for the time being.

Engineering mode does not route the ITM data to SWO pin, but can be used for firmware testing on the CortexM4 side, it allows to use the STLINK as a JTAG/SWD interface (in SW4STM32 for instance) and isolate Linux on A7. (https://wiki.st.com/stm32mpu/wiki/STM32CubeMP1_Package#Introduction_to_boot_mode), then it should be just a question of retargeting ITM0 to SWO but no luck so far on my side.

Glad to hear that this is not a blocking point for you, and that you are able to use UART for printf, and use virtual com port in SW4STM32.

BR

Olivier

View solution in original post

5 REPLIES 5
OlivierK
ST Employee

Hello K,

ITM functions are present in the CMSIS/Include directory, They are visible in "core_cm4.h" since they are linked to ARM Cortex M4 core and included in the STM32Cube_FW_MP1_V1.0.0 release. In this release version, we don't have yet an example for retargeting ITM0 on SWO pin but it should be similar as in your existing F4 project if you set your board and project in "Engineering mode" where the cortex A7 and the linux part is bypassed as if the STM32MP1 is reduced to a single core STM32F4-like MCU. Which IDE are you currently using?

There are 2 other possibilities than using ITM0 to retarget printf to the console, one is to use UART4 linked to STLink on our STM32MP1 boards. (https://wiki.st.com/stm32mpu/wiki/Trace_and_debug_scenario_-_UART_issue) an example in STM32Cube_FW will be available in revision V1.1.0 targeted in October.

The second one which is the intrusive debugging method using semihosting, works fine with SW4STM32 IDE.

(Help->Help Contents: search Semihosting).

Kind Regards

Olivier

Hey Olivier,

Thanks for your reply! Yes, i did insert my ITM init code and referenced the ITM registers immediately, i guess i wasn't searching properly, my bad. The code integrates fine, i think the main problem is that the STLink will not connect to the board and allow to start the SWV windwos in the STM32 ST-Link utility.

The 'Engineering Mode', does that just routes the ITM data internally ? Because i still need to run the loading script on the Linux part and execute my M4 firmware.

I am using the UART to redirect printf right now, and using the virtual com port created by the ST-Link. I would have preffer the ITM, but it is ok, once it is available. I do use the SystemWorks for this project (no semihosting is just too much, i need only basic print).

BR, K.

OlivierK
ST Employee

Hello K,

You are correct, I tried STLink Utility which connects in JTAG/SWD via STLINK but this tool was primarily designed for STM32MCUs and not been upgraded yet to STM32MP1, therefore you won't be able to use SWV window for the time being.

Engineering mode does not route the ITM data to SWO pin, but can be used for firmware testing on the CortexM4 side, it allows to use the STLINK as a JTAG/SWD interface (in SW4STM32 for instance) and isolate Linux on A7. (https://wiki.st.com/stm32mpu/wiki/STM32CubeMP1_Package#Introduction_to_boot_mode), then it should be just a question of retargeting ITM0 to SWO but no luck so far on my side.

Glad to hear that this is not a blocking point for you, and that you are able to use UART for printf, and use virtual com port in SW4STM32.

BR

Olivier

Hi Olivier,

Thanks for the link! That makes it better. All is working on my side. The MP1 is a nice chip, but takes some time to learn all little details.

BR

Hello Guys,

I am developing firmware on the STM32MP157C-DK2 in engineering mode and using STM32Cube_FW_MP1_V1.4.0 and STM32CubeIDE. I must say this is my first project with a STM device and the tools. I am unable to direct printf to the UART4 linked to the onboard VCP of the STLink debugger. The cube package example 'UART_Receive_Transmit_Console' seems to directing printf to USART3 port, not the UART4. After reading the application note 'AN4989 Rev 3: STM32 microcontroller debug toolbox', printf redirection to uart port seems quite simple task. But since UART4 cannot be assigned to the CortextM4, it is shared port. I am unable to figure out where the handle of UART4 port is defined, which is essentially needed to redirect printf command. Thanks in advance for any help in making it work.

Kind regards

Jatala