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(天嵌 ...
随机推荐
- vue-cli run dev 和 run build 出现的问题(运行项目、打包项目)
前些天做项目,过程中遇到了一个比较奇怪的问题:npm run dev 和 npm run build 的时候,出现了错误,导致项目无法启动.打包无法成功.报了一堆错误: 错误展示: 找了一下解决方案, ...
- Python——追加学习笔记(三)
错误与异常 AttributeError:尝试访问未知的对象属性 eg. >>> class myClass(object): ... pass ... >>> m ...
- Python——追加学习笔记(二)
文件处理 # 文件内移动 seek()方法可以在文件中移动文件指针到不同的位置,offset字节代表相对于某个位置偏移量,默认为0,代表从文件开头算起,1代表从当前位置算起,2代表从文件末尾算起. s ...
- 百度地图JavaScript开发入门先知
最近项目紧急开发了一些百度地图的功能,觉得百度地图实数强大!于是今天不忙总结一下,看到不错的文章先转载. 文章出处:https://www.opengps.cn/Blog/View.aspx?id=1 ...
- python25 python的三目运算符
其他语言的三目运算符大类似: 条件 ? 条件为真返回值: 条件为假返回值 python不一样: 条件为真的返回值 if 条件 else 条件为假的返回值 或者 ...
- 【洛谷5309】[Ynoi2012] D1T1(分块)
点此看题面 大致题意: 两种操作,区间求和,将形如\(ax+y\)的位置的元素值加\(z\). 分块 这种题目显然就是按照\(x\)与\(\sqrt n\)的大小关系来分块. 对于\(x>\sq ...
- 解决TextBox Ctrl+A不能全选的问题
// 添加keyPress事件 private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar = ...
- PAML学习一
前言 模式识别起源于工程,而机器学习从计算机科学中产生.然而这两者被看做同一领域的两方面,过去十年里他们获得了极大的发展.特别是,贝叶斯方法已经发展成主流,而图模型已经被融入用于描述和应用概率模型的通 ...
- sqlite迁移mysql(导入导出数据)
第一步,将数据导出 进入sqlite3->.open [打开文件路径]->.cd [要保存的路径]->.output [导出文件名字.sql]->.dump 等待导出成功后,就 ...
- 学大伟业 Day 5 培训总结
今天讲数据结构 先从mzx大佬的ppt摘抄一段: 数据结构是计算机存储.组织数据的方式.数据结构是指相互之间存在一种或多种特定关系的数据元素的集合. 通常情况下,精心选择的数据结构可以带来更高的运行或 ...