initcall: 3200f110
U-Boot code: 32000000 -> 3207E780 BSS: -> 320CDD70
initcall: 3200038c
CPUID: 32440001
FCLK: 405.600 MHz
HCLK: 101.400 MHz
PCLK: 50.700 MHz
initcall: 3200f368
DRAM: initcall: 3200116c
initcall: 3200f2b8
Monitor len: 000CDD70
Ram size: 04000000
Ram top: 34000000
initcall: 3200eeec
initcall: 3200f0b8
TLB table from 33ff0000 to 33ff4000
initcall: 3200ef04
initcall: 3200f06c
Reserving 823k for U-Boot at: 33f22000
initcall: 3200f040
Reserving 4160k for malloc() at: 33b12000
initcall: 3200f26c
memset_count:-1Reserving 80 Bytes for Board Info at: 33b11fb0
initcall: 3200ef0c
initcall: 3200f00c
Reserving 168 Bytes for Global Data at: 33b11f08
initcall: 3200ef94
initcall: 3200ef40
initcall: 3200ef14
initcall: 3200f358
initcall: 3200f1e4
RAM Configuration:
Bank #0: 30000000 64 MiB
DRAM: 64 MiB
initcall: 3200ef78
New Stack Pointer is: 33b11ee0
initcall: 3200f1a8
initcall: 3200f13c
Relocation Offset is: 01f22000
Relocating to 33f22000, new gd at 33b11f08, sp at 33b11ee0
initcall: 33f313e4
initcall: 33f313ec
initcall: 3200f5d0 (relocated to 33f315d0)
WARNING: Caches not enabled
initcall: 3200f404 (relocated to 33f31404)
initcall: 3200f42c (relocated to 33f3142c)
initcall: 3200f5b4 (relocated to 33f315b4)
using memory 0x33b12000-0x33f22000 for malloc()
搜索关键字“using memory”定位到dlmalloc.c文件,查看源码
void mem_malloc_init(ulong start, ulong size)
{
mem_malloc_start = start;
mem_malloc_end = start + size;
mem_malloc_brk = start;
debug("using memory %#lx-%#lx for malloc()\n", mem_malloc_start, //using memory 0x33b12000-0x33f22000 for malloc()
mem_malloc_end);
#ifdef CONFIG_SYS_MALLOC_CLEAR_ON_INIT
memset((void *)mem_malloc_start, 0x0, size);
#endif
debug("malloc_bin_reloc() before;\n");
malloc_bin_reloc();
debug("malloc_bin_reloc() after;\n");
}
debug("malloc_bin_reloc() before;\n");和debug("malloc_bin_reloc() after;\n");是我添加上去定位BUG所在位置,结果控制台的输出结果依旧没变。锁定了错误在
memset((void *)mem_malloc_start, 0x0, size); 经计算的出(0x33f22000-0x33b12000=4M)在追到memset源码
void * memset(void * s,int c,size_t count)
{
unsigned long *sl = (unsigned long *) s;
unsigned long cl = 0;
char *s8;
int i;
printf("memset_begin",(int)count);
/* do it one word at a time (32 bits or 64 bits) while possible */
if ( ((ulong)s & (sizeof(*sl) - 1)) == 0) {
for (i = 0; i < sizeof(*sl); i++) {
cl <<= 8;
cl |= c & 0xff;
}
while (count >= sizeof(*sl)) {
*sl++ = cl;
count -= sizeof(*sl);
}
}
/* fill 8 bits at a time */
s8 = (char *)sl;
while (count--)
*s8++ = c;
return s;
}
具体原因有待深究。
解决方法是:
mem_malloc_init中memset((void *)mem_malloc_start, 0x0, size/2);此处将size的范围缩小一半可以解决这个BUG。
哪位大神知道这是什么原因引起的?
2 个解决方案
#1
uboot里除了设堆的位置外也设置了栈的位置的,会不会它们两者的位置有重叠了?
#2
结帖咯~~~
#1
uboot里除了设堆的位置外也设置了栈的位置的,会不会它们两者的位置有重叠了?
#2
结帖咯~~~