cancel
Showing results for 
Search instead for 
Did you mean: 

Malloc to SD-Ram

MMett
Associate III

I am using a STM32 Discovery Board with external SD Ram. I used the memory in RAM so far by creating a Ponter in the SD-Ram address area.

But now my program is getting more and more complex and I could use a memory manager. Can I use the Malloc, Calloc and Free functions to allocate data in the SD Ram address range if I wish?

2 REPLIES 2

Yes, in GNU/GCC you'll likely need to fix the allocator in syscalls.c so that _sbrk understands the memory region, and that you can't use the stack as the top-of-heap limit.

Don't use SDRAM for the stack, it is relatively slower memory, and will cause a performance drag on everything.

In Keil, you'll what to direct the heap into the SDRAM section, but also want to initialize the SDRAM in SystemInit() so that it is functional when the C runtime code initializes the statics, etc.

You might want to consider multiple memory pools, as some memory is faster than others, some memory is suitable for DMA while others aren't.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
MMett
Associate III

There's a lot that's new to me. I use the GCC. I was looking for "syscalls" or "_sbrk" in my project. I only found a few files from the µOS++ distribution which are not used. How do I get on with the problem? What do I have to search for?