uboot中内存测试内存检测方法二.docx
- 文档编号:7722973
- 上传时间:2023-01-26
- 格式:DOCX
- 页数:9
- 大小:15.36KB
uboot中内存测试内存检测方法二.docx
《uboot中内存测试内存检测方法二.docx》由会员分享,可在线阅读,更多相关《uboot中内存测试内存检测方法二.docx(9页珍藏版)》请在冰豆网上搜索。
uboot中内存测试内存检测方法二
uboot中内存测试、内存检测方法二
具体代码实现如下:
staticvoidmove64(unsignedlonglong*src,unsignedlonglong*dest)
{
*dest=*src;
}
/*
*Thisis64bitwidetestpatterns.NotethattheyresideinROM
*(whichpresumablyworks)andthetestswritethemtoRAMwhichmay
*notwork.
*
*The"otherpattern"iswrittentodrivethedatabustovaluesother
*thanthetestpattern.Thisisfordetectingfloatingbuslines.
*
*/
conststaticunsignedlonglongpattern[]={
0xaaaaaaaaaaaaaaaaULL,
0xccccccccccccccccULL,
0xf0f0f0f0f0f0f0f0ULL,
0xff00ff00ff00ff00ULL,
0xffff0000ffff0000ULL,
0xffffffff00000000ULL,
0x00000000ffffffffULL,
0x0000ffff0000ffffULL,
0x00ff00ff00ff00ffULL,
0x0f0f0f0f0f0f0f0fULL,
0x3333333333333333ULL,
0x5555555555555555ULL
};
constunsignedlonglongotherpattern=0x0123456789abcdefULL;
/*数据线检测*/
staticintmemory_post_dataline(unsignedlonglong*pmem)
{
unsignedlonglongtemp64=0;
intnum_patterns=sizeof(pattern)/sizeof(pattern[0]);
inti;
unsignedinthi,lo,pathi,patlo;
intret=0;
for(i=0;i<num_patterns;i++)
{
move64((unsignedlonglong*)&(pattern[i]),pmem++);
/*
*Putadifferentpatternonthedatalines:
otherwisethey
*mayfloatlongenoughtoreadbackwhatwewrote.
*/
/*预防floatingbuses错误*/
move64((unsignedlonglong*)&otherpattern,pmem--);
move64(pmem,&temp64);
#ifdefINJECT_DATA_ERRORS
temp64^=0x00008000;
#endif
if(temp64!
=pattern[i])
{
pathi=(pattern[i]>>32)&0xffffffff;
patlo=pattern[i]&0xffffffff;
hi=(temp64>>32)&0xffffffff;
lo=temp64&0xffffffff;
post_log("Memory(dateline)errorat%08x,"
"wrote%08x%08x,read%08x%08x!
",
pmem,pathi,patlo,hi,lo);
ret=-1;
}
}
returnret;
}
/*地址线检测*/
staticintmemory_post_addrline(ulong*testaddr,ulong*base,ulongsize)
{
ulong*target;
ulong*end;
ulongreadback;
ulongxor;
intret=0;
end=(ulong*)((ulong)base+size);/*pointerarith!
*/
xor=0;
for(xor=sizeof(ulong);xor>0;xor<<=1)
{
/*对测试的地址的某一根地址线的值翻转*/
target=(ulong*)((ulong)testaddr^xor);
if((target>=base)&&(target<end))
{
/*由于target是testaddr某一根地址线的值翻转得来
故testaddr!
=target,下面赋值操作后
应有*testaddr!
=*target*/
*testaddr=~*target;
readback=*target;
#ifdefINJECT_ADDRESS_ERRORS
if(xor==0x00008000)
{
readback=*testaddr;
}
#endif
/*出现此种情况只有testaddr==target,即某根地址线翻转无效*/
if(readback==*testaddr)
{
post_log("Memory(addressline)errorat%08x<->%08x,"
"XORvalue%08x!
",
testaddr,target,xor);
ret=-1;
}
}
}
returnret;
}
staticintmemory_post_test1(unsignedlongstart,
unsignedlongsize,
unsignedlongval)
{
unsignedlongi;
ulong*mem=(ulong*)start;
ulongreadback;
intret=0;
for(i=0;i<size/sizeof(ulong);i++){
mem[i]=val;
if(i%1024==0)
WATCHDOG_RESET();
}
for(i=0;i<size/sizeof(ulong)&&ret==0;i++){
readback=mem[i];
if(readback!
=val){
post_log("Memoryerrorat%08x,"
"wrote%08x,read%08x!
",
mem+i,val,readback);
ret=-1;
break;
}
if(i%1024==0)
WATCHDOG_RESET();
}
returnret;
}
staticintmemory_post_test2(unsignedlongstart,unsignedlongsize)
{
unsignedlongi;
ulong*mem=(ulong*)start;
ulongreadback;
intret=0;
for(i=0;i<size/sizeof(ulong);i++){
mem[i]=1<<(i%32);
if(i%1024==0)
WATCHDOG_RESET();
}
for(i=0;i<size/sizeof(ulong)&&ret==0;i++){
readback=mem[i];
if(readback!
=(1<<(i%32))){
post_log("Memoryerrorat%08x,"
"wrote%08x,read%08x!
",
mem+i,1<<(i%32),readback);
ret=-1;
break;
}
if(i%1024==0)
WATCHDOG_RESET();
}
returnret;
}
staticintmemory_post_test3(unsignedlongstart,unsignedlongsize)
{
unsignedlongi;
ulong*mem=(ulong*)start;
ulongreadback;
intret=0;
for(i=0;i<size/sizeof(ulong);i++){
mem[i]=i;
if(i%1024==0)
WATCHDOG_RESET();
}
for(i=0;i<size/sizeof(ulong)&&ret==0;i++){
readback=mem[i];
if(readback!
=i){
post_log("Memoryerrorat%08x,"
"wrote%08x,read%08x!
",
mem+i,i,readback);
ret=-1;
break;
}
if(i%1024==0)
WATCHDOG_RESET();
}
returnret;
}
staticintmemory_post_test4(unsignedlongstart,unsignedlongsize)
{
unsignedlongi;
ulong*mem=(ulong*)start;
ulongreadback;
intret=0;
for(i=0;i<size/sizeof(ulong);i++){
mem[i]=~i;
if(i%1024==0)
WATCHDOG_RESET();
}
for(i=0;i<size/sizeof(ulong)&&ret==0;i++){
readback=mem[i];
if(readback!
=~i){
post_log("Memoryerrorat%08x,"
"wrote%08x,read%08x!
",
mem+i,~i,readback);
ret=-1;
break;
}
if(i%1024==0)
WATCHDOG_RESET();
}
returnret;
}
staticintmemory_post_tests(unsignedlongstart,unsignedlongsize)
{
intret=0;
if(ret==0)
ret=memory_post_dataline((unsignedlonglong*)start);
WATCHDOG_RESET();
if(ret==0)
ret=memory_post_addrline((ulong*)start,(ulong*)start,size);
WATCHDOG_RESET();
if(ret==0)
ret=memory_post_addrline((ulong*)(start+size-8),
(ulong*)start,size);
WATCHDOG_RESET();
if(ret==0)
ret=memory_post_test1(start,size,0x00000000);
WATCHDOG_RESET();
if(ret==0)
ret=memory_post_test1(start,size,0xffffffff);
WATCHDOG_RESET();
if(ret==0)
ret=memory_post_test1(start,size,0x55555555);
WATCHDOG_RESET();
if(ret==0)
ret=memory_post_test1(start,size,0xaaaaaaaa);
WATCHDOG_RESET();
if(ret==0)
ret=memory_post_test2(start,size);
WATCHDOG_RESET();
if(ret==0)
ret=memory_post_test3(start,size);
WATCHDOG_RESET();
if(ret==0)
ret=memory_post_test4(start,size);
WATCHDOG_RESET();
returnret;
}
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- uboot 内存 测试 检测 方法
![提示](https://static.bdocx.com/images/bang_tan.gif)