转自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         

 KiB hi_sfc at : is now currentdevice
## Ready for binary (ymodem) download to0x82000000 at bps...
CCC
Starting ymodem transfer. Press Ctrl+C to cancel.
% KB KB/s :: Errors ## Total Size = 0x000379ec = Bytes
Erasing at 0x80000 -- % complete.
Writing at 0x80000 -- % 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
"
#define CONFIG_BURNKERNEL"sf probe 0;mw.b 82000000 ff 480000;loady 82000000 root_cramfs.img;sferase 80000 0x480000;sf write 8200000
"
#define CONFIG_BURN_APP"sf probe 0;mw.b 82000000 ff 0xa00000;loady 82000000 app_jffs2.img;sferase 500000 0xa00000;sf write 82000000
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 " 

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 ;sf read 500000x1B6B2;decjpg;setvobg 0x00;stopvo0;startvo ;startvo ;startgx 0x86000000 ;sfread 0x84000000 0x80000 0x400000;cramfsload;bootm 0x82000000
bootdelay=
baudrate=
ethaddr=:::::
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 ;mw.b82000000 ff ;loady 0x82000000 uboot_logo.bin;sf erase ;sf write82000000
blx=sf probe ;mw.b82000000 ff ;loady root_cramfs.img;sf erase 0x480000;sfwrite
bapp= sf probe ;mw.b82000000 ff 0xa00000;loady app_jffs2.img;sf erase 0xa00000;sfwrite 0xa00000
bfl=sf probe ;mw.b82000000 ff ;loady 0x82000000 ZMD-PROGRAMMING-FLASH.binl;sf erase ;sf write
stdin=serial
stdout=serial
stderr=serial
verify=n
ver=U-Boot 2010.06 (Nov - ::)
filesize=379EC Environment size: / 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 < )
{
cmd_usage(cmdtp);
return ;
}
if (run_command (getenv (argv[]), flag)< )
{
return -;
} return ;
} U_BOOT_CMD(
boot, , , 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

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

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

Uboot-201507 am437x平台

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

在CONFIG_EXTRA_ENV_SETTINGS宏中添加update_qspi_flash

[uboot]在uboot里面添加环境变量使用run来执行的更多相关文章

  1. 在uboot里面添加环境变量使用run来执行

    在uboot里面添加环境变量使用run来执行 本文链接:https://blog.csdn.net/u010979030/article/details/41038259 Author:杨正  Dat ...

  2. 在uboot里面加入环境变量使用run来运行

    Author:杨正  Date:2014.11.11   Email:yz2012ww@gmail.com QQ:1209758756 在移植uboot的时候,能够在uboot里面加入定义一些自己的环 ...

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

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

  4. postman 添加环境变量 并 读取变量 作为参数 传入,跑整个场景

    上篇文章 写了 postman 基本使用 和 检查点. 这篇 记录一下 多个测试用例组成的一个场景下. 如何通过读取变量跑完整个场景. 因为有些场景 的用例是彼此关联的. 所以通过参数来实现. 如 我 ...

  5. linux命令(11)下查看和添加环境变量

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

  6. 软件 利用 win+R 快速启动(无需添加环境变量)

    前言:以 "Typora" 软件 为例 ,无需添加环境变量,实现键盘快速启动 第一步 找到 为知笔记的快捷方式 打开文件位置 鼠标右击该软件的桌面快捷方式 复制该软件的快捷方式 第 ...

  7. mac 添加环境变量(jmeter添加至环境变量中)

    Mac系统的环境变量,加载顺序为:a. /etc/profileb. /etc/pathsc. ~/.bash_profiled. ~/.bash_logine. ~/.profilef. ~/.ba ...

  8. php 添加环境变量

    1.php添加环境变量主要为了能在 cmd和软件的客户端用php来运行 首先我们要做的第一步: 添加环境变量(记住php.exe的路径,然后再环境变量中编辑path 多个用逗号分隔开,保存重启电脑) ...

  9. 使用setx 命令添加环境变量(Windows)

    背景 用GUI的方法可能添加环境变量可能会比较麻烦,为此可采用命令行操作的方式. 步骤 以管理员身份运行 cmd 输入 setx /M "%path%" "%path%[ ...

随机推荐

  1. 【LeetCode】31. Next Permutation (2 solutions)

    Next Permutation Implement next permutation, which rearranges numbers into the lexicographically nex ...

  2. 【LeetCode】120. Triangle (3 solutions)

    Triangle Given a triangle, find the minimum path sum from top to bottom. Each step you may move to a ...

  3. Windows远程连接局域网内或同一个网段或同一个路由器的某台机器

    http://bbs.shendu.com/thread-1443245-1-1.html     亲自试验,具体操作如下:    我现在有三台机器和对应的ip地址(ip地址自己手动填写,不会网上搜) ...

  4. 'Provide value on 'System.Windows.StaticResourceExtension' threw an exception.'

    产生这个错误的原因是,StaticResource必须先定义再引用,但是DynamicResource就没有这个限制,为避免这个错误出现,可将StaticResource的定义放在Window.xam ...

  5. RabbitMQ概念及环境搭建(三)RabbitMQ cluster

    测试环境:VMS00781 VMS00782 VMS00386 (centos5.8) 1.先在三台机器上分别安装RabbitMQ Server 2.读取其中一个节点的cookie,并复制到其他节点( ...

  6. Python学习笔记020——数据库基本操作

    本数据库的操作是Linux虚拟机平台下进行的 1 启动和链接MySQL服务 1.1 服务端 (1)查看服务状态 sudo /etc/init.d/mysql stauts (2)启动服务端 sudo ...

  7. Template Method - 模板方法模式

    1.概述 在面向对象开发过程中,通常我们会遇到这样的一个问题:我们知道一个算法所需的关键步骤,并确定了这些步骤的执行顺序.但是某些步骤的具体实现是未知的,或者说某些步骤的实现与具体的环境相关.例子1: ...

  8. Linux常见的进程调度算法

    进程调度:在操作系统中调度是指一种资源分配. 调度算法是指: 根据系统的资源分配策略所规定的资源分配算法. 操作系统管理了系统的有限资源,当有多个进程(或多个进程发出的请求)要使用这些资源时,因为资源 ...

  9. swagger and restful api 参考

      http://git.oschina.net/redArmy/spring-cloud-books/blob/master/spring-cloud-provider-book/src/main/ ...

  10. texturePacker黄色文件夹和蓝色文件夹

    texturePacker中以黄色文件夹添进来的文件夹中的图片,不用带文件夹名,以蓝色文件夹添进来的文件要带文件夹名.