This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Malloc returns NULL

Setup

Keil: uVision 5.17.0.0
ARM: LPC1768
A standard project with some UARTS and I2C
"Use memory Layout form target" is checked (using the standard scatter file)
"Use MicroLIB" is not checked

from startup_LPC17xx.s
Heap_Size EQU 0x00002000

AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit

Problem
Any call to malloc returns NULL, that is, the system can not allocate memory.

Why does not the mallco work, is my only options to
1) Use microLIB
2) Implement _init_alloc() and __rt_heap_extend() on my own

?

Regards Stefan

Parents
  • Additional information

    I have even tried an own scatter file

    RW_IRAM_STACK 0x10000000 0x10002000 { ; RW data .ANY (STACK) }

    RW_IRAM1 0x10002000 0x10006000 { ; RW data .ANY (+RW +ZI) }

    RW_IRAM_HEAP 0x10006000 0x10008000 { ; RW data .ANY (HEAP) }

    But this does not work either

    It also seems that the code does not call the default generated code

    IMPORT __use_two_region_memory EXPORT __user_initial_stackheap
    __user_initial_stackheap

Reply
  • Additional information

    I have even tried an own scatter file

    RW_IRAM_STACK 0x10000000 0x10002000 { ; RW data .ANY (STACK) }

    RW_IRAM1 0x10002000 0x10006000 { ; RW data .ANY (+RW +ZI) }

    RW_IRAM_HEAP 0x10006000 0x10008000 { ; RW data .ANY (HEAP) }

    But this does not work either

    It also seems that the code does not call the default generated code

    IMPORT __use_two_region_memory EXPORT __user_initial_stackheap
    __user_initial_stackheap

Children