我在初始化ARM9260EJ-S CPU(AT91SAM9260EJ-S)时遇到了一个问题,SDRAM 8M,按Section初始化,影射成8个块,每块1M,SDRAM的物理地址为0x20000000,未启动MMU时,SDRAM上的所有读写都正常,启动MMU之后,0x20500000开始的1M SDRAM读写就发现异常,MMU初始化的代码如下:
//*----------------------------------------
//* \fn AT91F_InitMMU
//* \brief Initialize MMU
//*----------------------------------------
void AT91_ARM_MMUInit(void)
{
int i;
unsigned int *pTranslationTable=(unsigned int *)_MMUTT_STARTADDRESS;
AT91_ARM_DisableDCache();
AT91_ARM_DisableICache();
AT91_ARM_CleanDCache();//
AT91_ARM_InvalidateICache();
AT91_ARM_DisableMMU();
AT91_ARM_InvalidateIDTLB();
// Program the TTB
AT91_ARM_WriteTTB(_MMUTT_STARTADDRESS);
// Program the domain access register
AT91_ARM_WriteDomain(0x55555555);
//能否访问将根据节或页描述符中的访问权限位确定
// Reset table entries
for (i = 0; i < 4096; ++i)
pTranslationTable[i] = 0;
// Program level 1 page table entry
pTranslationTable[0x0] =
(0x200 < < 20) | // Physical Address(SDRAM-1ST)
(1 < < 10) | // Access in supervisor mode
(15 < < 5) | // Domain 15
1 < < 4 | //
3 < < 2 | // C=B=1
0x2; // Set as 1 Mbyte section
//
pTranslationTable[0x1] =
(0x001 < < 20) | // Physical Address(INTROM)
(1 < < 10) | // Access in supervisor mode
(15 < < 5) | // Domain 15
(1 < < 4 ) | //
(0 < < 2 ) | // C=B=0
0x2; // Set as 1 Mbyte section
pTranslationTable[0x2] =
(0x002 < < 20) | // Physical Address(INTSRAM0)
(1 < < 10) | // Access in supervisor mode
(15 < < 5) | // Domain 15
(1 < < 4 ) | //
(3 < < 2 ) | // C=B=1
0x2; // Set as 1 Mbyte section