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

Using external memory for the heap

I'm trying to configure a STR9 system to use an external memory device connected as Ext, MEM CS0 but I can't seam to get the malloc function to return a pointer to off chip memory. I have changed the standard STR91x.s to define Heap_Mem as 0x3C000000 and Heap_Size is set as normal. I have checked that the implementation of __user_initial_stackheap in the file is setting R0 and R2 to the correct values but when I look at a pointer returned by malloc it is at address 0x21770CB4. Does anyone know what I have missed?

  • A very simple solution is the following adaptation of the STR91x.s startup file:

    Replace

            AREA    HEAP, NOINIT, READWRITE, ALIGN=3
    


    with

            AREA    |.ARM.__AT_0x3C000000|, NOINIT, READWRITE, ALIGN=3
    

    Now Heap will be located at address 0x3C000000. No other changes are required except adjusting the Heap_Size.

  • Thanks for that again __user_initial_stackheap is setting the correct values but the malloc is returning an invalid pointer.

    I think I may have found the problem the __user_initial_stackheap function is being called before main is entered and the external memory is initialised in main. could it be that the library that calls the function initialises something in the heap area before main? which would fail as the interface isn't initialised.