There are a number of commands that provide access to the flash array or perform other operations on the SPI flash memory. All SPI transactions in master mode depend upon commands supported by a slave device connected to the AXI QUAD SPI core. Refer to the respective SPI flash memory data sheet for the supported commands. The Micron MT25QU256ABASPI flash memory commands are described in Micron Serial NOR Flash Memory N25Q256A11E and MT25Q256U Data Sheets (www.micron.com). This reference design provides user access to a subset of commands by way of the menu shown in Program SPI Flash Memory with update.bin. The commands implemented for the SPI flash on the KCU105 are shown in the flow diagrams in the following figures.
The flowchart for Program/Verify (Program SPI Flash Memory with update.bin Tera Term main menu option 4).
Each of the supported operations shown in the Flow Diagrams has a specific command sequence. The command sequences are provided below for each of the major operations.
Write Enable Command Sequence
The write enable command must be issued before every write transaction
(erase/program data to the flash/register write of flash) command to the flash.
Disable the master transaction by asserting the master inhibit bit of SPI control
register (SPICR) and reset the RX and TX FIFOs through SPICR. Example: Write 0x1E6
to SPICR.
- Issue the write enable command by writing
0x06
into SPI Data Transmit Register (SPIDTR). - Issue chip select by writing
0x00
to SPI Slave Select Register (SPISSR). - Enable master transaction by deasserting the SPICR, master inhibit bit.
- Deassert chip select by writing
0x01
to SPISSR. - Disable master transaction by asserting the SPICR master inhibit bit.
Erase Command Sequence
- Reset RX and TX FIFOs through SPICR.
- Issue the bulk erase command to erase the entire flash followed
by the flash base address. Example: Write
0xC7
to SPIDTR - Issue chip select by writing
0x00
to SPISSR. - Enable master transaction by deasserting the SPICR master inhibit bit.
- Deassert chip select by writing
0x01
to SPISSR. - Disable master transaction by asserting the SPICR master inhibit bit.
Program Data Command Sequence
- Reset RX and TX FIFOs through SPICR.
- Issue the write data command into SPIDTR to write data into any specific sector followed by the flash sector address. Fill SPIDTR with the data to be written to flash. The maximum data size depends upon the configured QSPI FIFO size.
- Issue chip select by writing
0x00
to SPISSR. Enable master transaction by deasserting the SPICR master inhibit bit. - Deassert chip select by writing
0x01
to SPISSR. - Disable master transaction by asserting the SPICR master inhibit bit.
Read Data Command Sequence
- Reset RX and TX FIFOs through SPICR.
- Issue the read data command into SPIDTR to read data from any specific sector followed by the flash sector address. Fill SPIDTR with the dummy data to read required data from the flash.
- Issue chip select by writing
0x00
to SPISSR. - Enable master transaction by deasserting the SPICR master inhibit bit.
- Deassert chip select by writing
0x01
to SPISSR. - Disable master transaction by asserting SPICR master inhibit bit.
- Read SPIDRR, to get the read data that is received from the SPI bus.
The reference design menu option 4 performs
with one selection (see the preceding figure). The verify is a read of the full .bin file compared to the original .bin contents. If an error is detected the address of the failure will be provided.Program SPI Flash Memory with update.bin showcases option 4 in step 5, however, the Tera Term main menu also has individual operation options. When the individual operation option is selected (option 1, 2, 3, or 5) then the desired start address must be supplied along with either the stop address or number of bytes. An example read instruction is shown in the following figure.