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

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

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

然后使用run命令来执行:

hisilicon# runbbl         

16384KiB hi_sfc at 0:0 is now currentdevice

##Ready for binary (ymodem) download to0x82000000 at 115200 bps...

CCC

Startingymodem transfer.  Press Ctrl+C to cancel.

 100%    222 KB    6 KB/s 00:00:36       1Errors

 

##Total Size      = 0x000379ec = 227820 Bytes

Erasingat 0x80000 -- 100% complete.

Writingat 0x80000 -- 100% complete.

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

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

那么方法如下:

 

一、            uboot里面添加环境变量

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

/* Burnbootloader, linux kernel and rootfscommand */

#define CONFIG_BURNBL      "sf probe 0;mw.b 82000000 ff80000;loady 0x82000000 uboot_logo.bin;sf erase0 80000;sf write 82000000 0 8

0000"

#define CONFIG_BURNKERNEL"sfprobe 0;mw.b 82000000 ff 480000;loady 82000000 root_cramfs.img;sferase 800000x480000;sf write 8200000

0 80000480000"

#define CONFIG_BURN_APP"sfprobe 0;mw.b 82000000 ff 0xa00000;loady 82000000 app_jffs2.img;sferase 5000000xa00000;sf write 82000000

 5000000xa00000"

#define CONFIG_BURN_FLASH"sfprobe 0;mw.b 82000000 ff 1000000;loady 0x82000000ZMD-PROGRAMMING-FLASH.binl;sferase 0 1000000;sf writ

e82000000 0 1000000"

 

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

 

#ifdefCONFIG_BURNBL       /* Burn bootloader image toSPIflash*/

    "bbl="CONFIG_BURNBL "\0"

#endif             

#ifdefCONFIG_BURNKERNEL    /* Burn kernel image to SPIflash*/

    "blx="CONFIG_BURNKERNEL  "\0"

#endif

#ifdefCONFIG_BURN_APP       /* Burn APP image toSPIflash*/

    "bapp="CONFIG_BURN_APP  "\0"

#endif

#ifdefCONFIG_BURN_FLASH    /* Burn Flash APP image toSPIflash*/                                                                   

    "bfl="CONFIG_BURN_FLASH "\0"                

#endif

 

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

hisilicon# pr

bootargs=mem=96Mconsole=ttyAMA0,115200root=1f01rootfstype=cramfsmtdparts=hi_sfc:512K(boot),4M(romfs),10M(app),1536K(config)

bootcmd=sfprobe 0;sf read 86000000 500000x1B6B2;decjpg;setvobg  00x00;stopvo0;startvo 0 4 15;startvo 0 32 15;startgx 0 0x86000000 2560 0 0 12801024;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=sfprobe 0;mw.b82000000 ff 80000;loady 0x82000000 uboot_logo.bin;sf erase 080000;sf write82000000 0 80000

blx=sfprobe 0;mw.b82000000 ff 480000;loady 82000000 root_cramfs.img;sf erase 800000x480000;sfwrite 82000000 80000 480000

bapp=sf probe 0;mw.b82000000 ff 0xa00000;loady 82000000 app_jffs2.img;sf erase500000 0xa00000;sfwrite 82000000 500000 0xa00000

bfl=sfprobe 0;mw.b82000000 ff 1000000;loady 0x82000000 ZMD-PROGRAMMING-FLASH.binl;sferase 01000000;sf write 82000000 0 1000000

stdin=serial

stdout=serial

stderr=serial

verify=n

ver=U-Boot2010.06 (Nov 11 2014 - 21:27:51)

filesize=379EC

 

Environmentsize: 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>

 

intdo_run(int argc, char **argv)

  if (argc < 2)

  {

      cmd_usage(cmdtp);

      return 1;

  }

   if(cmd_tbl_t * cmdtp, int flag, run_command(getenv (argv[1]), flag)< 0)

   {

       return-1;

   }

 

   return0;

}

U_BOOT_CMD(

   boot,  1,  1, do_run

   "bootdefault, i.e., run 'bootcmd'",

   ""

);  

 

2  然后在u-boot-2010.06/include/configs目录的xxx.hxxxboard,如hi3520d.h)里面添加如下宏定义:

#defineCONFIG_CMD_RUN

3、在u-boot-2010.06/common目录的Makefile中添加如下代码:

COBJS-$(CONFIG_CMD_RUN)+= cmd_run.o

4  重新编译uboot,并烧录到单板

 

三、            运行

hisilicon# runbbl

16384KiB hi_sfc at 0:0 is now current device

##Ready for binary (ymodem) download to0x82000000 at 115200 bps...

C

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值