AnsweredAssumed Answered

malloc causing hard faults - how to adjust stack/heap

Question asked by jwoolston on Dec 4, 2013
Latest reply on Dec 6, 2013 by james_patterson

I've been working on firmware for one of our projects for a while now and all the features are starting to come together, which is causing some problems. I have several modules of code which have been tested independently so I know that by themselves they work fine, but now with the complete program I am encountering hard faults when malloc calls are made. Specifically, they occur in a module of code which processes incoming telnet command strings and allocates a new string to copy a subset of the incoming string:


raw_args = (char**) malloc(count * sizeof(char*));


Where raw_args is declared as a function local variable. It is used as an array of strings representing key/value pairs. Count is also a function local variable and where the offending line of code is executed, guaranteed to be greater than 0.


I strongly suspect I have exceeded my heap size but I am unaware of how to see how large the heap is or what my consumption is. The target processor is a STM32F407IG.