Sorry for newbie question, but today I met strange situation, which gave me a big kick to know more about STM32 stacks, heaps and how ChibiOS deals with all this. I had irqstack with size of 0x400, placed at start of RAM and everything was fine. But when I have moved it from start of memory, it was placed just after variables and before heap (linker's heap), and this was reason of some strange effects with my firmware. If I place irqstack at start of RAM or increase its size to 0x800 (just as a test) - problem disappeares. Wow, interrupts used more 1k of memory for stack? Hmm, but I do not know anything about how ChibiOS using interrupts, maybe OS uses interrupt stack for storing some bigdata from aliens..
So, ok, I have basic areas in my linker script, placed in RAM_region: IRQSTACK (0x400), DATABSS (variables lives here as I understand, with specific areas for threads, but I'm not sure if thread stacks lives here), HEAP (0x2000), SYSHEAP (without specific size settings, but actually set to size of 0 in map file), CSTACK (0x2000).
ChibiOS has its own heap and memory areas for threads, and I gave up here trying to understand which sizes I should set in linker script for different areas. I have read http://www.chibios.org/dokuwiki/doku.ph ... :kb:stacks, but I need some specific information for STM32 about how to set right sizes to this memory areas.
Can you help me and tell what lives in which areas in case of STM32 port?
Maybe some of this areas just not used with ChibiOS and can be set to zero (like not used SYSHEAP was set by linker)?
Maybe somewhere lives too much (like in IRQSTACK) and I should give more memory there?
Maybe some areas can be moved to CCMRAM (64k, not used at all) to increase memory available for OS heap?
Thank you in advance!
update: I have found another strange thing: increasing irqstack size not solves the problem, but shifts problematic effect to another, lower images, also I have following in MAP file:
Code: Select all
"P2-P4", part 1 of 2: 0x124c0
DATABSS 0x20000000 0x124c0 <Block>
DATABSS-1 0x20000000 0x40e <Init block>
SYSHEAP 0x200124c0 0x0 <Block>
SYSHEAP rw data 0x200124c0 0x0 cstartup.o 
- 0x200124c0 0x124c0
"P2-P4", part 2 of 2: 0x3000
IRQSTACK 0x200124c0 0x1000 <Block>
IRQSTACK uninit 0x200124c0 0x1000 <Block tail>
HEAP 0x200134c0 0x2000 <Block>
HEAP uninit 0x200134c0 0x2000 <Block tail>
- 0x200154c0 0x3000
__heap_base__ 0x200124c0 Data Gb cstartup.o 
__heap_end__ 0x2002e000 Data Gb cstartup.o 
So, ChibiOS initialized its heap at start of sysheap (which size is 0), and irqstack, located at same place. I wonder how it can work
But I still cannot understand which of these blocks should be used and which not.