J-Link Device Support Kit

From SEGGER Wiki
Revision as of 09:10, 7 September 2022 by Alex (talk | contribs)
Jump to: navigation, search

Supporting a new device usually requires a flashloader and in some cases also a script defining special connect and reset sequences, required by the device. While SEGGER maintains updating the J-Link software with new devices, still devices might be left out in the process. To enable customers filling in the gaps on their own, the J-Link Device Support Kit (DSK) is offered. To make creating the support as easy as possible, the J-Link DSK comes with the SEGGER Flash Loader (SFL) as well as a set of example script files for various devices that require special handling.

Adding a new device

In order to add a new device to the J-Link software (meaning that the device name is selectable and known to the J-Link utilities like J-Link Commander, J-Flash, ...) and XML file with the following minimal contents need to be created:

<Database>
  <Device>
    <ChipInfo Vendor="SEGGER" Name="SEGGER_Device0" Core="JLINK_CORE_CORTEX_M0"/>
  </Device>
  <Device>
    <ChipInfo Vendor="SEGGER" Name="SEGGER_Device1" Core="JLINK_CORE_CORTEX_M4"/>
  </Device>
</Database>

When adding a new device, the following tag and attributes are mandatory:

In case the device requires a special connect / reset / ... sequence, a J-Link script file needs to be specified via ChipInfo->JLinkScriptFile:

<Database>
  <Device>
    <ChipInfo Vendor="SEGGER" Name="SEGGER_Device0" Core="JLINK_CORE_CORTEX_M0" JLinkScriptFile="SEGGER/Example.jlinkscript"/>
  </Device>
</Database>

Inheriting from an existing device

Sometimes, multiple devices are added via the same XML file and many of these devices share many of their attributes.
For such cases, it can simplify things to use the ChipInfo->InheritFrom attribute to inherit all properties from the parent device and then overriding selective ones:

<Database>
  <Device>
    <ChipInfo Vendor="SEGGER" Name="SEGGER_Device0" Core="JLINK_CORE_CORTEX_M0" JLinkScriptFile="SEGGER/Example.jlinkscript"/>
  </Device>
  <Device>
    <ChipInfo InheritFrom="SEGGER_Device0" Name="SEGGER_Device1"/>
  </Device>
</Database>

Adding a flash loader

A device entry may also be associated with 1 or more flash loaders for that device. In general, the following combinations are supported by the J-Link DSK:

  • 1:0:0 = 1 device, 0 flash banks, 0 flash loaders associated
  • 1:1:1 = 1 device, 1 flash bank, 1 flash loader associated
  • 1:1:n = 1 device, 1 flash bank, n flash loaders associated
  • 1:m:n = 1 device, n flash banks, m flash loader associated per flash bank (number of loaders may be different for each bank)

The 1:m:n association makes sense for complex devices that provide multiple flash banks and at least one of these banks may provide multiple configurations.
For example: Device with internal code flash, internal data flash, external QSPI flash.
While there is only 1 loader for the code flash and 1 for the data flash, the QSPI flash may be connected to various pin pairs and so the QSPI connection may differ from hardware to hardware.
For such cases, it makes sense to have multiple loaders available to select from, where each loader for example provides support for a specific pin configuration.
Based on the above example, a device entry could look like as follows:

<Database>
  <Device>
    <ChipInfo Vendor="SEGGER" Name="SEGGER_Device0" WorkRAMAddr="0x20000000" WorkRAMSize="0x8000" Core="JLINK_CORE_CORTEX_M4" />
    <!-- 512 KB internal code flash bank with 1 loader -->
    <FlashBankInfo Name="Internal code flash" BaseAddr="0x08000000" AlwaysPresent="1" >
      <LoaderInfo Name="Default" MaxSize="0x80000" Loader="Flashloader_Device0_InternalCodeFlash.elf" LoaderType="FLASH_ALGO_TYPE_OPEN" />
    </FlashBankInfo>
    <!-- 4 KB internal data flash bank with 1 loader -->
    <FlashBankInfo Name="Internal data flash" BaseAddr="0x09000000" AlwaysPresent="1" >
      <LoaderInfo Name="Default" MaxSize="0x1000" Loader="Flashloader_Device0_InternalDataFlash.elf" LoaderType="FLASH_ALGO_TYPE_OPEN" />
    </FlashBankInfo>
    <!-- Max. 16 MB external QSPI flash with 3 loaders. Real size + sectorization is determined by loader at runtime -->
    <FlashBankInfo Name="Internal code flash" BaseAddr="0x60000000" AlwaysPresent="1" >
      <LoaderInfo Name="CLK@PIO0_D0@PIO1_D1@PIO2_D2@PIO3_D3@PIO4_CS@PIO5" MaxSize="0x1000000" Loader="Flashloader_Device0_ExternalQSPIFlash_PinConfig0.elf" LoaderType="FLASH_ALGO_TYPE_OPEN" />
      <LoaderInfo Name="CLK@PIO20_D0@PIO21_D1@PIO22_D2@PIO23_D3@PIO24_CS@PIO25" MaxSize="0x1000000" Loader="Flashloader_Device0_ExternalQSPIFlash_PinConfig1.elf" LoaderType="FLASH_ALGO_TYPE_OPEN" />
      <LoaderInfo Name="CLK@PIO30_D0@PIO31_D1@PIO32_D2@PIO33_D3@PIO34_CS@PIO35" MaxSize="0x1000000" Loader="Flashloader_Device0_ExternalQSPIFlash_PinConfig2.elf" LoaderType="FLASH_ALGO_TYPE_OPEN" />
    </FlashBankInfo>
  </Device>
</Database>

In addition to the mandatory fields for adding a new device, the following tags and attributes need to be defined when adding a flash loader:

JLinkDevices folder

In order to make the J-Link software aware of the new device, the previously created XML file need to be placed in the central JLinkDevices folder.
If the folder does not exist, it may be created.
The location of the central folder depends on the host OS, as well as on the active user on that OS:

OS Location
Windows C:\Users\<USER>\AppData\Roaming\SEGGER\JLinkDevices
Linux $HOME/.config/SEGGER/JLinkDevices
macOS $HOME/Library/Application Support/SEGGER/JLinkDevices

Example of JLinkDevices folder structure

\---JLinkDevices
    +---Vendor1
    |   +---DevFamily1
    |   |       Devices.xml
    |   |
    |   +---DevFamily2
    |   |       Devices.xml
    |   |
    |   \---DevFamily3
    |           Devices.xml
    |
    +---Vendor2
    |   +---DevFamily1
    |   |       Devices.xml
    |   |
    |   +---DevFamily2
    |   |       Devices.xml
    |   |
    |   \---DevFamily3
    |           Devices.xml
    |
    \---Vendor3
        +---DevFamily1
        |       Devices.xml
        |
        +---DevFamily2
        |       Devices.xml
        |
        \---DevFamily3
                Devices.xml
Note:
  1. This feature has been introduced with V7.62.
  2. The J-Link DLL will recursively look through the JLinkDevices folder for any *.xml files and evaluate them as JLinkDevices.xml files.
    Customers may freely structure the folder into subfolders with a maximum depth of 4 (four).

The process of placing (i.e. copying) the XML file(s) (and potential flash loaders, script files, ...) at the desired locations can be automated by using an installer.
The J-Link DSK comes with an installer template for Microsoft Windows.

The "Welcome" page of the Open Flashloader installer example