uboot运行脚本
流程控制:
if ; then ; [ elif ; then ; ] … [ else ; ] fi
while ; do ; done
until ; do ; done
for in ; do ; done
test命令用来比较两个环境变量,比如
if test ${ip_dyn} = yes; 判断ip_dyn变量是否为yes
可惜的是uboot下无法做算数运算
注意:有些命令的返回值有时候有点不太对劲,如tftp 0x21000000 uImage,正常情况下ARP Retry之后应该是重新配置网卡,因为netretry=yes
ETH0: PHY(phyaddr=1, rmii) link UP: DUPLEX=FULL : SPEED=100M
MAC: 32-61-64-01-3D-AE
Using gmac0 device
TFTP from server 169.254.11.23; our IP address is 169.254.11.10
Filename ‘uImage’.
Load address: 0x21000000
Loading: *
ARP Retry count exceeded; starting again
Wrong Image Format for bootm command
ERROR: can’t get kernel image!
do_bootm error!
实际测试:
setenv tftp_boot “while tftp 0x21000000 uImage; do bootm 0x21000000; done”;setenv bootcmd “run tftp_boot”;saveenv
这条语句可以修复上面这种情况,但是下面这条语句不行:
setenv tftp_boot “while tftp 0x21000000 uImage;bootm 0x21000000;do echo tftp done…;done”;
实际上下面这条更好:主意代码中的时候要加个\0
“vhd_initfs_tftp=setenv try 1;while test ${try} = 1;do tftp 0x21000000 uImage;bootm 0x21000000;done\0”