QSPI
| Board | QSPI in U-Boot | QSPI in Linux |
|---|---|---|
| RZ/G3E SOM | Yes | Yes |
The RZ/G3E SOM has one 16 Mb QSPI Flash memory.
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|partition len - read `len' bytes starting at
`offset' or from start of mtd
`partition'to memory at `addr'
sf write addr offset|partition len - write `len' bytes from memory
at `addr' to flash at `offset'
or to start of mtd `partition'
sf erase offset|partition [+]len - erase `len' bytes from `offset'
or from start of mtd `partition'
`+len' round up `len' to block size
sf update addr offset|partition len - erase and write `len' bytes from memory
at `addr' to flash at `offset'
or to start of mtd `partition'
sf protect lock/unlock sector len - protect/unprotect 'len' bytes starting
at address 'sector'
The memory can be seen with the probe command.
sf probe
SF: Detected at25ql128a with page size 256 Bytes, erase size 4 KiB, total 16 MiB
or
sf probe 0:0
SF: Detected at25ql128a with page size 256 Bytes, erase size 4 KiB, total 16 MiB
Linux
To see the QSPI flash.
cat /proc/mtd
dev: size erasesize name
mtd0: 00040000 00001000 "bl2"
mtd1: 00fa0000 00001000 "fip"
The table shows mtd0 and mtd1 but the corresponding block devices are mtdblock0 and mtdblock1.
The QSPI "bl2" and "fip" partitions contain the bootloader files and writing to them is very likely to cause your device to no longer boot. Make sure you know before attempting any of the commands below.
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