2023-10-07 10:28 PM - edited 2023-10-07 10:34 PM
Hi, I have STM32F407VET6 which has such memory layout.
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?
Solved! Go to Solution.
2023-10-08 02:03 AM - edited 2023-10-08 02:04 AM
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
2023-10-08 02:03 AM - edited 2023-10-08 02:04 AM
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
2023-10-08 03:49 AM - edited 2023-10-08 03:53 AM
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.
2023-10-08 06:08 AM - edited 2023-10-08 06:10 AM
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")));
?