From e302bb6edcc4789143db354cd04bfbd30d86c6df Mon Sep 17 00:00:00 2001 From: Gwenhael Goavec-Merou Date: Mon, 15 Dec 2025 17:14:04 +0100 Subject: [PATCH] spiFlash: added FlashDataSection to handle bitstream per sections when gap or 0xff area are present --- src/spiFlash.hpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/spiFlash.hpp b/src/spiFlash.hpp index 7270933..c1d5bf6 100644 --- a/src/spiFlash.hpp +++ b/src/spiFlash.hpp @@ -12,6 +12,32 @@ #include "spiInterface.hpp" #include "spiFlashdb.hpp" +/* Flash memory section record + * one instance per section when the bitstream contains gap + */ +class FlashDataSection { + public: + explicit FlashDataSection(uint32_t start_addr):_start_addr(start_addr) {} + + /* append data set to existing */ + void append(const uint8_t *data, size_t length) { + if (data && length > 0) + _record.insert(_record.end(), data, data + length); + } + /* Return section start addr */ + uint32_t getStartAddr() const noexcept { return _start_addr; } + /* Return last data addr */ + uint32_t getCurrentAddr() const noexcept { return _start_addr + static_cast(_record.size()); } + /* Return section length */ + size_t getLength() const noexcept { return _record.size(); } + /* Return section data set */ + const std::vector &getRecord() const noexcept { return _record; } + + private: + uint32_t _start_addr; // Section Start Address + std::vector _record; // Data set +}; + class SPIFlash { public: SPIFlash(SPIInterface *spi, bool unprotect, int8_t verbose);