Generic IDE

From SEGGER Wiki
Jump to: navigation, search

Generic IDE

This wiki article describes ways to set settings or use features of J-Link which work independently from the IDE / development environment used.


Getting started with J-Link

How can I get my development environment to work with J-Link?

Please refer to the Supported IDEs if there exists a wiki page dedicated to your IDE and / or consult the user manual of your IDE in order to find instructions on how to use J-Link with the debugger of the IDE used. If it is not specifically mentioned, please note that there are generic / "standardized" debugging interfaces, like RDI and GDB. If the IDE also does not support either of those, please get in touch with SEGGER via mail, so that we can evaluate what can be done.

I got my unlisted IDE to work with J-Link, but X is not working!

Please refer to this page in order to get to know about ways for setting settings or using features without using a IDEs GUI. If sth. still does not work, we suggest as a first step to test if it has sth. to do with the IDE in use by checking if it works when using SEGGER J-Link Commander (which is part of the J-Link software package) or SEGGER Ozone. Checking if a feature works using a binary build by your IDE with J-Link Commander or Ozone can usually be done in less then 10 minutes. If, on the contrary, you are facing issues verifying a setup with J-Link Commander or Ozone, please get in touch with us via mail.

Mandatory settings

Configuring target interface type

Specifying of the target interface type should be possible in the settings of debugger used.
The selected interface will be shown in the J-Link control panel
GenericIDE TargetIF Marked.png

As a workaround, the target interface can also be specified in a J-Link script file.

Configuring target interface speed

Specifying of the target interface speed should be possible in the settings of debugger used.
The selected interface speed will be shown in the J-Link control panel
GenericIDE TargetIF Marked.png
As a workaround, the target interface speed can also be changed in the J-Link control panel or specified in a J-Link script file.


Specifying the target device

If no target device or core is specified, the J-Link DLL will present a selection dialog to the user, asking for manual input.
GenericIDE Device Select.png
Alternatively, the target device can be specified by using one of the following ways:

  1. Adding a line "Device="<devicename>"" (e.g. Device="STM32F103ZE") to the [FLASH] section of the J-Link settings file
  2. Executing the command string "Device <devicename>" (e.g. Device stm32f103ve).
  3. Setting the device name in a J-Link script file

If the device is not listed as a supported device, either select the respective core, or follow the instructions given in Adding Support for New Devices in order to add your own device.

Connecting to a specific J-Link

If multiple J-Links are connected to the host PC, the J-Link DLL will ask the user which J-Link should be used.
GenericIDE JLink Select.png


If no J-Links are connected via USB the J-Link DLL will ask the user if a connection to a J-Link via TCP/IP should be established:

Using the J-Link Flash loader

Why should I use the J-Link Flash loader?

Using the J-Link flash loader allows fast flash programming, debugging and enables the Flash Breakpoint feature. For further information, please refer to UM08001, chapter "Flash download", section "Why should I use the J-Link flash download feature?".

Internal flash

If the device is specified (Specifying the target device), the J-Link Flash loader will be used automatically, if not overwritten by the IDE. If you want to use your own flash loader (or enhance / edit the J-Link flash loader), please follow the instructions given in Adding Support for New Devices

Generic - via J-Link script file

The setup for download into CFI-compliant memory is different from the one for internal flash. Initialization of the external memory interface the CFI flash is connected to, is user’s responsibility and is expected by the J-Link software to be done prior to performing accesses to the specified CFI area.

Specifying of the CFI area is done in a J-Link script file, as explained below. The following sample script defines a 16 MiB CFI flash at address 0x64000000 and a 64 KiB WorkRAM at address 0x20000000:

/*********************************************************************
*
*       ConfigTargetSettings
*/
int ConfigTargetSettings(void) {
  JLINK_ExecCommand("SetCFIFlash 0x64000000-0x64FFFFFF");
  JLINK_ExecCommand("SetWorkRAM 0x20000000-0x2000FFFF");
  return 0;
}


In the following example, it is explained which steps are necessary to prepare J-Link for download into external CFI flash memory based on a sample sequence for a ST STM32F103ZE device:

