From 7185bbd127ec5bd1fbeee5a90f7ecfdff03531ec Mon Sep 17 00:00:00 2001 From: Petr Nechaev Date: Sun, 16 Oct 2022 15:32:16 +0300 Subject: [PATCH 1/2] Support for microchip SST26VF064B flash --- src/spiFlashdb.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/spiFlashdb.hpp b/src/spiFlashdb.hpp index 23b32aa..b85319e 100644 --- a/src/spiFlashdb.hpp +++ b/src/spiFlashdb.hpp @@ -177,6 +177,19 @@ static std::map flash_list = { .bp_len = 0, .bp_offset = {0, 0, 0, 0}} }, + {0xBF2643, { + .manufacturer = "microchip", + .model = "SST26VF064B", + .nr_sector = 128, + .sector_erase = true, + .subsector_erase = true, + .has_extended = false, + .tb_otp = false, + .tb_offset = 0, + .tb_register = NONER, + .bp_len = 0, + .bp_offset = {0, 0, 0, 0}} + }, {0x9d6016, { .manufacturer = "ISSI", .model = "IS25LP032", From 1bbe448f3a8b22fb7aadb7300100101a1ccc0eae Mon Sep 17 00:00:00 2001 From: Petr Nechaev Date: Sun, 16 Oct 2022 15:44:33 +0300 Subject: [PATCH 2/2] Limit automatic read burst length to 64K Reading of very large binaries (e.g. 32 MB) can cause stack overflow. Put a reasonable limit on read burst length. --- src/spiFlash.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/spiFlash.cpp b/src/spiFlash.cpp index ed5832b..e1e75b6 100644 --- a/src/spiFlash.cpp +++ b/src/spiFlash.cpp @@ -382,8 +382,11 @@ int SPIFlash::erase_and_prog(int base_addr, uint8_t *data, int len) bool SPIFlash::verify(const int &base_addr, const uint8_t *data, const int &len, int rd_burst) { - if (rd_burst == 0) + if (rd_burst == 0) { rd_burst = len; + if (rd_burst > 65536) + rd_burst = 65536; + } printInfo("Verifying write (May take time)");