cancel
Showing results for 
Search instead for 
Did you mean: 

Locate Heap in SDRAM / System Workbench for STM32

franz2399
Associate II
Posted on February 08, 2016 at 13:53

Hello,

I

want to

locate heap in SDRAM. I found some Keil samples, but ...

SDRAM adress is 0xD0000000, size 8M.

Thanks a lot

#sdram #openstm32 #heap
6 REPLIES 6
Radosław
Senior II
Posted on February 08, 2016 at 15:21

Add SDRAM region

and edit 

  /* User_heap_stack section, used to check that there is enough RAM left */

  ._user_heap_stack :

  {

    . = ALIGN(8);

    PROVIDE ( end = . );

    PROVIDE ( _end = . );

    . = . + _Min_Heap_Size;

    . = . + _Min_Stack_Size;

    . = ALIGN(8);

  } >RAM

this.   If only heap you want into SDRAM split this section.

 

Posted on February 08, 2016 at 18:50

Be conscious that SDRAM is the slowest memory available to you, and you might only want to use it for large allocations that won't fit in the internal memories.

Look at the allocator in the newlib/stub file(s)
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
franz2399
Associate II
Posted on February 09, 2016 at 20:32

First - thank you very much!

Yes I want only heap into SDRAM (the heap can use the whole SDRAM), but how can I split this? Sorry but I am not very familiar with linker scripts

Radosław
Senior II
Posted on February 09, 2016 at 21:41

Why you don't read GCC docimentation?

  ._user_heap_stack :

  {

    . = ALIGN(8);

    PROVIDE ( end = . );

    PROVIDE ( _end = . );

    . = . + _Min_Heap_Size;   /// stack

    . = . + _Min_Stack_Size;  /// heap

    . = ALIGN(8);

  } >RAM

''.''  dot means address, be notice that end and other symbol must be corect for syscalls.

AC6 linker script is ugly.   

franz2399
Associate II
Posted on February 16, 2016 at 15:23

Attached the final code with all modifications

________________

Attachments :

code.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0vt&d=%2Fa%2F0X0000000biL%2FV7ne155SGoLFg3Gh2XEMIGuD4WSFfhHHw3QSLSgjC1c&asPdf=false
Danish1
Lead II
Posted on February 16, 2016 at 16:39

Also be aware that some stm32 had FMC errata items which could cause corruption of data read from it. For example stm32f437 revision ''A''.

  1. 2.9.4  Corruption of data read from the FMC

    Description

    When the FMC is used as stack, heap or variable data, an interrupt occurring during a CPU read access to the FMC may results in read data corruption or hard fault exception. This problem does not occur when read accesses are performed by another master or when FMC accesses are done when the interrupts are disabled. 

Workaround

Two workarounds can be applied:

  • Do not use the FMC as stack or heap, and make sure CPU read accesses to the FMC are performed while interrupts are disabled

  • Use only DMAs to perform read accesses to the FMC.

    This limitation is present only in revision “Aâ€� devices. It is fixed in revision “Yâ€�, “1â€� and “3â€�. 
Do check which revision of processor you have on your board(s) and whether it suffers from such an errata item.

Hope this helps,

Danish