Has anyone been successful in setting up the Keil tools and changing the Startup.s file to place the heap in external location (on SD/MMC Card or off-chip memory)?
The only reason that I want to use external memory is because I am using a library for the file system that needs to dynamically allocate space. The amount of space it needs to allocate is more than I have in internal memory.
Iam working on LPC2378 with keil uvision4.
Any help will be appreciated. Thanks in advance
Isn't your RAM is 32k + 16k + 8k + 2k if you don't need the extra RAM regions for other things?
If you need more RAM, your only option is to get more RAM. Either a chip with more RAM, or - as the LPC2378 have support for two external 64kB memory regions - add external RAM.
But the compiler expects RAM to be that Random Access Memory. In this case, the compiler requires the addresses to be directly accessible. That isn't true with any serially connected memory.
The other option is to check closer what you need and what you really do with your RAM. Maybe you have things in RAM that could have been in flash as const data. Maybe you have things in RAM that could be stored on the SD memory card and only read in when needed. Maybe you have too large buffers. Or too many buffers.
Thanks Per and Andrew for ur valuable suggestions. Yes my RAM is 32k + 16k + 8k + 2k where in which 32K is for SRAM and remaining for USB, Ethernet etc., As of now in my application, in the Options for Target, my IRAM1 start is 0x40000000 and size is 0x8000. How can I make use of the additional RAM?
Also how to configure external RAM in my application? What settings I need to make?
Thanks in advance
If you turn on the power to the Ethernet device, then you can open your project settings and add the start address and size of the 16kB Ethernet RAM as second memory region.
If you make use of the scatter file, you can add the start address and size of the USB RAM too (but remember to turn on the power) and if you have power supplied to the VBAT pin you can add the 2kB of battery-backed RAM to the scatter file too.
Adding the individual RAM regions to the project is only needed if you want the compiler/linker to be able to place variables in these memory regions. It's possible to place a stack or a heap or large buffers in these memory regions without specifying the memory region in scatter file or project file. This can be done using either absolutely located variables or by using pointers. Just note that if the startup file doesn't know about the extra RAM regions, then they will not be zero-initialized when your program boots. On the other hand, you normally don't want the battery-backed RAM to be zero-initialized on every reboot since that destroys the usefulness of having a backup battery.
One thing to remember is that the extra memory regions do have some limitations when it comes to DMA transfers, ISP for reprogramming the flash or for code execution from RAM.
Thanks Per
It's possible to place a stack or a heap or large buffers in these memory regions without specifying the memory region in scatter file or project file.
Can you please explain me a little bit more about how can we acheive this one?
You probably have something similar to:
; <h> Heap Configuration ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> ; </h> Heap_Size EQU 0x00000000 AREA HEAP, NOINIT, READWRITE, ALIGN=3 __heap_base Heap_Mem SPACE Heap_Size __heap_limit
in your startup file. You can explicitly control where HEAP should be located. Or you can just add more memory regions to the project and have the linker figure out where there are free space to store the HEAP.