/*********************************************************************
*
*       SetupTarget
*/
int SetupTarget(void) {
  int r;

  r = 0;

  JLINK_TARGET_Halt();
  JLINK_ExecCommand("SetCFIFlash 0x64000000-0x64FFFFFF");
  JLINK_ExecCommand("SetWorkRAM 0x20000000-0x2000FFFF");
  r |= JLINK_MEM_WriteU32(0x40021014, 0x00000114); // RCC_AHBENR, FSMC clock enable
  r |= JLINK_MEM_WriteU32(0x40021018, 0x000001FD); // GPIOD~G clock enable
  r |= JLINK_MEM_WriteU32(0x40011400, 0xB4BB44BB); // GPIOD low config, NOE, NWE => Output, NWAIT => Input
  r |= JLINK_MEM_WriteU32(0x40011404, 0xBBBBBBBB); // GPIOD high config, A16-A18
  r |= JLINK_MEM_WriteU32(0x40011800, 0xBBBBBBBB); // GPIOE low config, A19-A23
  r |= JLINK_MEM_WriteU32(0x40011804, 0xBBBBBBBB); // GPIOE high config, D5-D12
  r |= JLINK_MEM_WriteU32(0x40011C00, 0x44BBBBBB); // GPIOF low config, A0-A5
  r |= JLINK_MEM_WriteU32(0x40011C04, 0xBBBB4444); // GPIOF high config, A6-A9
  r |= JLINK_MEM_WriteU32(0x40012000, 0x44BBBBBB); // GPIOG low config, A10-A15
  r |= JLINK_MEM_WriteU32(0x40012004, 0x444B4BB4); // GPIOG high config, NE2 => output
  r |= JLINK_MEM_WriteU32(0xA0000008, 0x00001059); // CS control reg 2, 16-bit, write enable, Type: NOR flash
  r |= JLINK_MEM_WriteU32(0xA000000C, 0x10000505); // CS2 timing reg (read access)
  r |= JLINK_MEM_WriteU32(0xA000010C, 0x10000505); // CS2 timing reg (write access)
  if (r < 0) {
    return -1;
  }
  return 0;
}

J-Flash

  1. Create a new project
  2. Select the correct device or at least the core
  3. Add the device specific initialization of the external memory controller to the J-Flash init steps which are part of the project (Project settings -> MCU -> Init steps).

