heap - Why does malloc only work immediately after flashing cortex-m3? -


i'm trying dynamically allocate memory using newlib's malloc running on cortex-m3 (bare-metal) , i've run perplexing problem. after flashing device, malloc , free both work expected. however, once reset device malloc returns null. else works except malloc. hints on cause kind of behaviour?

here linker script:

memory {     flash (rx) : origin = 0x00000000, length = 512k     sram (rwx) : origin = 0x10000000, length = 32k }  /* section definitions */ sections {    .text :   {     keep(*(.isr_vector .isr_vector.*))     *(.text .text.*)     *(.gnu.linkonce.t.*)     *(.glue_7)     *(.glue_7t)     *(.gcc_except_table)     *(.rodata .rodata*)     *(.gnu.linkonce.r.*)     _etext = .;   } > flash    __exidx_start = .;   .arm.exidx   : { *(.arm.exidx* .gnu.linkonce.armexidx.*) } > flash   __exidx_end = .;    /*.data : @ (_etext)*/   .data : @ (__exidx_end)   {     _data = .;     *(vtable vtable.*)     *(.data .data.*)     *(.gnu.linkonce.d*)     . = align(4);     _edata = . ;   } > sram    /* .bss section used uninitialized data */   .bss (noload) :   {     _bss = . ;     *(.bss .bss.*)     *(.gnu.linkonce.b*)     *(common)     . = align(4);     _ebss = . ;   } > sram    .stackarea (noload) :   {     . = align(8);     *(.stackarea .stackarea.*)     . = align(8);   } > sram    . = align(4);   _end = . ;   provide (end = .);  } 

and memory map:

.stackarea      0x10000d3c        0x4                 0x10000d40                . = align (0x8)  *fill*         0x10000d3c        0x4 00  *(.stackarea .stackarea.*)                 0x10000d40                . = align (0x8)                 0x10000d40                . = align (0x4)                 0x10000d40                _end = .                 0x10000d40                provide (end, .) 

when malloc succeeds, starts allocating @ 0x10000d48.

i'm not quite sure how works on cortext-m3, did have memory management issues on rx62n awhile back. in end, decided own memory management creating large heap , allocate memory through own api functions. used simple linked list memory management. way, can guarantee it'll work every time on board , code :)

hope helps :) cheers!


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -