From c4d26da89fcdf5299b82360bb5972ab812bec0bc Mon Sep 17 00:00:00 2001 From: Gwenhael Goavec-Merou Date: Mon, 23 Feb 2026 08:33:47 +0100 Subject: [PATCH] spiFlash: added Macronix MX25L6405 --- src/spiFlash.cpp | 8 +++++--- src/spiFlashdb.hpp | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/spiFlash.cpp b/src/spiFlash.cpp index 628f30b..be991d9 100644 --- a/src/spiFlash.cpp +++ b/src/spiFlash.cpp @@ -421,19 +421,21 @@ bool SPIFlash::prepare_flash(const int base_addr, const int len) _must_relock = true; } } + const uint32_t jedec = _jedec_id >> 8; /* ISSI IS25LP032 seems have a bug: * block protection is always in top mode regardless of * the TB bit: if write is not at offset 0 -> force unlock */ - if ((_jedec_id >> 8) == 0x9d6016 && tb == 1 && base_addr != 0) { + if (jedec == 0x9d6016 && tb == 1 && base_addr != 0) { _unprotect = true; _must_relock = true; } - /* ST M25P16 has not TB bit: + /* ST M25P16 / MX25L6045 have not TB bit: * block protection is always in top mode: * if write is not at offset 0 -> force unlock */ - if ((_jedec_id >> 8) == 0x202015 && tb == 1 && base_addr != 0) { + if (((jedec == 0x202015) || (jedec == 0xC22017)) + && tb == 1 && base_addr != 0) { _unprotect = true; _must_relock = true; } diff --git a/src/spiFlashdb.hpp b/src/spiFlashdb.hpp index 2e21fc2..3a7f8fd 100644 --- a/src/spiFlashdb.hpp +++ b/src/spiFlashdb.hpp @@ -500,6 +500,23 @@ static std::map flash_list = { .quad_mask = (1 << 6), .global_lock = false, }}, + {0xc22017, { + /* https://www.macronix.com/Lists/Datasheet/Attachments/8554/MX25L1605D,%203V,%2016Mb,%20v1.5.pdf */ + .manufacturer = "Macronix", + .model = "MX25L6405", + .nr_sector = 128, + .sector_erase = true, + .subsector_erase = true, + .has_extended = false, + .tb_otp = true, + .tb_offset = 0, + .tb_register = NONER, + .bp_len = 5, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}, + .quad_register = NONER, + .quad_mask = 0, + .global_lock = false, + }}, {0xc22018, { /* https://www.macronix.com/Lists/Datasheet/Attachments/8934/MX25L12833F,%203V,%20128Mb,%20v1.0.pdf */ .manufacturer = "Macronix",