OSPI NOR Flash
This guide will show you how to access the 64MB NOR Flash featured on the phyCORE-i.MX8X development kit carrier board. The NOR Flash is accessible through the OSPI interface and can also be used as an alternative boot source.
Available NOR Partitions
Make sure the NOR interface was initialized properly.
mtdinfo
Count of MTD devices: 1 Present MTD devices: mtd0 Sysfs interface supported: yes
View basic partition information.
cat /proc/mtd
dev: size erasesize name mtd0: 04000000 00020000 "5d120000.spi"
More detailed information can be viewed using the “mtdinfo” command on a specific partition.
mtdinfo /dev/mtd0
mtd0 Name: 5d120000.spi 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).
dd if=/dev/urandom of=test.dat bs=1k count=512
512+0 records in 512+0 records out 524288 bytes (524 kB, 512 KiB) copied, 0.0265253 s, 19.8 MB/s
Copy the generated file to the mtd0 partition using the “flashcp” command.
flashcp -v test.dat /dev/mtd0
Erasing blocks: 4/4 (100%) Writing data: 512k/512k (100%) Verifying data: 512k/512k (100%)
Reading from OSPI
Dump the contents of /dev/mtd0 partition to a new file:
dd if=/dev/mtd0 of=read.dat bs=1k count=512
512+0 records in 512+0 records out 524288 bytes (524 kB, 512 KiB) copied, 0.167633 s, 3.1 MB/s
Make sure the output file was not corrupted during the transfer using md5sum.
md5sum test.dat read.dat
3497f295076c7ef96443b109ab9be333 test.dat 3497f295076c7ef96443b109ab9be333 read.dat