一、原理
uboot選單其實就是乙個uboot中的命令,和其他的命令沒有什麼差別。
uboot啟動時,如果進入uboot命令模式,先執行這個命令,就會列印出乙個選單介面。在uboot的命令模式,通過鍵入「menu」命令,同樣可以調出這個介面。
二、操作步驟
1、在uboot的common目錄下建立cmd_menu.c, 定義乙個uboot cmd:
u_boot_cmd
( menu,3,
0, do_menu,
"menu - display a menu, to select the items to do something\n"
," - display a menu, to select the items to do something"
);
cmd的名為 menu ,執行的動作是do_menu函式。
實現do_menu:
int do_menu (cmd_tbl_t *cmdtp,
int flag,
int argc,
char
*ar**)
然後繼續完善cmd_menu.c,內容如下:
#include
#include
#ifdef config_cmd_menu
#define use_tftp_down 1
#define use_usb_down 2
extern
char console_buffer;
/* * reads and returns a character from the serial port
* - times out after delay iterations checking for presence of character
* - sets *error_p to uart error bits or - on timeout
* - on timeout, sets *error_p to -1 and returns 0
*/static
char
awaitkey
(unsigned
long delay,
int* error_p)
}else}if
(error_p)
*error_p =-1
;return0;
}static
intbbootfrmnorflash
(void
)else
}void
main_menu_usage
(char menu_type)
else
if( menu_type == use_tftp_down)
if( menu_type == use_usb_down)
else
if( menu_type == use_tftp_down)
printf
("[2] download eboot (eboot.nb0) to nand flash\r\n");
printf
("[3] download linux kernel (zimage.bin) to nand flash\r\n");
if( menu_type == use_usb_down)
else
if( menu_type == use_tftp_down)
printf
("[6] download yaffs image (root.bin) to nand flash\r\n");
printf
("[7] download program (ucos-ii or tq2440_test) to sdram and run it\r\n");
printf
("[8] boot the system\r\n");
printf
("[9] format the nand flash\r\n");
printf
("[0] set the boot parameters\r\n");
printf
("[a] download user program (eg: ucos-ii or tq2440_test)\r\n");
printf
("[b] download logo picture (.bin) to nand flash \r\n");
printf
("[l] set lcd parameters \r\n");
if( menu_type == use_usb_down)if(
bbootfrmnorflash()
)printf
("[o] download u-boot to nor flash\r\n");
if( menu_type == use_tftp_down)
printf
("[p] test network (tq2440 ping pc's ip) \r\n");
printf
("[r] reboot u-boot\r\n");
printf
("[t] test linux image (zimage)\r\n");
if( menu_type == use_usb_down)
else
if( menu_type == use_tftp_down)
printf
("enter your selection: ");
}void
tftp_menu_shell
(void
)case
'2':
case
'3':
case
'4':
case
'5':
else
break;}
case
'6':
case
'7':
case
'8':
case
'9':
case
'a':
case
'a':
case
'b':
case
'b':
case
'o':
case
'o':
break;}
case
'p':
case
'p':
case
'r':
case
'r':
case
't':
case
't':
case
'q':
case
'q':
default:;
}}}u_boot_cmd
( menu,3,
0, do_menu,
"menu - display a menu, to select the items to do something\n"
," - display a menu, to select the items to do something");
int do_menu (cmd_tbl_t *cmdtp,
int flag,
int argc,
char
*ar**)
#endif
/* #ifdef config_cmd_menu */
2、新建乙個名為:cmd_menu.c的檔案,放到common目錄下,修改同目錄下的makefile檔案,加入編譯選項:
cobjs-$(config_cmd_menu)
+= cmd_menu.o
ifdef config_cmd_menu
run_command
("menu",0
);endif
if
(bootdelay >=
0&& s &&
!abortboot (bootdelay)
)#ifdef config_cmd_menu
run_command
("menu",0
);#endif
增加一行:
#define config_cmd_menu 1
然後重新編譯uboot,燒寫到開發板即可看到uboot 選單。
-the end-
怎樣在Apache上安裝MOD SSL
怎樣在apache上安裝mod ssl 然在安裝mod ssl時已經使用 make certificate 命令建立了伺服器 的證書簽名,但是有時你可能需要改變它。當然有很多自動的指令碼可以實現它,但是最可靠的方法是手工簽署 證書。首先我假定你已經安裝好了openssl和mod ssl,如果你的op...
怎樣在github上協同開發
描述 how to co work wither parter via github.github協同開發情景模擬 github不僅有很多開源的專案可以參考,同樣也是協同開發的最佳工具,接下來的就模擬一下協同開發的過程。專案發起者 koffuxu 專案貢獻者之一 xugangfeng 1,koffu...
在選單條上新增泡泡提示
該功能的實現 於codeproject上面的乙個例子 tooltips for menu item and popup menuitem 其實例子講的步驟很簡單,不過我不打算簡單的翻譯一下,林語堂先生不是說 只用一樣東西,不明白它的道理,實在不高明 實現該功能的核心在於作者自己建立的乙個menuto...