Spiflash使用tftp进行烧录与备份

【版权申明】转载请附上出处链接

Spiflash使用tftp进行烧录与备份

uboot下的内存操作指令:

b:	8位 
w:	16位 
l:	32位(默认值) 
mw(Memory Write),即向内存写入数据指令。
mw - memory write (fill)
Usage:
mw [.b, .w, .l] address value [count]
md(Memory Display),即从内存读出数据并显示。
md - memory display
Usage:
md [.b, .w, .l] address [# of objects]

使用sf命令操作Spiflash

# 探测并初始化Spiflash
sf probe [[bus:]cs] [hz] [mode] - init flash device on given SPI bus and chip select

# 读取flash数据到内存
sf read addr offset len              - read 'len' bytes starting at 'offset' to memory at 'addr'

# 写内存数据到flash
sf write addr offset len             - write 'len' bytes from memor at 'addr' to flash at 'offset'

# 擦除指定位置,指定长度的flash内容, 擦除后内容全1
sf erase offset [+]len                - erase 'len' bytes from 'offset' '+len' round up 'len' to block size

# erase和write操作的集合
sf update addr offset len         - erase and write 'len' bytes from memory at 'addr' to flash at 'offset'

当前flash的分区(以16M为例)

|            1M            |      3M      |     12M         |
|--------------------------|--------------|-----------------|
|          u-boot          |    kernel    |    rootfs       |

烧写部分:

# 从内存地址0x82000000开始,长度为0x100000的区域全置为1.
mw.b 0x82000000 ff 0x100000

# 使用tftp将镜像放置到0x82000000开头的内存地址处(据说需要先把该内存区域全部置为1,这是由于硬件特性所限制的,这正是我们上面所进行的操作)
tftp 0x82000000 uboot.bin/uImage.bin/rootfs.jffs2

# sf probe 0;sf erase 0 0x100000;sf write 0x82000000 0 0x100000		#它其实是三条指令的集合,拆分如下
# 探测并初始化在0号位上的Spiflash
sf probe 0
# 擦除Spiflash,从0地址处开始,长度为0x100000(长度必须是块大小的整数倍)
sf erase 0 0x100000
# 写Spiflash,将内存地址从0x82000000开始的地方,长度为0x100000的数据写入Spiflash的0地址处
sf write 0x82000000 0 0x100000

读取备份部分:

sf probe 0

# 读取Spiflash,将flash的0地址处,长度为0x100000的数据读出到内存地址0x82000000处
sf read 0x82000000 0 0x100000

# tftp上传,将内存地址0x82000000开始,长度为0x100000的区域上传至tftp服务器,名字为uboot.bin
tftp 0x82000000 uboot.bin 0x100000
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

安河桥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值