void emmc_set_recovery_cmd(recovery_cmd_type_t cmd_type) { struct recovery_message msg; if (emmc_get_recovery_msg(&msg)) { dprintf(CRITICAL, "emmc_get_recvoery_msg error!\n"); return; } strcpy(msg.recovery, "recovery\n"); if (cmd_type == WIPE_DATA) { strcat(msg.recovery, "--wipe_data"); } else if (cmd_type == WIPE_CACHE) { strcat(msg.recovery, "--wipe_cache"); #ifdef LGE_WITH_RESIZE_DATA } else if (cmd_type == RESIZE_DATA) { strcat(msg.recovery, "--resize_data"); #endif } else { dprintf(INFO, "Unexpected recovery command !!!\n"); return; } strcat(msg.recovery, "\0\n"); if (emmc_set_recovery_msg(&msg)) { dprintf(CRITICAL, "emmc_set_recvoery_msg error!\n"); return; } boot_into_recovery = 1; dprintf(INFO, "emmc_set_recovery_cmd\n"); }
int emmc_recovery_init(void) { int update_status = 0; struct recovery_message msg; struct update_header header; unsigned valid_command = 0; // get recovery message if(emmc_get_recovery_msg(&msg)) return -1; if (msg.command[0] != 0 && msg.command[0] != 255) { dprintf(INFO,"Recovery command:%s\n",msg.command); } msg.command[sizeof(msg.command)-1] = '\0'; //Ensure termination if (!strcmp("boot-recovery",msg.command)) { valid_command = 1; strcpy(msg.command, ""); // to safe against multiple reboot into recovery strcpy(msg.status, "OKAY"); emmc_set_recovery_msg(&msg); // send recovery message boot_into_recovery = 1; // Boot in recovery mode return 0; } if (!strcmp("update-bootloader",msg.command)) { read_update_header_for_emmc_bootloader(&header); if(update_firmware_emmc_image(&header , "bootloader") == -1) return -1; } else return 0; // do nothing strcpy(msg.command, "boot-recovery"); // clearing recovery command emmc_set_recovery_msg(&msg); // send recovery message boot_into_recovery = 1; // Boot in recovery mode reboot_device(0); return 0; }
int _emmc_recovery_init(void) { int update_status = 0; struct recovery_message msg; // get recovery message if(emmc_get_recovery_msg(&msg)) return -1; if (msg.command[0] != 0 && msg.command[0] != 255) { dprintf(INFO,"Recovery command: %d %s\n", sizeof(msg.command), msg.command); } msg.command[sizeof(msg.command)-1] = '\0'; //Ensure termination if (!strcmp("update-radio",msg.command)) { /* We're now here due to radio update, so check for update status */ int ret = get_boot_info_apps(UPDATE_STATUS, (unsigned int *) &update_status); if(!ret && (update_status & 0x01)) { dprintf(INFO,"radio update success\n"); strlcpy(msg.status, "OKAY", sizeof(msg.status)); } else { dprintf(INFO,"radio update failed\n"); strlcpy(msg.status, "failed-update", sizeof(msg.status)); } boot_into_recovery = 1; // Boot in recovery mode } if (!strcmp("reset-device-info",msg.command)) { reset_device_info(); } if (!strcmp("root-detect",msg.command)) { set_device_root(); } else return 0; // do nothing strlcpy(msg.command, "", sizeof(msg.command)); // clearing recovery command emmc_set_recovery_msg(&msg); // send recovery message return 0; }
int _emmc_recovery_init(void) { int update_status = 0; struct recovery_message *msg; uint32_t block_size = 0; block_size = mmc_get_device_blocksize(); // get recovery message msg = (struct recovery_message *)memalign(CACHE_LINE, block_size); ASSERT(msg); if(emmc_get_recovery_msg(msg)) { if(msg) free(msg); return -1; } msg->command[sizeof(msg->command)-1] = '\0'; //Ensure termination if (msg->command[0] != 0 && msg->command[0] != 255) { dprintf(INFO,"Recovery command: %d %s\n", sizeof(msg->command), msg->command); } if (!strcmp(msg->command, "boot-recovery")) { boot_into_recovery = 1; } if (!strcmp("update-radio",msg->command)) { /* We're now here due to radio update, so check for update status */ int ret = get_boot_info_apps(UPDATE_STATUS, (unsigned int *) &update_status); if(!ret && (update_status & 0x01)) { dprintf(INFO,"radio update success\n"); strlcpy(msg->status, "OKAY", sizeof(msg->status)); } else { dprintf(INFO,"radio update failed\n"); strlcpy(msg->status, "failed-update", sizeof(msg->status)); } boot_into_recovery = 1; // Boot in recovery mode } if (!strcmp("reset-device-info",msg->command)) { reset_device_info(); } if (!strcmp("root-detect",msg->command)) { set_device_root(); } else goto out;// do nothing strlcpy(msg->command, "", sizeof(msg->command)); // clearing recovery command emmc_set_recovery_msg(msg); // send recovery message out: if(msg) free(msg); return 0; }