Skip to main content

QSPI

BoardQSPI in U-BootQSPI in Linux
iMX6 SoloX COMYesYes
iMX6 Quad COMNot supportedNot supported
iMX6 DualLite COMNot supportedNot supported
iMX6 UltraLite COMNot supportedNot supported
iMX7 Dual (u)COMYesYes
iMX7ULP uCOMYesNot driver available since QSPI should only be used by Cortex-M4
iMX8M Quad COMNot supportedNot supported
iMX8M Mini uCOMNot supportedNot supported
iMX8M Nano uCOMNot supportedNot supported
iMX93 uCOMNot supportedNot supported

The iMX6 SoloX COM board has two 8Mbyte QSPI Flash memories (originally the board has two 32Mbyte memories).

The iMX7 Dual COM board has one 32MByte QSPI Flash memory.

The iMX7 Dual uCOM board does not have a QSPI memory on the uCOM board, but has one 32MByte QSPI Flash memory on the uCOM Adapter Board.

U-Boot

The U-Boot has the sf command to handle SPI flash.

sf
sf - SPI flash sub-system
Usage:
sf probe [[bus:]cs] [hz] [mode] - init flash device on given SPI
bus and chip select
sf read addr offset len - read 'len' bytes starting at
'offset' to memory at 'addr'
sf write addr offset len - write 'len' bytes from memory
at 'addr' to flash at 'offset'
sf erase offset [+]len - erase 'len' bytes from 'offset'
'+len' round up 'len' to block
size
sf update addr offset len - erase and write 'len' bytes from
memory at 'addr' to flash at
'offset'

The two memories can be seen with the probe command.

sf probe 0:0
SF: Detected N25Q256 with page size 256 Bytes, erase size 4 KiB,
total 32 MiB
sf probe 1:0
SF: Detected N25Q256 with page size 256 Bytes, erase size 4 KiB,
total 32 MiB

Linux

To see the QSPI flash (output from iMX6 SoloX COM board).

cat /proc/mtd
dev:    size   erasesize name
mtd0: 02000000 00010000 "21e4000.qspi"
mtd1: 02000000 00010000 "21e4000.qspi"

The table shows mtd0 and mtd1 but the corresponding block devices are mtdblock0 and mtdblock1. To test the flash start by creating a test file with 16Kbyte random data.

dd if=/dev/urandom of=write.dat bs=1024 count=16

Write the random data to the block device.

time dd if=write.dat of=/dev/mtdblock0
32+0 records in
32+0 records out

real 0m0.074s
user 0m0.000s
sys 0m0.030s

Read back the data.

time dd if=/dev/mtdblock0 of=read.dat bs=1024 count=16
16+0 records in
16+0 records out

real 0m0.006s
user 0m0.000s
sys 0m0.000s

Compare the two files to make sure that nothing was lost.

diff read.dat write.dat

If the files are identical the diff command will not output anything. If there is a difference then it will look like this.

diff read.dat write.dat
Files read.dat and write.dat differ