测试DDR2
用三星S5PV210做了几块板子,加载完程序后,发现跑不起来,怀疑是DDR2的问题。想在代码中加入测试DDR2。不知道怎么加,用的是WINCE操作系统,有谁弄过这块,帮下忙哦,谢谢。
[解决办法]
這種東西當然是要加在C:\WINCE600\PLATFORM\SMDKV210\SRC\BOOTLOADER\STEPLDR\main.c裡面
不然是要怎嚜測試整各DRAM
void main(void)
{
Port_Init();
Led_Display_Off(1); //RED
Led_Display_Off(2); //BLUE
Led_Display_On(3); //GREEN
if(!DRAM_Test())
{
Led_Display_On(1); //RED
RAM_Error();
}
}
BOOL DRAM_Test(void);
unsigned long* DRAM_DeviceTest(unsigned long *BaseAddr, unsigned long nBytes);
unsigned long* DRAM_AddrBusTest(unsigned long *BaseAddr, unsigned long nBytes);
unsigned long DRAM_DataBusTest(unsigned long *Addr);
//*----------------------------------------
//* \fn DRAM_DataBusTest
//* \brief Test the DRAM Data Bus
//* return succeed return 0 / fail return Data Value
//*----------------------------------------
unsigned long DRAM_DataBusTest(unsigned long *Addr)
{
unsigned long pattern;
for(pattern = 1; pattern != 0; pattern <<= 1)
{
*Addr = pattern;
Addr[1] = ~pattern;
if(*Addr != pattern)
return pattern;
}
return 0;
}
//*----------------------------------------
//* \fn DRAM_AddrBusTest
//* \brief Test the DRAM Address Bus
//* return succeed return 0 / Fail return Error Address
//* 測試區塊盡可能為2的次方
//*----------------------------------------
unsigned long* DRAM_AddrBusTest(unsigned long *BaseAddr, unsigned long nBytes)
{
unsigned long offset,testOffset;
unsigned long pattern = 0xAAAAAAAA;
unsigned long antipattern = 0x55555555;
unsigned long addressMask = (nBytes - 1)>>2; /*設定用來當成停止狀況,一次測試4個Bytes*/
for(offset = 4;(offset & addressMask) != 0; offset <<= 1)
{
BaseAddr[offset] = pattern;
}
/*檢查是否有其他位址線也出現1的訊號*/
BaseAddr[0] = antipattern;
for(offset = 4;(offset & addressMask) != 0; offset <<= 1)
{
if(BaseAddr[offset] != pattern)
return (unsigned long*) &BaseAddr[offset];
}
BaseAddr[0] = pattern;
/*檢查是否有短路或誤接到低電位的位址線*/
for(testOffset = 4;(testOffset & addressMask) != 0; testOffset <<= 1)
{
BaseAddr[testOffset] = antipattern;
for(offset = 4;(offset & addressMask) != 0; offset <<= 1)
{
if(BaseAddr[offset] != pattern && (offset != testOffset))
return (unsigned long*) &BaseAddr[testOffset];
}
BaseAddr[testOffset] = pattern;
}
return 0;
}
//*----------------------------------------
//* \fn DRAM_DeviceTest
//* \brief Test the DRAM
//*----------------------------------------
unsigned long* DRAM_DeviceTest(unsigned long *BaseAddr, unsigned long nBytes)
{
unsigned long offset;
unsigned long nDWords = nBytes/4;
unsigned long pattern=0xAAAAAAAA;
unsigned long antipattern=0x55555555;
/*
//將整個記憶體填入已知的資料數值
for(offset = 0;offset < nDWords; offset++)
{
BaseAddr[offset] = pattern;
if(offset % 0x100000 == 0)
DebugString(".");
}
//確認每個位址上的資料,並將他反向,作第二回合測試
for(offset = 0;offset < nDWords;offset++)
{
if(BaseAddr[offset] != pattern)
{
return (unsigned long*)&BaseAddr[offset];
}
BaseAddr[offset] = antipattern;
if(offset % 0x100000 == 0)
DebugString(".");
}
//確認每個位址上的資料是否被反向,然後歸0
for(pattern = 1,offset = 0;offset < nDWords; pattern++,offset++)
{
if(BaseAddr[offset] != antipattern)
{
return (unsigned long*)&BaseAddr[offset];
}
BaseAddr[offset] = 0;
if(offset % 0x100000 == 0)
DebugString(".");
}
DebugString("\n");
*/
//確認Data Bus ok
BaseAddr[0] = pattern;
if(BaseAddr[0] != pattern)
{
return (unsigned long*)&BaseAddr[0];
}
BaseAddr[0] = antipattern;
if(BaseAddr[0] != antipattern)
{
return (unsigned long*)&BaseAddr[0];
}
/*
//確認Address Bus ok
for(offset = 0;offset < nDWords;) //offset++
{
BaseAddr[offset] = pattern;
offset++;
BaseAddr[offset] = antipattern;
if(BaseAddr[offset] != antipattern
[解决办法]
BaseAddr[offset-1] != pattern)
{
return (unsigned long*)&BaseAddr[offset];
}
offset++;
}
*/
return 0;
}
//*----------------------------------------
//* \fn DRAM_Test
//* \brief Test All the DRAM: Data/Address/Every Bit
//*----------------------------------------
BOOL DRAM_Test(void)
{
unsigned long Value;
unsigned long *pValue;
unsigned long DRAM0_BASE = 0x20000000;
unsigned long DRAM0_SIZE = 0x8000000; //128M
unsigned long DRAM1_BASE = 0x40000000;
unsigned long DRAM1_SIZE = 0x8000000; //128M
//////////////////////////////////////////////////////////////////////////////
Value = DRAM_DataBusTest((unsigned long *)DRAM1_BASE);
if(Value != 0)
{
//DebugString("DRAM1 Data Bus Error\n");
return FALSE;
}
pValue = DRAM_AddrBusTest((unsigned long *)DRAM1_BASE,DRAM1_SIZE);
if(pValue != 0)
{
//DebugString("DRAM1 Address Bus Error\n");
return FALSE;
}
pValue = DRAM_DeviceTest((unsigned long *)DRAM1_BASE,DRAM1_SIZE);
if(pValue != 0)
{
//DebugString("DRAM1 Device Error\n");
return FALSE;
}
//////////////////////////////////////////////////////////////////////////////
Value = DRAM_DataBusTest((unsigned long *)DRAM0_BASE);
if(Value != 0)
{
//DebugString("DRAM0 Data Bus Error\n");
return FALSE;
}
pValue = DRAM_AddrBusTest((unsigned long *)DRAM0_BASE,DRAM0_SIZE);
if(pValue != 0)
{
//DebugString("DRAM0 Address Bus Error\n");
return FALSE;
}
pValue = DRAM_DeviceTest((unsigned long *)DRAM0_BASE,DRAM0_SIZE);
if(pValue != 0)
{
//DebugString("DRAM0 Device Error\n");
return FALSE;
}
//////////////////////////////////////////////////////////////////////////////
return TRUE;
}
[解决办法]
关掉data cache,执行数据线测试、地址线测试,具体算法参考8楼代码,若是地址线/数据线焊接问题,是可以定位出哪根线有问题;
如果怀疑DDR颗粒问题,还可以执行存储单元测试,算法很多种,自己上网去搜;