Keil Logo

µVISION DEBUGGER: Using a Segger J-Link Script File During Debugging


Information in this knowledgebase article applies to:

  • MDK v4.0 and later

SYMPTOM

I cannot establish a debug or trace connection using Keil MDK and a Segger J-Link (or a Segger J-Trace). I have verified this works using third-party software tools. Are there additional settings I can set in a debug script?

CAUSE

Since Segger manufactures the J-Link adaptor, they provide a J-Link dll to Keil. To use this dll in the Keil µVision IDE: in the Project -> Options For Target -> Debug tab, on the right-hand side, click the Settings button to open the Cortex JLink/Jtrace Target Driver Setup dialog. In this dialog, configure the Debug and Flash Download settings settings for the Segger J-Link or J-Trace.

Instead of just using a debug script initialisation file (.ini file) on the Debug tab, use these methods provided by Segger for additional configuration options.

  • J-Link Commander - a command line interface for inputting J-Link Commands.
  • J-Link Control Panel - the J-Link dll called in the background by the Keil µVision Debugger. Use it to monitor debug status, and configure some J-Link features.
  • J-Link Debug Script files - for additional control of reset, trace configuration, delays, debug commands, etc.
Debug Script Types

Two types of Segger debug script files are:

  • *.JLinkScript file: J-Link Script File in plain text format
  • *.Pex File: pre-compiled, non-modifiable file, i.e., it is not plain text or human-readable. Contact Segger if the project needs a modified version of the script file.
  • Some CMSIS-PACK examples come with JLinkScript files. Using Windows Explorer, search the pack directory of your device family (typically in C:\Keil_v5\Arm\pack) for ext:JLinkScript.
  • Segger provides examples projects that include J-Link script files. See their debug probe wiki page for those examples.
    • Download and unzip an example project to view the J-Link script file.
  • Make a custom J-Link script file. See their sample J-Link script wiki page.

RESOLUTION

When starting the Keil µVision Debugger, the J-Link dll always tries to use the JLinkSettings.JLinkScript in the project directory (if present). So to use a .JLinkScript file in Keil MDK5:

  1. Using Windows Explorer, open the folder where the µVision project file (*.uvprojx) is.
  2. Copy the *.JLinkScript into this folder. Rename it JLinkSettings.JLinkScript.
  3. In the µVision IDE, select Debug -> Start/Stop Debug Session and verify the J-Link script ran.
  4. See more in the Segger wiki page for Keil MDK.

Another method for including a Segger J-Link script file within a Keil MDK project:

  1. In the Keil IDE, on the Project -> Options For Target -> Debug tab, click the click the Settings button to open the Cortex JLink/Jtrace Target Driver Setup dialog - this activates the J-Link dll.
  2. With the J-Link driver in use, a j-link-control-panel-icon J-Link system tray icon - a green box with a white "J" - appears in the Microsoft Windows task bar notification area.
  3. Click on the J-Link Icon to open the Segger J-Link Control Panel.
  4. There, switch to Settings tab.
  5. In the third field in the dialog - the Script file field - click the button. Browse to the J-link script file. Press Open to close this dialog.
  6. For *.pex file types: change the file filter from J-Link script files (*.Jlinkscript) to All Files (*.*) then press Open.
  7. Close the Segger J-Link Control panel this saves the reference J-link Script file settings in the JLinkSettings.ini in the project folder.
  8. In the µVision IDE, select Debug -> Start/Stop Debug Session and verify the J-Link script ran.
  9. More information in their J-Link script file wiki page.

Additional Notes

  • Debug Configuration (dbgconf) files will not work with a J-Link or J-Trace. Use a Segger debug script instead.
  • In some cases, the debug sequence in the J-Link script file is only implemented for JTAG. In such cases, JTAG mode must also be set in the Cortex JLink/Jtrace Target Driver Setup dialog (in the Project -> Options For Target -> Debug tab).
  • Every time the J-Link dll connects to the J-Link debug adaptor, it automatically generates a JLinkSettings.ini file in the project directory. Changing a value in the Cortex JLink/Jtrace Target Driver Setup dialog updates a corresponding field in the JLinkSettings.ini file.

Troubleshooting

More Information

  • Read more about using a J-link with Keil MDK on Segger's webpage.
  • To read about Segger J-Link commands in the J-Link / J-Trace User Guide, download the J-Link Manual here.

See Also

Last Reviewed: Monday, January 11, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.