fix(vd960DBN): SPI Flash 识别去厂商代码判断 — 兼容其他厂家同容量型号

- W25Qxx 宏 0XEF13~17 -> 0X13~17 (去掉厂商前缀, 只留设备 ID)
- SPI_Flash_ReadJEDEC_ID() 删除 id[0]!=0xEF||id[1]!=0x40 校验, 直接返回容量码 id[2]
  (JEDEC 容量码跨厂商标准化, offlog/snapshot 分区判断随之生效)
- storage_init() switch 改 Flash_Model & 0xFF 低字节匹配
- 换非华邦芯片 (如 0x1A 厂商) 时识别不再不一致
This commit is contained in:
wangfq
2026-08-19 14:45:30 +08:00
parent 9209a9f034
commit f1d9ac4e48
2 changed files with 39 additions and 9 deletions
@@ -19,11 +19,11 @@
/* Winbond SPIFalsh ID */
#define W25Q80 0XEF13
#define W25Q16 0XEF14
#define W25Q32 0XEF15
#define W25Q64 0XEF16 //64Mbit, 8MByte
#define W25Q128 0XEF17
#define W25Q80 0X13 // device ID only, no vendor code
#define W25Q16 0X14
#define W25Q32 0X15
#define W25Q64 0X16 //64Mbit, 8MByte
#define W25Q128 0X17
/* Winbond SPIFalsh Instruction List */
#define W25X_WriteEnable 0x06
@@ -228,8 +228,10 @@ u16 SPI_Flash_ReadID(void)
/*********************************************************************
* @fn SPI_Flash_ReadJEDEC_ID
*
* @brief Read JEDEC ID (0x9F). Return 3rd byte (device id).
* W25Q32=0x16 Q64=0x17 Q128=0x18 Q256=0x19; 0 if not Winbond.
* @brief Read JEDEC ID (0x9F). Return 3rd byte (capacity code).
* W25Q32=0x16 Q64=0x17 Q128=0x18 Q256=0x19.
* 2026-08-19: no vendor code check (id[0]/id[1]) - compatible
* with other vendors same-capacity parts.
*
* @return device id byte
*/
@@ -244,7 +246,8 @@ uint8_t SPI_Flash_ReadJEDEC_ID(void)
id[2] = SPI1_ReadWriteByte(0xFF);
GPIO_WriteBit(GPIOA, GPIO_Pin_4, 1);
if (id[0] != 0xEF || id[1] != 0x40) return 0;
/* 2026-08-19: no vendor code check - JEDEC capacity code (id[2])
is standardized across vendors (e.g. 0x16=32Mbit for ISSI/GD too) */
return id[2];
}
@@ -505,7 +508,7 @@ void storage_init(void)
SPI_Flash_Init();
uint16_t Flash_Model = SPI_Flash_ReadID();
switch(Flash_Model)
switch(Flash_Model & 0xFF) /* device ID low byte only, no vendor check */
{
case W25Q80: PRINT("W25Q80 OK!\r\n"); break;
case W25Q16: PRINT("W25Q16 OK!\r\n"); break;