android P OTA差分升级时报错记录
生活随笔
收集整理的這篇文章主要介紹了
android P OTA差分升级时报错记录
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在android P版本中制作出了差分升級包和差分降級包,在執行差分升級時報錯,日志如下:
[ 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)對應的updater-script腳本內容
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分區節點失敗if (!dev) {printf("failed to open emmc partition \"%s\": %s\n", partition, strerror(errno));return -1;}SHA_CTX sha_ctx;SHA1_Init(&sha_ctx);查看了一下,正在運行的設備中果然沒有by-name/boot分區節點,只有by-name/boot_a,問題可能出在這里。
想著既然跟分區相關,那應該和fstab中的配置有關吧,修改一下fstab后,問題得到解決。
--------------------------- 分割線 --------------------------------
接著執行差分升級,又遇到另外一個system校驗不通過問題
本地system分區基礎上沒修改什么代碼,所以基礎上排除代碼本身的問題。
看了下網上的資料,說是out中的system.img和obj/target中的system.img不同,手動fastboot flash target zip包中的system.img和vendor.img后,再執行差分升級,就成功了。
且看到有人整理了在編譯時替換img的腳本,本地調試了一下,確實可以用,貼出來給需要的人。
#!/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:])對應的編譯打包日志
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到這里后,整個差分升級就成功了,沒有再報錯。
總結
以上是生活随笔為你收集整理的android P OTA差分升级时报错记录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 关于ASP.NET MVC的业务逻辑验证
- 下一篇: 考研英语作文:一封欢迎词