uboot sf command usage

uboot sf command usage

If you support spi/qspi flash in uboot, you can use sf's erase, read, and write commands to operate spi flash

sf read is used to read flash data to memory

sf write write memory data to flash

sf erase erase the specified location, the specified length of the flash content, the content after erasing is all 1

Specific 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 memor 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'

Usage example

sf probe

Before using sf read sf write, be sure to call sf probe

sf write 0x82000000 0x0 0x20000

Write the data at memory 0x8200 0000 to offset 0x0 of flash, the length of the written data is 0x20000 (128KB), the minimum unit of operation offset and length is Byte

sf read 0x82000000 0x10000 0x20000

Write flash offset 0x10000 (64KB) with a length of 0x20000 (128KB) data into memory 0x82000000, the minimum unit of operation offset and length is Byte

sf erase 0x0 0x10000

Erase the erase block from offset 0x0 to 0x10000. The erase operation is based on the erase block, and the offset and len parameters must be aligned with the erase block

From the sf command, several points can be seen:

1. SPI flash does not have oob data, that is, there is no need to consider EDC ECC, and there is no concept of bad block management.

2. Support Byte-level read and write operations, support random access. 

How to verify the read and write effect

It can be combined with uboot md command, sf read, sf write are related to memory operations, you can use md to view memory data

md 0x82000000 0x100

Print memory data starting at 0x82000000 with a length range of 256 bytes
Copyright statement: This article is the original article of the CSDN blogger "kickxxx", following the CC 4.0 BY-SA copyright Agreement, please attach the original source link and this statement for reprinting.
Original link: https://blog.csdn.net/kickxxx/article/details/56012456

Reference : https://blog.csdn.net/juicyzx/article/details/102798084