转自:http://blog.csdn.net/yangzheng_yz/article/details/41038259

在移植uboot的时候,可以在uboot里面添加定义一些自己的环境变量,这些环境变量可以大大提高以后的工作效率,比如我在uboot里面添加如下环境变量:

bbl=sf probe 0;mw.b 82000000 ff 80000;loady0x82000000 uboot_logo.bin;sf erase 0 80000;sf write 82000000 0 80000

然后使用run命令来执行:

hisilicon # run bbl         

16384 KiB hi_sfc at 0:0 is now currentdevice
## Ready for binary (ymodem) download to0x82000000 at 115200 bps...
CCC
Starting ymodem transfer.  Press Ctrl+C to cancel.100%     222 KB    6 KB/s 00:00:36       1 Errors## Total Size      = 0x000379ec = 227820 Bytes
Erasing at 0x80000 -- 100% complete.
Writing at 0x80000 -- 100% complete.

那么这样就不用每次都输入很长的一串字符串,如:

hisilicon # sf probe 0;mw.b 82000000 ff80000;loady 0x82000000 uboot_logo.bin;sf erase 0 80000;sf write 82000000 080000

那么方法如下:

一、在uboot里面添加环境变量

1、  在u-boot-2010.06/include/configs目录下的xxx.h(xxx是board,如hi3520d.h)里面定义环境变量:

/* Burn bootloader, Linux kernel and rootfscommand */
#define CONFIG_BURNBL       "sf probe 0;mw.b 82000000 ff80000;loady 0x82000000 uboot_logo.bin;sf erase 0 80000;sf write 82000000 0 8
0000"
#define CONFIG_BURNKERNEL"sf probe 0;mw.b 82000000 ff 480000;loady 82000000 root_cramfs.img;sferase 80000 0x480000;sf write 8200000
0 80000 480000"
#define CONFIG_BURN_APP"sf probe 0;mw.b 82000000 ff 0xa00000;loady 82000000 app_jffs2.img;sferase 500000 0xa00000;sf write 82000000500000 0xa00000"
#define CONFIG_BURN_FLASH"sf probe 0;mw.b 82000000 ff 1000000;loady 0x82000000ZMD-PROGRAMMING-FLASH.binl;sf erase 0 1000000;sf writ
e 82000000 0 1000000" 

2、  然后在u-boot-2010.06/common目录下的evn_common.c里面添加如下代码:

#ifdef CONFIG_BURNBL       /* Burn bootloader image to SPIflash*/"bbl=" CONFIG_BURNBL "\0"
#endif
#ifdef CONFIG_BURNKERNEL    /* Burn kernel image to SPIflash*/"blx="CONFIG_BURNKERNEL   "\0"
#endif
#ifdef CONFIG_BURN_APP       /* Burn APP image to SPIflash*/"bapp= "CONFIG_BURN_APP  "\0"
#endif
#ifdef CONFIG_BURN_FLASH    /* Burn Flash APP image to SPIflash*/                                                                   "bfl="CONFIG_BURN_FLASH  "\0"
#endif

3、  重新编译uboot,并烧录到单板,用printenv或pri可以看到已定义的环境变量:

hisilicon # pr

bootargs=mem=96M console=ttyAMA0,115200root=1f01 rootfstype=cramfsmtdparts=hi_sfc:512K(boot),4M(romfs),10M(app),1536K(config)
bootcmd=sf probe 0;sf read 86000000 500000x1B6B2;decjpg;setvobg  0 0x00;stopvo0;startvo 0 4 15;startvo 0 32 15;startgx 0 0x86000000 2560 0 0 1280 1024;sfread 0x84000000 0x80000 0x400000;cramfsload;bootm 0x82000000
bootdelay=1
baudrate=115200
ethaddr=00:00:23:34:45:66
ipaddr=192.168.28.110
jpeg_addr=0x86000000
jpeg_size=0x1b6b2
vobuf=0x86000000
cramfsaddr=0x84000000
cramfsldaddr=0x82000000
serverip=192.168.28.100
netmask=255.255.255.0
bootfile=/boot/hikernel
bbl=sf probe 0;mw.b82000000 ff 80000;loady 0x82000000 uboot_logo.bin;sf erase 0 80000;sf write82000000 0 80000
blx=sf probe 0;mw.b82000000 ff 480000;loady 82000000 root_cramfs.img;sf erase 80000 0x480000;sfwrite 82000000 80000 480000
bapp= sf probe 0;mw.b82000000 ff 0xa00000;loady 82000000 app_jffs2.img;sf erase 500000 0xa00000;sfwrite 82000000 500000 0xa00000
bfl=sf probe 0;mw.b82000000 ff 1000000;loady 0x82000000 ZMD-PROGRAMMING-FLASH.binl;sf erase 01000000;sf write 82000000 0 1000000
stdin=serial
stdout=serial
stderr=serial
verify=n
ver=U-Boot 2010.06 (Nov 11 2014 - 21:27:51)
filesize=379EC Environment size: 1202/65532 bytes

二、            在uboot里面添加run命令

1、  在u-boot-2010.06/common目录下添加一个文件cmd_run.c,代码如下:

