日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android P OTA差分升级时报错记录

發(fā)布時(shí)間:2025/3/15 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android P OTA差分升级时报错记录 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

在android P版本中制作出了差分升級(jí)包和差分降級(jí)包,在執(zhí)行差分升級(jí)時(shí)報(bào)錯(cuò),日志如下:

[ 7.974280] Verifying current system... [ 7.974298] failed to open emmc partition "/dev/block/platform/0.soc/fa507000.sdhci/by-name/boot": **No such file or directory** [ 8.356131] file "EMMC:/dev/block/platform/0.soc/fa507000.sdhci/by-name/boot:11044864:59b6b0595c184367de46d97fa567e620ad20b3c1:11044864:de5a6f5bbac9abd332a21416144f75537223b5e7" doesn't have any of expected sha1 sums; checking cache [ 8.356168] failed to stat "/cache/saved.file": No such file or directory [ 8.356209] failed to load cache file [ 8.356230] script aborted: E3005: "EMMC:/dev/block/platform/0.soc/fa507000.sdhci/by-name/boot:11044864:59b6b0595c184367de46d97fa567e620ad20b3c1:11044864:de5a6f5bbac9abd332a21416144f75537223b5e7" has unexpected contents. [ 8.356254] E:Error in /data/upgrade.zip (Status 7)

對(duì)應(yīng)的updater-script腳本內(nèi)容

ui_print("Verifying current system..."); apply_patch_check("EMMC:/dev/block/platform/0.soc/fa507000.sdhci/by-name/boot:11044864:59b6b0595c184367de46d97fa567e620ad20b3c1:11044864:de5a6f5bbac9abd332a21416144f75537223b5e7") || abort("E3005: \"EMMC:/dev/block/platform/0.soc/fa507000.sdhci/by-name/boot:11044864:59b6b0595c184367de46d97fa567e620ad20b3c1:11044864:de5a6f5bbac9abd332a21416144f75537223b5e7\" has unexpected contents.");

代碼打印異常的地方在android/boot/recovery/中的applypatch.cpp

static int LoadPartitionContents(const std::string& filename, FileContents* file) {std::vector<std::string> pieces = android::base::Split(filename, ":");if (pieces.size() < 4 || pieces.size() % 2 != 0 || pieces[0] != "EMMC") {printf("LoadPartitionContents called with bad filename \"%s\"\n", filename.c_str());return -1;}size_t pair_count = (pieces.size() - 2) / 2; // # of (size, sha1) pairs in filenamestd::vector<std::pair<size_t, std::string>> pairs;for (size_t i = 0; i < pair_count; ++i) {size_t size;if (!android::base::ParseUint(pieces[i * 2 + 2], &size) || size == 0) {printf("LoadPartitionContents called with bad size \"%s\"\n", pieces[i * 2 + 2].c_str());return -1;}pairs.push_back({ size, pieces[i * 2 + 3] });}// Sort the pairs array so that they are in order of increasing size.std::sort(pairs.begin(), pairs.end());const char* partition = pieces[1].c_str();unique_file dev(ota_fopen(partition, "rb")); ###fopen分區(qū)節(jié)點(diǎn)失敗if (!dev) {printf("failed to open emmc partition \"%s\": %s\n", partition, strerror(errno));return -1;}SHA_CTX sha_ctx;SHA1_Init(&sha_ctx);

查看了一下,正在運(yùn)行的設(shè)備中果然沒有by-name/boot分區(qū)節(jié)點(diǎn),只有by-name/boot_a,問題可能出在這里。
想著既然跟分區(qū)相關(guān),那應(yīng)該和fstab中的配置有關(guān)吧,修改一下fstab后,問題得到解決。

--------------------------- 分割線 --------------------------------
接著執(zhí)行差分升級(jí),又遇到另外一個(gè)system校驗(yàn)不通過問題

[ 20.585518] failed to read blocks for diff [ 20.585536] failed to execute command [bsdiff 0 308806 83fd740b9f442ead28c97c11170edee811ecfc8b 57b5c6785db138b2c149b9fa38b7d24018c4f4a2 2,209853,211277 1425 2,209853,211278] [ 20.974211] deleting stash 67d0d452af7be9d984c6c3cf2bd69fe4141e9b91 [ 20.974240] /dev/block/platform/0.soc/fa507000.sdhci/by-name/system image corrupted, attempting to recover... [ 20.974262] script aborted: unable to use metadata to correct errors [ 20.974282] E1004: system partition fails to recover [ 20.974300] E:Error in /data/0428_upgrade.zip (Status 7)

本地system分區(qū)基礎(chǔ)上沒修改什么代碼,所以基礎(chǔ)上排除代碼本身的問題。
看了下網(wǎng)上的資料,說是out中的system.img和obj/target中的system.img不同,手動(dòng)fastboot flash target zip包中的system.img和vendor.img后,再執(zhí)行差分升級(jí),就成功了。

且看到有人整理了在編譯時(shí)替換img的腳本,本地調(diào)試了一下,確實(shí)可以用,貼出來給需要的人。

#!/usr/bin/env python # # Copyright (C) 2014 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.""" Given a target-files zipfile that does contain images (ie, does have an IMAGES/ top-level subdirectory), replace the images to the output dir. Usage: replace_img_from_target_files target_files output """import sysif sys.hexversion < 0x02070000:print >> sys.stderr, "Python 2.7 or newer is required."sys.exit(1)import errno import os import re import shutil import subprocess import tempfile import zipfileimage_replace_list = ["boot.img","system.img","vendor.img"]if not hasattr(os, "SEEK_SET"):os.SEEK_SET = 0def main(argv):print "replace target images to output directory"if len(argv) != 2:print "must need two parameter, please check!"sys.exit(1)if not os.path.exists(argv[0]):print "Target file:%s is invalid" % argv[0]sys.exit(1)if not os.path.exists(argv[1]):print "Output dir:%s is invalid" % argv[1]sys.exit(1)zf = zipfile.ZipFile(argv[0], 'r')for img in zf.namelist():if img.find("IMAGES/") != -1:if img.find(".img") != -1:data = zf.read(img)name = img.replace("IMAGES/", '')if name in image_replace_list:print "Replace %s" % namename = '/'.join((argv[1], name))file = open(name, "w")file.write(data)file.close()if __name__ == '__main__':main(sys.argv[1:])

對(duì)應(yīng)的編譯打包日志

replace target images to output directory Replace boot.img Replace system.img Replace vendor.img [100% 1006/1006] Package OTA: out/target/product/xxx/xxx.zip

到這里后,整個(gè)差分升級(jí)就成功了,沒有再報(bào)錯(cuò)。

總結(jié)

以上是生活随笔為你收集整理的android P OTA差分升级时报错记录的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。