具有嵌入式系统的硬件设备。 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?如何解锁 NVRAM 以从 u-boot shell 中写入?我尝试写入 NVRAM,但不允许。
这是 U-boot dump里面有所有命令。 Spansion串行闪存S25FL064A
最佳答案
您提供了以下 U-Boot 命令输出:
=> md nvram
00000000: 7b1b1185 77ef4e0f 20082c8c 561a45d0 {...w.N. .,.V.E.
00000010: 699012a1 c36840a9 8f825272 9fd95faf <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9af3b4b4b4b4f2dab4b4b4c8e8" rel="noreferrer noopener nofollow">[email protected]</a>.._.
...
这是“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
将此图像文件与您要写入的文件进行比较,看看它是否确实已损坏。
Is it possible to update NVRAM from within U-boot shell mode?
假设“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
关于linux - 从 U-boot shell 模式写入 NVRAM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25083671/