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; }