目录
前言
一 使用mmc write擦除环境变量
二 使用mmc erase擦除环境变量
三 使用tftp和mmc write升级uboot
四 使用ext4load和mmc write升级uboot
总结
为什么要做出厂设置呢,为什么要把报错的环境变量擦掉呢,我和我的一次经历有关,我曾经改环境变量的默认值,然后测试没效果,当时以为改错地方了。后来通过fastboot烧写好像可以,为什么fastboot可以呢,因为fastboot的时候,重新格式化了整个外存,如果每次改完,都用fastboot烧写,就很不坏算,所以如果有一个擦除环境变量的命令,就很完美了,所以就有了这篇文章。
mmc write
mmc write addr blk# cnt
就是将addr起始的内存地址,cnt*512字节的数据写入 blk这个数据扇区,cnt是扇区数量,每个扇区512字节,blk是块号,也就是扇区号。
这里做一个恢复环境变量出厂设置的测试
在80800000 起始的地址,8192长度的DDR写入0xff,然后将这个8192个ff写入环境变量分区0x600 0x10个块,验证如下所示
先切换设备
=> mmc dev 1
switch to partitions #0, OK
mmc1(part 0) is current device
这里使用填充内存命令mw
=> help mw
mw - memory write (fill)Usage:
mw [.b, .w, .l] address value [count]
80800000 开始的8192字节填充FF,然后使用md命令读32个字节,看看写的对不对。
=> mw.b 80800000 FF 2000
=> md.b 80800000 20
80800000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
80800010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
开始写emmc,写16个块是0x10哦,不可以这样写:(mmc write 80800000 600 16,这便是写22个块)。
=> mmc write 80800000 600 10MMC write: dev # 1, block # 1536, count 16 ... 16 blocks written: OK
重启后打印环境变量,环境变量确实恢复到默认值了。
使用mmc write擦除环境变量,更多的是学习命令的组合运行,mmc erase才是正确用法。
mmc erase blk# cnt
mmc erase 块号 块数量
mmc erase 600 10
测试如下
=> mmc erase 600 10MMC erase: dev # 1, block # 1536, count 16 ...Caution! Your devices Erase group is 0x400
The erase range would be change to 0x400~0x7ff16 blocks erased: OK
=>
分四步骤
1.切换分区
=> mmc dev 1 0
2通过网络下载u-boot.imx
tftp 80800000 u-boot.imx
3 将内存数据写入emmc
mmc write 80800000 2 26e
4 分区配置
mmc partconf 1 1 0 0
整个操作过程如下所示:
=> mmc dev 1 0
switch to partitions #0, OK
mmc1(part 0) is current device
=> tftp 80800000 u-boot.imx
FEC0 Waiting for PHY auto negotiation done
Using FEC0 device
TFTP from server 192.168.0.11; our IP address is 192.168.0.3
Filename 'u-boot.imx'.
Load address: 0x80800000
Loading: ######################2.4 MiB/s
done
Bytes transferred = 318464 (4dc00 hex)
=> mmc write 80800000 2 26eMMC write: dev # 1, block # 2, count 622 ... 622 blocks written: OK
=> mmc partconf 1 1 0 0
=> reset
首先,将u-boot.imx文件放到根文件系统的根目录中,放到别的目录也可以,只是ext4load的时候要使用绝对路径。
1 将u-boot.imx加载到内存
ext4load mmc 1:2 80800000 u-boot.imx
=> ext4load mmc 1:2 80800000 u-boot.imx
318464 bytes read in 133 ms (2.3 MiB/s)
=>
这里如果发现读取的字节数不能被512整除,那肯定是出错了,就别升级了。看看自己是不是把u-boot.bin下载过来了。
2 计算得到写入的块数量318464/512 = 622 = 0x26e
3 将内存数据写入emmc
mmc write 80800000 2 26e
4 分区配置
mmc partconf 1 1 0 0
整个操作过程如下:
=> ext4ls mmc 1:2
/*略*/318464 u-boot.imx=> ext4load mmc 1:2 80800000 u-boot.imx
318464 bytes read in 133 ms (2.3 MiB/s)
=> mmc write 80800000 2 26eMMC write: dev # 1, block # 2, count 622 ... 622 blocks written: OK
=> mmc partconf 1 1 0 0
=> saveenv
Saving Environment
Writing to MMC(1)... done
=> reset
resetting ...
表示一篇文章结束啦。
本文发布于:2024-01-28 20:40:36,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170644564110143.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |