擦除 NVRAM 中的数据

逆向工程 linux 固件 记忆 串行通讯 尖峰
2021-07-03 01:06:37

电缆调制解调器 SPI Flash 存储器具有以下结构:

7 cmdlinepart partitions found on MTD device spansion
partitions[0] = {.name = U-Boot, .offset = 0x00000000,.size = 0x00020000 (128K) }
partitions[1] = {.name = env1, .offset = 0x00020000,.size = 0x00010000 (64K) }
partitions[2] = {.name = env2, .offset = 0x00030000,.size = 0x00010000 (64K) }
partitions[3] = {.name = firmware_101222c, .offset = 0x004a0000,.size = 0x002d0000 (2880K) }
partitions[4] = {.name = nvram, .offset = 0x007b0000,.size = 0x00050000 (320K) }
partitions[5] = {.name = UBFI1, .offset = 0x00040000,.size = 0x003b0000 (3776K) }
partitions[6] = {.name = UBFI2, .offset = 0x003f0000,.size = 0x003b0000 (3776K) }
Creating 7 MTD partitions on "spansion":
0x00000000-0x00020000 : "U-Boot"
0x00020000-0x00030000 : "env1"
0x00030000-0x00040000 : "env2"
0x004a0000-0x00770000 : "firmware_101222c"
0x007b0000-0x00800000 : "nvram"
0x00040000-0x003f0000 : "UBFI1"
0x003f0000-0x007a0000 : "UBFI2"

引导加载程序正在工作,我可以通过串行接口连接到调制解调器,控制引导过程并上传固件。我无法通过 ip 192.168.100.1 连接管理界面,可能是由于 nvram 中存储的配置错误。我可以只擦除 Nvram 而不触及其他分区吗?

?       - alias for 'help'
autoscr - run script from memory
base    - print or set address offset
bdinfo  - print Board Info structure
boot    - boot default, i.e., run 'bootcmd'
bootd   - boot default, i.e., run 'bootcmd'
bootm   - boot application image from memory
bootp   - boot image via network using BootP/TFTP protocol
cmp     - memory compare
coninfo - print console devices and information
cp      - memory copy
crc32   - checksum calculation
echo    - echo args to console
erase   - erase FLASH memory
eval    - return addition/subraction
exit    - exit script
flinfo  - print FLASH memory information
go      - start application at address 'addr'
help    - print online help
iminfo  - print header information for application image
imls    - list all images found in flash
itest   - return true/false on integer compare
loadb   - load binary file over serial line (kermit mode)
loads   - load S-Record file over serial line
loady   - load binary file over serial line (ymodem mode)
loop    - infinite loop on address range
md      - memory display
mm      - memory modify (auto-incrementing)
mtest   - simple RAM test
mw      - memory write (fill)
nm      - memory modify (constant address)
printenv- print environment variables
protect - enable or disable FLASH write protection
rarpboot- boot image via network using RARP/TFTP protocol
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
saveenv - save environment variables to persistent storage
setenv  - set environment variables
sleep   - delay execution for some time
test    - minimal test like /bin/sh
tftpboot- boot image via network using TFTP protocol
version - print monitor version
1个回答

您可能可以使用erase一些参数来仅擦除 nvram 分区,但我不确定 U-Boot 是否可以重新初始化 nvram 存储。由于 nvram 通常包含启动命令,因此擦除所有内容可能会使您的设备无法启动。因此我建议只删除特定的变量。

你可以使用setenv

要修改 U-Boot 环境,您必须使用 setenv 命令。当只用一个参数调用时,它会从 U-Boot 的环境中删除该名称的任何变量,如果这样的变量存在的话。任何为此类变量占用的存储空间都将自动回收:

INCA-IP # printenv foo
foo=This is an example value.
INCA-IP # setenv foo
INCA-IP # printenv foo
## Error: "foo" not defined
INCA-IP #

确保使用 保存修改saveenv