From 8c4b1b3afde0164514a3d105cdfed710c4de7745 Mon Sep 17 00:00:00 2001 From: Stephan Ruloff Date: Fri, 25 Mar 2022 21:15:09 +0100 Subject: [PATCH 1/3] 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", From 8337a926fb15a39da466703b3649132c6e56577b Mon Sep 17 00:00:00 2001 From: Stephan Ruloff Date: Mon, 28 Mar 2022 17:54:43 +0200 Subject: [PATCH 2/3] Removed TOP/BOTTOM settings from SST25VF040B --- src/spiFlashdb.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/spiFlashdb.hpp b/src/spiFlashdb.hpp index 478a364..e4b2c21 100644 --- a/src/spiFlashdb.hpp +++ b/src/spiFlashdb.hpp @@ -15,7 +15,7 @@ typedef enum { STATR = 0, /* status register */ FUNCR = 1, /* function register */ CONFR = 2, /* configuration register */ - NONER = 99, /* configuration register */ + NONER = 99, /* "none" register */ } tb_loc_t; typedef struct { @@ -132,9 +132,9 @@ static std::map flash_list = { .sector_erase = true, .subsector_erase = true, .has_extended = false, - .tb_otp = true, - .tb_offset = (1 << 1), - .tb_register = FUNCR, + .tb_otp = false, + .tb_offset = 0, + .tb_register = NONER, .bp_len = 4, .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}} }, From 648d8b9e3bbb21e9f150a77854c61f28b4773362 Mon Sep 17 00:00:00 2001 From: Stephan Ruloff Date: Tue, 29 Mar 2022 18:30:23 +0200 Subject: [PATCH 3/3] Removed `must_relock` part for the "SST25VF040B" as requested --- src/spiFlash.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/spiFlash.cpp b/src/spiFlash.cpp index f672273..7d14f6b 100644 --- a/src/spiFlash.cpp +++ b/src/spiFlash.cpp @@ -311,10 +311,6 @@ 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) {