一、OTA升级脚本ota_info.sh 脚本内容示范:
update_engine_client --update --follow --payload=file:///data/ota_package/update.zip --offset=3283 --size=1477355701 --headers="FILE_HASH=rW+2uC1eDSj07+1xSwgsyopHUag4wM1g8hNmWX1NWGw=
FILE_SIZE=1477355701
METADATA_HASH=CFaa1l58FuWZzOEdt6I2MF0KMOCKqHOyLfXvpnuvV3U=
METADATA_SIZE=112597
备注:data/ota_package/update.zip 为升级包的路径
二、错误码汇总
ErrorCode::kSuccess (0) 升级成功
ErrorCode::kSuccess (1) 升级失败
ErrorCode::kFilesystemCopierError (4) 未知,暂时未使用的错误码
ErrorCode::kPostinstallRunnerError (5) 升级安装结束,设置启动分区失败
ErrorCode::kPayloadMismatchedType (6) 升级包的升级类型不匹配或升级包minor version不兼容
ErrorCode::kInstallDeviceOpenError (7) 无法启动升级。可能是原因:分区错误,设备支持升级的分区和升级包内的不匹配;设备处于disable-verity状态;
ErrorCode::kKernelDeviceOpenError (8) 未知,暂时未使用的错误码
ErrorCode::kDownloadTransferError (9) w,找不到升级包
ErrorCode::kPayloadHashMismatchError (10) FILE_HASH值不匹配
ErrorCode::kPayloadSizeMismatchError (11) 数据size不匹配
ErrorCode::kDownloadPayloadVerificationError (12) 签名验证失败
ErrorCode::kDownloadStateInitializationError (20) 升级包写入时失败 一般都是发生在差分包升级时,检测boot、system、vendor的hash值不匹配。
ErrorCode::kDownloadInvalidMetadataMagicString (21) 未找到正确bin文件,一般是offset不对导致
ErrorCode::kDownloadInvalidMetadataSize (32) METADATA_SIZE值不匹配
ErrorCode::kPayloadTimestampError (51) 升级包的date比机器当前版本早
具体错误见:system\update_engine\common\error_code.h
具体原因在system查找返回的错误码即可:
grep -rn "kDownloadOperationHashMismatch"
update_engine/common/error_code_utils.cc:94: case ErrorCode::kDownloadOperationHashMismatch: update_engine/common/error_code_utils.cc:95: return "ErrorCode::kDownloadOperationHashMismatch"; update_engine/common/error_code.h:55: kDownloadOperationHashMismatch = 29, update_engine/payload_consumer/delta_performer.cc:1249: return ErrorCode::kDownloadOperationHashMismatch; update_engine/payload_consumer/delta_performer_integration_test.cc:847: expected_error = ErrorCode::kDownloadOperationHashMismatch; update_engine/metrics_utils.cc:63: case ErrorCode::kDownloadOperationHashMismatch: update_engine/metrics_utils.cc:215: case ErrorCode::kDownloadOperationHashMismatch: update_engine/cros/payload_state.cc:304: case ErrorCode::kDownloadOperationHashMismatch: update_engine/update_manager/chromeos_policy.cc:83: case ErrorCode::kDownloadOperationHashMismatch:
例如:在system\update_engine\payload_consumer\delta_performer.cc
if (calculated_op_hash != expected_op_hash) { LOG(ERROR) << "Hash verification failed for operation " << next_operation_num_ << ". Expected hash = "; utils::HexDumpVector(expected_op_hash); LOG(ERROR) << "Calculated hash over " << operation.data_length() << " bytes at offset: " << operation.data_offset() << " = "; utils::HexDumpVector(calculated_op_hash); return ErrorCode::kDownloadOperationHashMismatch; }