From 6cfff048290771cb6c295fa52d6ced33b7222eb4 Mon Sep 17 00:00:00 2001 From: Marcin Kajor Date: Fri, 9 Sep 2022 10:45:07 +0200 Subject: [PATCH] [nrf fromtree] Fix BDX transfer resumption When OTA is interrupted in the middle of a BDX transfer and the transfer is then re-initiated after the 5-minute idle timeout, it may fail with the following error: dfu_target_stream: stream_flash_buffered_write error -12 Signed-off-by: Damian Krolik (cherry picked from commit 5e6279cc1debd0bb9da0a97dd82592f089a0c920) --- src/platform/nrfconnect/OTAImageProcessorImpl.cpp | 2 +- src/platform/nrfconnect/OTAImageProcessorImpl.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/nrfconnect/OTAImageProcessorImpl.cpp b/src/platform/nrfconnect/OTAImageProcessorImpl.cpp index cacc5b1fbf..8e3fa456ab 100644 --- a/src/platform/nrfconnect/OTAImageProcessorImpl.cpp +++ b/src/platform/nrfconnect/OTAImageProcessorImpl.cpp @@ -71,7 +71,7 @@ CHIP_ERROR OTAImageProcessorImpl::PrepareDownloadImpl() writer.image_id = image_id; writer.open = [](int id, size_t size) { return dfu_target_init(DFU_TARGET_IMAGE_TYPE_MCUBOOT, id, size, nullptr); }; writer.write = [](const uint8_t * chunk, size_t chunk_size) { return dfu_target_write(chunk, chunk_size); }; - writer.close = [](bool success) { return dfu_target_done(success); }; + writer.close = [](bool success) { return success ? dfu_target_done(success) : dfu_target_reset(); }; ReturnErrorOnFailure(System::MapErrorZephyr(dfu_multi_image_register_writer(&writer))); }; diff --git a/src/platform/nrfconnect/OTAImageProcessorImpl.h b/src/platform/nrfconnect/OTAImageProcessorImpl.h index 99b9c13e9d..09c94bb196 100644 --- a/src/platform/nrfconnect/OTAImageProcessorImpl.h +++ b/src/platform/nrfconnect/OTAImageProcessorImpl.h @@ -56,7 +56,7 @@ class OTAImageProcessorImpl : public OTAImageProcessorInterface bool IsFirstImageRun() override; CHIP_ERROR ConfirmCurrentImage() override; -private: +protected: CHIP_ERROR PrepareDownloadImpl(); CHIP_ERROR ProcessHeader(ByteSpan & aBlock);