问题描述
我有以下 U-Boot 环境变量:
nas220> printenv
autoload=no
autostart=no
baudrate=115200
bootargs=console=ttyS0,115200
bootargs_base=console=ttyS0,115200
bootcmd=run bootcmd_nand
bootcmd_nand=setenv bootargs console=ttyS0,115200 cmdlinepart.mtdparts=orion_nand:0xa0000@0x0(uboot),0x010000@0xa0000(env),0x500000@0xc0000(uimage),0x1a40000@0x5c0000(rootfs)
bootcmd_rescue=setenv bootargs_extra rescue/enable=true; run bootcmd_usb
bootcmd_usb=setenv bootargs ${bootargs_base} ${mtdparts} ${bootargs_extra}; usb start; fatload usb 0:1 0x40000 uImage-dtb; fatload usb 0:1 0x800000 uInitrd; bootm 0x40000 0x800000
bootdelay=3
ethact=egiga0
ethaddr=00:10:75:07:0D:8D
ethadr=00:10:75:07:0D:8D
mtdids=nand0=orion_nand
mtdparts=cmdlinepart.mtdparts=orion_nand:0xa0000@0x0(uboot),0x1a40000@0x5c0000(rootfs)
stderr=serial
stdin=serial
stdout=serial
Environment size: 876/65532 bytes
我需要更改 bootcmd_nand
变量:
setenv bootargs console=ttyS0,0x1a40000@0x5c0000(rootfs)
到
setenv bootargs console=ttyS0,0x1a30000@0x5c0000(rootfs)
但是当我尝试运行时:
setenv bootcmd_nand setenv bootargs console=ttyS0,0x1a30000@0x5c0000(rootfs)
系统从 nand 读取并启动,因此我无法运行 saveenv
命令来持久保存更改。
如何在不启动系统的情况下进行更改?
解决方法
我发现了我的错误,但留下这个问题以防其他人遇到这个问题。要在不实际运行代码的情况下运行 setenv
命令,您只需将变量括在单引号中即可。例如运行,
setenv bootcmd_nand setenv bootargs console=ttyS0,115200 cmdlinepart.mtdparts=orion_nand:0xa0000@0x0(uboot),0x010000@0xa0000(env),0x500000@0xc0000(uimage),0x1a30000@0x5c0000(rootfs)
将运行代码并从 nand 读取而不是永久保存变量。不管怎样运行,
setenv bootcmd_nand 'setenv bootargs console=ttyS0,0x1a30000@0x5c0000(rootfs)'
在不运行代码的情况下设置变量,以便我可以运行 saveenv
并永久保存。