[U-Boot] dlmalloc: sbrk_base error after cpu reset.

Macpaul Lin macpaul at gmail.com
Fri Dec 24 08:29:21 CET 2010


Dear Wolfgang,

2010/12/23 Wolfgang Denk <wd at denx.de>:
> Dear Macpaul Lin,
>
> In message <macpaul at gmail.com> you wrote:
>>
>> 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.
>
> I'm not sure I understand what you mean.  This shouds as if the
> "reset" command in U-Boot woul perform just apartial re-initialization
> of the software, but not a real hardware reset of the board?

Yes, the "reset" in this problem is meant to the software reset "command"
which could be manually executed from console.

If the "reset" command in u-boot just do apartial re-initialization,
then I think
the problem could not to allocate memory might be some static variable
wasn't cleared after the reset process.

I think the "reset" command will called do_reset() here.
void do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
{
        ......
        /*currently no ROM loader at addr 0. do not use reset_cpu(0) */
        reset_cpu(CONFIG_SYS_TEXT_BASE);
}

The CONFIG_SYS_TEXT_BASE is 0x3200000

I found that the problem cannot do malloc() after software reset might
related to
malloc_extend_top() is also failed.

The following debug output is the first cold boot of the u-boot.
/* gdb load binary log */
Loading section .text, size 0x16ba4 lma 0x3200000
Loading section .rodata, size 0x12c4 lma 0x3216ba4
Loading section .rodata.str1.4, size 0x5d04 lma 0x3217e68
Loading section .rodata.cst4, size 0x8 lma 0x321db6c
Loading section .data, size 0xb54 lma 0x321db74
Loading section .u_boot_cmd, size 0x450 lma 0x321e6c8
Start address 0x3200000, load size 125720

/* debug log of mem_malloc_init() */
mem_malloc_init: start: 0x03180000, size: 0x00080000

/* the first malloc has been called in himport_r() */
malloc: mem_malloc_start: 0x03180000,  mem_malloc_end: 0x03200000
bytes: 0x0000001d
is small request: nb: 40, idx: 5
malloc: remainder_size: -40, chunksize(top): 0, nb: 40
malloc_extend_top: old_end: 0x0321e040, old_top: 0x0321e040,
old_top_size: 0x00000000
malloc_extend_top: &sbrk_base: 0x0321e448, sbrk_base: 0xffffffff,
(char*)(-1): 0xffffffff
Destroy Hash Table: 0321eb18 table = (null)
Create Hash Table: N=67

/* the following is the debug output after the "reset" command" */
NDS32 # reset
mem_malloc_init: start: 0x03180000, size: 0x00080000

malloc: mem_malloc_start: 0x03180000,  mem_malloc_end: 0x03200000
bytes: 0x0000001d
is small request: nb: 40, idx: 5
malloc: remainder_size: -40, chunksize(top): 0, nb: 40
malloc_extend_top: old_end: 0x03180570, old_top: 0x03180570,
old_top_size: 0x00000000
malloc_extend_top: &sbrk_base: 0x0321e448, sbrk_base: 0x03180000,
(char*)(-1): 0xffffffff
malloc_extend_top: sbrk_size: 0x00000038
malloc: remainder_size: -40
himport_r: can't malloc 29 bytes
ERROR: Environment import failed: errno = 12




> Note that "reset" means a hard reset of the whole board, includine the
> CPU and all peripherals (similar to pressing a reset button, if there
> is one).
>
> Best regards,
>
> Wolfgang Denk
>
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> Insults are effective only where emotion is present.
>        -- Spock, "Who Mourns for Adonais?"  stardate 3468.1
>



-- 
Best regards,
Macpaul Lin


More information about the U-Boot mailing list