Skip to main content
Visitor II
June 21, 2019
Solved

M4 Core ITM trace

  • June 21, 2019
  • 2 replies
  • 2154 views

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.

    This topic has been closed for replies.
    Best answer by OlivierK

    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

    2 replies

    Technical Moderator
    June 26, 2019

    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

    K.Ata15Author
    Visitor II
    June 27, 2019

    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.

    OlivierKAnswer
    Technical Moderator
    June 27, 2019

    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

    K.Ata15Author
    Visitor II
    June 27, 2019

    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