韌館-LearnHouse

[Android]OTA差分包(Incremental OTA)升級失敗訊息與解法

我們都知道要產生Incremental OTA的方法可以透過下列指令:

$./build/tools/releasetools/ota_from_target_files -v --block -p out/host/linux-x86 -k YOUR_KEY -i target_files-old.zip target_files-new.zip update.zip

其中
-k YOUR_KEY指的是你的KEY路徑,通常是vendor/company/security/releasekey
-i target_files-old.zip是上一次build的target file,產生在./out/target/product/device/obj/PACKAGING/target_files_intermediates下;target_files-new.zip則是這次build的,路徑也是在一樣的地方;update.zip則是要產生的差分包。
紅色的部分是依你的project不同則有不同的名稱。

當很理所當然地產生出來後,卻發現升級都會出現ErrorCode::kDownloadStateInitializationError,整體的錯誤內容如下:

08-04 17:45:16.799   ERROR:fec_file_descriptor.cc(30)] No ECC data in the passed file
08-04 17:45:16.800   ERROR:delta_performer.cc(430)] Unable to open ECC source partition boot on slot A, file /dev/block/by-name/boot_a: Invalid argument (22)
08-04 17:45:16.800   ERROR:delta_performer.cc(1135)] 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.
08-04 17:45:16.800   ERROR:delta_performer.cc(1140)] Expected:   sha256|hex = 6534AC84D075B5CDA8CDB45CB3B169C86CCB376853EC4E28AA1242B89A440B6A
08-04 17:45:16.800   ERROR:delta_performer.cc(1143)] Calculated: sha256|hex = 464588BD71E535D8E424CF692EF13A574097D673ACB896538FAB5B42E6CD0C5F
08-04 17:45:16.800   ERROR:delta_performer.cc(1154)] Operation source (offset:size) in blocks: 0:2194
08-04 17:45:16.800   ERROR:delta_performer.cc(1435)] source_fd != nullptr failed.
08-04 17:45:16.800   ERROR:delta_performer.cc(296)] Failed to perform BROTLI_BSDIFF operation 0, which is the operation 0 in partition "boot"
08-04 17:45:16.801   ERROR:download_action.cc(336)] Error ErrorCode::kDownloadStateInitializationError (20) in DeltaPerformer's Write method when processing the received payload -- Terminating processing
08-04 17:45:16.802   INFO:delta_performer.cc(313)] Discarding 122 unused downloaded bytes
08-04 17:45:16.802   INFO:multi_range_http_fetcher.cc(177)] Received transfer terminated.
08-04 17:45:16.803   INFO:multi_range_http_fetcher.cc(129)] TransferEnded w/ code 200
08-04 17:45:16.803   INFO:multi_range_http_fetcher.cc(131)] Terminating.
08-04 17:45:16.806   INFO:action_processor.cc(116)] ActionProcessor: finished DownloadAction with code ErrorCode::kDownloadStateInitializationError
08-04 17:45:16.806   INFO:action_processor.cc(121)] ActionProcessor: Aborting processing due to failure.
08-04 17:45:16.806   INFO:update_attempter_android.cc(469)] Processing Done.

這是因為make otapackage時會將用給tool燒入的system.img重新打包一次,導致和使用OTA的system.img的Hash值不一致。整包升級(Full OTA)會替換system.img,而差分包升級(Increment OTA)則需要保證系統內部的system.img和整包中system.img一致才能升級成功。
因此就要先用Full OTA刷過一次,才可以以這版的target-file為base製作新的Increment OTA

而當你出現的是ErrorCode::kDownloadMetadataSignatureMismatch就代表你用錯加密的key了,只要修正-k參數的KEY路徑指向對的就能解決,整體的錯誤內容如下:

