Difference between revisions of "How to configure JLinkScript files to enable tracing"
(→Troubleshooting) |
m |
||
Line 7: | Line 7: | ||
To enable tracing on a target device two configurations must be met: |
To enable tracing on a target device two configurations must be met: |
||
− | # The trace related Arm Coresight module |
+ | # The trace related Arm Coresight module needs to be set up (done automatically by J-Link software) |
− | # Target device specific |
+ | # Target device specific pins and SFRs need to be initialized (done by the user in the J-Link Script file) |
− | |||
− | Part one is taken care of by the J-Link software automatically. The device specific initialization must be configured by the user. |
||
For the best trace experience we recommend using Ozone: https://www.segger.com/products/development-tools/ozone-j-link-debugger/ |
For the best trace experience we recommend using Ozone: https://www.segger.com/products/development-tools/ozone-j-link-debugger/ |
||
Line 16: | Line 14: | ||
== Generic Guide == |
== Generic Guide == |
||
− | # Create a J-Link script file by |
+ | # Create a J-Link script file by creating a plain text file and renaming it to Filename.JLinkScript and open it in a text editor. |
− | # Add function OnTraceStart() to the J-Link script file (more information about script file functions in the J-Link User Manual UM08001) |
+ | # Add the function OnTraceStart() to the J-Link script file. (more information about script file functions in the J-Link User Manual UM08001) |
− | # |
+ | # Locate the trace pins used on your board schematics. |
− | # Initialize the trace pins and enable the trace clock with the corresponding clock registers if needed |
+ | # Initialize the trace pins and enable the trace clock with the corresponding clock registers if needed. |
− | # If available, configure additional trace config registers that are not part of Arm Coresight modules |
+ | # If available, configure additional trace config registers that are not part of Arm Coresight modules. |
# Set the script file in your IDE/debugger of choice: https://wiki.segger.com/Using_J-Link_Script_Files |
# Set the script file in your IDE/debugger of choice: https://wiki.segger.com/Using_J-Link_Script_Files |
||
+ | # Connect the J-Trace via the trace connector to your target. |
||
− | # Start tracing |
||
+ | # Start tracing. |
||
== Example Setup == |
== Example Setup == |
||
Line 29: | Line 28: | ||
* J-Link software version V6.16i or later |
* J-Link software version V6.16i or later |
||
* Ozone V2.44d or later |
* Ozone V2.44d or later |
||
− | * J-Trace PRO |
+ | * J-Trace PRO Cortex-M or J-Trace PRO Cortex |
* Cortex-M Trace Reference Board (enclosed with each J-Trace PRO delivery) |
* Cortex-M Trace Reference Board (enclosed with each J-Trace PRO delivery) |
||
* Example project: https://wiki.segger.com/Tracing_on_ST_STM32F407_(SEGGER_Cortex-M_Trace_Reference_Board) |
* Example project: https://wiki.segger.com/Tracing_on_ST_STM32F407_(SEGGER_Cortex-M_Trace_Reference_Board) |
||
− | The example project is already configured to run out-of-the-box with Ozone. However this tutorial is meant to teach how to create new |
+ | The example project is already configured to run out-of-the-box with Ozone. However this tutorial is meant to teach how to create a new configuration for any target device that is supported. |
=== Setup === |
=== Setup === |
||
Line 41: | Line 40: | ||
The Cortex-M Trace Reference Board is based on a ST STM32F407VE. |
The Cortex-M Trace Reference Board is based on a ST STM32F407VE. |
||
− | # Get a copy of the STM32F407VE Reference Manual from ST, this documentation will be needed to have all necessary register information |
+ | # Get a copy of the STM32F407VE Reference Manual from ST, this documentation will be needed to have all necessary register information. |
− | # Create a J-Link script file by simply creating a plain text file and renaming it to .JLinkScript |
+ | # Create a J-Link script file by simply creating a plain text file and renaming it to Filename.JLinkScript. |
− | # Add function OnTraceStart()to the J-Link script file. It follows C like syntax which is explained further in the J-Link user manual |
+ | # Add function OnTraceStart()to the J-Link script file. It follows C like syntax which is explained further in the J-Link user manual. |
− | # |
+ | # Locate the trace pins used on your board schematics, in case of the example device pins PE2-PE6 are used for tracing. |
− | # For most Arm Cortex devices peripheral clocks for GPIOs are disabled after reset, in case of the example device register RCC_AHB1ENR needs to be edited to enable the GPIOE clock |
+ | # For most Arm Cortex devices peripheral clocks for GPIOs are disabled after reset, in case of the example device register RCC_AHB1ENR needs to be edited to enable the GPIOE clock. |
− | # Access 32-bit registers through the script file by using JLINK_MEM_ReadU32() and JLINK_MEM_WriteU32() |
+ | # Access 32-bit registers through the script file by using JLINK_MEM_ReadU32() and JLINK_MEM_WriteU32(). |
− | # Set the corresponding GPIO registers to enable alternate function mode for pins PE2-PE6, we recommend using the highest speed setting for trace pins to stay within timing requirements for trace |
+ | # Set the corresponding GPIO registers to enable alternate function mode for pins PE2-PE6, we recommend using the highest speed setting for trace pins to stay within timing requirements for trace. |
− | # For the example device there is an additional device specific trace register that must be set, it is called DBGMCU_CR. In this register the used pin number (1-4) must be configured and trace enabled |
+ | # For the example device there is an additional device specific trace register that must be set, it is called DBGMCU_CR. In this register the used pin number (1-4) must be configured and trace enabled. |
# Save the script file and set it in your IDE/debugger of choice: https://wiki.segger.com/Using_J-Link_Script_Files |
# Save the script file and set it in your IDE/debugger of choice: https://wiki.segger.com/Using_J-Link_Script_Files |
||
− | # Start tracing |
+ | # Start tracing. |
== Troubleshooting == |
== Troubleshooting == |
||
Do you get no or incorrect trace data? Consider the following troubleshooting steps: |
Do you get no or incorrect trace data? Consider the following troubleshooting steps: |
||
− | * Check if registers need to be unlocked first |
+ | * Check if registers need to be unlocked first. |
− | * Check if the correct peripheral clocks have been enabled, the clock tree in the target device manual should give more insight |
+ | * Check if the correct peripheral clocks have been enabled, the clock tree in the target device manual should give more insight. |
− | * Check if the correct pins are configured, on some devices the GPIO settings must be set in the right order |
+ | * Check if the correct pins are configured, on some devices the GPIO settings must be set in the right order. |
− | * Check if there is an additional device specific trace related register which needs to be configured |
+ | * Check if there is an additional device specific trace related register which needs to be configured. |
− | * Make sure there are no capacitive or inductive elements connected to the trace lanes (e.g. Diodes, capacitors, inductors etc.) |
+ | * Make sure there are no capacitive or inductive elements connected to the trace lanes (e.g. Diodes, capacitors, inductors etc.). |
− | * Some target devices allow multiple sets of trace pins that can be activated, if you are mixing them make sure that this is supported by the MCU |
+ | * Some target devices allow multiple sets of trace pins that can be activated, if you are mixing them make sure that this is supported by the MCU. |
− | * Does the issue persist when using Ozone instead? Some IDE/debugger vendors do not support all trace features that the J-Trace PRO offers |
+ | * Does the issue persist when using Ozone instead? Some IDE/debugger vendors do not support all trace features that the J-Trace PRO offers. |
Revision as of 13:54, 27 March 2018
This article will describe how to enable trace with a JLinkScript file for supported target devices.
Contents
Introduction
To enable tracing on a target device two configurations must be met:
- The trace related Arm Coresight module needs to be set up (done automatically by J-Link software)
- Target device specific pins and SFRs need to be initialized (done by the user in the J-Link Script file)
For the best trace experience we recommend using Ozone: https://www.segger.com/products/development-tools/ozone-j-link-debugger/
Generic Guide
- Create a J-Link script file by creating a plain text file and renaming it to Filename.JLinkScript and open it in a text editor.
- Add the function OnTraceStart() to the J-Link script file. (more information about script file functions in the J-Link User Manual UM08001)
- Locate the trace pins used on your board schematics.
- Initialize the trace pins and enable the trace clock with the corresponding clock registers if needed.
- If available, configure additional trace config registers that are not part of Arm Coresight modules.
- Set the script file in your IDE/debugger of choice: https://wiki.segger.com/Using_J-Link_Script_Files
- Connect the J-Trace via the trace connector to your target.
- Start tracing.
Example Setup
Prerequisites
The following prerequisites must be met to be able to work with the example setup:
- J-Link software version V6.16i or later
- Ozone V2.44d or later
- J-Trace PRO Cortex-M or J-Trace PRO Cortex
- Cortex-M Trace Reference Board (enclosed with each J-Trace PRO delivery)
- Example project: https://wiki.segger.com/Tracing_on_ST_STM32F407_(SEGGER_Cortex-M_Trace_Reference_Board)
The example project is already configured to run out-of-the-box with Ozone. However this tutorial is meant to teach how to create a new configuration for any target device that is supported.
Setup
In the example project you will find a .JLinkScript file that already configures the target device correctly. This script file will now be used as reference to explain how a script file would be created for the Cortex-M Trace Reference Board from scratch.
The Cortex-M Trace Reference Board is based on a ST STM32F407VE.
- Get a copy of the STM32F407VE Reference Manual from ST, this documentation will be needed to have all necessary register information.
- Create a J-Link script file by simply creating a plain text file and renaming it to Filename.JLinkScript.
- Add function OnTraceStart()to the J-Link script file. It follows C like syntax which is explained further in the J-Link user manual.
- Locate the trace pins used on your board schematics, in case of the example device pins PE2-PE6 are used for tracing.
- For most Arm Cortex devices peripheral clocks for GPIOs are disabled after reset, in case of the example device register RCC_AHB1ENR needs to be edited to enable the GPIOE clock.
- Access 32-bit registers through the script file by using JLINK_MEM_ReadU32() and JLINK_MEM_WriteU32().
- Set the corresponding GPIO registers to enable alternate function mode for pins PE2-PE6, we recommend using the highest speed setting for trace pins to stay within timing requirements for trace.
- For the example device there is an additional device specific trace register that must be set, it is called DBGMCU_CR. In this register the used pin number (1-4) must be configured and trace enabled.
- Save the script file and set it in your IDE/debugger of choice: https://wiki.segger.com/Using_J-Link_Script_Files
- Start tracing.
Troubleshooting
Do you get no or incorrect trace data? Consider the following troubleshooting steps:
- Check if registers need to be unlocked first.
- Check if the correct peripheral clocks have been enabled, the clock tree in the target device manual should give more insight.
- Check if the correct pins are configured, on some devices the GPIO settings must be set in the right order.
- Check if there is an additional device specific trace related register which needs to be configured.
- Make sure there are no capacitive or inductive elements connected to the trace lanes (e.g. Diodes, capacitors, inductors etc.).
- Some target devices allow multiple sets of trace pins that can be activated, if you are mixing them make sure that this is supported by the MCU.
- Does the issue persist when using Ozone instead? Some IDE/debugger vendors do not support all trace features that the J-Trace PRO offers.