OSPI Flash

An Octal Serial Peripheral Interface (OSPI) Flash is populated on the SOM as a programmable nonvolatile storage. The OSPI interface supports single, dual, quad, or octal read/write access to the flash device. This guide will walk through how to read and write from the OSPI. The OSPI Flash can be used for a fast boot source, see the guide OSPI Boot for more on booting from OSPI. For more information on the OSPI interface, see section 6.1.4 in the Hardware Manual.

View Available NOR Partitions

  • Verify that the NOR interface was initialized properly.

Target (Linux)
mtdinfo
Expected Output
Count of MTD devices:           1
Present MTD devices:            mtd0
Sysfs interface supported:      yes
  • View basic partition information.

Target (Linux)
cat /proc/mtd
Expected Output
dev: size erasesize name
mtd0: 04000000 00020000 "fc40000.spi.0"
  • More detailed information can be viewed using the “mtdinfo” command on a specific partition.

Target (Linux)
mtdinfo /dev/mtd0
Expected Output
mtd0
Name:                           fc40000.spi.0
Type:                           nor
Eraseblock size:                131072 bytes, 128.0 KiB
Amount of eraseblocks:          512 (67108864 bytes, 64.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 OSPI

  • Create a random file equal to the size of the /dev/mtd0 partition (512 kBytes).

Target (Linux)
dd if=/dev/urandom of=test.dat bs=1k count=512
Expected Output
512+0 records in
512+0 records out
524288 bytes (524 kB, 512 KiB) copied, 0.0152006 s, 34.5 MB/s
  • Copy the generated file to the mtd0 partition.

Target (Linux)
flashcp -v test.dat /dev/mtd0
Expected Output
Erasing blocks: 4/4 (100%)
Writing data: 512k/512k (100%)
Verifying data: 512k/512k (100%)

Read from OSPI

  • Dump the contents of /dev/mtd0 partition to a new file:

Target (Linux)
dd if=/dev/mtd0 of=read.dat bs=1k count=512
Expected Output
512+0 records in
512+0 records out
524288 bytes (524 kB, 512 KiB) copied, 0.167633 s, 3.1 MB/s
  • Verify that the output files were not corrupted during the transfer using md5sum.

Target (Linux)
md5sum test.dat read.dat
Expected Output
3497f295076c7ef96443b109ab9be333  test.dat
3497f295076c7ef96443b109ab9be333  read.dat