1. 程式人生 > >Android OTA差分包升級失敗

Android OTA差分包升級失敗

升級失敗log如下:
I update_engine: [0530/162336:INFO:delta_performer.cc(359)] Applying 21701 operations to partition "system"
E update_engine: [0530/162336:ERROR:delta_performer.cc(1060)] The hash of the source data on disk for this operation doesn't match the expected value. This could mean that the delta update payload was targeted for another version, or that the source partition was modified after it was installed, for example, by mounting a filesystem.
E update_engine: [0530/162336
:ERROR:delta_performer.cc(1065)] Expected: sha256|hex = 839ACF5296B9AB820DC822B6C09EBA896905531EB2C581093A357411F1A444A0 E update_engine: [0530/162336:ERROR:delta_performer.cc(1068)] Calculated: sha256|hex = 18AF8D6842A71554893F1DE65B87F2A9639FB390357C71D5383C6ED7A6051AFA E update_engine: [0530/162336:ERROR:delta_performer.cc(1077
)] Operation source (offset:size) in blocks: 0:2,193:1,218:456,23471:8,32769:1,32961:1,37333:4,37351:3,37554:3,37570:2,37951:1,37959:1,38111:1,38125:1,38129:1,38139:1,38147:1,38149:1,38151:2,38155:1,38157:1,38360:5,38372:1,38377:5,38384:1,38437:1,38442:1,38447:1,38452:1,38457:1,38462:1,38467:1 E update_engine: [0530/162336
:ERROR:delta_performer.cc(1260)] ValidateSourceHash(source_hasher.raw_hash(), operation, error) failed. E update_engine: [0530/162336:ERROR:delta_performer.cc(283)] Failed to perform SOURCE_BSDIFF operation 8, which is the operation 0 in partition "system" E update_engine: [0530/162336:ERROR:download_action.cc(273)] Error 20 in DeltaPerformer's Write method when processing the received payload -- Terminating processing I update_engine: [0530/162336:INFO:delta_performer.cc(299)] Discarding 113721 unused downloaded bytes I update_engine: [0530/162336:INFO:multi_range_http_fetcher.cc(171)] Received transfer terminated. I update_engine: [0530/162336:INFO:multi_range_http_fetcher.cc(123)] TransferEnded w/ code 200 I update_engine: [0530/162336:INFO:multi_range_http_fetcher.cc(125)] Terminating. I update_engine: [0530/162336:INFO:action_processor.cc(116)] ActionProcessor: finished DownloadAction with code ErrorCode::kDownloadStateInitializationError I update_engine: [0530/162336:INFO:action_processor.cc(121)] ActionProcessor: Aborting processing due to failure. I update_engine: [0530/162336:INFO:update_attempter_android.cc(286)] Processing Done. I update_engine: [0530/162336:INFO:update_attempter_android.cc(306)] Resetting update progress.

The hash of the source data on disk for this operation doesn't match the expected value. This could mean that the delta update payload was targeted for another version, or that the source partition was modified after it was installed, for example, by mounting a filesystem.

這個操作的磁碟上的源資料的雜湊與預期值不匹配。這可能意味著增量更新有效負載是針對另一個版本的,或者是在安裝之後修改了源分割槽,例如,通過安裝檔案系統。

原因: make otapackage 會對system.img重新打包 導致重新打包的system.img和out目錄下的system.img Hash值不一致.也就是線刷版本的system.img和OTA包的system.img不一致;整包升級會替換system.img,而差分包升級則需要保證系統內部的system.img和整包中system.img一致才能升級成功(差分包中儲存了通過sha256 Hash演算法計算出整包system.img的值,通過這個值來確定兩個system.img一致).

驗證是否如上原因導致:
    將整包中system.img通過fastboot燒錄到當前系統,再驗證差分包升級
    adb reboot bootloader
    fastboot devices 
    //切換到system.img所在的目錄
    fastboot flash system system.img
    fastboot reboot

解決:保證差分包或整包的system.img和線刷(也就是out目錄下)的system.img保持一致.將make otapackage源包中的system.img替換out目錄下system.img

out/target/product/xxx_qn6005_64/obj/PACKAGING/systemimage_intermediates/system.img

out/target/product/xxx_qn6005_64/system.img

指令碼實現:

1.在/build/core/Makefile中新增:

$(hide) ./build/tools/releasetools/replace_img_from_target_files.py [email protected] $(PRODUCT_OUT)

2.在/build/tools/releasetools/中定義replace_img_from_target_files.py指令碼

#!/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 sys

if 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 zipfile

image_replace_list = ["boot.img","system.img"]

# missing in Python 2.4 and before
if not hasattr(os, "SEEK_SET"):
  os.SEEK_SET = 0

def main(argv):

  if len(argv) != 2:
    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" % name
          name = '/'.join((argv[1], name))
          file = open(name, "w")
          file.write(data)
          file.close()

if __name__ == '__main__':
  main(sys.argv[1:])

相關推薦

Android OTA分包升級失敗

