rework addressing the review comments

Reverted 'mfr_id' to 'manufacturer_id'
Moved devices table definition to flashmem.h
Single global variable 'spi_flash_pages64k'
The local structure holding the actual device data is used in firmware.c only

difference in code:
```
   text    data     bss     dec     hex filename
 223189  138560    6067  367816   59cc8 ./armsrc/obj/fullimage.elf <-- c9e751d darkside: fix backdoor support

 223437  138624    6075  368136   59e08 ./armsrc/obj/fullimage.elf <-- this commit
 ======================================
   +248     +64      +8    +320
```
This commit is contained in:
ANTodorov 2024-11-20 14:08:28 +02:00
commit 76aaef96cc
No known key found for this signature in database
GPG key ID: 318CC11D7ED4016B
6 changed files with 76 additions and 74 deletions

View file

@ -122,7 +122,7 @@ bool Flash_Erase4k(uint8_t block, uint8_t sector);
bool Flash_Erase64k(uint8_t block);
typedef struct {
uint8_t mfr_id;
uint8_t manufacturer_id;
uint8_t device_id;
uint8_t device_id2;
} flash_device_type_t; // extra device_id used for the JEDEC ID read via cmd 9F
@ -137,18 +137,42 @@ void Flashmem_print_status(void);
void Flashmem_print_info(void);
typedef struct {
uint8_t mfr_id;
uint8_t manufacturer_id;
uint8_t device_id;
uint16_t jedec_id;
uint8_t p64k;
char *desc;
uint8_t pages64k;
char *device;
}spi_flash_t;
extern const spi_flash_t spiFlashTable[];
extern const spi_flash_t *spi_flash_p;
extern spi_flash_t spi_flash_data;
static const spi_flash_t SpiFlashTable[] = {
// first element is the default of 4 * 64kB pages (256kB)
{ 0x00, 0x00, 0x0000, 4, "unknown" }, // 256k
// Manufacturer: Puya
{ 0x85, 0x00, 0x6015, 32, "P25Q16H" }, // 2048k
/// Manufacturer: Renesas
{ 0x1F, 0x46, 0x0000, 32, "AT25XE161D" }, // 2048k
{ 0x1F, 0x47, 0x0000, 64, "AT25XE321D" }, // 4096k
// Manufacturer: Winbond
{ 0xEF, 0x00, 0x3012, 4, "W25X20BV" }, // 256k
{ 0xEF, 0x00, 0x3013, 8, "W25X40BV" }, // 512k
bool FlashDetect(const spi_flash_t **);
{ 0xEF, 0x00, 0x4013, 8, "W25Q40BV" }, // 512k
{ 0xEF, 0x00, 0x4014, 16, "W25Q80BV" }, // 1024k
{ 0xEF, 0x14, 0x4015, 32, "W25Q16BV" }, // 2048k
{ 0xEF, 0x15, 0x4016, 64, "W25Q32BV" }, // 4096k
{ 0xEF, 0x21, 0x7022, 4, "W25Q02JV" },
// identified by Manufacturer /Device ID
// { 0xEF, 0x05, 0x0000, 1, "Winbond!!!" },
{ 0xEF, 0x10, 0x0000, 2, "W25*10BV!!!" }, // 128k
{ 0xEF, 0x11, 0x0000, 4, "W25*20BV" }, // 256k
{ 0xEF, 0x12, 0x0000, 8, "W25*40BV" }, // 512k
{ 0xEF, 0x13, 0x0000, 16, "W25*80BV" } // 1024k
};
extern uint8_t spi_flash_pages64k;
bool FlashDetect(void);
#ifndef ARRAYLEN
# define ARRAYLEN(x) (sizeof(x)/sizeof((x)[0]))