Debugging a crash

Debugging a Crash

When the crash happens, it will print some useful info upon next boot, and it will also tell you the last running task before the crash happened (if you are running FreeRTOS). The next clues can be determined by doing this:

Note down the address of PC and LR from the crash info printout

Open *.lst file from the _build folder, and search for last four digits of PC. That is where the crash happened.

LR is the "return address" of the previously called function. But I think if you see "0x123F", search for "1240" or "123C" because I think you have to subtract one from the LR value so that it lies on 4 byte boundary.

Data logging

One of the best ways to debugging a project is to log useful information. There is a logging facility available and it is best to use FreeRTOS that provides optimized operation. See "file_logger.h" for more details and parameters.

#include "file_logger.h"
void foo()
{
LOG_INFO("Some info");
LOG_WARN("Some warning");
LOG_ERROR("Some error happened, value is: %u", 123);
/* All the info is logged to a file (log.csv)
* You can open this file using terminal command "cat log.csv"
* You can also modify the destination to the SD card by defining
* logging filename to "1:log.csv" at file_logger.h
*/
}