升級失敗log如下:I update_engine: [0530/162336:INFO:delta_performer.cc(359)] Applying 21701 operations to partition "system" E update_engine: [05

高通Android平臺 OTA分包的生成方法

1、首先高通平臺的編譯流程與android原生態的編譯流程一樣,需要經歷以下幾步:    a. source build/envsetup.sh;    b. lunch 選擇專案    c. make -j24     編譯完之後    4.make otapackage

Android關於如何編譯 OTA 包以及如何製作 OTA 分包

如何編譯 OTA 包以及如何製作 OTA 差分包。 一、何為 OTA 升級? OTA(Over-the-Air Technology)空中下載技術,就是官方推送的升級包。 OTA升級是Android系統提供的標準軟體升級方式。主要通過網路下載OTA升級包、自動升級,但是也支援通過下載OTA升級包到SD卡手動

MTK平臺M非kk版本的ota分包的製作方法

        之前做過MTK平臺android4.4版本的差分升級相關工作,用google標準的ota製作指令碼,標準的指令即可生成,而同樣的MTK平臺(6797),用的android6.0的版本,用標準命令做出來差分升級包之後,總是升級失敗,提示“找不到sactter.t

Android 生成分包

原部落格地址:http://blog.csdn.net/u013705351/article/details/22722499 如果沒用增量升級,我們的升級流程是這樣的: 1、打包好apk上傳到伺服器,設定apk版本 2、客戶端發現伺服器端有高版本apk。 3、直接下載最

Android OTA升級原理和流程分析(二)---update.zip分包問題的解決

Android OTA升級原理和流程分析(二)—update.zip差分包問題的解決 在上一篇末尾提到的生成差分包時出現的問題,現已解決,由於最近比較忙,相隔的時間也比較長,所以單列一個篇幅提示大家。這個問題居然是原始碼中的問題,可能你已經制作成功了,不過我的

解決android系統進行OTA升級失敗時進入recovery介面不能自動重啟問題

1.前言          在使用android系統中我們肯定需要對其進行OTA升級,因專案原因,我們機器升級頻率比較高,android系統升級出現失敗的情況肯定是有的,原因用多方面,下面會說到。升級

Android Studio 的 gradle 外掛升級失敗

故事從這坨紅字開始 11:20 Gradle sync failed: Could not find com.android.tools.build:gradle:3.0.0. Searched in the following locations: f

Android OTA線上升級一(架構分析)

1、前言     OTA(Over-the-Air Technology)空中下載技術。是通過行動通訊(GSM或CDMA)的空中介面對SIM卡資料及應用進行遠端管理的技術。空中介面可以採用WAP、GPRS、CDMA1X及短訊息技術。OTA技術的應用,使得行動通訊不僅可以提供語音和資料服務,而且還能提供新業

Android OTA升級新舊版本任意升級

1. Android升級到較新的版本後,想用.zip升級包升回舊的版本時,在升級時會發錯。這是由於android系統時對升級檔案有版本檢測。 2. build/tools/releasetools/ota_from_target_files: def main(argv):

Android OTA升級原理和流程分析(一)

這篇及以後的篇幅將通過分析update.zip包在具體Android系統升級的過程,來理解Android系統中Recovery模式服務的工作原理。我們先從update.zip包的製作開始,然後是Android系統的啟動模式分析,Recovery工作原理,如何從

OTA--卡刷全包、升級包製作、分析(程式碼摘自Google)---2

1 .OTA升級流程框架 標準的OTA升級流程包括一下幾個步驟: 1).Android裝置首先會與OTA伺服器進行互動,如果有更新會推送給客戶。推送的資訊常常會包含OTA更新包的下載地址和一些版本資訊。 2).Update程式會將更新包下載到cac

Android OTA升級原理和流程分析(三)---Android系統的三種啟動模式

        以下的篇幅開始分析我們在上兩個篇幅中生成的update.zip包在具體更新中所經過的過程,並根據原始碼分析每一部分的工作原理。 一、       系統更新update.zip包的兩種方式 1.  通過上一個文件,我們知道了怎樣製作一個updat

Android系統Recovery工作原理2---update.zip分包問題的解決

一、生成OTA增量包失敗的解決方案            在上一篇中末尾使用build/tools/releasetools/ota_from_target_files指令碼製作update.zip

Android 分包製作流程分析

整包與差分包生成流程 差分包生成指令 make otapackage 將編譯生成的(xxx專案為例) out/target/product/xxxxxxx/full_xxx_hxxxx-target_files-1527715386.zip 此時生成的是base.

Android+OTA+升級之一:編譯升級包---make+otapackage

Android OTA 升級之一:編譯升級包 作者: 宋立新 前言        OTA 升級是 Android 系統提供的標準軟體升級方式。 它功能強大,提供了完全升級、增量升級模式,可以通過 SD卡升級,也可以通過網路升級。        這裡,我們先研究最簡單的情況

Android OTA升級包製作指令碼詳解(一,引數解析)

寫在前面:     “build/tools/releasetools/ota_from_target_files  -u lk.bin  -n target.zip update.zip”這是製作整包的命令,很顯然這裡支援lk升級。本系列博文主要對該命令的執行流程及原理進

Android OTA系統升級---原理一

            int signatureStart = (footer[0] & 0xff) | ((footer[1] & 0xff) << 8);             byte[] eocd = new byte[commentSize + 22];      

Android OTA升級(1):編譯升級全包

2013-3-23     Android原生系統中就已經支援OTA升級。所謂OTA升級就是通過空中介面獲取升級包,然後更新系統韌體。一般地,升級包無論如何獲取,哪怕是直接TCard本地升級,也被稱為OTA升級。     OTA升級首要是生成OTA升級包,升級包又分為升級全包

Android OTA升級的補救措施

問題場景如下:        產品已經上市,由於銷量太好了,某個硬體連二供都供應不上,沒辦法,只能用三供的硬體,但是之前量產版本的軟體(軟體A)不支援三供的硬體,所以為相容三供硬體,需要出軟體B,軟體A和軟體B版本號一樣(為了使所有使用者在表面上看拿到都是了一樣的產品)。但