博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Uboot 中的hush shell
阅读量:4070 次
发布时间:2019-05-25

本文共 1966 字,大约阅读时间需要 6 分钟。

今天有一个要求,要在uboot启动后不断的执行一些命令。方法记录一下:

1.直接改代码,比较麻烦。

2.制作uboot的执行脚本,用mkimage命令,然后通过tftp下载到内存,然后通过source命令来执行。这个也挺麻烦的。

3.还有一个方法是使用hush shell,uboot中定义了CONFIG_SYS_HUSH_PARSE就可以支持,

网上有资料说uboot中的hush shell是从busybox移植来的,进行了一些精简。但是查找hush shell的使用资料没有找到,直接把好用的命令记下来吧

setenv loopping while true\; do ping 192.168.1.1\; done\;

run loopping

这里是实现不停的执行ping命令。

下面贴一下资料,供参考和进一步研究

Hush shell:

  • similar to Bourne shell, with control structures like if...then...else...fifor...do...donewhile...do...doneuntil...do...done, ...
  • supports environment ("global") variables (through setenv / saveenv commands) and local shell variables (through standard shell syntax name=value ); only environment variables can be used with the run command, especially as the variable to run (i. e. the first argument).
  • In the current implementation, the local variables space and global environment variables space are separated. Local variables are those you define by simply typing like name=value. To access a local variable later on, you have to write '$name' or '${name}'; to execute the contents of a variable directly you can type '$name' at the command prompt. Note that local variables can only be used for simple commands, not for compound commands etc.
  • Global environment variables are those you can set and print using setenv and printenv. To run a command stored in such a variable, you need to use the run command, and you must not use the '$' sign to access them.
  • To store commands and special characters in a variable, use single quotation marks surrounding the whole text of the variable, instead of the backslashes before semicolons and special symbols.
  • Be careful when using the hash ('#') character - like with a "real" Bourne shell it is the comment character, so you have to escape it when you use it in the value of a variable.

Examples:

setenv bootcmd bootm \$address        setenv addip 'setenv bootargs $bootargs ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off'

转载地址:http://hrqji.baihongyu.com/

你可能感兴趣的文章
LINUX起死回生记
查看>>
网站规划之初稿 (工控帮 http://www.opc-china.com)
查看>>
网站系统之咨询(网奇行业门户)(如此做法怎么能对的起“中国建站第一品牌”)
查看>>
数字电影《大寒小寒》(淳朴,无私)
查看>>
讨论:国内企业对开发的投入是多少
查看>>
LEX与YACC 词汇表
查看>>
个人六年工作回顾
查看>>
春节感想(沂蒙山区的变化)之2008
查看>>
《OPCDA服务器与客户程序开发指南》下载
查看>>
国产PLC应该学习一下国产变频器
查看>>
关于OPC(Ole for process control)服务器开发需要的知识
查看>>
利用OPC技术实现双网冗余系统的通讯驱动
查看>>
OPC技术在监控系统中的应用
查看>>
OPC客户程序(VB篇——同步)
查看>>
OPC客户程序(VB篇——异步)
查看>>
Data Access IDL Specification(OPC2.0规范)
查看>>
OPCError.h(OPC2.0规范)
查看>>
远程访问OPC SERVER DCOM的配置
查看>>
在工控领域用到的VC++知识(个人经验)
查看>>
OPC BROWSER ITEM程序(VB篇)
查看>>