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(天嵌 ...
随机推荐
- Apache转发到Tomcat
#vi /etc/httpd/conf/httpd.conf 添加下面配置 NameVirtualHost *:80 <VirtualHost *:80>ProxyPreserveHost ...
- Windows7建立无线热点
很实用的技巧,加以记录. 最初我是想使用connectify的,不过安装这个软件之后,发现有线账号登不上了,所以就选择使用Windows7自带的工具了. 首先以管理员身份运行cmd. 进入之后cd到c ...
- Catia 二次开发资料(转)
Catia 二次开发 CATIA V5在开发之初就遵循面向对象的设计思想(OO),构建了完全基于组件的体系结构(PPR: Products,Process,Resource),有效地解决了维护.管理. ...
- 面向切面编程-AOP的介绍
AOP简介 AOP(Aspect-Oriented Programming, 面向切面编程): 是一种新的方法论, 是对传统 OOP(Object-Oriented Programming, 面向对象 ...
- ASP.NET中引用dll“找不到指定模块"的完美解决办法 z
DllImport是System.Runtime.InteropServices命名空间下的一个属性类,其功能是提供从非托管DLL导出的函数的必要调用信息.DllImport属性应用于方法,要求最少要 ...
- Windows 2012R2远程桌面服务部署环境简介
一.部署环境 服务器名 所属域 IP地址 服务器用途 备注 AD01 CONTOSO.COM 192.168.1.1 域控制器 采用Windows Server 2012 R2 Datacenter ...
- 随tomcat启动的Servlet程序
由于需要做一定定时轮询程序,自己写了一个Servlet小程序,在Servlet里面的Init函数中做一个Timer,定时执行程序. 代码如下: public class MailStartup ex ...
- python入门21 pip安装、更新、卸载第三方包,验证包是否安装成功;pip自身更新升级
1 安装第三方包 python3自带安装工具pip,且在安装时勾选添加path也会将pip.exe所在目录加入到环境变量(python安装目录\Scripts). 因此安装第三方软件特别简单,打开命令 ...
- python:进程操作
一.多进程应用 import socket from multiprocessing import Process def talk(conn): conn.send(b'connected') re ...
- ACM-ICPC(10/23)
贪心 区间相关问题 选择不相交区间: hdu 2037 给定一些区间,选择尽量多的区间,他们互相不交叉.(活动安排问题) 分析:贪心思路是解决活动安排问题的好方案. 按照区间右端点排序,从前往后遍历, ...