在uboot里面加入环境变量使用run来运行
Author:杨正 Date:2014.11.11 Email:yz2012ww@gmail.com QQ:1209758756
在移植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 82000000
500000 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(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;
}
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...
C
在uboot里面加入环境变量使用run来运行的更多相关文章
- 在uboot里面添加环境变量使用run来执行
在uboot里面添加环境变量使用run来执行 本文链接:https://blog.csdn.net/u010979030/article/details/41038259 Author:杨正 Dat ...
- [uboot]在uboot里面添加环境变量使用run来执行
转自:http://blog.csdn.net/yangzheng_yz/article/details/41038259 在移植uboot的时候,可以在uboot里面添加定义一些自己的环境变量,这些 ...
- uboot指令和环境变量
一.uboot指令 1.printenv(pri) - 打印环境变量 2.setenv - 设置环境变量,和saveenv 配合使用 3.saveenv - 保存环境变量 4.run - 执行设置好的 ...
- u-boot中filesize环境变量【转载】
转载地址:https://blog.csdn.net/fzs333/article/details/48518559 U-Boot中的环境命令可以使用$(filesize)来确定刚下载(传输)得到的文 ...
- uboot移植之环境变量在NandFlash
一.概述 u-boot环境变量可以设置在Norflash上,也可以在NandFlash上. 倘若环境变量在NorFlash上,再假设S3C2440从NorFlash启动,是能正确从NorFlash上读 ...
- 0、驱动及应用小技巧、uboot指令及环境变量配置、linux常用命令
(内核make menuconfig之后,通过insmod安装的驱动都应该重新make,可能会出现一些莫名的问题) (nor flash/SDRAM/DM9000都受内存控制器控制,需要配置内存控制器 ...
- 在linux系统中通过fw_printenv查看和设置u-boot中的环境变量
uboot下可以通过命令访问(printenv)和修改环境变量(setenv),但是如果需要在Linux系统下访问这些数据该怎么办呢?其实uboot早就帮我们想好了. 1.编译fw_printenv ...
- 嵌入式Linux环境变量如何参与程序运行
1.环境变量一共有两份,一份在Flash中,另一份在DDR中.uboot开机时一次性从Flash中读取全部环境变量到DDR中作为环境变量的初始化值,然后使用过程中都是用DDR这一份,用户可以用save ...
- 安装JDK+Tomcat,进行环境变量设置,和运行JSP
系统:windows 7 64-bit 安装前需要用到的软件 JDK7u21 Tomcat 8.0 下载64-bit Windows zip就好 安装JDK7u21 和平常安装软件一样,路径也不要动, ...
随机推荐
- HDU1004题解分析(字符串处理)
这道题是从上个星期开始做的,看到题时觉得似曾相似,好像做过,理了一下思路敲完代码又不对,后来发现是数组用错了,之后又重新想了数组和比较用法,昨天改了一个多小时,后来样例输出全部正确,所有情况都考虑到了 ...
- 网站压力测试之ApacheBench
ApacheBench是 Apache 附带的一个小工具,专门用于 HTTP Server 的benchmark testing,可以同时模拟多个并发请求.使用yum安装apache,ab工具在/us ...
- asp.net 页面执行过程
Application_BeginRequest Application_AuthenticateRequest Application_AuthorizeRequest Application_Re ...
- Linux下Qt应用程序的发布(使用LDD命令查看所有依赖的库文件)
最近一直在学习Qt,用Qt写了一个程序,但是不知道怎么发布,网上说的都是在windows下怎么发布Qt应用程序,但是,在windows下Qt应用程序依赖的库文件与linux下的名字不同.于是,我就想到 ...
- spring的定时执行代码 跑批
最近公司上线了抽奖的活动,活动需求 1:每天凌晨更新状态,实现自动开启和关闭活动 2:活动结束自动抽取中奖号码 在这里提供spring的定时调度功能 1:首先是配置文件 在你的web.xml中,查看配 ...
- boost::thread用法
最近在做一个消息中间件里面涉及到多线程编程,由于跨平台的原因我采用了boost线程库.在创建线程时遇到了几种线程创建方式现总结如下: 首先看看boost::thread的构造函数吧,boost::th ...
- linux 命令之sar——监视系统状态
摘要:在进行系统或者内核测试的时候,我们经常需要观察cpu利用率,缓冲区使用情况,文件读写情况等等.在linux系统下,我们可以用sar命令来达到这个要求. sar 命令行的常用格式: sar [op ...
- C++拾遗
1三个概念 字符串字面值是一串常量字符(是一个常量),字符串字面值常量用双引号括起来的零个或多个字符表示,为兼容C语言,C++中所有的字符串字面值都由编译器自动在末尾添加一个空字符.字符串字面值的类型 ...
- php 取小数
- sizeof,一个其貌不扬的家伙(转)
sizeof,一个其貌不扬的家伙,引无数菜鸟竟折腰,小虾我当初也没少犯迷糊,秉着“辛苦我一个,幸福千万人”的伟大思想,我决定将其尽可能详细的总结一下.但当我总结的时候才发现,这个问题既可以简单,又可以 ...