Hello kackle,
Based on the situation you described, the reason related to "printf" has been ruled out for the hardfault, but the same C structure in the memory has been corrupted. I suggest that you carefully check the parts of the code that operate on this memory area to see if there are situations like pointer out-of-bounds or array out-of-bounds writing. You can conduct further debugging to locate where the problem lies.
Regarding the issue that the "Allocated" size in the heap usage doesn't match the size of the task stack usage, your understanding of what "Allocated" means is somewhat reasonable. Under the memory management mechanism of FreeRTOS, it indeed records the size of the entire allocated memory block, including the part actually used by the task and the management overhead. It's possible that 40 kB is allocated while the task stack only uses 25 kB. On the one hand, there's the extra overhead of memory management, and on the other hand, it might be affected by memory alignment factors. However, it's necessary to pay attention to whether there's a memory leak. You can observe the changes in heap usage over a long period of time or use a memory analysis tool to check it out.
If necessary, you can send us your project for us to have a look. You can create a private case and tell us the detailed steps to reproduce the problem.
You may submit a case and describe your problem or what you want to know, and engineer will reply and provide related resource by email.
Please follow up below steps to submit a case:
1. Go to SUPPORTHOME, click on "Submit a Ticket" in the middle of this page. http://www.nxp.com/support/support:SUPPORTHOME
2. Login, Or Register with your business email
Hope it can help you.
BRs,
Celeste