ubootsf命令⽤法
uboot中如果⽀持spi/qspi , 那么可以使⽤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 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
offset命令sf write 0x82000000 0x0 0x20000
把内存0x8200 0000处的数据, 写⼊flash的偏移0x0, 写⼊数据长度为0x20000(128KB), 操作偏移和长度最⼩单位是Byte
sf 0x82000000 0x10000 0x20000
把flash偏移0x10000(64KB)处, 长度为0x20000(128KB)的数据, 写⼊到内存0x82000000, 操作偏移和长度最⼩单位是Byte sf erase 0x0 0x10000
擦除偏移0x0处, 到0x10000之间的擦除块, 擦除操作是以erase block为单位的, 要求offset和len参数必须是erase block对齐的从sf命令,可以看出⼏点:
1. spi flash没有oob数据存在, 也就是不⽤考虑EDC ECC, 也没有坏块管理概念.
2. ⽀持Byte级的读写操作, ⽀持随机访问.
如何验证读写效果
可以结合uboot md命令, sf read, sf write都涉及到内存操作, 可以⽤md查看内存数据
md 0x82000000 0x100

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。