Using CCM on stm32f4xx for stacks under Keil/RVCT
Moderators: RoccoMarco, lbednarz, tfAteba
-
fallentemplar
- Posts: 6
- Joined: Tue Nov 06, 2012 8:53 pm
Using CCM on stm32f4xx for stacks under Keil/RVCT
Hi,
Was just wondering how to use CCM memory for process stack memory under Keil/RVCT, for GCC there is a nice linker script example in "/os/ports/GCC/ARMCMx/STM32F4xx/ld/STM32F407xG_CCM.ld" but none for Keil...
Was just wondering how to use CCM memory for process stack memory under Keil/RVCT, for GCC there is a nice linker script example in "/os/ports/GCC/ARMCMx/STM32F4xx/ld/STM32F407xG_CCM.ld" but none for Keil...
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Using CCM on stm32f4xx for stacks under Keil/RVCT
Hi,
I use the 32K-limited version, this version does not support scatter files so I can't do it the same way it is done with GCC. You could define the CCM memory as RAM1 in the project options and then change cstartup.s in order to allocate stacks in that region.
Giovanni
I use the 32K-limited version, this version does not support scatter files so I can't do it the same way it is done with GCC. You could define the CCM memory as RAM1 in the project options and then change cstartup.s in order to allocate stacks in that region.
Giovanni
-
fallentemplar
- Posts: 6
- Joined: Tue Nov 06, 2012 8:53 pm
Re: Using CCM on stm32f4xx for stacks under Keil/RVCT
Thanks, I might just try the Chibi-Eclipse, found the Keil editor to be horrible...
On another note:
What do I need to modify in cstart.s to shift the stack to CCM?
On another note:
What do I need to modify in cstart.s to shift the stack to CCM?
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Using CCM on stm32f4xx for stacks under Keil/RVCT
I should find details in manuals but I think it would just require to change the "AREA" directives before the stack declarations.
Giovanni
Giovanni
Re: Using CCM on stm32f4xx for stacks under Keil/RVCT
Remember that you can't DMA to/from the CCM (CPU coupled memory for those wondering), you must be VERY careful about what you use that memory for, particularly when using system drivers.
In order to keep a tight control on what's being placed there, what I've done is turned it into a heap and I explicitly allocate chunks of memory from it when I know there's no chance I'll be using DMA on them:
Hope it helps.
In order to keep a tight control on what's being placed there, what I've done is turned it into a heap and I explicitly allocate chunks of memory from it when I know there's no chance I'll be using DMA on them:
Code: Select all
MemoryHeap ccm_heap;
chHeapInit(&ccm_heap, (void *)0x10000000, 0x10000);
Hope it helps.
-
fallentemplar
- Posts: 6
- Joined: Tue Nov 06, 2012 8:53 pm
Re: Using CCM on stm32f4xx for stacks under Keil/RVCT
Thanks! Heapmemory did the trick, the odd thing is that events are not working (hard fault ) when I place the child process into CCM. Events work when I use static allocation onto the main RAM.
Would I have to place the main process stack onto CCM also? I tried that, didn't seem to help.
Would I have to place the main process stack onto CCM also? I tried that, didn't seem to help.
Re: Using CCM on stm32f4xx for stacks under Keil/RVCT
Sorry, I have no idea why events don't work in CCM (I'm not using them). As far as I know the only limitation of the CCM is that you can't DMA to/from it (that includes the internal DMA modules in the USB and ethernet peripherals).
Double check that you're not using DMA on CCM. It may not be evident, for example, just a chprintf to a serial port may end un sending data to the USART via DMA.
Rgds.
Double check that you're not using DMA on CCM. It may not be evident, for example, just a chprintf to a serial port may end un sending data to the USART via DMA.
Rgds.
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Using CCM on stm32f4xx for stacks under Keil/RVCT
The serial driver does not use DMA and I think events are unrelated to CCM, there must be something else, probably a small error somewhere.
Giovanni
Giovanni
-
fallentemplar
- Posts: 6
- Joined: Tue Nov 06, 2012 8:53 pm
Re: Using CCM on stm32f4xx for stacks under Keil/RVCT
Checked, and found something pretty odd.
I have my ADC IRQ handler:
Using this code snippet, the system would hard fault when a process is created, (the IRQ is not even called), just set up to be called.
But if I insert a return into the last line of the hander, everything goes well:
I can enter a return anywhere in the IRQ and things will go well, if I take out the return, hardfault during process creation.
This is all when I use the CCM, when the thread is created in the 128k memory region, this problem does not occur...
I have my ADC IRQ handler:
Code: Select all
CH_IRQ_HANDLER(ADC_HANDLER)
{
<blocks of code>
}
Using this code snippet, the system would hard fault when a process is created, (the IRQ is not even called), just set up to be called.
But if I insert a return into the last line of the hander, everything goes well:
Code: Select all
CH_IRQ_HANDLER(ADC_HANDLER)
{
<blocks of code>
return;
}
I can enter a return anywhere in the IRQ and things will go well, if I take out the return, hardfault during process creation.
This is all when I use the CCM, when the thread is created in the 128k memory region, this problem does not occur...
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Using CCM on stm32f4xx for stacks under Keil/RVCT
Hard to tell without looking at the code, IRQ handlers are not related to threads creation in any meaningful way, it must be the code inside.
Giovanni
Giovanni