在uboot里面添加环境变量使用run来执行并启动时自动执行run
2015-11-13 17:36
786 查看
在移植uboot的时候,可以在uboot里面添加定义一些自己的环境变量,这些环境变量可以大大提高以后的工作效率,比如我在uboot里面添加如下环境变量:
然后使用run mirror命令来执行。
一、 在uboot里面添加环境变量
1、 在u-boot-2010.06/include/configs目录下的xxx.h(xxx是board,如hi3520d.h)里面定义环境变量:
/* 跳过uboot烧写镜像,防止弄坏uboot*/
2、
然后在u-boot-2010.06/common目录下的evn_common.c里面添加如下代码:
3、
重新编译uboot,并烧录到单板,用printenv或pri可以看到已定义的环境变量:
hisilicon
# pri
mirror=sf probe 0;mw.b 82000000 ff F80000;tftp 0x82000000 FWHI2104HF_20151106_DVR_R5104-AHD_2_2_8_0A_413221.flash;sf erase 0x80000 0xF80000;sf write 82000000 0x80000 0xF80000
bootargs=mem=64M console=ttyAMA0,115200
bootcmd=setenv serverip 192.168.1.68;saveenv;run mirror
bootdelay=1
baudrate=115200
ethaddr=00:00:23:34:45:66
ipaddr=192.168.1.10
netmask=255.255.255.0
bootfile="uImage"
stdin=serial
stdout=serial
stderr=serial
verify=n
ver=U-Boot 2010.06 (Nov 13 2015 - 17:47:53)
serverip=192.168.1.68
Environment size: 502/65532 bytes
二、 在uboot里面添加run命令
1、
在u-boot-2010.06/common目录下添加一个文件cmd_run.c,代码如下:
2、
在u-boot-2010.06/include/configs目录的xxx.h(xxx是board,如hi3520d.h)里面添加如下宏定义:
#define CONFIG_CMD_RUN
3、 在u-boot-2010.06/common目录的Makefile里面添加如下定义:
COBJS-$(CONFIG_CMD_RUN) += cmd_run.o
4、 重新编译uboot,并烧录到单板
<span style="font-size:14px;">mirror=sf probe 0;mw.b 82000000 ff F80000;tftp 0x82000000 FWHI2104HF_20151106_DVR_R5104-AHD_2_2_8_0A_413221.flash;sf erase 0x80000 0xF80000;sf write 82000000 0x80000 0xF80000"</span>
然后使用run mirror命令来执行。
一、 在uboot里面添加环境变量
1、 在u-boot-2010.06/include/configs目录下的xxx.h(xxx是board,如hi3520d.h)里面定义环境变量:
/* 跳过uboot烧写镜像,防止弄坏uboot*/
<span style="font-size:14px;">#define CONFIG_BURNMIRROR "sf probe 0;mw.b 82000000 ff F80000;tftp 0x82000000 FWHI2104HF_20151106_DVR_R5104-AHD_2_2_8_0A_413221.flash;sf erase 0x80000 0xF80000;sf write 820000000x80000 0xF80000"</span>
2、
然后在u-boot-2010.06/common目录下的evn_common.c里面添加如下代码:
<span style="font-size:14px;">#ifdef CONFIG_BURNMIRROR "mirror=" CONFIG_BURNMIRROR "\0" #endif</span>
3、
重新编译uboot,并烧录到单板,用printenv或pri可以看到已定义的环境变量:
hisilicon
# pri
mirror=sf probe 0;mw.b 82000000 ff F80000;tftp 0x82000000 FWHI2104HF_20151106_DVR_R5104-AHD_2_2_8_0A_413221.flash;sf erase 0x80000 0xF80000;sf write 82000000 0x80000 0xF80000
bootargs=mem=64M console=ttyAMA0,115200
bootcmd=setenv serverip 192.168.1.68;saveenv;run mirror
bootdelay=1
baudrate=115200
ethaddr=00:00:23:34:45:66
ipaddr=192.168.1.10
netmask=255.255.255.0
bootfile="uImage"
stdin=serial
stdout=serial
stderr=serial
verify=n
ver=U-Boot 2010.06 (Nov 13 2015 - 17:47:53)
serverip=192.168.1.68
Environment size: 502/65532 bytes
二、 在uboot里面添加run命令
1、
在u-boot-2010.06/common目录下添加一个文件cmd_run.c,代码如下:
<span style="font-size:14px;">#include <common.h> #include <watchdog.h> #include <command.h> #include <image.h> #include <malloc.h> #include <u-boot/zlib.h> #include <bzlib.h> #include <environment.h> #include <lmb.h> #include <linux/ctype.h> #include <asm/byteorder.h> #if defined(CONFIG_CMD_RUN) int do_run (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) { int i; if (argc < 2) { cmd_usage(cmdtp); return 1; } for (i=1; i<argc; ++i) { char *arg; if ((arg = getenv (argv[i])) == NULL) { printf ("## Error: \"%s\" not defined\n", argv[i]); return 1; } #ifndef CONFIG_SYS_HUSH_PARSER if (run_command (arg, flag) == -1) return 1; #else if (parse_string_outer(arg, FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0) return 1; #endif } return 0; } U_BOOT_CMD( boot, 1, 1, do_run, "boot default, i.e., run 'bootcmd'", "" ); #endif</span>
2、
在u-boot-2010.06/include/configs目录的xxx.h(xxx是board,如hi3520d.h)里面添加如下宏定义:
#define CONFIG_CMD_RUN
3、 在u-boot-2010.06/common目录的Makefile里面添加如下定义:
COBJS-$(CONFIG_CMD_RUN) += cmd_run.o
4、 重新编译uboot,并烧录到单板
相关文章推荐
- 在C#代码中提取PDF中的注释文本
- WPF笔记(2.3 StackPanel)——Layout
- WPF笔记(2.2 DockPanel)——Layout
- 大学记忆(3)[三国杀(终)]
- iOS8 UIAlertView键盘闪一下的问题
- Android-Universal-Image-Loader 配置UIL配置
- JavaScript基础——面向对象的程序设计
- TCP/IP协议组
- WPF笔记(1.10 绘图)——Hello,WPF!
- 大学记忆(2)[计算机]
- 大学记忆(1)[记忆之殇]
- Compiler Error Message: CS0246: The type or namespace name 的一个解决方法
- 中间件-消息中间件
- 工作备忘-钥匙串存储UUID和账号密码
- maven-jetty-plugin保存文件报错:请求的操作无法在使用用户映射区域打开的文件上执行
- Object-C 字符串类各种操作方法
- 判断某个字符是否在结果集中
- 开源ImageFilter库v0.4:新增26种图片效果
- 2)PHP中把读取.txt中内容并转为UTF-8格式
- shell uniq sort -u 去重排序