从U-boot shell模式写入NVRAM

时间:2014-08-01 15:30:28

标签: linux memory memory-management embedded u-boot

带嵌入式系统的硬件设备。 NVRAM已损坏,我想替换nvram。是否可以在U-boot shell模式下更新NVRAM? U-boot提供了升级固件,u-boot,uimage和其他组件的选项:U-boot代码的两个例子:

update_uboot=tftpboot 0x80000100 u-boot.bin && protect off 0x48000000 +${filesize} && erase 0x48000000 +${filesize} && sleep ${sdelay} && cp.b ${fileaddr} 0x48000000 ${filesize} && protect on 0x48000000 +${filesize}

update_uimage=tftpboot 0x80000100 uImage && protect off ${UBFIADDR1} +${filesize} && erase ${UBFIADDR1} +${filesize} && sleep ${sdelay} && cp.b ${fileaddr} ${UBFIADDR1} ${filesize} && protect on ${UBFIADDR1} +${filesize}

U-boot代码中没有任何有关NVRAM升级的说明或提示。 nvram.bin偏移地址在u-boot设置中指定,是否可以从U-boot shell模式替换NVRAM?如何从u-boot shell中解锁NVRAM以进行写入?我尝试写入NVRAM,但它不允许。

这是U-boot dump,其中包含所有命令。 Spansion Serial Flash S25FL064A

1 个答案:

答案 0 :(得分:1)

您提供了以下U-Boot命令输出:

=> md nvram
00000000: 7b1b1185 77ef4e0f 20082c8c 561a45d0    {...w.N. .,.V.E.
00000010: 699012a1 c36840a9 8f825272 9fd95faf    i....h@...Rr.._.
... 

这是" nvram"的虚假数据 在 printenv 输出中,没有环境变量名称" nvram"。
符号" nvram"似乎未定义,似乎默认值为0.

基于内核命令行和MTD分区映射,您所谓的" NVRAM" 可能不是内存设备,而是Spansion串行闪存芯片中的一个分区,即

partitions[4] = {.name = nvram, .offset = 0x007b0000,.size = 0x00050000 (320K) }

如果是这样,该分区显然会在U-Boot中映射到0x487b0000到0x487fffff。

您应该能够使用命令

检查该分区的数据
md 0x487b0000  

如果要复制它,应该启动Linux并使用 dd 命令

dd if=/dev/mtdblock4 of=save_nvram.img

将此图像文件与您要编写的内容进行比较,以查看它是否实际已损坏。

  

是否可以在U-boot shell模式下更新NVRAM?

假设" NVRAM"实际上是串行Flash末尾的分区,然后是 根据两个更新变量的命令语法,以下U-Boot命令应完成任务:

tftpboot 0x80001000 new_nvram.img
protect off 0x487b0000 +0x50000
erase 0x487b0000 +0x50000
cp.b 0x80001000 0x487b0000 0x50000
protect on 0x487b0000 +0x50000

注意:
您提供的信息不一致。
 在U-Boot printenv 命令中, bootargs 定义为:

root=/dev/mtdblock5 mtdparts=physmap-flash.0:512k(U-Boot)ro,256K(env1),256K(env2),0x40000(script),0x140000(Kernel),0x140000(RootFileSystem),5M@1M(UBFI1),5M(UBFI2) console=ttyS0,115200n8 ethaddr0=${ethaddr}

但是内核日志表明传递的实际命令行是

root=/dev/mtdblock3 mtdparts=spansion:0x20000(U-Boot)ro,0x10000(env1),0x10000(env2),0x2d0000@0x4a0000(fWare-FS),0x50000@0x7B0000(nvram),0x3B0000@0x40000(UBFI1),0x3B0000@0x3F0000(UBFI2) console=ttyS0,115200n8