Hi, I'm using FRDM-K64F dev board and I would like to use the the Heap for large array data allocation.
I tried suggested settings for heap and stack in PE (like changing heap and stack in the PEx CPU Build panel) with no compiling errors but failing debugging at run time.
I would like to configure the heap for using .data sections areas and allow malloc() to dynamically allocate arrays in this area.
I don't use any ROTS since I prefer bare metal configurations and programming with KDS and PEx without KSDK.
A user heap section specification like possible with FreeRTOS would be perfect but I don't know how to do it without.
Thank you for your help guys.
Hello Torquato,
Could you please show your configuration and code , and i will test on my side .
BR
Alice
Hi Alice.
Thanks for your the interest.
I kept the standard memory sections config.
I tried changing the in the Build Options settings panel:
the Heap amount from 0x0400 to upper values (0x0C00 or 0x1000) with no compiling and linking errors, but I have run time exceptions on isatty() call.
Following suggestions like described in Memory Areas and Using malloc() , I tried to configure linker with -WI switch but I think that symbol definition is different from the one I used. I found other suggestions like reported in compiler construction - use no heap in gnu gcc - Stack Overflow and others without achieving more heap.
I'm testing the available memory amount with this simple function
uint32_t GetAvailableMemory(void)
{
char *p;
uint32_t siz = 1;
p = calloc(1,siz);
while (p)
{
siz++;
p = realloc(p,siz);
}
free(p);
return siz;
}
At least I could follow tweaks like Allocation of Variables at Absolute Address in RAM - Cypress using static or global pre-allocation
but I would like not to change malloc()-like calls because I'm generating C-code from a Matlab algorithm.
The .ld Linker file obviously reflects the PE config for I ask to generate linker code.
Hello Torquato,
I test your code on my side , the realloc() function can work well, while i don/t know why you use while(p) , does here the "P"can repeated by some other
cycle conditons?
And i'm sorry that i don't know where you think is wrong , could your tell me ? and tell me the right situation you think ! thank !
BR
Alice