第1阶段——uboot分析之仿照bootm制作hello命令(7)
仿照bootm命令生成来制作一个hello命令,功能:打印出hello,world!和参数值
1.点击New File ,创建cmd_hello.c
将./common/cmd_bootm.c的头文件复制到 cmd_hello.c中
(因为cmd_bootm.c的头文件都是包括的命令相关的文件):
#include <common.h>
#include <watchdog.h>
#include <command.h>
#include <image.h>
#include <malloc.h>
#include <zlib.h>
#include <bzlib.h>
#include <environment.h>
#include <asm/byteorder.h>
2.点击保存:
保存在./common文件下,(命令文件都存在common文件里)
3.写执行命令需要调用的函数:
复制./common/cmd_bootm.c里
int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
}
改成:
int do_hello (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) //执行命令需要调用的函数
{
int i;
printf ("hello,world!,arg_numble=%d\n",argc); //打印"hello,world!"和参数个数arg_numble
for(i=0;i<argc;i++)
printf("argv[i]=%s",i,arg[i]); //打印命令名字和参数值
return 0;
}
4. 添加U_BOOT_CMD宏(实现:通过U_BOOT_CMD宏来将命令保存在.u_boot_cmd段里):
U_BOOT_CMD(
hello, //命令名
CFG_MAXARGS, //参数最大值
1, //支持重复使用命令
do_hello, //函数指针,用于命令执行时需要调用什么函数,就是第2节的do_hello函数
"hello - just for help...", //短的使用说明
"hello - long help... ..." //长的使用说明,敲打"help hello"命令,就会出现这段字符串
#endif
);
5.将cmd_hello.c复制到虚拟机中u-boot-1.1.6/common目录下。
6.进入common目录,输入"vi mkfine" 修改conmon目录下mkfine,在mkefine第54行,COBJS里添加cmd_hello.o文件
7.输入"make",生成u-boot.bin文件重新下载就可以使用hello命令了.
cmd_hello.C源码:
#include <common.h>
#include <watchdog.h>
#include <command.h>
#include <image.h>
#include <malloc.h>
#include <zlib.h>
#include <bzlib.h>
#include <environment.h>
#include <asm/byteorder.h> int do_hello (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) //执行命令需要调用的函数
{
int i;
printf ("hello,world!,arg_numble=%d\n",argc); //打印"hello,world!"和参数个数arg_numble
for(i=;i<argc;i++)
printf("argv[i]=%s",i,arg[i]); //打印参数 return ;
}
U_BOOT_CMD(
hello, //命令名
CFG_MAXARGS, //参数最大值
, //支持重复使用命令
do_hello, //函数指针,用于命令执行时需要调用什么函数,就是第2节的do_hello函数
"hello - just for help...\n", //短的使用说明
"hello - long help... ...\n" //长的使用说明,敲打"help hello"命令,就会出现这段字符串
#endif
);
第1阶段——uboot分析之仿照bootm制作hello命令(7)的更多相关文章
- 第1阶段——uboot分析之查找命令run_command函数和命令定义过程(6)
本节主要学习,run_command函数命令查找过程,命令生成过程 1.run_command函数命令查找过程分析:在u-boot界面中(main_loop();位于u-boot-1.1.6/comm ...
- 第1阶段——uboot分析之启动函数bootm命令 (9)
本节主要学习: 详细分析UBOOT中"bootcmd=nand read.jffs2 0x30007FC0 kernel;bootm 0x30007FC0"中怎么实现bootm命令 ...
- 第1阶段——uboot分析之硬件初始化start_armboot函数(5)
start_armboot()分析:在start.S初始化后跳转到start_armboot实现第2阶段硬件相关的初始化(烧写擦除flash,网卡驱动,usb驱动,串口驱动,从FLASH读内核,启动内 ...
- 第1阶段——uboot分析之通过nand命令读内核(8)
本节主要学习: 详细分析UBOOT中"bootcmd=nand read.jffs2 0x30007FC0 kernel;bootm 0x30007FC0" 怎么实现nand命令读 ...
- 第1阶段——uboot分析之硬件初始化start.S(4)
分析uboot第一个执行函数_start(cpu/arm920t/start.S) 打开cpu/arm920t/start.S .globl _start // .globl定义一个全局符号" ...
- 第1阶段——u-boot分析之make指令(2)
通过make 100ask24x0_config 指令配置好芯片选型后,使用make指令来生成uboot.bin文件 本文学习目标: 对Makefile文件进行基本了解,掌握make指令是怎么实现生成 ...
- 第1阶段——u-boot分析之make 100ask24x0_config指令(1)
本文学习目标: 掌握"make 100ask24x0_config"指令在Makefile和mkconfig文件中是怎么实现配置芯片选型 1.执行make 100a ...
- u-boot分析(十)----堆栈设置|代码拷贝|完成BL1阶段
u-boot分析(十) 上篇博文我们按照210的启动流程,分析到了初始化nand flash,由于接下来的关闭ABB比较简单所以跳过,所以我们今天按照u-boot的启动流程继续进行分析. 今天我们会用 ...
- Linux之uboot分析与移植20160601
说一下uboot分析与移植: 1.下载.建立source insight工程.编译.烧写.如果无运行分析原因 tar xjf u-boot-2012.04.01.tar.bz2 cd u-boot-2 ...
随机推荐
- [补档][Tvyj 1729]文艺平衡树
[Tvyj 1729]文艺平衡树 题目 您需要写一种数据结构(可参考题目标题),来维护一个有序数列,其中需要提供以下操作:翻转一个区间,例如原有序序列是5 4 3 2 1,翻转区间是[2,4]的话,结 ...
- JS实现extend函数
//写一个函数,该函数的名称是extend,有两个参数:destination,source 1.如果destination和source都是json对象,完成从source到destination的 ...
- mybatis example使用 and和or联合查询(转)
这两天项目用到ibatis,碰到and or的联合查询,语句像这样的 select * from table where xxx = "xxx" and (xx1="xx ...
- 再起航,我的学习笔记之JavaScript设计模式06(工厂方法模式)
上一次已经给大家介绍了简单工厂模式,相信大家对创建型设计模式有了初步的了解,本次我将给大家介绍的是工厂方法模式. 工厂方法模式 工厂方法模式(Factory Method):通过对产品类的抽象使其创建 ...
- Node.js Up and Runing 学习日记(一)
认识一个Node.js程序 HTTP模块是专为快速非阻塞式HTTP服务器而用C重新编写的. 1. var http = require('http'); 2. http.createServer(fu ...
- 逻辑回归的实现(LogicalRegression)
1.背景知识 在刚刚结束的天猫大数据s1比赛中,逻辑回归是大家都普遍使用且效果不错的一种算法. (1)回归 先来说说什么是回归,比如说我们有两类数据,各有50十个点 ...
- 【有意思的BUG】浏览器的Title和Icon
序:Icon在术语上也称为"ico",比如豆瓣的ICON地址:http://img3.douban.com/favicon.ico 先贴一张图,有助于理解这篇文档的标题--< ...
- 进程通信-SendMessage使用方法
进程通信-SendMessage的使用方法 用过SendMessage进行进程通信的同学都知道,这个函数一般都搭配FindWindow使用.通过FindWindow查找进程句柄,然后使用SendMes ...
- Oracle用户的初始化问题
上一篇博文介绍了关于.bashrc和.bash_profile的相关知识,在oracle的用户设置中能发挥作用. 场景:上周准备学习一下oracle,下载了安装文件后,在linux上新建了一个用户or ...
- python join 和 split的常用使用方法
函数:string.join()Python中有join()和os.path.join()两个函数,具体作用如下: join(): 连接字符串数组.将字符串.元组.列表中的元素以指定的字符 ...