J-Link script files
In some situations it it necessary to customize some actions performed by J-Link. In most cases it is the connection sequence and/or the way in which a reset is performed by J-Link, since some custom hardware needs some special handling which cannot be integrated into the generic part of the J-Link software. J-Link script files are written in C-like syntax in order to have an easy start to learning how to write J-Link script files. The script file syntax supports most statements (if-else, while, declaration of variables, …) which are allowed in C, but not all of them. Moreover, there are some statements that are script file specific. The script file allows maximum flexibility, so almost any target initialization which is necessary can be supported. For further information regarding J-Link script files, please refer to the J-Link User Manual (UM08001), chapter J-Link script files.
Using J-Link script files
In some IDEs, the J-Link script file can be configured directly (e.g. in the project file). If the IDE does not offer a native J-Link script file configuration option, there are some alternative options which can be used to use J-Link script files anyhow. For further information regarding this, please refer to Using J-Link Script Files#Generic.
Please note that there are two different kind of script files:
- Plaintext script files (*.JLinkScriptFile)
- Pre-compiled script files (*.pex)
Both script file types are accepted by the DLL.
To use a .JLinkScript file in Embedded Studio simply go to the project settings Project->Edit Options... and set the J-Link script file path under Debug->J-Link->Script File
The absolute path on the drive must be used. Note that macros can be used (e.g. "$(ProjectDir)/MyScript.JLinkScript").
To use a .JLinkScript file in Ozone first a Ozone project needs to be created. Next the .jdebug file needs to be edited. To set the J-Link script file function Project.SetJLinkScript(); needs to be used.
Either the absolute path on the drive or the relative path in regards to the .jdebug file can be used.
This function can be called in any of the Ozone project functions. More information can be found in the Ozone user manual.
If no J-Link settings file is present, "Default.JLinkScript" is loaded if present in the same directory as the J-Link DLL.
If a J-Link J-Link settings file is present, but no script file is specified inside of the script file, "<Name of the J-Link settings file>.JLinkScript" is loaded if present in the same directory as the J-Link settings file.
Alternatively, a J-Link script file can be specified by using one of the following ways:
- Via J-Link settings file:
- Add or edit the line
"ScriptFile="<path to script file>""
- (e.g. ScriptFile="C:\Work\Test.jlinkscript") to the [CPU] section of the J-Link settings file
- Via J-Link command strings
- Execute the command string
"ScriptFile = <path>"
- e.g. ScriptFile = C:\Work\Test.jlinkscript
- Via the J-Link control panel
J-Link script file samples
Exclude illegal memory regions
This example shows how to exclude an illegal memory region using the map region J-Link Command String. The J-Link DLL will ignore all read / write accesses to the specified region(s). This can be used if an IDE for example accesses an illegal memory address for some reason.
Connect to a specific core of a multi-core device
By default J-Link auto detects the ROM-table and selects the first core of the target device it finds. If you want to select another core as the by default selected core, you need to setup a J-LinkScript file. Within the JLinkScript file you need to define the AP map of the device, the AP to use for your core and the base address of the debug registers of the core you want to select.
The next example shows how to select the correct AP to connect to the Cortex-M7 core on a STM32H757 series device.
This example shows a special handling for NXP S32V234 (Cortex-A53, Cortex-M4, Cortex-M0+):