Allocating dynamic memory in External SDRAM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Allocating dynamic memory in External SDRAM

2,114 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nils28 on Thu Jan 09 09:53:03 MST 2014
Hi!

I'm using LPC4337 near to a SDRAM. I would like to use this SDRAM for my memory allocation.

Is there a way to tell to calloc and malloc functions to allocate memory space in SDRAM instead of Internal RAM ?

Thanks a lot for your answer.

Labels (1)
0 Kudos
5 Replies

1,223 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bavarian on Mon Jan 13 08:31:16 MST 2014
Both ways are valid somehow.

For the malloc library functions the heap is used, the location of the heap can be defined in the linker script.

Look here in the section "Linker script template":  http://support.code-red-tech.com/CodeRedWiki/EnhancedManagedLinkScripts

Either you provide directly an address like 0x28000000 or a symbol like .SDRAM0 which you defined with the memory editor.

For any buffers or structures or parameters you want to place in SDRAM you can use the other method, providing in the memory editor a section name for the SDRAM (Edit --> Add RAM) and work with "__attribute__ ((section("..."))" .

If you place anything in SDRAM then you need to take care that the SDRAM is set up before it is used. This means you need to do it at a very early stage, before any access to the SDRAM is made to e.g. zero-initialize data.

Regards,
NXP Support Team
0 Kudos

1,223 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Mon Jan 13 07:57:16 MST 2014
I would suggest taking a look at these two FAQs…

http://www.lpcware.com/content/faq/lpcxpresso/linker-script-templates
http://www.lpcware.com/content/faq/lpcxpresso/heap-checking-redlib

Regards,
LPCXpresso Support

0 Kudos

1,223 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nils28 on Mon Jan 13 06:50:13 MST 2014
I'm using LPCXpresso then I use GCC, I think.
Do I have to create a new memory section located at address 0x28000000 in MCU Settings and use
"__attribute__ ((section("..."))" keyword for each memory pointer defined ? Or as goffi  said simple use  "PROVIDE(_pvHeapStart = 0x2800000);" in my linker script is enough?

thanks
0 Kudos

1,223 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by goffi on Mon Jan 13 04:59:56 MST 2014
In your linker configuration, put the heap at the dram address. All the malloc/calloc will reserve a block from that memory  (remember to initialize the dram with the right values before use it!)
0 Kudos

1,223 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bavarian on Mon Jan 13 01:21:32 MST 2014
Simply tell the linker that this is an available memory for allocation.
In case you want to partition the available memory in the system do different jobs, e.g. parameters in internal SRAM and buffers in external SDRAM, then you need to use specific keywords when you declare the buffers, so that the linker knows that you want to have them in a specific memory section. This heavily depends on the toolchain you use (Keil, IAR, GCC).

Best regards,
NXP Support Team
0 Kudos