From 10634958b17df6827cddeca83c2b7cebff5024a5 Mon Sep 17 00:00:00 2001 From: pankore <86098180+pankore@users.noreply.github.com> Date: Mon, 21 Feb 2022 14:10:13 +0800 Subject: [PATCH] Fix restyle --- src/platform/Ameba/AmebaOTAImageProcessor.cpp | 20 +++++++++++-------- src/platform/Ameba/AmebaOTAImageProcessor.h | 8 ++++---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/platform/Ameba/AmebaOTAImageProcessor.cpp b/src/platform/Ameba/AmebaOTAImageProcessor.cpp index 7151c109c11ef3..789c631d642889 100644 --- a/src/platform/Ameba/AmebaOTAImageProcessor.cpp +++ b/src/platform/Ameba/AmebaOTAImageProcessor.cpp @@ -181,8 +181,8 @@ void AmebaOTAImageProcessor::HandleProcessBlock(intptr_t context) return; } - ByteSpan block = imageProcessor->mBlock; - CHIP_ERROR error = imageProcessor->ProcessHeader(block); + ByteSpan block = imageProcessor->mBlock; + CHIP_ERROR error = imageProcessor->ProcessHeader(block); uint8_t HeaderOffset = 32 - imageProcessor->RemainHeader; #if defined(CONFIG_PLATFORM_8721D) @@ -193,9 +193,10 @@ void AmebaOTAImageProcessor::HandleProcessBlock(intptr_t context) memcpy(imageProcessor->AmebaHeader + HeaderOffset, block.data(), imageProcessor->RemainHeader); imageProcessor->pOtaTgtHdr = (update_ota_target_hdr *) ota_update_malloc(sizeof(update_ota_target_hdr)); - memcpy(imageProcessor->pOtaTgtHdr, imageProcessor->AmebaHeader, 8); // Store FwVer, HdrNum + memcpy(imageProcessor->pOtaTgtHdr, imageProcessor->AmebaHeader, 8); // Store FwVer, HdrNum memcpy(&(imageProcessor->pOtaTgtHdr->FileImgHdr[0].ImgId), imageProcessor->AmebaHeader + 8, 4); // Store OTA id - memcpy(&(imageProcessor->pOtaTgtHdr->FileImgHdr[0].ImgHdrLen), imageProcessor->AmebaHeader + 12, 16); // Store ImgHdrLen, Checksum, ImgLen, Offset + memcpy(&(imageProcessor->pOtaTgtHdr->FileImgHdr[0].ImgHdrLen), imageProcessor->AmebaHeader + 12, + 16); // Store ImgHdrLen, Checksum, ImgLen, Offset if (imageProcessor->ota_target_index == OTA_INDEX_1) imageProcessor->pOtaTgtHdr->FileImgHdr[0].FlashAddr = LS_IMG2_OTA1_ADDR; @@ -222,7 +223,8 @@ void AmebaOTAImageProcessor::HandleProcessBlock(intptr_t context) // Erase update partition ChipLogProgress(SoftwareUpdate, "Erasing target partition..."); - erase_ota_target_flash(imageProcessor->pOtaTgtHdr->FileImgHdr[0].FlashAddr, imageProcessor->pOtaTgtHdr->FileImgHdr[0].ImgLen); + erase_ota_target_flash(imageProcessor->pOtaTgtHdr->FileImgHdr[0].FlashAddr, + imageProcessor->pOtaTgtHdr->FileImgHdr[0].ImgLen); ChipLogProgress(SoftwareUpdate, "Erased partition OTA%d", imageProcessor->ota_target_index + 1); // Set RemainBytes to image length, excluding 8bytes of signature @@ -235,7 +237,7 @@ void AmebaOTAImageProcessor::HandleProcessBlock(intptr_t context) imageProcessor->signature = &(imageProcessor->pOtaTgtHdr->Sign[0][0]); // Store the signature temporarily - uint8_t * tempbufptr = const_cast (block.data() + imageProcessor->pOtaTgtHdr->FileImgHdr[0].Offset); + uint8_t * tempbufptr = const_cast(block.data() + imageProcessor->pOtaTgtHdr->FileImgHdr[0].Offset); memcpy(imageProcessor->signature, tempbufptr, 8); tempbufptr += 8; @@ -299,7 +301,8 @@ void AmebaOTAImageProcessor::HandleProcessBlock(intptr_t context) if (imageProcessor->block_len > 0) { device_mutex_lock(RT_DEV_LOCK_FLASH); - if (flash_burst_write(&flash_ota, imageProcessor->flash_addr + 32, imageProcessor->block_len, block.data() + 32) < 0) + if (flash_burst_write(&flash_ota, imageProcessor->flash_addr + 32, imageProcessor->block_len, block.data() + 32) < + 0) { device_mutex_unlock(RT_DEV_LOCK_FLASH); ChipLogError(SoftwareUpdate, "Write to flash failed"); @@ -334,7 +337,8 @@ void AmebaOTAImageProcessor::HandleProcessBlock(intptr_t context) if (imageProcessor->block_len > 0) { device_mutex_lock(RT_DEV_LOCK_FLASH); - if (flash_burst_write(&flash_ota, imageProcessor->flash_addr + 32 + imageProcessor->size, imageProcessor->block_len, block.data()) < 0) + if (flash_burst_write(&flash_ota, imageProcessor->flash_addr + 32 + imageProcessor->size, imageProcessor->block_len, + block.data()) < 0) { device_mutex_unlock(RT_DEV_LOCK_FLASH); ChipLogError(SoftwareUpdate, "Write to flash failed"); diff --git a/src/platform/Ameba/AmebaOTAImageProcessor.h b/src/platform/Ameba/AmebaOTAImageProcessor.h index 1869a3a6b684c9..2c78a6c1a4597c 100644 --- a/src/platform/Ameba/AmebaOTAImageProcessor.h +++ b/src/platform/Ameba/AmebaOTAImageProcessor.h @@ -21,9 +21,9 @@ #include #include #include +#include #include #include -#include #if defined(CONFIG_PLATFORM_8710C) #include "ota_8710c.h" @@ -79,9 +79,9 @@ class AmebaOTAImageProcessor : public OTAImageProcessorInterface #endif MutableByteSpan mBlock; OTADownloader * mDownloader; - uint32_t size = 0; - uint8_t RemainHeader = 32; - uint8_t AmebaHeader[32] = {0}; + uint32_t size = 0; + uint8_t RemainHeader = 32; + uint8_t AmebaHeader[32] = { 0 }; uint32_t flash_addr; OTAImageHeaderParser mHeaderParser; uint32_t mSoftwareVersion;