This might be a bit long, but it describes a problem I’ve been having.
Environment STM32L562VETQ processor: ARM, 512K Flash, 256K RAM, V 10.3.1. C++ overlay on basic HAL drivers (in C). C++ overlay is the major driver calling C low level routines where needed.
Additional memory added and memory mapped to processor address space.
Routines include graphics (writes to virtual memory screen and then updates display), SPI support, I2C support, Serial support, NRF24L01 mesh networking. It’s a complicated system.
Heap4 memory used and mapped to additional memory. (256K allocated, which is the maximum, why?).
Routines and memory are allocated, but never released. Buffers and drivers are created with “new” which has been made thread safe as a malloc wrapper. Arrays are directly created as normal.
My problem (at the moment, which I worked around) is that I increased the size of an array by adding a few integer elements, and the array initialization wiped out a driver created by “new”.
FreeRTOS did not make any comments about the stack being overrun. That doesn’t help, nor do I see any routines that might help diagnose the problem, not in FreeRTOS.
So that’s an indicator of difficulty, even though FreeRTOS may not be the tool to solve it.
I worked around this by writing my own memory manager (somewhat similar to heap4 in concept) that pointed to an unused area (256K bytes) of additional memory, and using it to store some of the larger arrays. This, and resizing the heap memory for particular tasks seems to have worked.
So essentially two things, at least.
- Does FreeRTOS have any tools that would help? I already asked for a modification to the malloc failed hook that would provide how much was asked for (we don’t always know) and by how much we failed. This proves very useful in adjusting stack sizes. From what your documentation says (and I believe it), that’s one of the major difficulties in trimming any FreeRTOS system.
- If FreeRTOS had an additional memory manager, or at least allowed two of them, then in this case at least, I would not have had to write my own. I know that heap5 manages two separate memory regions as one, and that would not be a problem except for:
A) is the same 256K memory limit still extant? Ends up with the same problem as heap4.
B) it needs to manage a separate area where FreeRTOS stacks cannot overrun existing
data, in fact, the separate memory manager guarantees it.
C) Note that there were NO stack overflows at all, and the Malloc overflow hook did not
trip.
For all I know, this is a C++ and C problem, but as far as I can tell, shouldn’t do this.
I’ve worked around this, but I’m looking for a more graceful solution.
What tools does FreeRTOS have to help solve this problem?
Thanks