默认rk3368不支持外置SD卡升级,升级时候会报错。Android系统 为6.0
首先在bootable/recovery/roots.h下添加
void ensure_usb_mounted();
void ensure_sd_mounted();
文件 recovery.cpp
void ensure_sd_mounted()
{
int i;
for(i = 0; i < 10; i++) {
if(0 == ensure_path_mounted(EX_SDCARD_ROOT)){
bSDMounted = true;
break;
}else {
printf("delay 2sec\n");
sleep(2);
}
}
}
void ensure_usb_mounted()
{
int i;
for(i = 0; i < 10; i++) {
if(0 == mount_usb_device()){
bUsbMounted = true;
break;
}else {
printf("delay 2sec\n");
sleep(2);
}
}
}
在install.cpp中添加
static int
really_install_package(const char *path, bool* wipe_cache, bool needs_mount)
{
bNeedClearMisc = false;
ui->SetBackground(RecoveryUI::INSTALLING_UPDATE);
ui->Print("Finding update package...\n");
// Give verification half the progress bar...
ui->SetProgressType(RecoveryUI::DETERMINATE);
ui->ShowProgress(VERIFICATION_PROGRESS_FRACTION, VERIFICATION_PROGRESS_TIME);
LOGI("Update location: %s\n", path);
// Map the update package into memory.
ui->Print("Opening update package...\n");
char really_path[100];
if (path && needs_mount) {
if (path[0] == '@') {
ensure_path_mounted(path+1);
} else {
ensure_path_mounted(path);
}
}
MemMapping map;
if(strncmp(path, "/storage/", 9) == 0){
//external_sd
LOGI("try to read update.zip from /mnt/external_sd");
strcpy(really_path, "/mnt/external_sd/");
ensure_sd_mounted();
strcat(really_path, "update.zip");
if(sysMapFile(really_path, &map) != 0){
//usb_storage
LOGI("try to read update.zip from /mnt/usb_storage");
strcpy(really_path, "/mnt/usb_storage/");
ensure_usb_mounted();
strcat(really_path, "update.zip");
if(sysMapFile(really_path, &map) != 0){
LOGE("failed to map file\n");
return INSTALL_CORRUPT;
}
}
}else if (sysMapFile(path, &map) != 0) {
LOGE("failed to map file\n");
return INSTALL_CORRUPT;
}else{
strcpy(really_path, path);
}
LOGI("update.zip path is %s\n", really_path);
int numKeys;
Certificate* loadedKeys = load_keys(PUBLIC_KEYS_FILE, &numKeys);
if (loadedKeys == NULL) {
LOGE("Failed to load keys\n");
return INSTALL_CORRUPT;
}
LOGI("%d key(s) loaded from %s\n", numKeys, PUBLIC_KEYS_FILE);
ui->Print("Verifying update package...\n");
int err;
err = verify_file(map.addr, map.length, loadedKeys, numKeys);
free(loadedKeys);
LOGI("verify_file returned %d\n", err);
if (err != VERIFY_SUCCESS) {
LOGE("signature verification failed\n");
sysReleaseMap(&map);
return INSTALL_CORRUPT;
}
/* Try to open the package.
*/
ZipArchive zip;
err = mzOpenZipArchive(map.addr, map.length, &zip);
if (err != 0) {
LOGE("Can't open %s\n(%s)\n", really_path, err != -1 ? strerror(err) : "bad");
sysReleaseMap(&map);
return INSTALL_CORRUPT;
}
/* Verify and install the contents of the package.
*/
ui->Print("Installing update...\n");
ui->SetEnableReboot(false);
int result = try_update_binary(really_path, &zip, wipe_cache);
ui->SetEnableReboot(true);
ui->Print("\n");
sysReleaseMap(&map);
return result;
}