In the linkfile I have
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
}
and
.ccmram :
{
. = ALIGN(4);
_sccmram = .; /* create a global symbol at ccmram start */
*(.ccmram)
*(.ccmram*)
. = ALIGN(4);
_eccmram = .; /* create a global symbol at ccmram end */
} >CCMRAM
and in the C source I have
#define CCMRAM __attribute__((section(".ccmram")))
CCMRAM uint8_t inbuf[PKT_BUF_LEN];
and yes this definitely works; chcked in the symbol list and in the memory usage.
Re the crash, it crashes in osKernelStart(); and it ends up here
and the stack backtrace shows
and this is where it does a stack test which fails
But I understand this is not something which can be debugged on a forum
I am posting it in case somebody has come across this before. The FreeRTOS memory management is complicated and I don't understand it (this project was started by someone else). AIUI the RTOS has various memory management options to suit different usage scenarios and AIUI in ours we give it a 48k heap (actually 32k now because the 48k overflowed the 128k RAM once that was brought down from the 192k bug
) and it then allocates the various thread stack requirements out of that. So you could have say 10 threads each with 3.2k of stack. Well, not quite; for some reason allocating more than ~2k to any thread bombs the system. Also the RTOS code probably assumes the initial stack (which continues to be used in main.c until the RTOS starts, and continues to be used by ISRs) sits in main RAM, so changing _estack = 0x20020000 (top of main 128k RAM) to _estack = 0x10010000 (top of CCM) falls over. Obviously using the heap in an embedded system is generally dumb (unless one always matches the malloc and free, but then why not just do it in a function and have the data on the stack, to be safely dumped when it returns) but in this case the malloc is done only once as each thread is initialised.
And definitely the linkfile calculation to warn if the heap reaches the bottom of the stack
fails. Once I get the SP in CCM running then I will try to fix that.
This is where I am now
I am generally familiar with text data and bss etc from countless previous projects (I go back to before macro-80) but the syntax here is pretty impenetrable at times.
Grateful as always to anyone with the patience to read this stuff