The phyCORE-i.MX7 development kit has a 16 MiB QSPI NOR Flash populated. This guide will show how to read from and write to the QSPI NOR.

Partition Information

To view the software defined partitions for the QSPI NOR Flash, enter the following commands:

  • The first command outputs general information regarding the number of mounted partitions. 

    Target (Linux)

  • The second command outputs more detailed information for each partition, such as size. 

    Target (Linux)

    cat /proc/mtd
  • The third command gives a closer look at the specified partition. 

    Target (Linux)

    mtdinfo /dev/mtd0

You can expect an output similar to the one below. In this example the QSPI NOR Flash has only 1 partition named 30bb0000.qspi and it is 16 MiB in size.

Expected Output

root@imx7d-phyboard-zeta-004:~# mtdinfo
Count of MTD devices:           1
Present MTD devices:            mtd0
Sysfs interface supported:      yes

root@imx7d-phyboard-zeta-004:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 01000000 00010000 "30bb0000.qspi"

root@imx7d-phyboard-zeta-004:~# mtdinfo /dev/mtd0
Name:                           30bb0000.qspi
Type:                           nor
Eraseblock size:                65536 bytes, 64.0 KiB
Amount of eraseblocks:          256 (16777216 bytes, 16.0 MiB)
Minimum input/output unit size: 1 byte
Sub-page size:                  1 byte
Character device major/minor:   90:0
Bad blocks are allowed:         false
Device is writable:             true

Write to QSPI

Using this example you will create a random file the size of the /dev/mtd0 partition (16 MiB) and transfer it to the QSPI NOR using the flashcp command. Run the following from the command line:

Target (Linux)

dd if=/dev/urandom of=test.dat bs=16777216 count=1
flashcp -v test.dat /dev/mtd0

Expected Output

root@imx7d-phyboard-zeta-004:~# dd if=/dev/urandom of=test.dat bs=16777216 count=1
1+0 records in
1+0 records out
16777216 bytes (17 MB, 16 MiB) copied, 0.595579 s, 28.2 MB/s
root@imx7d-phyboard-zeta-004:~# flashcp -v test.dat /dev/mtd0
Erasing blocks: 256/256 (100%)
Writing data: 16384k/0k (100%)%)
Verifying data: 16384k/0k (100%)%)

Read from QSPI

Going the opposite direction of the previous example, to read the QSPI NOR flash, you can dump the contents of /dev/mtd0 to a new file:

Target (Linux)

dd if=/dev/mtd0 of=read.dat bs=16777216 count=1

To check that the file read (read.dat) is the same that was written (test.dat) you can use md5sum and compare to verify the data transfer was successful:

Target (Linux)

md5sum test.dat && md5sum read.dat

Expected Output

root@imx7d-phyboard-zeta-004:~# md5sum test.dat && md5sum read.dat
f0f001364aa72b64019c14956880cb94  test.dat
f0f001364aa72b64019c14956880cb94  read.dat