这些天,我开始学习 Nucleus Plus 操作系统。构建操作系统并将镜像下载到板子后,操作系统无法成功运行。我发现错误发生在函数 CMEM_Index(); 我已经阅读了代码,但我找不到原因。而且我什至不知道系统是如何获取combo_mem_id_list等ID列表的。现在这里是 CMEM_Index() 的代码。有人知道 Nucleus Plus 吗?或者谁能告诉我系统如何获取nor flash ID列表?请。
#if defined(__DUAL_SERIAL_FLASH_SUPPORT__)
kal_int32 CMEM_Index(const kal_uint16 CS)
#else //ADMUX or Nand or SF without Dual SF enable
kal_int32 CMEM_Index()
#endif
{
kal_int32 i, j;
CMEMFlashID id;
const CMEMEntryID *id_list=NULL;
#if !defined(__DUAL_SERIAL_FLASH_SUPPORT__)
if (cmem_index>=0) return cmem_index;
#endif
// Read Flash ID
#if defined(_NAND_FLASH_BOOTING_)
#if defined(__UBL__)
return CMEM_INVALID_INDEX;
#else
if(DAL_is_initialized == 0)
{
DAL_init(); // Call DAL init to ensure FlashID alreay there.
}
MTD_ReadID(8, id.NAND);
#endif
#elif defined(__DUAL_SERIAL_FLASH_SUPPORT__)
#if defined(__UBL__)
//begin from MT6255, remapping is done before NOR_ReadID
if(CS !=2) //Skip Read ID for dummy SF2
{
if(EMI_QueryIsRemapped())
NOR_ReadID(CS,(void*)0x10000000, id.NOR);
else
NOR_ReadID(CS, (void*)0, id.NOR);
}
#else
if(CS !=2)//Skip Read ID for dummy SF2
NOR_ReadID(CS, (void *)(INT_RetrieveFlashBaseAddr() + NOR_FLASH_BASE_ADDRESS), id.NOR);
#endif
#else //ADMUX and SF without Dual SF enable
#if defined(__UBL__)
//begin from MT6255, remapping is done before NOR_ReadID
if(EMI_QueryIsRemapped())
NOR_ReadID(0,(void*)0x10000000, id.NOR);
else
NOR_ReadID(0, (void*)0, id.NOR);
#else
NOR_ReadID(0, (void *)(INT_RetrieveFlashBaseAddr() + NOR_FLASH_BASE_ADDRESS), id.NOR);
#endif
#endif //defined(_NAND_FLASH_BOOTING_)
#ifdef __SV5_ENABLED__
id_list=combo_mem_id_list.m_data.List;
#else
id_list=combo_mem_id_list.List;
#endif
// seach CMEM list for specific Flash ID
for (i=0; i<COMBO_MEM_DEVICE_COUNT; i++) {
// Check 1: Compare ID
for (j=0; j<id_list[i].IDLength; j++) {
#if defined(_NAND_FLASH_BOOTING_)
if (id_list[i].ID[j]!=id.NAND[j]) break;
#else // __SERIAL_FLASH__ || NOR FLASH
if (id_list[i].ID[j]!=id.NOR[j]) break;
#endif
}
// Check 2: Compare RegionInfo
if (j==id_list[i].IDLength) {
// TBD: Compare RegionInfo
cmem_index=i;
break; // entry found, break the loop
}
}
#if defined(__DUAL_SERIAL_FLASH_SUPPORT__)
/*Get Dummy SF entry ID*/
if(CS==2)
{
// seach CMEM list for specific Flash ID
for (i=0; i<COMBO_MEM_DEVICE_COUNT; i++) {
// Check 1: Compare ID
for (j=0; j<id_list[i].IDLength; j++) {
if(j==0)
if (id_list[i].ID[j]!= 0x00) break;
if(j==1)
if (id_list[i].ID[j]!= 0x34) break;
if(j==2)
if (id_list[i].ID[j]!= 0x56) break;
}
if (j==id_list[i].IDLength)
{
// TBD: Compare RegionInfo
cmem_index=i;
break; // entry found, break the loop
}
}
}
#endif
return cmem_index;
}