Hi Scott
After looking into this issue, we have found the problem:
First of all, you need to defined your _estack as CW have it in default:
_estack = 0x20000000;
__SP_INIT = _estack;
Now, you need to defined the stack and heap separated, one in m_data and the other onne in m_data_20000000, so you can define:
._user_stack :
{
. = ALIGN(4);
. = . + __stack_size;
. = ALIGN(4);
} > m_data
._user_heap :
{
. = ALIGN(4);
PROVIDE ( end = . );
PROVIDE ( _end = . );
__heap_addr = .;
. = . + __heap_size;
. = ALIGN(4);
} > m_data_20000000
Now, the problem here is that malloc function uses sbrk fucntion, which verify that your heap is no bigger than stack, because it guess that you going to keep both in the same memory. So you need to redefine this function in your main.c file with your custom use, in this case I comment the lines that verify this:
void *sbrk ( uint32_t delta )
{
extern char _end;
static char *heap_end;
char *prev_heap_end;
if (heap_end == 0) {
heap_end = &_end;
}
prev_heap_end = heap_end;
heap_end += delta;
return (void *) prev_heap_end;
}
And with all this change then you can realocate your heap in 20000000 and up, and keep your stack in 20000000 and down.
Hope this information helps you
Have a great day,
Jorge Alcala
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------