Personal tools

Difference between revisions of "How to enable trace feature on i.MX RT"

From SomLabs Wiki

Jump to: navigation, search
(Created page with "{{PageHeader|How to enable trace feature on i.MX RT}} By default, trace pins are configured as GPIO. To use trace functionality, it is necessary to configure pinmux and enabl...")
 
 
Line 5: Line 5:
 
This operation has to be done as early as possibly in init code.
 
This operation has to be done as early as possibly in init code.
  
Best way is to use ''SystemInitHook'' function, which is called in early init steps.
+
The best way is to use ''SystemInitHook'' function, which is called in early init steps.
 
By default, there is an empty ''SystemInitHook'' defined in CMSIS files, with ''__weak__'' linking attribute.
 
By default, there is an empty ''SystemInitHook'' defined in CMSIS files, with ''__weak__'' linking attribute.
If linker finds ''SystemInitHook'' in any user files it will be used instead of default one.
+
If linker finds ''SystemInitHook'' in any user files it will be used instead of the default one.
  
 
So, to enable trace support, we need to define following function in any *.c file:
 
So, to enable trace support, we need to define following function in any *.c file:
Line 26: Line 26:
  
  
Segger J-Trace trace functionality is supported only by Ozone debugger from Segger.
+
Segger J-Trace trace functionality is supported by Ozone debugger from Segger.
 
It is important to properly configure trace parameters in Ozone to make it working, this could be done in menu ''Tools->Trace settings''. Recommended settings are shown on picture below.
 
It is important to properly configure trace parameters in Ozone to make it working, this could be done in menu ''Tools->Trace settings''. Recommended settings are shown on picture below.
 
[[File:Imxrt_trace_configuration.png|center|338px]]
 
[[File:Imxrt_trace_configuration.png|center|338px]]

Latest revision as of 09:20, 13 February 2019

How to enable trace feature on i.MX RT


By default, trace pins are configured as GPIO. To use trace functionality, it is necessary to configure pinmux and enable clock to trace unit. This operation has to be done as early as possibly in init code.

The best way is to use SystemInitHook function, which is called in early init steps. By default, there is an empty SystemInitHook defined in CMSIS files, with __weak__ linking attribute. If linker finds SystemInitHook in any user files it will be used instead of the default one.

So, to enable trace support, we need to define following function in any *.c file:

void SystemInitHook (void)
{
   // configure trace port
   // configure pinmux
   IOMUXC_SetPinMux(IOMUXC_GPIO_B0_04_ARM_CM7_TRACE00, 0U);
   IOMUXC_SetPinMux(IOMUXC_GPIO_B0_05_ARM_CM7_TRACE01, 0U);
   IOMUXC_SetPinMux(IOMUXC_GPIO_B0_06_ARM_CM7_TRACE02, 0U);
   IOMUXC_SetPinMux(IOMUXC_GPIO_B0_07_ARM_CM7_TRACE03, 0U);
   IOMUXC_SetPinMux(IOMUXC_GPIO_B0_12_ARM_CM7_TRACE_CLK, 0U);

   // enable clock
   CLOCK_EnableClock(kCLOCK_Trace);
}


Segger J-Trace trace functionality is supported by Ozone debugger from Segger. It is important to properly configure trace parameters in Ozone to make it working, this could be done in menu Tools->Trace settings. Recommended settings are shown on picture below.

Imxrt trace configuration.png
NXP Partner ST Partner Renesas Partner