imx6 手动进入recovery
2018-01-25 14:33
309 查看
写在前面
平板项目,需要音量减+关机键进入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 = 1; printf("Recovery key pressed\n"); } return recovery_mode || button_pressed; }
图形模式和show_text模式
上面已经做好了开机时按住音量减进入recovery模式,但是发现进入recovery后,什么显示都没有。然后在代码中发现了,由show_text这个变量,如果像要有问题提示,就要把show_text变量设置为1,这个变量的修改是从/cache/recovery/command文件中解析出来的
然后我正常进入系统,执行下面的命令,成功进入带文字提示的recovery
echo "--show_text" > /cache/recovery/command
static const struct option OPTIONS[] = { { "send_intent", required_argument, NULL, 's' }, { "update_package", required_argument, NULL, 'u' }, { "wipe_data", no_argument, NULL, 'w' }, { "wipe_cache", no_argument, NULL, 'c' }, { "show_text", no_argument, NULL, 't' }, { "just_exit", no_argument, NULL, 'x' }, { "locale", required_argument, NULL, 'l' }, { "stages", required_argument, NULL, 'g' }, { "shutdown_after", no_argument, NULL, 'p' }, { "reason", required_argument, NULL, 'r' }, { NULL, 0, NULL, 0 }, };
//bootable/recovery/recovery.cpp main() { ...... int wipe_data = 0, wipe_cache = 0, show_text = 0; ...... while ((arg = getopt_long(argc, argv, "", OPTIONS, NULL)) != -1) { switch (arg) { case 's': send_intent = optarg; break; case 'u': update_package = optarg; break; case 'w': wipe_data = wipe_cache = 1; break; case 'c': wipe_cache = 1; break; case 't': show_text = 1; break; case 'x': just_exit = true; break; case 'l': locale = optarg; break; case 'g': { if (stage == NULL || *stage == '\0') { char buffer[20] = "1/"; strncat(buffer, optarg, sizeof(buffer)-3); stage = strdup(buffer); } break; } case 'p': shutdown_after = true; break; case 'r': reason = optarg; break; case '?': LOGE("Invalid command argument\n"); continue; } } }
根据项目需要,用户从过app升级/恢复出厂,要进入图形模式,手动按键进入recovery,要进入文字模式。
修改代码如下,解决问题
main() { ...... int wipe_data = 0, wipe_cache = 0, show_text = 1; ...... while ((arg = getopt_long(argc, argv, "", OPTIONS, NULL)) != -1) { switch (arg) { case 's': {send_intent = optarg; break;} case 'u': {show_text = 0; update_package = optarg; break;} case 'w': {show_text = 0; wipe_data = wipe_cache = 1; break;} case 'c': {show_text = 0; wipe_cache = 1; break;} case 't': {show_text = 1; break;} case 'x': {show_text = 0; just_exit = true; break;} case 'l': {locale = optarg; break;} case 'g': { if (stage == NULL || *stage == '\0') { char buffer[20] = "1/"; strncat(buffer, optarg, sizeof(buffer)-3); stage = strdup(buffer); } break; } case 'p': shutdown_after = true; break; case 'r': reason = optarg; break; case '?': LOGE("Invalid command argument\n"); continue; } } }
也就是,默认是显示文字,不显示图形的。 如果用户通过app进行恢复出厂/升级系统,那么设置show_text=0,进入图形模式。
相关文章推荐
- 各个品牌常见机型的手动进入Recovery的方法
- Android------recovery 模式启动进入流程
- Mac OS 10.12 - 在VMwear Workstation12.5.2中以两种方式进入恢复模式(Recovery)!!!
- android adb shell 进入recovery刷机
- nexus5进入recovery模式
- 手动进入自启动界面
- [IOS]如何让手上的 iPhone 或 iPad 进入 DFU 或 Recovery 模式
- android app让系统重启进入Recovery模式
- Recovery启动流程 --- 应用层到开机进入recovery详解
- Android OTA升级原理和流程分析(五)---update.zip包从上层进入Recovery服务
- Android上层进入recovery流程
- adb 进入 recovery adb 进入 bootloader
- Recovery启动流程(1)--- 应用层到开机进入recovery详解
- 安卓原生系统怎么进入官方Recovery,显示 无命令 的解决方法
- htc one s 进入bootloadert和recovery方式
- Ubuntu进入recovery单用户模式获得读写权限
- 三星I9308(移动版)正确Root的方法,进入正确的recovery的关键(网上很多方法是误导)
- 进入U8150 fastboot模式和recovery模式的方法
- i9250 进入recovery模式
- Android系统Recovery工作原理之使用update.zip升级过程分析(五)---update.zip包怎样从上层进入Recovery服务