cmd_menu.c
#include <config.h>
#include <command.h>
static int quit_flag = 0;
char awaitkey(unsigned long delay, int* error_p)
{
int i;
while (1) {
if (tstc()) /* we got a key press */
return getc();
}
}
else {
for (i = 0; i < delay; i++) {
if (tstc()) /* we got a key press */
return getc();
udelay (10*1000);
}
}
if (error_p)
*error_p = -1;
return 0;
}
{
volatile unsigned long *pa = (volatile unsigned long * )0;
unsigned long pb;
*pa = 0x12345678;
if(*pa != 0x12345678) { //不可写
return 1;
}
else{
*pa = pb;
printf("nand \n");
return 0;
}
}
{
printf("\r\n##### u-boot cmd menu ##### \r\n");
if(isbootfromnor())
printf("[o] download u-boot to nor \r\n");
printf("[n] download u-boot to nand \r\n");
printf("[k] download kernel to nand \r\n");
printf("[f] download yaffs-rootfs to nand \r\n");
printf("[r] reset the u-boot \r\n");
printf("[b] boot the system \r\n");
printf("[q] quit from menu \r\n");
}
{
strcpy(cmd_buf, "protect off all;erase 0 7ffff;tftp 30000000 u-boot.bin;cp.b 30000000 0 80000");
run_command(cmd_buf, 0);
}
{
strcpy(cmd_buf, "nand erase.part u-boot;tftp 30000000 u-boot.bin;nand write 30000000 u-boot");
run_command(cmd_buf, 0);
}
{
strcpy(cmd_buf, "nand erase.part kernel;tftp 30000000 uImage;nand write 30000000 kernel");
run_command(cmd_buf, 0);
}
{
char *p = cmd_buf + 14;
strcpy(cmd_buf, "nand erase.part rootfs");
run_command(cmd_buf, 0);
strcpy(cmd_buf, "tftp 30000000 ");
strcpy(p, argv[1]);
run_command(cmd_buf, 0);
strcpy(cmd_buf, "nand write.yaffs 30000000 460000 ");
p = cmd_buf + 33;
strcpy(p, argv[2]);
run_command(cmd_buf, 0);
}
{
run_command("reset", 0);
}
{
run_command("boot", 0);
}
{
quit_flag = 1;
}
{
printf("sure you have prepared file by tftp! \n");
}
{
char cmd;
showmainmenu();
while(1){
cmd = awaitkey(-1, NULL);
switch(cmd){
case 'o':
pre_handle();
do_uboot_load_o();
break;
case 'n':
pre_handle();
do_uboot_load_n();
break;
case 'k':
pre_handle();
do_kernel_load();
break;
case 'f':
pre_handle();
do_rootfs_load(argv);
break;
case 'r':do_reset_cmd();
break;
case 'b':
do_bootm_cmd();
break;
case 'q':
do_quit();
break;
}
if(quit_flag == 1)
break;
cmd = 0;
}
quit_flag = 0;
}
{
menu_shell(argv);
return 0;
}
menu, 3, 1, do_menu,
"sure you have prepared file by tftp, and press corresponding key",
"sure you have prepared file by tftp \n"
"press corresponding key, the u-boot will help you download file to the suited memory location \n"
"note: this menu only support yaffs rootfs, if you want to download jffs rootfs, you must input cmd by hand! \n"
"if you want to download rootfs, you must input 3 paramters like <menu> <rootfs_name> <rootfs_size> \n"
);
cmd_menu.c的更多相关文章
- uboot补丁的分析
接下来分析一下韦老师的uboot补丁: -------------------------------------------------------------------------------- ...
- (转载)U-boot启动完全分析
1.1 U-Boot工作过程 U-Boot启动内核的过程可以分为两个阶段,两个阶段的功能如下: (1)第一阶段的功能 Ø 硬件设备初始化 Ø 加载U-Boot第二阶段代码到RAM空间 Ø 设置好栈 Ø ...
- 改进uboot,添加自定义快捷菜单
.在common目录下新增cmd_menu.c文件,内容为: #include<common.h> #include<command.h> #ifdef CONFIG_MENU ...
- u-boot代码学习内容
前言 u-boot代码庞大,不可能全部细读,只能有选择的读部分代码.在读代码之前,根据韦东山教材,关于代码学习内容和深度做以下预先划定. 一.Makefile.mkconfig.config.mk等 ...
- 在uboot上创建菜单
一.原理 菜单其实就是一个uboot中的命令,和其他的命令没有什么差别. uboot启动时,如果进入uboot命令模式,先运行这个命令,就会打印出一个菜单界面. 在uboot的命令模式,通过键入“m ...
- U-Boot启动过程完全分析
U-Boot启动过程完全分析 1.1 U-Boot工作过程 U-Boot启动内核的过程可以分为两个阶段,两个阶段的功能如下: (1)第一阶段的功能 硬件设备初始化 加载U-Boot第二阶段 ...
- 修改LVDS支持1024*600分辨率
一.在boot中增加LVDS设置分辨率1024*600选项 1.修改文件TQIMX6_android-4.2.2\bootable\bootloader\uboot-imx\common\cmd_me ...
- ok6410 u-boot-2012.04.01移植七完善u-boot移植(u-boot移植结束)
继ok6410 u-boot-2012.04.01移植六后,开发板已支持MLC NAND.DM9000等.但还需要完善比如环境变量.mtdpart分区.裁剪.制作补丁等.下面的工作就是完善移植的u-b ...
- AM3358--Uboot支持LCD输出1024*768
1. uboot/include/lcd/tq3358_fb.h #define TFT240320 1 #define TFT320240 2 #define TFT480272 3//T43(天嵌 ...
随机推荐
- C++异常安全的思考
异常安全的代码是指,满足两个条件 1异常中立性 : 是指当你的代码(包括你调用的代码)引发异常时,这个异常 能保持原样传递到外层调用代码 2.异常安全性: 1,抛出异常后,资源不泄露, 2,抛出异常 ...
- java面试之----堆(heap)、栈(stack)和方法区(method)
JAVA的JVM的内存可分为3个区:堆(heap).栈(stack)和方法区(method)也叫静态存储区. 堆区: 1.存储的全部是对象,每个对象都包含一个与之对应的class的信息.(class的 ...
- Flask入门模板Jinja2语法与函数(四)
1 模板的创建 模板文件结构: project/ templates/ 模板文件 跳转模板一般使用: from flask import render_template,render_template ...
- 【Spring实战】—— 9 AOP环绕通知
假如有这么一个场景,需要统计某个方法执行的时间,如何做呢? 典型的会想到在方法执行前记录时间,方法执行后再次记录,得出运行的时间. 如果采用Spring的AOP,仅仅使用前置和后置方法是无法做到的,因 ...
- 查询python的安装路径
参考链接: https://blog.csdn.net/orangleliu/article/details/44907221 (tf_14) novak@novak-ZBook15G2:~$ pyt ...
- Machine Learing 入门 —— 开门第0篇
一.最近懒了 7月没怎么写博客,倒是一直在学Machine Learning的入门知识,在这里给大家推荐一个不错的自学网站:https://www.coursera.org/ ,Andrew Ng是联 ...
- ABAP和Java里关于DEFAULT(默认)机制的一些语言特性
ABAP 740的新语法: 上图的代码相当于: DATA: ls_data LIKE LINE OF it_data. READ TABLE it_data INTO ls_data WITH KEY ...
- 小故事学设计模式之Observer : (三) 老婆帮忙订机票
(IT的事就是过场多,过场多了就容易忘,所以我们不妨看一个记一个,这也是一个办法,顺便还能跟同行们交流一下) 要和老婆一起回老家了, 成都离我们安徽太远, 两个人飞一下过去就要花掉近三千块, 于是我 ...
- Java Android 32位16位 MD5加密
// md5加密 32位小写 private String Md5(String sourceStr) { String result = ""; try { MessageDig ...
- chpasswd
功能说明:从标准输入中读取一定格式的用户名.密码来批量更新用户的密码,其格式为 “用户名:密码”. 参数选项:-e 默认格式是明文密码,使用-e参数则需要加密的密码.