From 5e6279cc1debd0bb9da0a97dd82592f089a0c920 Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Thu, 8 Sep 2022 13:00:58 -0700 Subject: [PATCH] [nrfconnect] Fix BDX transfer resumption (#22401) (#22412) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Damian Krolik Signed-off-by: Damian Krolik Co-authored-by: Damian Królik <66667989+Damian-Nordic@users.noreply.github.com> Co-authored-by: Andrei Litvin --- 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 bb8f846d8d900c..842ec4d7392fa5 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 99b9c13e9d7693..09c94bb1969456 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);