1. Introduction
In this article I'm going to explain how the FRDM-RW612 SDK (v26.06) configures the external NOR flash of the FRDM-RW612. And give a brief explanation on how the memory parameters from the flash datasheet are mapped into the SDK structures (FCB, LUT).
It focuses on software-level configuration, including:
FCB
LUT
Relevant SDK files
2. Overview of the RW612 External Flash System
This section explains how the RW612 interacts with the external NOR flash (W25Q512JV) at boot and runtime.
The RW61x supports a FlexSPI memory size up to 1 Gbit. The RW61x supports all JESD216-compliant flash memories. Refer to Table 15 of the RW61x Design Guide to see the recommended memories.
2.1 Flash Configuration Block (FCB)
When the RW612 is powered on, the Boot ROM is the first piece of code that is executed. To access the external flash, the Boot ROM reads a data structure stored at a fixed offset in flash called the Flash Configuration Block.
The FCB tells the Boot ROM:
what flash protocol to use (i.e. single, dual, quad)
what read opcode to send
how many dummy cycles are needed
which LUT sequence defines the read operation
In the SDK, this is defined though specific FCB fields like lookupTable, lutCustomSeq, deviceModeCfgEnable, etc. The meaning of the fields of the FCB can be found in section 11.4.1.1 of the RW61x User Manual.
The RW61x ROM can initialize the FlexSPI in two ways:
1. FCB from external flash: If FLEXSPI_AUTO_PROBE_EN is 0, the Boot ROM looks for an FCB in the external flash. It reads the 512 byte FCB into on-chip SRAM and configures the FlexSPI controller according to that structure.
2. Flash auto-probe: If FLEXSPI_AUTO_PROBE_EN is 1 , the Boot ROM performs a flash auto probe sequence using OTP fuse parameters such as FLEXSPI_PROBE_TYPE FLEXSPI_FLASH_TYPE, FLEXSPI_DUMMY_CYCLES , and FLEXSPI_FREQUENCY.
Refer to section 11.4 of the RW61x User Manual for more information.
Each FlexSPI NOR flash driver API depends on a common fc_flexspi_nor_config_t parameter to perform the proper operation. The structure can be found in flash_config.c . This is the FCB in the code.
2.2 Lookup Table (LUT)
The FlexSPI LUT contains the encoded command sequences the FlexSPI uses to communicate with the external flash. The RW61x LUT contains 16 command sequences, and each sequence consists up to 8 instructions. These define:
the command opcode
the number of pads
the address phase
dummy cycles
mode bits
read/write operations
the stop instruction
In other words, the FCB is the configuration used by the Boot ROM. And the LUT are the sequences used by the FlexSPI controller during both boot and runtime. The FCB contains the LUT.
The SDK defines these sequences using the macro FC_FLEXSPI_LUT_SEQ() inside flash_config.c . For example, the default “Fast Read Quad I/O” sequence on the FRDM‑RW612 for the W25Q512JV flash memory includes:
a command opcode (0xEC)
an address phase using 4 pads
a mode byte (0xF0)
dummy cycles (0x04)
the read operation using 4 pads
Each flash vendor uses its own set of opcodes, timing requirements, and dummy cycles. Therefore, when adapting the RW612 SDK to work with a different flash, customers will need to update the LUT entries in flash_config.c . However, the changes are not limited to the LUT, since other parameters such as pad configuration, clock settings, and device mode may also need to be adjusted.
The LUT is essential not only for IP commands but also for XIP, where FlexSPI uses a single LUT sequence (selected by ARDSeqIndex and ARDSeqNumber ) to perform every AHB read.
The following is recommended to check when using a custom flash:
sflashPadType
serialClkFreq
sflashA1Size
page size /sector size
read opcode
address width: 24 bit vs 32 bit
dummy cycles
Quad Enable
status register BUSY bit
write enable command
page program opcode
sector/block erase opcode
sample clock / DQS configuration
For more detailed information refer to section 34.2.6 of the RW61x User Manual.
2.3 From the Memory Datasheet to the SDK
Configuring the external flash on the RW612 is essentially a translation process: you extract details from the flash datasheet, and encode them into the SDK’s FCB and LUT.
This section explains exactly which datasheet parameters matter, where each one appears in the SDK, and how the SDK structures correspond to the flash device’s command set.
Example:
Datasheet
SDK
Flash size
sflashA1Size
Supported I/O mode: 1-1-1, 1-1-4, 4-4-4
sflashPadType
Fast read opcode
LUT read sequence
Dummy cycles
LUT DUMMY_SDR operand
Mode bits required by the read command
LUT MODE8_SDR operand inside the read sequence
Quad Enable bit / flash configuration register write
deviceModeCfgEnable , deviceModeSeq , deviceModeArg , plus matching LUT sequence
Datasheet Parameter → FCB Fields
The flash datasheet defines the electrical and protocol characteristics that the Boot ROM must use to perform the very first read command (XIP). These values map directly into the FCB ( fc_flexspi_nor_config_t ) found in flash_config.c .
a) Pad configuration (Single / Dual / Quad)
Datasheet: specifies the supported bus protocols and the number of pads used during each command phase.
SDK mapping: .sflashPadType = kSerialFlash_4Pads; selects the serial-flash pad configuration used by the FlexSPI controller. However, the pad width for each command, address, mode, dummy, read, and write phase is encoded independently in the LUT instructions. For example, the default W25Q512JV Fast Read Quad I/O sequence using opcode 0xEC is a 1-4-4 transaction: the command is transmitted on one pad, while the address, mode, dummy, and data phases use four pads.
This configures how FlexSPI drives the CMD/ADDR/DATA pads.
b) Read frequency
Datasheet: supports up to 133MHz
SDK mapping: .serialClkFreq = 5; (Refer to Table 65 of the RW61x User Manual)
The value must be chosen so that the final FlexSPI clock does not exceed the flash’s read timing limits.
c) Dummy cycles for fast‑read
Datasheet: fast‑read commands require N dummy cycles depending on frequency.
SDK mapping: encoded directly in LUT using: [1] = FC_FLEXSPI_LUT_SEQ(MODE8_SDR, 4PAD, 0xF0,
DUMMY_SDR, 4PAD, 0x04),
Here the last operand ( 0x04 ) is the dummy-cycle count.
In this example, 0xF0 is the mode byte transmitted during the read command. It is not the same as the Quad Enable configuration. QE is handled separately through the device mode sequence.
d) Quad-enable (QE)
Datasheet: describes how to enable Quad I/O (usually by writing SR1/SR2), or how to enter 4‑byte mode.
SDK mapping: The FCB “device mode sequence,”: .deviceModeCfgEnable = 1,
.deviceModeSeq = {.seqNum = 1, .seqId = 2},
.deviceModeArg = 0x02,
In this W25Q512JV configuration, the Boot ROM executes LUT sequence 2, which sends command 0x31 followed by one data byte. The argument 0x02 sets bit 1 of Status Register 2, corresponding to the Quad Enable bit for this flash device. This value is device-specific and must not be treated as a generic QE configuration for other flash memories.
e) Flash size
Datasheet: total memory capacity.
SDK mapping: .sflashA1Size = 0x4000000U; // 64 MB
Datasheet Parameter → LUT Commands
The flash datasheet defines opcodes and sequences for:
Fast-read
Read-status
Write-enable
Page program
Sector erase
These map to FlexSPI LUT entries inside lookupTable in flash_config.c . Example of a Quad I/O fast read:
[0] = FC_FLEXSPI_LUT_SEQ(FC_CMD_SDR, FC_FLEXSPI_1PAD, 0xEC, FC_RADDR_SDR, FC_FLEXSPI_4PAD, 0x20),
[1] = FC_FLEXSPI_LUT_SEQ(FC_MODE8_SDR, FC_FLEXSPI_4PAD, 0xF0, FC_DUMMY_SDR, FC_FLEXSPI_4PAD, 0x04),
[2] = FC_FLEXSPI_LUT_SEQ(FC_READ_SDR, FC_FLEXSPI_4PAD, 0x04, FC_STOP_EXE, FC_FLEXSPI_1PAD, 0x00),
The flash datasheet defines the command opcode, address length, mode bits, dummy-cycle requirements, and data-transfer protocol. These parameters must then be encoded using the RW612 FlexSPI LUT instruction types, pad definitions, operands, and sequence format specified in the RW61x documentation.
Decoding the LUT:
[0] = FC_FLEXSPI_LUT_SEQ(FC_CMD_SDR, FC_FLEXSPI_1PAD, 0xEC, FC_RADDR_SDR, FC_FLEXSPI_4PAD, 0x20)
FC_FLEXSPI_LUT_SEQ(...) packs two LUT instructions into one 32 bit word: (cmd0, pad0, op0) and (cmd1, pad1, op1).
FC_CMD_SDR: Transmit command code to flash in SDR mode
Why LUT entries in flash_config.c Use “[4 * index + Offset]”
Why does flash_config.c write LUT entries using expressions like [4 * index + 0] , [4 * index + 1] , etc? Each LUT sequence ID occupies 4 × 32-bit LUT words , and each 32-bit LUT word packs two 16-bit FlexSPI instructions , so one sequence can contain up to 8 instructions .
[4 * index + 0]
[4 * index + 1]
[4 * index + 2]
[4 * index + 3]
Inside FlexSPI:
A sequence ID represents one full command operation (e.g., fast-read).
Each sequence index reserves four 32-bit LUT words, which together encode up to eight 16 bit LUT instructions.
Each LUT sequence occupies four 32-bit words in the lookupTable array. Each 32-bit word contains two 16-bit FlexSPI instructions, so one sequence can contain up to eight 16-bit instructions. Therefore, sequence N starts at word index 4 * N and occupies the four words 4 * N through 4 * N + 3.
seqId 0 → entries 0,1,2,3
seqId 1 → entries 4,5,6,7
seqId 2 → entries 8,9,10,11
This indexing scheme is required by the hardware.
2.4 FlexSPI Access Types
The RW612 uses two distinct access paths to the external flash:
AHB Path (XIP / Memory-Mapped Access)
Once the Boot ROM configures FlexSPI using the FCB, the controller maps the external flash into the AHB address space. Instruction fetches, constant data reads, and general code execution can occur directly from flash using Execute-In-Place (XIP). The configured AHB read sequence is selected through the FlexSPI AHB read-sequence configuration. FlexSPI also provides separate AHB-write sequence configuration; however, the default RW612 SDK configures AHB writes as a dummy operation and performs flash program and erase operations through explicit IP commands. The correctness of the FCB, LUT, and AHB configuration is therefore essential for reliable XIP and memory-mapped access.
Uses only the read LUT sequence (usually the fast‑read command).
Cannot perform program/erase.
Depends entirely on the correctness of the FCB + LUT.
IP Command Path (Program / Erase / Status Read)
This path is used for explicit command‑based transactions. The SDK’s mflash_drv.c uses this mode to implement:
Write Enable
Page Program
Sector Erase
Read Status (BUSY polling)
Program/erase operations require:
correct LUT sequences
correct WREN opcode
correct erase opcode
correct busy‑bit polarity and offset
Customers replacing the flash must update these sequences in the LUT and, if needed, adjust the busy‑bit handling in mflash_drv.c .
2.5 External Flash on the FRDM‑RW612
The FRDM‑RW612 comes with a QuadSPI NOR flash connected to FlexSPI Port A1. The default configuration in the SDK sets:
Quad‑pad mode ( sflashPadType = 4 )
Fast‑read Quad I/O opcode ( 0xEC )
Mode byte and dummy cycles for this device
Sector size and page size
LUT entries for read, status, write‑enable, page‑program, and erase
This configuration is a reference template showing how the flash’s datasheet values are encoded into the FCB and LUT.
HW setup for the W25Q512JV memory
The W25Q512JV NOR flash is connected to Port A (GPIO28 to GPIO34) of the FlexSPI module of the RW612. See the below snapshot from the FRDM-RW612 Schematics Rev1.
The table below shows the RW612 FlexSPI pinout. On the FRDM-RW612 board, the external NOR flash is connected to the FlexSPI Port A signals used by the board design
RW612 pin
QSPI function
GPIO_28
FLASH_SSEL0
GPIO_29
FLASH_DQS
GPIO_30
FLASH_DATA0
GPIO_31
FLASH_DATA1
GPIO_32
FLASH_DATA2
GPIO_33
FLASH_DATA3
GPIO_34
FLASH_CLK0
2.6 Key SDK Files for the External Flash Configuration
The RW612 SDK includes several software components that together define how the external flash is initialized, accessed, and programmed. Customers adapting the SDK to a different flash device will primarily interact with the following files:
flash_config.c
Contains the FCB used by the Boot ROM, including:
FlexSPI timing configuration
pad mode (single/dual/quad)
serial clock settings
device‑mode configuration (e.g., QE or 4‑byte mode)
the boot‑time LUT used for fast‑read and basic flash commands
flash_config.h
Defines:
FCB data structures ( fc_flexspi_nor_config_t )
macros used to encode FlexSPI LUT instructions
command type definitions and constants
mflash_drv.c / mflash_drv.h
Implements the runtime flash driver using the IP command path, including:
Write Enable
Page Program
Sector Erase
Status register polling (BUSY bit)
cache/buffer invalidation after programming These functions rely on LUT entries and must be updated if the flash device uses different opcodes or timing.
4. References
RW61x User Manual
RW612 datasheet
RW61x Registers
MCUXpresso SDK
RW61x Design Guide
View full article