cancel
Showing results for 
Search instead for 
Did you mean: 

STM3240G-EVAL & SRAM

mailmail9116
Associate II
Posted on January 03, 2013 at 20:25

Hi.

I know that the evaluation board have ~192k of ram , and 16mbit of external RAM,

my question is how can i use the 16mbit of RAM,how do i ''tag'' variables to be allocated on the external RAM ?

Thanks

Michael
10 REPLIES 10
Posted on January 03, 2013 at 20:52

I know that the evaluation board have ~192k of ram , and 16mbit of external RAM,

 

my question is how can i use the 16mbit of RAM,how do i ''tag'' variables to be allocated on the external RAM ?

You'd define the region within your linker script or scatter file. Define sections which fall in those regions, and then use compiler specific directives or #pragma to direct data/code into those sections. A review of your tool chain documentation, and examples from this and other platform will also provide some perspective.

Alternatively you could implement your own dynamic allocations (malloc/realloc/free) against the external memory. Generally you'd want to use the internal memory for speed critical data and structures.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
mailmail9116
Associate II
Posted on January 04, 2013 at 08:39

Hi Clive,

First of all i want to thank you for your great support ! I tried to do what you said following the next tutorial : http://www.atollic.com/index.php/kb/1-kb_building/58-kb_create_a-new_memory_region_and_place_code_there in the linker script i added the following :

1.
MEMORY
2.
{
3.
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
4.
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
5.
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
6.
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
7.
ExtRAM (rw) : ORIGIN = 0x64080000, LENGTH = 2M 
/*This is what i added */
8.
}

Then little down below i added this :


.data : 

{

. = ALIGN(4);

_sdata = .; 
/* create a global symbol at data start */

*(.data) 
/* .data sections */

*(.data*) 
/* .data* sections */


. = ALIGN(4);

_edata = .; 
/* define a global symbol at data end */

} >RAM AT> FLASH


.extram : 
/* This is what i added */

{

*(.Extram*);

} > ExtRAM

And in my source code i did the following :

1.
__attribute__((section(
''.Extram''
))) 
char
* buffer;

But when trying to allocate the array , i am still getting a fault . Any ideas about what i am doing wrong ? Thanks Michael
mailmail9116
Associate II
Posted on January 04, 2013 at 08:48

Also when looking in the map file i see that the variable created in the correct section :

.extram 0x64080000 0xc
*(.Extram*)
.Extram 0x64080000 0xc src\TinyXML\tinyxml.o
0x64080000 buffer
0x080585e0 _siccmram = LOADADDR (.ccmram)

Thanks Michael
infoinfo980
Associate II
Posted on January 04, 2013 at 17:23

Any ideas about what i am doing wrong ?

Have you set up the FSMC to provide access to the external SRAM? If so, please post your FSMC initialisation code.
Posted on January 04, 2013 at 17:57

The initialization for the specified board can be found here.

STM32F4xx_DSP_StdPeriph_Lib_V1.0.0\Project\STM32F4xx_StdPeriph_Examples\FSMC\SRAM_DataMemory\system_stm32f4xx.c One needs to ensure that SystemInit() configures the memory. /*!< Uncomment the following line if you need to use external SRAM mounted on STM324xG_EVAL board as data memory */ #define DATA_IN_ExtSRAM See also, where the base of EXTRAM is

0x64000000

STM32F4xx_DSP_StdPeriph_Lib_V1.0.0\Project\STM32F4xx_StdPeriph_Templates\TrueSTUDIO\stm32f4xx_flash_extsram.ld

..
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
RAM (xrw) : ORIGIN = 0x64000000, LENGTH = 2048K
CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
}
..

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
mailmail9116
Associate II
Posted on January 04, 2013 at 18:25

Hi,

Yes I forgot to initialize the FSMC ,its now working when i declare a variable.

but when i try to do malloc/new it failes,i suspect that malloc/new does not do the allocation in the correct address,am i correct?

Thanks

Michael

mailmail9116
Associate II
Posted on January 05, 2013 at 14:11

Hi ,

I just want to be sure,do i need to re-implement malloc ?,because as far as i see,that even if i declare the pointer in the external ram area,when calling malloc/new ,it still tries to allocate it in the internal RAM

Thanks

Michael

mailmail9116
Associate II
Posted on January 05, 2013 at 14:11

Hi ,

I just want to be sure,do i need to re-implement malloc ?,because as far as i see,that even if i declare the pointer in the external ram area,when calling malloc/new ,it still tries to allocate it in the internal RAM

Thanks

Michael

Posted on January 05, 2013 at 19:31

Well it depends, I'm not too familiar with Atollic's allocator, I would suspect you can park the heap in any region you want, but how to configure that will depend on how the library/syscalls handle it.

Allocating from two regions may require some additional work.

Embedded generally use dynamic allocation in a different way than you would on a PC, as running out and fragmenting the heap can be fatal. Some embedded allocators use a pool of fixed size resources to combat the fragmentation issues. Most embedded stuff uses static allocation to ensure resources are committed/available, and transient requirements uses the stack.

Would suggest you skim though the library code and see if the allocator source is available, and then look at if it is table driven, and how it is initialized. Other allocators which work with GNU might well be a quick internet search away.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..