写在前面
平板项目,需要音量减+关机键进入recovery模式。中间遇到了一些问题,记录一下。
配置音量键
uboot启动以后会检测音量上下键是否被按,然后进入不同的分支
board/freescale/common/recovery.c
/* export to lib_arm/board.c */
void check_recovery_mode(void)
{
if (check_key_pressing()) {
puts("Fastboot: Recovery key pressing got!\n");
setup_recovery_env();
} else if (check_recovery_cmd_file()) {
puts("Fastboot: Recovery command file found!\n");
setup_recovery_env();
} else {
puts("Fastboot: Normal\n");
}
}
#define GPIO_VOL_DN_KEY IMX_GPIO_NR(2, 1)
iomux_v3_cfg_t const recovery_key_pads[] = {
(MX6_PAD_NANDF_D1__GPIO2_IO01 | MUX_PAD_CTRL(NO_PAD_CTRL)),
};
int check_recovery_cmd_file(void)
{
int button_pressed = 0;
int recovery_mode = 0;
recovery_mode = recovery_check_and_clean_flag();
/* Check Recovery Combo Button press or not. */
imx_iomux_v3_setup_multiple_pads(recovery_key_pads,
ARRAY_SIZE(recovery_key_pads));
gpio_direction_input(GPIO_VOL_DN_KEY); //由此可见,uboot阶段,会读取一个gpio口,把这个gpio设置为自己主板对应的就能进入recovery了
if (gpio_get_value(GPIO_VOL_DN_KEY) == 0) { /* VOL_DN key is low assert */
button_pressed =