From 8c4b1b3afde0164514a3d105cdfed710c4de7745 Mon Sep 17 00:00:00 2001 From: Stephan Ruloff Date: Fri, 25 Mar 2022 21:15:09 +0100 Subject: [PATCH] Support for the Microchip SST25VF040B flash. Programming is slow, only one byte at a time :-( --- src/spiFlash.cpp | 7 +++++++ src/spiFlashdb.hpp | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/spiFlash.cpp b/src/spiFlash.cpp index 93a6893..f672273 100644 --- a/src/spiFlash.cpp +++ b/src/spiFlash.cpp @@ -311,6 +311,10 @@ int SPIFlash::erase_and_prog(int base_addr, uint8_t *data, int len) if ((status & 0x1c) != 0) must_relock = true; } + if ((_jedec_id >> 8) == 0xbf258d) { + if ((status & 0x1c) != 0) + must_relock = true; + } /* if it's needs to unlock */ if (must_relock) { @@ -334,6 +338,9 @@ int SPIFlash::erase_and_prog(int base_addr, uint8_t *data, int len) int size = 0; for (int addr = 0; addr < len; addr += size, ptr+=size) { size = (addr + 256 > len)?(len-addr) : 256; + if ((_jedec_id >> 8) == 0xbf258d) { + size = 1; + } if (write_page(base_addr + addr, ptr, size) == -1) return -1; progress.display(addr); diff --git a/src/spiFlashdb.hpp b/src/spiFlashdb.hpp index 077a6d9..478a364 100644 --- a/src/spiFlashdb.hpp +++ b/src/spiFlashdb.hpp @@ -125,6 +125,19 @@ static std::map flash_list = { .bp_len = 4, .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 6)}} }, + {0xbf258d, { + .manufacturer = "microchip", + .model = "SST25VF040B", + .nr_sector = 8, + .sector_erase = true, + .subsector_erase = true, + .has_extended = false, + .tb_otp = true, + .tb_offset = (1 << 1), + .tb_register = FUNCR, + .bp_len = 4, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}} + }, {0xBF2642, { .manufacturer = "microchip", .model = "SST26VF032B",