316 CHAPTER 11 J-Flash SPI
J-Link / J-Trace (UM08001) ©
2004-2017 SEGGER Microcontroller GmbH & Co. KG
11.7 Custom Command Sequences
J-Flash SPI supports sending custom command sequences, which may be different
for different SPI flashes (e.g. program OTP, program security register, etc...), via the
SPI interface. Due to the generic syntax, this feature can be used to implement any
kind of required command sequence. The sequence is stored in the J-Flash SPI
project file (*.jflash) and therefore it can be included in automated production envi-
ronments without any problems and be used with the command line version of J-
Flash SPI as well.
The custom command sequence can be configured in the Setup tab of the J-Flash
project settings as part of the Init / Exit Steps which allow to enter custom
sequences using a pre-defined list of operations. The following list shows all valid
commands which can be used:
11.7.1 Init / Exit steps
The init sequence will be performed as part of the connect sequence, for example to
disable security, while the exit sequence will be executed after programming, for
example to enable the security in order to secure the SPI flash.
11.7.2 Example
The example below demonstrates how to use the custom command sequence feature
to implement a read-modify-write security register on the Winbond W25Q128FVSIG
SPI flash using the init steps. To make sure that the output of the example is exactly
the same, the sample erases the security register to have defined values.
Step #0 to Step#2: Set Write Enable
Step #3 to Step#6: Erase security register to have a defined values (0xFF)
Step #7 to Step#11: Read 16 byte security register into Var buffer
Step #12 to Step#19: Modify the data in the Var buffer
Step #20 to Step#22: Set Write Enable
Step #23 to Step#27: Program security register with values from Var buffer
Step #28 to Step#32: Read back security register to verify successful programming
Command Value0 Value1 Description
Delay Delay in ms -- Waits a given time
Activate CS -- -- Sets the CS signal low
Deactivate CS -- -- Sets the CS signal high
Write data NumByte(s)
ByteStream
separated by
commas (hex)
Send a number of bytes via the SPI
interface to the SPI. (e.g.:
9F,13,CA)
Var Read Data OffInVarBuffer
NumByte(s)
max. 16 bytes
Reads the specified number of bytes
via the SPI interface into the
VarBuffer which is 16 bytes in size.
Var Write
Data
OffInVarBuffer
NumByte(s)
max. 16 bytes
Writes the specified number of
bytes via the SPI interface from the
VarBuffer (filled via Var Read).
Var AND ByteIndex Value (hex)
Logical AND combination of the
internal var buffer at the specified
index with a given value.
Var OR ByteIndex Value (hex)
Logical OR combination of the inter-
nal var buffer at the specified index
with a given value.
Var XOR ByteIndex Value (hex)
Logical XOR combination of the
internal var buffer at the specified
index with a given value.
Table 11.11: J-Flash SPI Custom Command Sequence commands