[fix][flash] flash auto identify if mid != 0xff
This commit is contained in:
parent
1c26e68beb
commit
92063f0092
@ -57,11 +57,11 @@ static BL_Err_Type ATTR_TCM_SECTION flash_set_qspi_enable(SPI_Flash_Cfg_Type *p_
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief flash_l1c_set_wrap
|
||||
* @brief flash_set_l1c_wrap
|
||||
*
|
||||
* @return BL_Err_Type
|
||||
*/
|
||||
static BL_Err_Type ATTR_TCM_SECTION flash_l1c_set_wrap(SPI_Flash_Cfg_Type *p_flash_cfg)
|
||||
static BL_Err_Type ATTR_TCM_SECTION flash_set_l1c_wrap(SPI_Flash_Cfg_Type *p_flash_cfg)
|
||||
{
|
||||
if (((p_flash_cfg->ioMode >> 4) & 0x01) == 1) {
|
||||
L1C_Set_Wrap(DISABLE);
|
||||
@ -93,10 +93,13 @@ static BL_Err_Type ATTR_TCM_SECTION flash_config_init(SPI_Flash_Cfg_Type *p_flas
|
||||
arch_memcpy(jedec_id, (uint8_t *)&jid, 3);
|
||||
jid &= 0xFFFFFF;
|
||||
ret = SF_Cfg_Get_Flash_Cfg_Need_Lock_Ext(jid, p_flash_cfg);
|
||||
if (ret == SUCCESS) {
|
||||
p_flash_cfg->mid = (jid&0xff);
|
||||
}
|
||||
|
||||
/* Set flash controler from p_flash_cfg */
|
||||
flash_set_qspi_enable(p_flash_cfg);
|
||||
flash_l1c_set_wrap(p_flash_cfg);
|
||||
flash_set_l1c_wrap(p_flash_cfg);
|
||||
XIP_SFlash_State_Restore(p_flash_cfg, p_flash_cfg->ioMode & 0x0f, offset);
|
||||
XIP_SFlash_Opt_Exit();
|
||||
__enable_irq();
|
||||
@ -112,14 +115,21 @@ static BL_Err_Type ATTR_TCM_SECTION flash_config_init(SPI_Flash_Cfg_Type *p_flas
|
||||
BL_Err_Type ATTR_TCM_SECTION flash_init(void)
|
||||
{
|
||||
BL_Err_Type ret = ERROR;
|
||||
uint8_t clkDelay = 1;
|
||||
uint8_t clkInvert = 1;
|
||||
uint32_t jedec_id = 0;
|
||||
|
||||
__disable_irq();
|
||||
L1C_Cache_Flush_Ext();
|
||||
SF_Cfg_Get_Flash_Cfg_Need_Lock_Ext(0, &g_flash_cfg);
|
||||
g_flash_cfg.ioMode = g_flash_cfg.ioMode & 0x0f;
|
||||
L1C_Cache_Flush_Ext();
|
||||
__enable_irq();
|
||||
if (g_flash_cfg.mid != 0xff) {
|
||||
return SUCCESS;
|
||||
}
|
||||
clkDelay = g_flash_cfg.clkDelay;
|
||||
clkInvert = g_flash_cfg.clkInvert;
|
||||
g_flash_cfg.ioMode = g_flash_cfg.ioMode & 0x0f;
|
||||
|
||||
ret = flash_config_init(&g_flash_cfg, (uint8_t *)&jedec_id);
|
||||
MSG("flash ID = %08x\r\n", jedec_id);
|
||||
@ -127,6 +137,8 @@ BL_Err_Type ATTR_TCM_SECTION flash_init(void)
|
||||
if (ret != SUCCESS) {
|
||||
MSG("flash config init fail!\r\n");
|
||||
}
|
||||
g_flash_cfg.clkDelay = clkDelay;
|
||||
g_flash_cfg.clkInvert = clkInvert;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -120,9 +120,9 @@ static const ATTR_TCM_CONST_SECTION SPI_Flash_Cfg_Type flashCfg_Gd_Md_40D = {
|
||||
.qpageProgramCmd = 0x32,
|
||||
.qppAddrMode = SF_CTRL_ADDR_1_LINE,
|
||||
|
||||
.ioMode = SF_CTRL_DO_MODE,
|
||||
.ioMode = 0x11,
|
||||
.clkDelay = 1,
|
||||
.clkInvert = 0x3f,
|
||||
.clkInvert = 0x01,
|
||||
|
||||
.resetEnCmd = 0x66,
|
||||
.resetCmd = 0x99,
|
||||
@ -220,7 +220,7 @@ static const ATTR_TCM_CONST_SECTION SPI_Flash_Cfg_Type flashCfg_MX_KH25 = {
|
||||
|
||||
.ioMode = 0x11,
|
||||
.clkDelay = 1,
|
||||
.clkInvert = 0x3f,
|
||||
.clkInvert = 0x01,
|
||||
|
||||
.resetEnCmd = 0x66,
|
||||
.resetCmd = 0x99,
|
||||
@ -318,7 +318,7 @@ static const ATTR_TCM_CONST_SECTION SPI_Flash_Cfg_Type flashCfg_FM_Q80 = {
|
||||
|
||||
.ioMode = SF_CTRL_QIO_MODE,
|
||||
.clkDelay = 1,
|
||||
.clkInvert = 0x3f,
|
||||
.clkInvert = 0x01,
|
||||
|
||||
.resetEnCmd = 0x66,
|
||||
.resetCmd = 0x99,
|
||||
@ -416,7 +416,7 @@ static const ATTR_TCM_CONST_SECTION SPI_Flash_Cfg_Type flashCfg_Winb_16JV = {
|
||||
|
||||
.ioMode = SF_CTRL_QIO_MODE,
|
||||
.clkDelay = 1,
|
||||
.clkInvert = 0x3f,
|
||||
.clkInvert = 0x01,
|
||||
|
||||
.resetEnCmd = 0x66,
|
||||
.resetCmd = 0x99,
|
||||
@ -503,6 +503,46 @@ static const ATTR_TCM_CONST_SECTION Flash_Info_t flashInfos[] = {
|
||||
.name = "ZB_VQ16_16_33",
|
||||
.cfg = &flashCfg_Winb_16JV,
|
||||
},
|
||||
{
|
||||
.jedecID = 0x144020,
|
||||
.name = "XM_25QH80_80_33",
|
||||
.cfg = &flashCfg_Winb_16JV,
|
||||
},
|
||||
{
|
||||
.jedecID = 0x154020,
|
||||
.name = "XM_25QH16_16_33",
|
||||
.cfg = &flashCfg_Winb_16JV,
|
||||
},
|
||||
{
|
||||
.jedecID = 0x164020,
|
||||
.name = "XM_25QH32_32_33",
|
||||
.cfg = &flashCfg_Winb_16JV,
|
||||
},
|
||||
{
|
||||
.jedecID = 0x174020,
|
||||
.name = "XM_25QH64_64_33",
|
||||
.cfg = &flashCfg_Winb_16JV,
|
||||
},
|
||||
{
|
||||
.jedecID = 0x13325E,
|
||||
.name = "ZB_D40B_80_33",
|
||||
.cfg = &flashCfg_MX_KH25,
|
||||
},
|
||||
{
|
||||
.jedecID = 0x14325E,
|
||||
.name = "ZB_D80B_80_33",
|
||||
.cfg = &flashCfg_MX_KH25,
|
||||
},
|
||||
{
|
||||
.jedecID = 0x15405E,
|
||||
.name = "ZB_25Q16B_15_33",
|
||||
.cfg = &flashCfg_Winb_16JV,
|
||||
},
|
||||
{
|
||||
.jedecID = 0x16405E,
|
||||
.name = "ZB_25Q32B_16_33",
|
||||
.cfg = &flashCfg_Winb_16JV,
|
||||
},
|
||||
};
|
||||
|
||||
/*@} end of group SF_CFG_EXT_Private_Variables */
|
||||
@ -585,7 +625,10 @@ BL_Err_Type ATTR_TCM_SECTION SF_Cfg_Get_Flash_Cfg_Need_Lock_Ext(uint32_t flashID
|
||||
}
|
||||
} else {
|
||||
if (SF_Cfg_Get_Flash_Cfg_Need_Lock(flashID, pFlashCfg) == SUCCESS) {
|
||||
return SUCCESS;
|
||||
/* 0x134051 flash cfg is wrong in rom, find again */
|
||||
if ((flashID&0xFFFFFF) != 0x134051) {
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(flashInfos) / sizeof(flashInfos[0]); i++) {
|
||||
@ -621,7 +664,10 @@ uint32_t ATTR_TCM_SECTION SF_Cfg_Flash_Identify_Ext(uint8_t callFromFlash,
|
||||
ret = SF_Cfg_Flash_Identify(callFromFlash, autoScan, flashPinCfg, restoreDefault, pFlashCfg);
|
||||
|
||||
if ((ret & BFLB_FLASH_ID_VALID_FLAG) != 0) {
|
||||
return ret;
|
||||
/* 0x134051 flash cfg is wrong in rom, find again */
|
||||
if ((ret&0xFFFFFF) != 0x134051) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
jdecId = (ret & 0xffffff);
|
||||
|
Reference in New Issue
Block a user