Locate Heap in SDRAM
Hello Franz,
you need to specify SDRAM memory in your linker file (here I am using a linker for STM32L476RGTx with 1M FLASH and 96K RAM)
/* Specify the memory areas */ MEMORY { FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1M RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K SDRAM(xrw) : ORIGIN = 0x????????, LENGTH = 8M }
And modify >RAM by >SDRAM
/* User_heap_stack section, used to check that there is enough RAM left */ ._user_heap_stack : { . = ALIGN(4); PROVIDE ( end = . ); PROVIDE ( _end = . ); . = . + _Min_Heap_Size; . = . + _Min_Stack_Size; . = ALIGN(4); } >SDRAM
Update:
Do not forget to initialize you SDRAM before your application starts !
It should be done in Reset Handler (in startup file) in assembly.
There are better solutions that writing in assembler
1- Start with the default STACK&HEAP location (RAM), initialize your SDRAM then switch to SDRAM as STACK&HEAP location
2- Separate Heap and stack locations (STACK in RAM and HEAP in SDRAM) in linker file, than initialize SDRAM in your main before any malloc usage