
Hi all,
I have a problem about malloc() fail after the cpu has been reset. This problem I have not encountered when porting with older version of u-boot. Unfortunately I've forget which version (commit) is still work with my port (NDS32)
The problem is that, after the command "reset" under u-boot console. The cpu will do flush I/D cache , disable interrupt , redo mem_malloc_init(). Then redo the init process.
Reset was successful, however, when the code is executed to himport default env, will encounter malloc fail in the himport_r function. It won't occur before reset.
The malloc() called in himport_r was the first time u-boot called malloc() after reset.
After I have traced into the dlmalloc, I've found that The 1st success u-boot startup, sbrk_base seems a correct value in malloc_extend_top().
(The following is gdb output) 2017 if (sbrk_base != (char*)(-1)) malloc_extend_top: sbrk_base: 0xffffffff, (char*)(-1): 0xffffffff Destroy Hash Table: 0321ea58 table = (null)
When the u-boot has been reset, sbrk_base seems not cleared/reset. (sbrk_base is a static global variable) (The following is gdb output after system has been reset) 2017 if (sbrk_base != (char*)(-1)) malloc_extend_top: sbrk_base: 0x03180000, (char*)(-1): 0xffffffff 2018 sbrk_size = (sbrk_size + (pagesz - 1)) & ~(pagesz - 1); malloc_extend_top: sbrk_size: 0x00000050
Is this correct? Should I clear sbrk_base after u-boot has been reset? Or it looks like where was the misconfiguration about the memory layout? Could anyone give some suggestion? Thanks a lot.