J-Flash SPI - Custom Device Support

From SEGGER Knowledge Base
Jump to navigation Jump to search

While J-Flash SPI already supports a large number of SPI flashes, there might still be devices that are not yet included.
To allow customers to fill the gaps on their own, custom J-Flash SPI device support can be expanded through XML files.
This article details how custom device support can be added.

Adding a new device

In order to add a new SPI flash device to the J-Flash SPI software, the device can be added to the Flash.xml file found in the J-Link software installation directory under ETC\JFlashSPI\Flash.xml or to a custom FlashDevices XML file.
Devices are split into <DeviceInfo> and <Device> tags. When adding a new device, it should first be checked wether a <DeviceInfo> tag with the same attributes already exists. If so, the new <Device> tag can be added as a child of that <DeviceInfo> tag. Otherwise, a new <DeviceInfo> and <Device> tag should be created.
The file uses the following structure:

<DeviceList>
  <Flash>
    <Eeprom>
      <DeviceInfo Id3B="0x000000" PageSize="0x00000020" SectSize="0x00000000" DevSize="0x00001000" StatRegFormat="MICRON" Type4BMode="NONE" SpiApi="EEPROM_2BADDR">
        <Device Vendor="ST" Name="M95320"/>
      </DeviceInfo>
    </Eeprom>
    <Nor>
      <DeviceInfo Id3B="0x158020" PageSize="0x00000100" SectSize="0x00010000" DevSize="0x00200000" StatRegFormat="WINBOND_3BP" Type4BMode="NONE" SpiApi="NORMAL">
        <Device Vendor="ST" Name="M25PE16"/>
      </DeviceInfo>
    </Nor>
    <Fram>
      <DeviceInfo Id3B="0x0822C2" PageSize="0x00000100" SectSize="0x00008000" DevSize="0x00008000" StatRegFormat="MICRON" Type4BMode="NONE" SpiApi="FRAM">
        <Device Vendor="Infineon" Name="FM25V02A"/>
      </DeviceInfo>
    </Fram>
  </Flash>
</DeviceList>

FlashDevices folder

Similar to the JLinkDevices folder, custom XML files can be placed into the FlashDevices folder.
This is recommended for custom device support, as adding devices to the included Flash.xml file will result in lost changes after updating the J-Link software package, while the FlashDevices folder is persistent.
In case a custom device shares an ID and name with an internal device, the custom devices will fully override the internal device.
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\FlashDevices
Linux $HOME/.config/SEGGER/FlashDevices
macOS $HOME/Library/Application Support/SEGGER/FlashDevices

Flash Device XML file

The Flash.xml file is used to add support for new flash devices.
This section explains the structure, tags, attributes etc. of the Flash.xml file.

In the following, the valid XML tags and their possible attributes are explained.
General rules

  • Attributes may only occur inside an opening tag
  • Attribute values must be enclosed by quotation marks

Tag Description

Tag Description
<DeviceList> Opens the XML file top-level tag.
<Flash> Opens the flash device list.
<Eeprom> Opens the EEPROM device list.
<Nor> Opens the NOR device list.
<Fram> Opens the FRAM device list.
<DeviceInfo> Specifies general device information that can be applied to multiple flash devices.
<Device> Specifies device specific information.

XML-tag DeviceList

Example

<DeviceList>
  <Flash>
    <Nor>
      <DeviceInfo Id3B="0x158020" PageSize="0x00000100" SectSize="0x00010000" DevSize="0x00200000" StatRegFormat="WINBOND_3BP" Type4BMode="NONE" SpiApi="NORMAL">
        <Device Vendor="ST" Name="M25PE16"/>
      </DeviceInfo>
    </Nor>
  </Flash>
</DeviceList>

Explanation
Opens the XML file top-level tag. Only present once per XML file.

Attributes
This tag has no attributes.

Notes

  • Must only occur once per XML file
  • Must be closed via </DeviceList>

XML-tag Flash

Example

<Flash>
  <Nor>
    <DeviceInfo Id3B="0x158020" PageSize="0x00000100" SectSize="0x00010000" DevSize="0x00200000" StatRegFormat="WINBOND_3BP" Type4BMode="NONE" SpiApi="NORMAL">
      <Device Vendor="ST" Name="M25PE16"/>
    </DeviceInfo>
  </Nor>
