stm32f429I-DISC1: mbed use sdram as heap

Sysprogs forums Forums VisualGDB stm32f429I-DISC1: mbed use sdram as heap

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #11566
    krid
    Participant

    Hello,

    target: stm32f429I-DISC1

    How can I use the SDRAM as heap?

    First I initialized the SDRAM stting GPIOs, fmc, clock… -> SDRAM accessable, fine.
    Next I modified the linker script and enabled a SDRAM memory section and moved the heap into SDRAM

    SDRAM (rwx) : ORIGIN = 0xD0000000, LENGTH = 8M
        .heap (NOLOAD):
        {
            __uvisor_heap_start = .;
            __end__ = .;
            end = __end__;
            . += HEAP_SIZE;
            __HeapLimit = .;
            __uvisor_heap_end = .;
        } > SDRAM
    On project build I get the ASSERT-error "Region RAM overflowed with stack and heap".

    I commented that out. No need for testing.

    If I now allocate memory by using “new” I get until _sbrk in mbed_retarget.cpp which fetches a valid pointer from SDRAM:

        static unsigned char* heap = (unsigned char*)&__end__;
        unsigned char*        prev_heap = heap;
        unsigned char*        new_heap = heap + incr;

    but compares it to the MSP

    if (new_heap >= (unsigned char*)__get_MSP()) {

    and then gives ENOMEM

    errno = ENOMEM;
     return (caddr_t)-1;
     }

    because new_heap (0xD0nnnnnn) is greater than MSP (0x200mmmmm).

     

    Do I really have to implement my own _sbrk syscall in order to put the HEAP onto the SDRAM?

     

    Thanks

    best regards

    dirk

    • This topic was modified 7 years, 6 months ago by krid.
    #11572
    support
    Keymaster

    Hi,

    You could try using the _sbrk() implementation that comes from our “Fixed-size stack and heap” framework described in this tutorial: https://visualgdb.com/tutorials/arm/stack/

    You would need to modify the linker script to place the “.heap” section into SDRAM and explicitly set the heap size via VisualGDB Project Properties.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.