cancel
Showing results for 
Search instead for 
Did you mean: 

How to use CCM RAM within STM32 microcontroller for functions and variables

Mootaz Amr
Associate II
Posted on March 24, 2017 at 18:33

Hi STM32 lovers.

I am currently using a STM32F429 �C in my project.

I would like to use the 64kB CCM memory for placing some buffers (Not accessed by peripherals and DMA) and some critical functions (ISR functions that need to run very fast).

I am lost with the �mysterious� GNU Linker file, I tried my best and succeeded to place some variables (even initialized) using the attribute GCC command and the startup code.

Using the modified linker script attached (sections.ld) and t

he memory file (.mem) file and the makefile, the compiler outputs a 384MB .bin file, of course will not fit the 2MB �C�s Flash.

I travelled all around forums and tutorials, followed the most famous ones:

Application note AN4296 :

http://www.st.com/resource/en/application_note/dm00083249.pdf

From analog Devices forum:

https://l.facebook.com/l.php?u=https%3A%2F%2Fez.analog.com%2Fthread%2F10607&h=ATO9qAIqK8blFdIK7E-UOAKRcok--2gR3fyfe4EHXTEkhiDcQvkj0VCrrRbc1VUZfaTb9UIvG-Un_HiYsrixhJlOR6ogtkTCXELeM4SxhyoGFs-dhIydLmjauhI3oPobxbkG9Qe_S1TAkHJc_w&enc=AZN39kcBTXtajIQNQa0EWCZrAoaun5YQJ71v9USwWMgpgy6NiLoEWEwxU5aEEkREKXdr3aY...

But in vain !

Could anyone say what I did wrong, what is missing ? How should the script file be edited ?

#stm32-stm32f4-ccm-linker-section
4 REPLIES 4
S.Ma
Principal
Posted on March 25, 2017 at 17:28

If the linker file already put the stack in the CCM, maybe creating a big array inside the main() will automatically put it with no effort in the CCM. For putting code in the CCM, this might be tricky as the code should be generated for the CCM memory space, backed up in the flash, copied in the CCM at the beginning of main() or startup...

Rob.Riggs
Senior III
Posted on March 25, 2017 at 21:45

I use GCC.  I followed the steps outlined in AN4296 and it worked for me.  Section 4 explains all of the steps needed.

You don't need to completely understand the linker script syntax, just follow the steps as outlined.  It will work.  Look at the map file in order to see what addresses each symbol is placed.

You should see something like this (I used the name .bss2 instead of .ccmram):

.bss2  0x0000000010000000 0x3580 load address 0x000000000801d058

      0x0000000010000000 . = ALIGN (0x4)

      0x0000000010000000 _sbss2 = .

*(.bss2)

.bss2 0x0000000010000000 0x3f8 Drivers/CMSIS/Lib/Source/FilteringFunctions/arm_fir_f32.o

       0x0000000010000000 arm_fir_f32
Posted on March 26, 2017 at 22:10

Hi riggs.rob, Thanks for your engagement

Could you please upload your linker file (where .bss2 is stated), so I can view a working linker file.

My original script file (from where I started modifying it) doesn't have

.data { .......

} >RAM AT>FLASH

as the AN4296 show, but instead 

.data : AT ( _sidata ) { 

.......

} >RAM

So It seems that I have to modify further the linker rather than just adding what is in the red box, and 

I don't know if I should also change .data to >RAM AT>FLASH ?

I would be grateful

Posted on March 27, 2017 at 00:02

https://gist.github.com/mobilinkd/2eeea5d783c33a4e334d652402e6abad

 

This should get you going.