We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I'm playing around with scatter-loading in Keil 5.25 with armcc compiler. Now I have a dummy project that allocates stack and heap in 'default' startup assembly file:
Stack_Size EQU 0x00000400 AREA STACK, NOINIT, READWRITE, ALIGN=3 Stack_Mem SPACE Stack_Size __initial_sp ; <h> Heap Configuration ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> ; </h> Heap_Size EQU 0x00000200 AREA HEAP, NOINIT, READWRITE, ALIGN=3 __heap_base Heap_Mem SPACE Heap_Size __heap_limit PRESERVE8 THUMB
I'm trying to use scatter file to place stack and heap at some specific memory regions. I do it like this:
LR_IROM1 0x8000000 0x4000 { ; load region size_region ER_IROM1 0x8000000 0x4000 { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) } ARM_LIB_STACK 0x20000000 { *(STACK) } ARM_LIB_HEAP 0x20004000 { *(HEAP) } RW_IRAM1 0x20006000 { *(+RW +ZI) } }
And in main I call malloc to allocate some memory.
When I build the project, linker gives me this warning: "./dummy.sct(34): warning: L6329W: Pattern *(HEAP) only matches removed unused sections."
But I use malloc, so I should be using heap memory. In debugger I can see that memory that I allocated by malloc was already taken by some global variable, which I presume means that heap region is indeed removed by the linker.
But why is it happening? What am I doing wrong?
I was able to force linker not to remove heap by --keep option but I still want to know what is wrong.
Yes, apparently if I name my linker sections differently (i.e. won't use special Keil names) - it will place stack and heap as I need and no warning will be generated.