在U-Boot中添加命令
来源:互联网 发布:beowulf linux 编辑:程序博客网 时间:2024/06/05 15:01
命令的结构体表示(include/command.h)
struct cmd_tbl_s { char*name;/* Command Name*/ intmaxargs;/* maximum number of arguments*/ intrepeatable;/* autorepeat allowed?*//* Implementation function*/ int(*cmd)(struct cmd_tbl_s *, int, int, char *[]); char*usage;/* Usage message(short)*/#ifdefCFG_LONGHELP char*help;/* Help message(long)*/#endif#ifdef CONFIG_AUTO_COMPLETE /* do auto completion on the arguments */ int (*complete)(int argc, char *argv[], char last_char, int maxv, char *cmdv[]);#endif};
使用U_BOOT_CMD()这个宏来声明一个命令。
示例:
U_BOOT_CMD(flinfo, 2, 1, do_flinfo,"flinfo - print FLASH memory information\n","\n - print information for all FLASH memory banks\n""flinfo N\n - print information for FLASH memory bank # N\n");
#define Struct_Section __attribute__ ((unused,section (".u_boot_cmd")))#ifdef CFG_LONGHELP#define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage, help}#else/* no long help info */#define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage}#endif/* CFG_LONGHELP */
比如: cmd_console.c文件
………………………………………………….void do_test_addcmd(){printf("only test adding command\n");}/***************************************************/U_BOOT_CMD(coninfo,3,1,do_coninfo,"coninfo - print console devices and information\n","");U_BOOT_CMD(test_addcmd,1,1,do_test_addcmd,"test_addcmd - only test adding command \n","");
实例:
在U-Boot中添加一个打开或关闭蜂鸣器的命令:当输入buzzer open时打开蜂鸣器使它响,输入buzzer close时关闭蜂鸣器。
cmd_buzzer.c(添加在common目录下,并在Makefile添加“COBJS-y +=cmd_buzze.o”语句):
#include <common.h>#include <command.h>#define GPD0CON ( *((volatile unsigned long *)0xE02000A0) ) #define GPD0DAT ( *((volatile unsigned long *)0xE02000A4) )void do_buzzer_addcmd(cmd_tbl_t *cmdtp, int flag, int argc,char *argv[]){GPD0CON &= 0xfffffff0;GPD0CON |= 0x00000001;//设置为输出GPD0DAT &= 0xfe; //关闭蜂鸣器if(0 == strcmp(argv[1],"open")){GPD0DAT |= 0x01;printf("Open the buzzer\n");}else if(0 == strcmp(argv[1],"close")){GPD0DAT &= 0xfe;printf("Close the buzzer\n");}else if(0 == strcmp(argv[1],"--help"))printf ("Help:\n%s\n", cmdtp->help);elseprintf ("Usage:\n%s\n", cmdtp->usage);}U_BOOT_CMD( buzzer, 2, 1, do_buzzer_addcmd, "\tbuzzer --Close or open the buzzer \n",//命令说明"\tbuzzer open --Open the buzzer\n" //帮助信息"\tbuzzer close --Close the buzzer\n");
在顶层make,把生成的u-boot.bin下载到开发板上,在u-boot下运行命令。
附录(下载、烧写U-Boot步骤,s5pv210为例):
1. 使用USB线通过DNW下载sq210_usb.bin到0xd0020010(初始化板子,使板子有一个下载环境)
2. 使用USB线通过DNW下载u-boot.bin到0x23e00000(下载到内存(RAM))
3. 烧录uboot(烧写到flash)
nand erase 0x0 0x60000
tftp 0x20008000 u-boot.bin
nand write 0x20008000 0x0 0x60000
0 0
- 在U-boot中添加加命令
- 在U-boot中添加加命令
- 在u-boot中添加命令
- 在u-boot中添加命令
- 在U-boot中添加命令
- 在u-boot中添加命令hello
- 在U-Boot中添加命令
- 如何在u-boot中添加命令
- 在u-boot中添加命令
- u-boot中添加命令
- 在U-boot-1.3.4中添加加命令
- 在u-boot下添加自定义命令
- u-boot中添加自定义命令
- u-boot中添加自定义命令
- U-boot中mtdparts命令添加
- 【记录】u-boot中添加命令
- 添加u-boot命令
- 添加U-Boot命令
- varchar(n),nvarchar(n) 长度、性能、及所占空间分析
- ./configure *: No such file or directory
- nyist 891 找点
- Introduction to the Transport Control Protocol (TCP) 1
- HDU 5000 Clone / 2014 ACM/ICPC Asia Regional Anshan Online
- 在U-Boot中添加命令
- j2ee规范——JDBC
- 模版的特化和偏特化
- 处理Struts2的action中对返回的json在另一端接收乱码问题
- Prefab in Prefab
- 唐山昌欣泰机械有限公司 1
- HTTP 协议详解
- 唐山大弘欣商贸有限公司 1
- 深圳胡购贸易有限公司 1