When we start declaring big global arrays, we quickly run out of internal memory on the HMI board. How do we control where the compiler allocates the variables (internal vs. external memory). Could you point to the documentation or an example? Thanks so much!
Kut
Hello Kut,
BSP defines few useful macros to control static memory allocation out of which, BSP_PLACE_IN_SECTION(x) is the most useful one (x is the memory section defined in your linker script, e.g. .sdram). This macro then resolves to GCC or IAR syntax depending on which toolchain you've set when creating a project.
Regards
Hi,
I've had the same problem awhile ago. Unfortunately, there are almost no documents including BSP_PLACE_IN_SECTION, let alone how to use it. Also changing .bss to sdram didn't help.
Here's what I have done to solve it. (This might work only for Synergy boards, I'm not sure at this moment)
Detect which variables need most RAM space. In my case, I had an array of 100k limit that would be do better in SDRAM.
Say your variable is:
float cQ;
This would normally be stored in RAM. RAM only has 640K for PE-HMI1 board. In order for this variable to be stored in SDRAM region or others you simply add the following next to the variable definition once.
float cQ __attribute__ ((aligned(64), section(".sdram")));
This is not something I came up with myself, but I found it using JPEG module.
Best
The BSP_PLACE_IN_SECTION macro works just fine, as long as you remember to put the dot before the section name i.e. BSP_PLACE_IN_SECTION(".sdram"). When creating custom sections, make sure they don't start with .data* as this will automatically default to .rodata section.
Alright, that works, too. Here's a sample for those who might have the same problem in the future:
float sampleVariable BSP_PLACE_IN_SECTION(".sdram");
Hello ChrisS,
I am not sure what can cause this error. Please try to use: __attribute__ ((section(".sdram"))) instead of the macro: BSP_PLACE_IN_SECTION(".sdram").
__attribute__ ((section(".sdram")))
BSP_PLACE_IN_SECTION(".sdram")
Best regards,anper
that's a good question. You can try to figure it out. The address of a variable can be found in e2 studio in the debug mode. To view the address you should run and then suspend the program and then hover the mouse cursor over the variable name in the code editor - a pop-up window will be displayed showing variable details. The same details can be viewed using the "Expressions" window:menu Window > Show View > Expressions
Then you can compare this address with data available in the "Memory Usage" window:menu Renesas Views > Debug > Memory UsageThere is the "Section" tab which shows address ranges for defined memory sections.
Please also refer to the documentation:S7G2 User's Manual > 4. Address Space
Hi ChrisS,
The heap can be placed in SDRAM by moving entry of script/S7G2.ld:
.heap (NOLOAD):{ . = ALIGN(8); KEEP(*(.heap_d1)) . = ALIGN(8); __HeapBase = .; __end__ = .; end = __end__; KEEP(*(.heap*)) __HeapLimit = .;} > RAM
.heap (NOLOAD):
{
. = ALIGN(8);
KEEP(*(.heap_d1))
__HeapBase = .;
__end__ = .;
end = __end__;
KEEP(*(.heap*))
__HeapLimit = .;
} > RAM
after
/* SDRAM */.sdram (NOLOAD):{ __SDRAM_Start = .; KEEP(*(.sdram*)) KEEP(*(.frame*)) __SDRAM_End = .;} > SDRAM
and changing the last line to "} > SDRAM":
.heap (NOLOAD):{ . = ALIGN(8); KEEP(*(.heap_d1)) . = ALIGN(8); __HeapBase = .; __end__ = .; end = __end__; KEEP(*(.heap*)) __HeapLimit = .;} > SDRAM
} > SDRAM
Regards,adboc