rk3368支持外置SD或TF的OTA卡升级

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

九霄的爸爸

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值