转载至:http://blog.csdn.net/kickxxx/article/details/56012456
2017-02-20 14:32
536人阅读评论(0)收藏举报分类:
版权声明:本文为博主原创文章,未经博主允许不得转载。
uboot中如果支持spi/qspi flash, 那么可以使用sf的erase, read, write命令操作spi flash
sf read用来读取flash数据到内存
sf write写内存数据到flash
sf erase 擦除指定位置,指定长度的flash内容, 擦除后内容全1
具体用法
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'
使用范例
sf probe
在使用sf read sf write之前,一定要调用sf probe
sf write 0x82000000 0x0 0x20000
把内存0x8200 0000处的数据, 写入flash的偏移0x0, 写入数据长度为0x20000(128KB), 操作偏移和长度最小单位是Byte
sf read 0x82000000 0x10000 0x20000
把flash偏移0x10000(64KB)处, 长度为0x20000(128KB)的数据, 写入到内存0x82000000, 操作偏移和长度最小单位是Byte
sf erase 0x0 0x10000
擦除偏移0x0处, 到0x10000之间的擦除块, 擦除操作是以erase block为单位的, 要求offset和len参数必须是erase block对齐的