uboot中添加自启动的快捷菜单
来源:互联网 发布:淘宝xbox360手柄一百多 编辑:程序博客网 时间:2024/05/21 17:53
u-boot下common内的每个cmd_*.c代表一个命令,可以把一些常用的命令做成快捷菜单:
1、在common文件夹中新建cmd_menu.c
2、在cmd_menu.c中加入下列代码
#include <common.h>#include <command.h>void main_menu_usage(void) { //以下全部通过tftp下载printf("[1] 下载bootloader到Nand Flash\r\n");printf("[2] 下载内核镜像到Nand Flash\r\n");printf("[3] 下载文件系统镜像到Nand Flash\r\n");printf("[4] 下载内核镜像到内存并运行\r\n");printf("[5] 重启设备\r\n");printf("[q] 退出菜单\r\n");// if (bBootFrmNORFlash == 1) // printf("[0] 下载bootloader到Nor Flash\r\n"); printf("Enter your selection: "); }void menu_shell(void){char ch;char cmd_buf[200];while(1){main_menu_usage();//打印菜单ch = getc();printf("%c\n",ch);switch(ch){case '1':{//nand擦除和写入的大小由分区表决定strcpy(cmd_buf, "tftp 0x32000000 u-boot.bin; nand erase 0x0 0x60000; nand write 0x32000000 0x0 0x60000");run_command(cmd_buf, 0);break;}case '2':{strcpy(cmd_buf, "tftp 0x32000000 uImage; nand erase 0x80000 0x200000; nand write 0x32000000 0x80000 0x200000");run_command(cmd_buf, 0);break;}case '3':{strcpy(cmd_buf, "tftp 0x32000000 fs.yaffs; nand erase 0x280000; nand write.yaffs2 0x32000000 0x280000 $(filesize)");run_command(cmd_buf, 0);break;}case '4':{strcpy(cmd_buf, "tftp 0x32000000 uImage; bootm 0x32000000");run_command(cmd_buf, 0);break;}case '5':{strcpy(cmd_buf, "reset");run_command(cmd_buf, 0);break;}case 'q':{return; break;}default:break; }}}int do_menu(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){menu_shell();return 0; }U_BOOT_CMD(menu, 3, 0, do_menu,"display a menu\n","select one item to do something\n");/*****************************U_BOOT_CMD(name,maxargs,rep,cmd,usage,help)各个参数的意义如下:name:命令名,非字符串,但在U_BOOT_CMD中用“#”符号转化为字符串maxargs:命令的最大参数个数rep:是否自动重复(按Enter键是否会重复执行)cmd:该命令对应的响应函数usage:简短的使用说明(字符串)help:较详细的使用说明(字符串)******************************/
3、修改common目录下的Makefile文件,让加入的cmd_menu.c文件参与编译,添加
COBJS-y += cmd_menu.o
4、在配置文件中(include/configs下与平台对应的头文件)加入宏
#define CONFIG_CMD_MENU 1
5、在main.c中调用menu命令,在main_loop函数中的abortboot(bootdelay)结束后添加
//设置启动uboot时自动执行menu命令#ifdef CONFIG_CMD_MENU run_command("menu", 0);#endif
- uboot中添加自启动的快捷菜单
- 改进uboot,添加自定义快捷菜单
- Uboot移植添加启动菜单
- uboot中的快捷菜单的制作说明
- uboot中的快捷菜单的制作说明
- uboot中的快捷菜单的制作说明
- Uboot中的快捷菜单的制作说明
- uboot中的快捷菜单的制作说明
- uboot中的快捷菜单的制作说明
- C#快捷菜单的添加
- 天祥 TX2440 UBOOT移植(6. 快捷启动菜单)
- VS2008中VC++添加快捷菜单
- 添加快捷菜单C++
- TX2440 ARM开发板Uboot移植 (六、实现启动快捷菜单)
- TX2440 ARM开发板Uboot移植 (六、实现启动快捷菜单)
- TX2440 ARM开发板Uboot移植 (六、实现启动快捷菜单)
- 右键快捷菜单中添加开启命令行窗口命令
- 在右键菜单中添加Dos快捷通道
- Google V8编程详解(一)V8的编译安装(Ubuntu)
- Google V8编程详解(二)HelloWorld
- Java读写Excel
- Hibernate复习笔记
- 黄聪:wordpress调用函数大全
- uboot中添加自启动的快捷菜单
- 测试经理的工作以及素质
- 如何在C++获得系统时间(转)
- [TI DLP Buglist]DRAM fail after screen capture
- Json for Java 代码示例
- 线段树总结
- Deep Learning in NLP (一)词向量和语言模型
- oracle导入dmp文件
- Android 上层界面到内核代码的完整的流程分析,以alarm为例子