cancel
Showing results for 
Search instead for 
Did you mean: 

How to move stack and heap to CCM in IAR?

mandrake
Senior
Posted on March 07, 2017 at 05:00

How do I change the IAR linker in order to move the stack and heap to CCM? I am using STM32F407.

6 REPLIES 6
Posted on March 07, 2017 at 05:47

You'd want to modify the .ICF file, describing the CCM section, and placing the stack/heap into it.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on March 08, 2017 at 00:47

Thanks for the tip.

I added three lines:

define symbol CCM_start = 0x10000000;

define symbol CCM_end = 0x1000FFFF;

define region CCM_region = mem:[from CCM_start to CCM_end];

and edited one line:

place in CCM_region   { readwrite, block CSTACK, block HEAP };

Works like a charm.

Just curious. There is 64kB of contention-free SRAM sitting on the chip not being used.

Why didn't they default to this CCM in the first place?

Posted on March 08, 2017 at 08:24

On STM32F437 the link file is setup already to put the Stack in the CCM.

/* ♯ ♯ ♯ ICF ♯ ♯ ♯ Section handled by ICF editor, don't touch! ****/

/*-Editor annotation file-*/

/* IcfEditorFile='$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml' */

/*-Specials-*/

define symbol __ICFEDIT_intvec_start__ = 0x08000000;

/*-Memory Regions-*/

define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;

define symbol __ICFEDIT_region_ROM_end__ = 0x080FFFFF;

define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;

define symbol __ICFEDIT_region_RAM_end__ = 0x2001FFFF;

define symbol __ICFEDIT_region_CCMRAM_start__ = 0x10000000;

define symbol __ICFEDIT_region_CCMRAM_end__ = 0x1000FFFF;

/*-Sizes-*/

define symbol __ICFEDIT_size_cstack__ = 0x800;

define symbol __ICFEDIT_size_heap__ = 0x400;

/**** End of ICF editor section. ♯ ♯ ♯ ICF ♯ ♯ ♯ */

define memory mem with size = 4G;

define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];

define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];

define region CCMRAM_region = mem:[from __ICFEDIT_region_CCMRAM_start__ to __ICFEDIT_region_CCMRAM_end__];

define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };

define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };

initialize by copy { readwrite };

do not initialize { section .noinit };

place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };

place in ROM_region { readonly };

place in RAM_region { readwrite,

block CSTACK, block HEAP };
Khouloud GARSI
Lead II
Posted on March 08, 2017 at 09:32

Hi

Chin.Kenrick

‌,

Happy that you have solved your issue. However, I advise you to have a look at

http://www.st.com/content/ccc/resource/technical/document/application_note/bb/09/ca/83/14/e9/44/c5/DM00083pdf/files/DM00083pdf/jcr:content/translations/en.DM00083pdf

. This application note gives a presentation of the core coupled memory (CCM) RAM available on STM32F303xB/xC and STM32F358xC MCUs and describes what is required to execute part of the application code from this memory region using different toolchains.

The procedures described throughout the application note are applicable to other RAM regions such as the CCM data RAM of some F4 devices, or external SRAM.

Khouloud.

Posted on March 08, 2017 at 14:47

Interesting. They define CCMRam_region but it is not used.

Posted on March 08, 2017 at 14:54

Thanks for the link to AN4296. My primary reason to move the stack and heap to CCM is because I am experiencing memory contention with DMA on regular SRAM.

It would appear that moving both code and variables to CCM is not recommended as stated on the bottom of page 5 of AN4296.

'It is not recommended to place both code and data together in the CCM, since the Cortex core will have to fetch code and data from the same memory with the risk of collisions. The core would then be in the Von Neuman configuration, and its performance would drop from 1.25DMIPS/MHz to below 1DMIPS/MHz.'