From 972ded1298fcb6c7896a49541061a3bd57b86595 Mon Sep 17 00:00:00 2001 From: Patrick Urban Date: Fri, 15 Mar 2024 00:44:17 +0100 Subject: [PATCH] spiFlashdb: add MX25R6435F and fix SPIFlash::bp_to_len --- src/spiFlash.cpp | 3 +++ src/spiFlashdb.hpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/spiFlash.cpp b/src/spiFlash.cpp index 2ebed49be4..d7bbbba0b1 100644 --- a/src/spiFlash.cpp +++ b/src/spiFlash.cpp @@ -895,6 +895,9 @@ std::map SPIFlash::bp_to_len(uint8_t bp, uint8_t tb) for (int i = 0; i < 4; i++) if ((bp & _flash_model->bp_offset[i])) tmp |= (1 << i); + /* 0 -> no block protected */ + if (tmp == 0) + return protect_area; /* bp code is 2^(bp-1) blocks */ uint16_t nr_sectors = (1 << (tmp-1)); printf("nr_sectors : %d\n", nr_sectors); diff --git a/src/spiFlashdb.hpp b/src/spiFlashdb.hpp index 0918a6d00a..3757cecdf6 100644 --- a/src/spiFlashdb.hpp +++ b/src/spiFlashdb.hpp @@ -354,6 +354,20 @@ static std::map flash_list = { .bp_len = 5, .bp_offset = {(1 << 2), (1 << 3), (1 << 4), (1 << 5)}} }, + {0xc22817, { + /* https://www.macronix.com/Lists/Datasheet/Attachments/8868/MX25R6435F,%20Wide%20Range,%2064Mb,%20v1.6.pdf */ + .manufacturer = "Macronix", + .model = "MX25R6435F", + .nr_sector = 128, + .sector_erase = true, + .subsector_erase = true, + .has_extended = false, + .tb_otp = true, + .tb_offset = (1 << 3), + .tb_register = CONFR, + .bp_len = 4, + .bp_offset = {(1 << 2), (1 << 3), (1 << 4), 0}} + }, {0xef4014, { /* https://cdn-shop.adafruit.com/datasheets/W25Q80BV.pdf */ .manufacturer = "Winbond",