uboot指定按键进入uboot
已有 441 次阅读2017-9-14 17:59
|个人分类:uboot操作
[backcolor=#ffffff][color=#3f3f3f][font= ]uboot源码中提供的进入uboot命令行的方式为输入任意键。我想将任意键换成Esc键。本次促改使用的是uboot.2012[/font][/color][/backcolor]
[b]修改方法:[/b]
[b]1、修改common/main.c[/b]
[b] 或者 find .|xargs grep -ri ‘Hit any key’[/b]
[color=#3f3f3f][font=microsoft yahei][backcolor=#ffffff][b]2、代码修改[/b][/backcolor][/font][/color]
[color=#3f3f3f][font=microsoft yahei][backcolor=#ffffff][/backcolor][/font][/color][backcolor=rgba(128, 128, 128, 0.05)][color=#000088][font= ] static[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] [/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#000088][font= ]int[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] __abortboot([/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#000088][font= ]int[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] bootdelay) [/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]{[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#000088][font= ] int[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] [/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#660066][font= ]abort[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] = [/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#006666][font= ]0[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ];[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#000088][font= ]unsigned[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] [/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#000088][font= ]long[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] ts;[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#444444][font= ]#ifdef CONFIG_MENUPROMPT[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ][/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#660066][font= ]printf[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ](CONFIG_MENUPROMPT);[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#444444][font= ]#else[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ][/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#880000][font= ]// printf("Hit any key to stop autoboot: %2d ", bootdelay);[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ][/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#660066][font= ]printf[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]([/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#008800][font= ]"Press 'ctrl+q/Q' to stop autoboot: %2d "[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ], bootdelay);[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#444444][font= ]#endif[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ][/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#880000][font= ]/*[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#880000][font= ]* Check if key already pressed[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#880000][font= ]*/[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ][/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#000088][font= ]if[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] (tstc()) { [/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#880000][font= ]/* we got a key press *[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#880000][font= ]/[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]([/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#000088][font= ]void[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]) getc(); [/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#880000][font= ]/* consume input */[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ][/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#660066][font= ]puts[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]([/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#008800][font= ]"\b\b\b 0"[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]);[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#660066][font= ]abort[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] = [/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#006666][font= ]1[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]; [/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#880000][font= ]/* don't auto boot */[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]}[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#000088][font= ]while[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] ((bootdelay > [/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#006666][font= ]0[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]) && (![/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#660066][font= ]abort[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]))[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] {[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]--bootdelay;[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#880000][font= ]/* delay 1000 ms */[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]ts = get_timer([/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#006666][font= ]0[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]);[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#000088][font= ]do[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] {[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#000088][font= ]if[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] (tstc()) [/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]{ [/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#880000][font= ]/* we got a key press */[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ][/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#000088][font= ]if[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ](2[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#006666][font= ]7[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] == getc()){[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#660066][font= ]abort[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] = [/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#006666][font= ]1[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]; [/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#880000][font= ]/* don't auto boot */[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]bootdelay = [/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#006666][font= ]0[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]; [/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#880000][font= ]/* no more delay */[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ][/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#444444][font= ]# ifdef CONFIG_MENUKEY[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]menukey = getc();[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#444444][font= ]# else[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]([/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#000088][font= ]void[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]) getc(); [/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#880000][font= ]/* consume input */[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ][/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#444444][font= ]# endif[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ][/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#000088][font= ]break[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ];[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]}[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]}[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]udelay([/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#006666][font= ]10000[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ])[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ];[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]} [/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#000088][font= ]while[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] (![/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#660066][font= ]abort[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] && get_timer(ts) < [/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#006666][font= ]1000[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]);[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#660066][font= ]printf[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]([/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#008800][font= ]"\b\b\b%2d "[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ], bootdelay)[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ];[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]}[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]putc([/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#008800][font= ]'\n'[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]);[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#000088][font= ]return[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ] [/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#660066][font= ]abort[/font][/color][/backcolor][backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ];[/font][/color][/backcolor]
[backcolor=rgba(128, 128, 128, 0.05)][color=#333333][font= ]}[/font][/color][/backcolor]