/*********************************************************************************                                                  *     Copyright:  (C) 2014 YangZheng<yz2012ww@gmail.com> *                  All rights reserved.**      Filename:  cmd_run.c*   Description:  This file*                *       Version:  1.0.0(11/11/2014~)*        Author:  Yang Zheng<yz2012ww@gmail.com>*     ChangeLog:  1, Release initialversion on "11/11/2014 09:05:08 PM"*                ********************************************************************************/
#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>int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char **argv)
{ if (argc < 2){cmd_usage(cmdtp);return 1;}if (run_command (getenv (argv[1]), flag)< 0){return -1;} return 0;
}U_BOOT_CMD(boot,   1,  1, do_run"boot default, i.e., run 'bootcmd'",""
);  

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,并烧录到单板

三、 运行

hisilicon # run bbl

16384 KiB hi_sfc at 0:0 is now current device
## Ready for binary (ymodem) download to0x82000000 at 115200 bps...

----------------------------------------------------------------------------------

Uboot-201507 am437x平台

uboot_2015.07/common/cli.c----->do_run()

在CONFIG_EXTRA_ENV_SETTINGS宏中添加update_qspi_flash

[uboot]在uboot里面添加环境变量使用run来执行相关推荐

  1. Linux下查看和添加环境变量

    转自:http://blog.sina.com.cn/s/blog_688077cf01013qrk.html $PATH:决定了shell将到哪些目录中寻找命令或程序,PATH的值是一系列目录,当您 ...

  2. linux下怎样查看环境变量,Linux下查看和添加环境变量(示例代码)

    $PATH:决定了shell将到哪些目录中寻找命令或程序,PATH的值是一系列目录,当您运行一个程序时,Linux在这些目录下进行搜寻编译链接. 编辑你的 PATH 声明,其格式为: PATH=$PA ...

  3. linux添加变量6,Linux下查看和添加环境变量

    $PATH:决定了shell将到哪些目录中寻找命令或程序,PATH的值是一系列目录,当您运行一个程序时,Linux在这些目录下进行搜寻编译链接. 编辑你的 PATH 声明,其格式为: PATH=$PA ...

  4. matlab 添加环境变量,CentOS 添加环境变量的三种方法

    在 Linux CentOS 系统上安装完 MATLAB 后,为了使用方便,需要将 matlab 命令加到系统命令中,如果在没有添加到环境变量之前,执行"matlab"命令时,则会 ...

  5. 【263】Linux 添加环境变量 全局 shell 脚本

    Linux电脑添加环境变量 方法一:通过修改 profile 文件添加环境变量 1. 打开终端,输入[vi /etc/profile],如下所示,点击回车 [ocean@ygs-jhyang-w1 L ...

  6. 超详细windows安装mongo数据库、注册为服务并添加环境变量

    1.官网下载zip安装包 官网地址https://www.mongodb.com/download-center/community?jmp=nav,现在windows系统一般都是64位的,选好版本. ...

  7. linux配置redis服务,记一次linux下安装redis, 设置redis服务, 及添加环境变量

    一. redis的安装 cd /opt                                                                                # ...

  8. python添加环境变量_windows系统下python学习-1 (python环境变量配置)

    python安装完成后检测一下是否添加了环境变量(基于你已经完成了python的安装) 使用 Windows+R 键调出运行窗口,输入 cmd 按回车调出命令提示符窗口,输入 python 回车 已添 ...

  9. mysql的优化-添加环境变量启动服务

    >回顾 前面我们已经成功的安装好了数据 但是每一次启动数据库的时候,都会有这样的一些经历 首先要把服务端开启 然后要开启客户端连接服务端输入账号和密码连接成功 . 服务端的开启 服务端文件的路径 ...

最新文章

  1. Distinction Between Strategy and Decorator
  2. Win10自动息屏太快解决方法
  3. Memcache存储大数据的问题(大于1m)
  4. Collection 和 Map接口及其实现类总结
  5. STM32之I2C原理
  6. Database2Sharp重要更新之完善EnterpriseLibrary架构代码
  7. mysql怎么精简_我这个mysql查询该如何精简,提高效率啊?
  8. 识别图片并可视化_数据可视化3大发展方向
  9. 6.jQuery appendTo问题解决
  10. 36. 打印数组的主次对角线
  11. github使用介绍
  12. GIS专业书籍、文档、数据、网站、工具等干货
  13. python实现直方图规定化
  14. 从word中复制图片到ckeditor编辑器中
  15. Pocket PC C#
  16. linux activemq 打印日志,Log4j.xml配置日志按级别过滤并将指定级别的日志发送到ActiveMQ...
  17. 使用腾讯地图来获取定位
  18. 一款免费的Veracrypt加密软件---U盘加密功能
  19. 换网站服务器需要备案吗,换服务器要重新备案吗?
  20. html5 自动失去焦点,js input失去焦点事件

热门文章

  1. QT-helloworld-Qt设计师编写
  2. jmeter模拟登陆
  3. 国外公司技术博客盘点
  4. [Java] [Lock] [Synchronized VS ReentrantLock]
  5. centos6.8安装httpd后无法访问
  6. RMAN备份与恢复(三)--备份相关概念
  7. ubuntu 在vm中如何上网及注意问题
  8. Integer String int 相互转化
  9. 播放视频和音频文件java
  10. XML解析的四种方式