</Flash>

Explanation
Opens the flash device list.

Attributes
This tag has no attributes.

Notes

  • Must only occur once in a <DeviceList> tag
  • Must be closed via </Flash>

XML-tag Eeprom

Example

<Eeprom>
  <DeviceInfo Id3B="0x000000" PageSize="0x00000020" SectSize="0x00000000" DevSize="0x00001000" StatRegFormat="MICRON" Type4BMode="NONE" SpiApi="EEPROM_2BADDR">
    <Device Vendor="ST" Name="M95320"/>
  </DeviceInfo>
</Eeprom>

Explanation
Opens the EEPROM device list.

Attributes
This tag has no attributes.

Notes

  • Must only occur once in a <Flash> tag
  • Must be closed via </Eeprom>

XML-tag Nor

Example

<Nor>
  <DeviceInfo Id3B="0x158020" PageSize="0x00000100" SectSize="0x00010000" DevSize="0x00200000" StatRegFormat="WINBOND_3BP" Type4BMode="NONE" SpiApi="NORMAL">
    <Device Vendor="ST" Name="M25PE16"/>
  </DeviceInfo>
</Nor>

Explanation
Opens the NOR device list.

Attributes
This tag has no attributes.

Notes

  • Must only occur once in a <Flash> tag
  • Must be closed via </Nor>

XML-tag Fram

Example

<Fram>
  <DeviceInfo Id3B="0x0822C2" PageSize="0x00000100" SectSize="0x00008000" DevSize="0x00008000" StatRegFormat="MICRON" Type4BMode="NONE" SpiApi="FRAM">
    <Device Vendor="Infineon" Name="FM25V02A"/>
  </DeviceInfo>
</Fram>

Explanation
Opens the FRAM device list.

Attributes
This tag has no attributes.

Notes

  • Must only occur once in a <Flash> tag
  • Must be closed via </Fram>

XML-tag DeviceInfo

Example

<DeviceInfo Id3B="0x158020" PageSize="0x00000100" SectSize="0x00010000" DevSize="0x00200000" StatRegFormat="WINBOND_3BP" Type4BMode="NONE" SpiApi="NORMAL">
  <Device Vendor="ST" Name="M25PE16"/>
</DeviceInfo>

Explanation
Specifies general device information that can be applied to multiple flash devices.

Attributes

Attribute Mandatory Description Example
Id3B YES.png Hexadecimal value that specifies the ID of the device. Id3B="0x158020"
Ignore2ndIdByte NO.png Specifies wether the second byte of the ID should be ignored for identification. Ignore2ndIdByte="1"
PageSize YES.png Hexadecimal value that specifies the page size of the device. PageSize="0x00000100"
SectSize YES.png Hexadecimal value that specifies the sector size of the device. SectSize="0x00010000"
DevSize YES.png Hexadecimal value that specifies the size of the device. DevSize="0x00200000"
StatRegFormat YES.png Specifies the format of the status register. For a list of valid attribute values, please refer to Attribute values - StatRegFormat. StatRegFormat="MICRON"
Type4BMode YES.png Specifies the supported 4B mode. For a list of valid attribute values, please refer to Attribute values - Type4BMode. Type4BMode="NONE"
SpiApi YES.png Specifies the used SPI API. For a list of valid attribute values, please refer to Attribute values - SpiApi. SpiApi="NORMAL"
IdInfo NO.png Specifies additional ID information. For a list of valid attribute values, please refer to Attribute values - IdInfo. IdInfo="S25FS512S"
QspiInfo NO.png Specifies additional information for QSPI devices. For a list of valid attribute values, please refer to Attribute values - QspiInfo. QspiInfo="GD25Q128E"

Notes

  • May occur multiple times in a <Eeprom>, <Nor> or <Fram> tag
  • Must include at least one <Device> tag
  • Must be closed via </DeviceInfo>

XML-tag Device

Example

<Device Vendor="ST" Name="M25PE16"/>

Explanation
Specifies device specific information.

Attributes

Attribute Mandatory Description Example
Vendor YES.png String value that specifies the vendor of the device. Vendor="ST"
Name YES.png String value that specifies the name of the device. Name="M25P16"

Notes

  • May occur multiple times in a <DeviceInfo> tag
  • No separate closing tag. Directly closed after attributes have been specified: <Device ... />