cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 using CCM data RAM for STACK and HEAP

JBond.1
Senior

Hi, I have STM32F407VET6 which has such memory layout.

0693W00000YA0E4QAL.png

As I understand CCM data RAM is unused by default and just waits to be used? So can I move STACK and HEAP to it? How do I move it? (I did not find defined STACK address anywhere in KEIL project)

Is there anything else I could use CCM for?

1 ACCEPTED SOLUTION

Accepted Solutions

In 'F4, I personally place both stack and all "normal" data (.data, .bss) into CCM. Into SRAM I then place communication buffers and other "large" structures (e.g. DMA can't work with CCM), so only those need to be tagged. I guess heap would fall into this "large" cathegory, except I refrain from using dynamic allocation in microcontrollers.

I don't use Keil so can't help with the particularities, but I am sure the manual to compiler/IDE explains how to locate the variables (IIRC Keil calls the linker script "scatter file" so that might be a starting point to search).

JW

View solution in original post

3 REPLIES 3

In 'F4, I personally place both stack and all "normal" data (.data, .bss) into CCM. Into SRAM I then place communication buffers and other "large" structures (e.g. DMA can't work with CCM), so only those need to be tagged. I guess heap would fall into this "large" cathegory, except I refrain from using dynamic allocation in microcontrollers.

I don't use Keil so can't help with the particularities, but I am sure the manual to compiler/IDE explains how to locate the variables (IIRC Keil calls the linker script "scatter file" so that might be a starting point to search).

JW

JBond.1
Senior

I found how to do it in KEIL. Need to go to:
Options for target 'project name' -> Linker -> uncheck Use Memory Layout from Target Dialog.
After that its possible to edit "Scatter file" in same window. In it I have added:

 

RW_IRAM3 0x10000000 0x00010000  {  ; CCM data
   .ANY (CCM_DATA)
   startup_stm32f407xx.o (STACK)
   startup_stm32f407xx.o (HEAP)
  }

 

But I guess your approach is better to place everything to CCM and only large buffers, DMA buffers to SRAM.

 

Do you mean like this:

 

; *************************************************************
; ***     Scatter-Loading Description File for STM32F4      ***
; *************************************************************

LR_IROM1 0x08004000 0x0007C000  {    ; load region size_region
  ER_IROM1 0x08004000 0x0007C000  {  ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
   .ANY (+XO)
  }
  RW_IRAM1 0x20000000 0x0001C000  {  ; RW data
   .ANY (SRAM)
   ;.ANY (+RW +ZI)
  }
  RW_IRAM2 0x2001C000 0x00004000  {
   .ANY (SRAM2)
   ;.ANY (+RW +ZI)
  }
  RW_IRAM3 0x10000000 0x00010000  {  ; CCM data
   .ANY (+RW +ZI)
   startup_stm32f407xx.o (STACK)
   startup_stm32f407xx.o (HEAP)
  }
}

 

"+RW +ZI, STACK, HEAP" - in CCM?
"+RW +ZI" is so called "normal" data (.data, .bss)?

And then lange buffers
static uint8_t Cache[CACHE_SIZE] __attribute__ ((section("SRAM")));
?