Alternatively the method in the beginning of this article (Generic - via J-Link script file) can be used to initialize CPU.

  1. Make sure that a flash bank is configured to "Automatically detect flash memory" (

[Deprecated] Via J-Link settings file

  1. Open the J-Link settings file (see J-Link settings file)
  2. Add the following lines to the file
[CFI]
CFISize = <FlashSize>
CFIAddr = <FlashAddr>
[GENERAL]
WorkRAMSize = <RAMSize>
WorkRAMAddr = <RAMAddr>
  1. After this the file should look similar to the sample in the following screenshot.
    IAR CFI Flash Settings Marked.png
  2. Save the settings file and restart the debug session.

J-Link Settings File

The J-Link Settings File stores configuration and selections which must not be changed by the user manually. If the IDE did not set the J-Link settings file, it can be manually set.

J-Link settings files are either passed by the application using the J-Link DLL before opening a connection to J-Link, or specified by executing the command string :

"ProjectFile = <path>"

J-Link Unlimited Flash Breakpoints

Unlimited Flash Breakpoints work if the J-Link flash loader works and a license for flash breakpoints is present. No additional setup is required. The flash breakpoint feature is available for internal flashes and for external flash (parallel NOR CFI flash as well as QSPI flash). For more information about how to setup for flash download, please refer to internal flash. Whether flash breakpoints are available can be verified using the J-Link control panel:
GenericIDE FlashBP Marked.png

Enable Monitor Mode Debugging

The Monitor Mode can be enabled using the following J-Link Script file:

How to use J-Link script files: https://wiki.segger.com/Using_J-Link_Script_Files

Using J-Link Command Strings

Please refer to: https://wiki.segger.com/Using_J-Link_Command_Strings#Generic

Using J-Link script files

Please refer to: https://wiki.segger.com/Using_J-Link_Script_Files

J-Link DLL version

Determining the version of JLink DLL

To determine which version of the JLinkARM.dll you are using, the DLL version can be viewed by right clicking the DLL in explorer and choosing Properties from the context menu. Select the Details tab to display information about the product version.
GenericIDE DLL Version.png

Determining which DLL is used by a program

To verify that the program you are working with is using the DLL you expect it to use, you can investigate which DLLs are loaded by your program with tools like Sysinternals' Process Explorer. It shows you details about the DLLs used by your program, such as manufacturer and version.
GenericIDE ProcessExplorer DLL Marked.png

Updating the J-Link DLL

The J-Link DLL is part of the J-Link software and documentation pack. The software package not only installs the new files to the path specified, but also makes sure that 3rd-party applications use the newly installed version as well, if requested to do so by the user.
This is handled differently, depending on the operating system:


Windows

After copying of the installed files, the J-Link DLL Updater Dialog is started.
GenericIDE DLL Updater.png
The J-Link DLL Updater list all applications supported by the DLL updater. These applications solely use "their" own copy of the DLL, usually located in the installation directory of that application. The user can select which applications' DLL copy shall be updated (Default: all).

Other applications query an entry in the Windows registry for the path of the DLL the use. This entry is updated by the DLL Updater if the newly installed version is higher than the value currently stored.


macOS

The software is installed to /Applications/SEGGER/JLink_VXYYO
Additionally, the symbolic link /Applications/SEGGER/JLink is updated so that it points to the most recently installed version.
Therefore, users can use links or shortcuts to SEGGER applications in /Applications/SEGGER/JLink which will always point to the most recently installed version of the application.
Similarly, developers can link against libjlinkarm.dylib in /Applications/SEGGER/JLink in order to make sure that their applications always used the most recently installed version of the J-Link library.


Linux

The software is installed to /opt/SEGGER/JLink_VXYYO
Additionally, the symbolic link /opt/SEGGER/JLink is updated so that it points to the most recently installed version.
Therefore, users can use links or shortcuts to SEGGER applications in /opt/SEGGER/JLink which will always point to the most recently installed version of the application.
Similarly, developers can link against libjlinkarm.so in /opt/SEGGER/JLink in order to make sure that their applications always uses the most recently installed version of the J-Link library.


Low power debugging

Via J-Link script file

Low-power handling mode can be activated via a J-Link command string (EnableLowPowerHandlingMode), e.g. from inside a J-Link script file, like as follows:

/*********************************************************************
*
*       InitEMU
*/
int InitEMU(void) {
  JLINK_ExecCommand("EnableLowPowerHandlingMode");
  return 0;
}


Via J-Link settings file

Low-power handling mode has to be activated in the J-Link settings file. Open the J-Link settings file in a text editor and add the following line in the [CPU] section:

LowPowerHandlingMode = 1

RDI

How to enable RDI in a debugging / development environment heavy depends on the environment used. In general the debugger needs to be pointed to the JLinkRDI.dll, which is located in the J-Link software installation directory.

Once the debugger has been successfully configured to use the JLinkRDI.dll, please refer to UM08001 for further information on how to use and configure J-Link RDI.

SWO

Implementing SWO in the target application

Some compilers come with an option to enable stdout redirection to SWO, which causes all stdout traffic to be ouput via SWO. A more generic und versatile approach is to include functions dedicated to SWO output into the application code. This allows to distinguish between messages which should be output via SWO and other which should be output via stdout. Needless to say, redirection of stdout is also possible with this approach and does not depend on IDE features.

In UM08001 chapter "J-Link software and documentation package" subsection "Target example code for terminal output" an code example code is provided. Furthermore, in subsection "Configure SWO output after device reset" a code example for starting SWO output after reset is provided.

Better alternative to SWO: SEGGER Real Time Transfer

Real Time Transfer (RTT) allows to output information from the target microcontroller as well as sending input to the application at a very high speed without affecting the target's real time behavior. In contrast to SWO, RTT does not require a extra pin, but works via the normal target debug interface (e.g. JTAG or SWD). Performance is vastly superior to SWO. For more information, please refer to the RTT website and the J-Link User Guide UM08001.