08-02 13:52:23.192   ERROR:payload_verifier.cc(84)] None of the 1 signatures is correct. Expected hash before padding:
08-02 13:52:23.192   INFO:utils.cc(439)] Logging array of length: 32
08-02 13:52:23.192   INFO:utils.cc(456)] 0x00000000 : 93 ce 57 06 9e 7e 2e 86 70 c6 52 40 55 e0 ef 2a 
08-02 13:52:23.192   INFO:utils.cc(456)] 0x00000010 : b4 c4 c9 7c cc 71 65 24 14 8f 8c 57 23 db f5 ae 
08-02 13:52:23.192   ERROR:payload_verifier.cc(87)] But found decrypted hashes:
08-02 13:52:23.192   INFO:utils.cc(439)] Logging array of length: 256
08-02 13:52:23.192   INFO:utils.cc(456)] 0x00000000 : cb 99 ca ee 49 83 fe 71 95 3a 71 44 68 86 4e 77 
08-02 13:52:23.192   INFO:utils.cc(456)] 0x00000010 : 82 3c fa b6 40 21 34 c3 48 06 20 c6 b1 0e 67 1d 
08-02 13:52:23.192   INFO:utils.cc(456)] 0x00000020 : b4 1f 8b 60 bd 24 9d 9c 97 94 6d 85 e3 31 5a 36 
08-02 13:52:23.192   INFO:utils.cc(456)] 0x00000030 : 4c 02 14 47 ce b3 8e 89 3d d0 15 89 21 86 21 74 
08-02 13:52:23.192   INFO:utils.cc(456)] 0x00000040 : ef 73 75 b3 aa 1c b2 a0 6a 9b b6 6f 13 be fe 6b 
08-02 13:52:23.192   INFO:utils.cc(456)] 0x00000050 : 67 7a 7b c6 ab 18 e6 8e 3d e1 e6 6e 5d ed 41 5a 
08-02 13:52:23.192   INFO:utils.cc(456)] 0x00000060 : 5e 2f f8 91 46 f8 b9 ca 9d e0 d4 b9 af a8 e2 ab 
08-02 13:52:23.192   INFO:utils.cc(456)] 0x00000070 : f0 ba f1 0a 75 75 8f 77 9d 29 4d 27 fc be 98 30 
08-02 13:52:23.192   INFO:utils.cc(456)] 0x00000080 : 70 f2 29 35 ec c6 44 a1 85 81 b9 b2 fb fe 76 fa 
08-02 13:52:23.192   INFO:utils.cc(456)] 0x00000090 : 64 b3 dc 1f e0 15 4e 1d ae 6e 52 43 a3 f6 e6 8c 
08-02 13:52:23.192   INFO:utils.cc(456)] 0x000000a0 : b9 8c 78 1c c1 df 48 20 01 9e 82 3d 6a e1 30 79 
08-02 13:52:23.192   INFO:utils.cc(456)] 0x000000b0 : 4b 42 dc f4 b2 38 1d b9 6a ad ff 83 0c 52 89 80 
08-02 13:52:23.192   INFO:utils.cc(456)] 0x000000c0 : fd db 24 74 74 b8 92 f8 7d 92 8b 48 be d2 cb fd 
08-02 13:52:23.192   INFO:utils.cc(456)] 0x000000d0 : bc f7 2f a5 71 cb 6b f3 b9 24 cc a3 c7 32 9f 2b 
08-02 13:52:23.192   INFO:utils.cc(456)] 0x000000e0 : de 41 3d 1d d7 5a d2 d2 3c 9f 49 bf 55 68 72 bb 
08-02 13:52:23.192   INFO:utils.cc(456)] 0x000000f0 : 78 81 07 de 7b ed 2d af fc 74 39 45 89 94 82 db 
08-02 13:52:23.192   ERROR:payload_metadata.cc(230)] Manifest hash verification failed.
08-02 13:52:23.192   ERROR:delta_performer.cc(544)] Mandatory metadata signature validation failed
08-02 13:52:23.193   ERROR:download_action.cc(336)] Error ErrorCode::kDownloadMetadataSignatureMismatch (26) in DeltaPerformer's Write method when processing the received payload -- Terminating processing
08-02 13:52:23.193   INFO:delta_performer.cc(313)] Discarding 96843 unused downloaded bytes
08-02 13:52:23.193   INFO:multi_range_http_fetcher.cc(177)] Received transfer terminated.
08-02 13:52:23.193   INFO:multi_range_http_fetcher.cc(129)] TransferEnded w/ code 200
08-02 13:52:23.193   INFO:multi_range_http_fetcher.cc(131)] Terminating.
08-02 13:52:23.193   INFO:action_processor.cc(116)] ActionProcessor: finished DownloadAction with code ErrorCode::kDownloadMetadataSignatureMismatch
08-02 13:52:23.193   INFO:action_processor.cc(121)] ActionProcessor: Aborting processing due to failure.
08-02 13:52:23.193   INFO:update_attempter_android.cc(469)] Processing Done.
posted by admin in 程式&軟體 and have No Comments

Place your comment

Please fill your data and comment below.
名稱:
信箱:
網站:
您的評論: