2021-10-10 18:25:09 +02:00
// SPDX-License-Identifier: Apache-2.0
/*
* Copyright ( C ) 2021 Gwenhael Goavec - Merou < gwenhael . goavec - merou @ trabucayre . com >
*/
# ifndef SRC_SPIFLASHDB_HPP_
# define SRC_SPIFLASHDB_HPP_
# include <stdint.h>
# include <map>
# include <string>
2021-10-19 06:55:30 +02:00
typedef enum {
2022-02-26 17:02:38 +01:00
STATR = 0 , /* status register */
FUNCR = 1 , /* function register */
CONFR = 2 , /* configuration register */
2022-03-28 17:54:43 +02:00
NONER = 99 , /* "none" register */
2021-10-19 06:55:30 +02:00
} tb_loc_t ;
2021-10-10 18:25:09 +02:00
typedef struct {
std : : string manufacturer ; /**< manufacturer name */
std : : string model ; /**< chip name */
uint32_t nr_sector ; /**< number of sectors */
bool sector_erase ; /**< 64KB erase support */
/* missing 32KB erase */
bool subsector_erase ; /**< 4KB erase support */
bool has_extended ;
bool tb_otp ; /**< TOP/BOTTOM One Time Programming */
uint8_t tb_offset ; /**< TOP/BOTTOM bit offset */
2021-10-19 06:55:30 +02:00
tb_loc_t tb_register ; /**< TOP/BOTTOM location (register) */
2021-10-10 18:25:09 +02:00
uint8_t bp_len ; /**< BPx length */
uint8_t bp_offset [ 4 ] ; /**< BP[0:3] bit offset */
} flash_t ;
static std : : map < uint32_t , flash_t > flash_list = {
2021-12-22 18:59:52 +01:00
{ 0x010216 , {
. manufacturer = " spansion " ,
. model = " S25FL064P / EPCS64 " ,
. nr_sector = 128 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = true ,
. tb_otp = false ,
. tb_offset = ( 1 < < 5 ) ,
. tb_register = CONFR ,
. bp_len = 3 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , 0 } }
} ,
2022-02-21 08:27:33 +01:00
{ 0x010219 , {
. manufacturer = " spansion " ,
. model = " S25FL256S " ,
. nr_sector = 512 ,
. sector_erase = true ,
. subsector_erase = false ,
. has_extended = true ,
. tb_otp = true ,
. tb_offset = ( 1 < < 5 ) ,
. tb_register = CONFR ,
. bp_len = 3 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , 0 } }
} ,
2022-05-14 10:16:08 +02:00
{ 0x010220 , {
. manufacturer = " spansion " ,
. model = " S25FL512S " ,
. nr_sector = 1024 ,
. sector_erase = true ,
. subsector_erase = false ,
. has_extended = true ,
. tb_otp = true ,
. tb_offset = ( 1 < < 5 ) ,
. tb_register = CONFR ,
. bp_len = 3 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , 0 } }
} ,
2021-12-22 18:59:52 +01:00
{ 0x012018 , {
. manufacturer = " spansion " ,
. model = " S25FL128S " ,
. nr_sector = 256 ,
. sector_erase = true ,
. subsector_erase = false ,
. has_extended = true ,
2022-02-21 08:27:33 +01:00
. tb_otp = true ,
2021-12-22 18:59:52 +01:00
. tb_offset = ( 1 < < 5 ) ,
. tb_register = CONFR ,
. bp_len = 3 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , 0 } }
} ,
2022-02-19 04:52:26 +01:00
{ 0x016019 , {
. manufacturer = " spansion " ,
. model = " S25FL256L " ,
. nr_sector = 512 ,
. sector_erase = true ,
. subsector_erase = false ,
. has_extended = true ,
. tb_otp = false ,
. tb_offset = ( 1 < < 6 ) ,
. tb_register = STATR ,
. bp_len = 4 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , ( 1 < < 5 ) } }
} ,
2023-03-05 13:14:01 +01:00
/* https://datasheet.octopart.com/M25P16-VME6G-STMicroelectronics-datasheet-7623188.pdf */
{ 0x00202015 , {
. manufacturer = " ST " ,
. model = " M25P16 " ,
. nr_sector = 32 ,
. sector_erase = true ,
. subsector_erase = false ,
. has_extended = false ,
. tb_otp = true ,
. tb_offset = 0 , // unused
. tb_register = STATR ,
. bp_len = 3 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , 0 } }
} ,
2021-12-22 18:58:51 +01:00
{ 0x0020ba16 , {
. manufacturer = " micron " ,
. model = " N25Q32 " ,
. nr_sector = 64 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = true ,
. tb_otp = false ,
. tb_offset = ( 1 < < 5 ) ,
. tb_register = STATR ,
. bp_len = 3 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , 0 } }
} ,
2022-05-10 19:07:56 +02:00
{ 0x0020ba17 , {
. manufacturer = " micron " ,
. model = " N25Q64 " ,
. nr_sector = 128 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = true ,
. tb_otp = false ,
. tb_offset = ( 1 < < 5 ) ,
. tb_register = STATR ,
. bp_len = 4 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , ( 1 < < 6 ) } }
} ,
2023-10-20 07:52:49 +02:00
{ 0x0020bb18 , {
/* https://www.micron.com/-/media/client/global/documents/products/data-sheet/nor-flash/serial-nor/n25q/n25q_128mb_1_8v_65nm.pdf */
/* MT25QU128ABA has the same JEDEC-standard signature: https://media-www.micron.com/-/media/client/global/documents/products/data-sheet/nor-flash/serial-nor/mt25q/die-rev-a/mt25q_qlhs_u_128_aba_0.pdf */
/* Differences: https://media-www.micron.com/-/media/client/global/documents/products/technical-note/nor-flash/tn2501_migrating_n25q_to_mt25ql.pdf */
. manufacturer = " micron " ,
. model = " MT25/N25Q128_1_8V " ,
. nr_sector = 256 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = true ,
. tb_otp = false ,
. tb_offset = ( 1 < < 5 ) ,
. tb_register = STATR ,
. bp_len = 4 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , ( 1 < < 6 ) } }
} ,
2021-10-10 18:25:09 +02:00
{ 0x0020ba18 , {
2023-10-20 07:52:49 +02:00
/* https://media-www.micron.com/-/media/client/global/documents/products/data-sheet/nor-flash/serial-nor/n25q/n25q_128mb_3v_65nm.pdf */
2021-10-10 18:25:09 +02:00
. manufacturer = " micron " ,
2023-10-20 07:52:49 +02:00
. model = " N25Q128_3V " ,
2021-10-10 18:25:09 +02:00
. nr_sector = 256 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = true ,
. tb_otp = false ,
. tb_offset = ( 1 < < 5 ) ,
2021-10-19 06:55:30 +02:00
. tb_register = STATR ,
2021-10-10 18:25:09 +02:00
. bp_len = 4 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , ( 1 < < 6 ) } }
} ,
{ 0x0020ba19 , {
. manufacturer = " micron " ,
. model = " N25Q256 " ,
. nr_sector = 512 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = true ,
. tb_otp = false ,
. tb_offset = ( 1 < < 5 ) ,
2021-10-19 06:55:30 +02:00
. tb_register = STATR ,
2023-01-21 13:47:51 +01:00
. bp_len = 4 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , ( 1 < < 6 ) } }
} ,
{ 0x0020bb21 , {
. manufacturer = " micron " ,
2023-02-20 08:41:48 +01:00
. model = " MT25QU01G " ,
2023-01-21 13:47:51 +01:00
. nr_sector = 2048 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = true ,
. tb_otp = false ,
. tb_offset = ( 1 < < 5 ) ,
. tb_register = STATR ,
2023-02-20 08:41:48 +01:00
. bp_len = 4 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , ( 1 < < 6 ) } }
} ,
{ 0x0020bb22 , {
. manufacturer = " micron " ,
. model = " MT25QU02G " ,
. nr_sector = 4096 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = true ,
. tb_otp = false ,
. tb_offset = ( 1 < < 5 ) ,
. tb_register = STATR ,
2021-10-10 18:25:09 +02:00
. bp_len = 4 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , ( 1 < < 6 ) } }
} ,
2022-03-25 21:15:09 +01:00
{ 0xbf258d , {
. manufacturer = " microchip " ,
. model = " SST25VF040B " ,
. nr_sector = 8 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = false ,
2022-03-28 17:54:43 +02:00
. tb_otp = false ,
. tb_offset = 0 ,
. tb_register = NONER ,
2022-03-25 21:15:09 +01:00
. bp_len = 4 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , ( 1 < < 5 ) } }
} ,
2022-02-26 16:31:41 +01:00
{ 0xBF2642 , {
. manufacturer = " microchip " ,
. model = " SST26VF032B " ,
. nr_sector = 64 ,
2022-02-26 19:10:18 +01:00
. sector_erase = false ,
. subsector_erase = true ,
2022-02-26 16:31:41 +01:00
. has_extended = false ,
2022-02-26 17:02:38 +01:00
. tb_otp = false ,
2022-02-26 16:31:41 +01:00
. tb_offset = 0 ,
2022-02-26 17:02:38 +01:00
. tb_register = NONER ,
2022-02-26 16:31:41 +01:00
. bp_len = 0 ,
2022-02-26 17:02:38 +01:00
. bp_offset = { 0 , 0 , 0 , 0 } }
2022-02-26 16:31:41 +01:00
} ,
2022-10-16 14:32:16 +02:00
{ 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 } }
} ,
2021-10-10 18:25:09 +02:00
{ 0x9d6016 , {
. manufacturer = " ISSI " ,
. model = " IS25LP032 " ,
. nr_sector = 64 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = false ,
. tb_otp = true ,
2021-12-22 18:57:34 +01:00
. tb_offset = ( 1 < < 1 ) ,
2021-10-19 06:55:30 +02:00
. tb_register = FUNCR ,
2021-10-10 18:25:09 +02:00
. bp_len = 4 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , ( 1 < < 5 ) } }
} ,
{ 0x9d6017 , {
. manufacturer = " ISSI " ,
. model = " IS25LP064 " ,
. nr_sector = 128 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = false ,
. tb_otp = true ,
2021-12-22 18:57:34 +01:00
. tb_offset = ( 1 < < 1 ) ,
2021-10-19 06:55:30 +02:00
. tb_register = FUNCR ,
2021-10-10 18:25:09 +02:00
. bp_len = 4 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , ( 1 < < 5 ) } }
} ,
2021-10-14 20:55:42 +02:00
{ 0x9d6018 , {
. manufacturer = " ISSI " ,
. model = " IS25LP128 " ,
. nr_sector = 256 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = false ,
. tb_otp = true ,
2021-12-22 18:57:34 +01:00
. tb_offset = ( 1 < < 1 ) ,
2021-10-19 06:55:30 +02:00
. tb_register = FUNCR ,
2021-10-14 20:55:42 +02:00
. bp_len = 4 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , ( 1 < < 5 ) } }
} ,
2024-02-01 19:48:21 +01:00
{ 0xc22016 , {
/* https://www.macronix.com/Lists/Datasheet/Attachments/8933/MX25L3233F,%203V,%2032Mb,%20v1.7.pdf */
. manufacturer = " Macronix " ,
. model = " MX25L3233F " ,
. nr_sector = 256 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = false ,
. tb_otp = true ,
. tb_offset = ( 1 < < 3 ) ,
. tb_register = CONFR ,
. bp_len = 5 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , ( 1 < < 5 ) } }
} ,
2023-03-05 16:02:22 +01:00
{ 0xc22018 , {
/* https://www.macronix.com/Lists/Datasheet/Attachments/8934/MX25L12833F,%203V,%20128Mb,%20v1.0.pdf */
. manufacturer = " Macronix " ,
. model = " MX25L12833 " ,
. nr_sector = 256 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = false ,
. tb_otp = true ,
. tb_offset = ( 1 < < 3 ) ,
. tb_register = CONFR ,
. bp_len = 5 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , ( 1 < < 5 ) } }
} ,
2023-10-18 16:02:45 +02:00
{ 0xc2201a , {
/* https://www.macronix.com/Lists/Datasheet/Attachments/8745/MX25L51245G,%203V,%20512Mb,%20v1.7.pdf */
. manufacturer = " Macronix " ,
. model = " MX25L51245G " ,
. nr_sector = 1024 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = false ,
. tb_otp = true ,
. tb_offset = ( 1 < < 3 ) ,
. tb_register = CONFR ,
. bp_len = 5 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , ( 1 < < 5 ) } }
} ,
2023-04-03 23:26:03 +02:00
{ 0xef4014 , {
/* https://cdn-shop.adafruit.com/datasheets/W25Q80BV.pdf */
. manufacturer = " Winbond " ,
. model = " W25Q80BV " ,
. nr_sector = 16 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = false ,
. tb_otp = false ,
. tb_offset = ( 1 < < 5 ) ,
. tb_register = STATR ,
. bp_len = 3 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , 0 } }
} ,
2021-12-22 18:58:07 +01:00
{ 0xef4015 , {
. manufacturer = " Winbond " ,
. model = " W25Q16 " ,
. nr_sector = 32 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = false ,
. tb_otp = false ,
. tb_offset = ( 1 < < 5 ) ,
. tb_register = STATR ,
. bp_len = 3 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , 0 } }
} ,
{ 0xef4016 , {
. manufacturer = " Winbond " ,
. model = " W25Q32 " ,
. nr_sector = 64 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = false ,
. tb_otp = false ,
. tb_offset = ( 1 < < 5 ) ,
. tb_register = STATR ,
. bp_len = 3 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , 0 } }
} ,
{ 0xef4017 , {
. manufacturer = " Winbond " ,
. model = " W25Q64 " ,
. nr_sector = 128 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = false ,
. tb_otp = false ,
. tb_offset = ( 1 < < 5 ) ,
. tb_register = STATR ,
. bp_len = 3 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , 0 } }
} ,
2021-10-10 18:25:09 +02:00
{ 0xef4018 , {
2021-10-14 20:52:46 +02:00
. manufacturer = " Winbond " ,
2021-10-10 18:25:09 +02:00
. model = " W25Q128 " ,
. nr_sector = 256 ,
. sector_erase = true ,
. subsector_erase = true ,
. has_extended = false ,
. tb_otp = false ,
. tb_offset = ( 1 < < 5 ) ,
2021-10-19 06:55:30 +02:00
. tb_register = STATR ,
2021-10-10 18:25:09 +02:00
. bp_len = 3 ,
. bp_offset = { ( 1 < < 2 ) , ( 1 < < 3 ) , ( 1 < < 4 ) , 0 } }
} ,
} ;
# endif // SRC_SPIFLASHDB_HPP_