Understand fault handler

I am running some bits of code that I have brought together, both of them have worked individually, I am unsure why they wouldn’t work together, all that is happening is that one part of the code dictates when the other runs, but now I am getting the following error

I am fairly sure I know what line causes the error, but I need that line to work and I don’t know why it would happen

I’ve followed the link provided, and a further link from there but I am struggling to understand how to read the error to truly know what the issue is

any insight at all would be helpful
many thanks

++ MbedOS Fault Handler ++

FaultType: HardFault

R5: 200001A4
R6: 800B614
R7: 20001AF0
R8: 800B600
R9: 0
R10: 0
R11: 0
MSP  : 20017FD0
CPUID: 410FC241
HFSR : 40000000
BFSR : 0
UFSR : 0
DFSR : 0
AFSR : 0
Mode : Thread
Priv : Privileged
Stack: PSP

-- MbedOS Fault Handler --

++ MbedOS Error Info ++
Error Status: 0x80FF013D Code: 317 Module: 255
Error Message: Fault exception
Location: 0xFFFFFFFF
Error Value: 0x20001D8C
Current Thread: main Id: 0x20002130 Entry: 0x800CF19 StackSize: 0x1000 StackMem: 0x20000B10 SP: 0x1FFFDBE4 
For more info, visit: https://mbed.com/s/error?error=0x80FF013D&tgt=NUCLEO_F401RE
-- MbedOS Error Info --

Hello George,

I am fairly sure I know what line causes the error …

Anyway, there is a debug tool to analyze crash logs in


For instructions how to use it read README.md

This is the only useful tool I know. But it’s only capable to confirm (or to disprove) your assumption.

I have tried to use it, typing in the following based on my understanding of the README

C:\Users\georg.LAPTOP-MIF8IBGQ>"C:\Users\georg.LAPTOP-MIF8IBGQ\Mbed Programs\SDMotors\mbed-os\tools\debug_tools\crash_log_parser\crash_log_parser.py"
"C:\Users\georg.LAPTOP-MIF8IBGQ\Mbed Programs\SDMotors\mbed-os\tools\debug_tools\crash_log_parser\crash_log.txt"
"C:\Users\georg.LAPTOP-MIF8IBGQ\Mbed Programs\SDMotors\BUILD\NUCLEO_F401RE\ARMC6\SDMotors.elf"
"C:\Users\georg.LAPTOP-MIF8IBGQ\Mbed Programs\SDMotors\BUILD\NUCLEO_F401RE\ARMC6\SDMotors.map"

(I’ve done new line for clarity, for the actual I did not put new line i just put space)

all that happens is a terminal opens and quickly closes I am unable to view any output, am I doing something wrong?

As I could see you run on Windows.

  • Make sure the complete crash report (as it is shown in your first post) is saved in the crash_log.txt file.

  • Open a command window and check whether the python command works:
    type python --version and hit ENTER. It should display the python version installed on your system.

  • If that works, in the command window type again python followed by a space and then put the command you already used (showed in your second post) and hit ENTER.

as far as I can tell this still has not worked, nothing appears to have come up
I dont get any errors or anything just nothing seems to happen
see screenshot here

Maybe there is some issue with the spaces in paths. I run on Linux so can’t test it but try the following:

  • Copy the crash_log_parser.py and crash_log.txt files to your build directory
C:\Users\georg.LAPTOP-MIF8IBGQ\Mbed Programs\SDMotors\BUILD\NUCLEO_F401RE\ARMC6
  • Open the command prompt and change directory to the one above.

  • In the command prompt execute:

python crash_log_parser.py crash_log.txt SDMotors.elf SDMotors.map

This thread might help too.

thanks for the help so far!
unfortunately, that hasn’t worked either, will be looking at the linked thread over the next day to try and understand what they’ve done differently
many thanks

Open a command prompt in the

C:\Users\georg.LAPTOP-MIF8IBGQ\Mbed Programs\SDMotors\mbed-os\tools\debug_tools\crash_log_parser

folder and execute the following command:

python crash_log_parser.py

That should print:

usage: crash_log_parser.py [-h] CRASH LOG [ELF FILE] [MAP FILE]
crash_log_parser.py: error: too few arguments

Otherwise your python installation (revision) is either corrupted or not compatible with the debug tool.

What do you get after executing the following command from the same command prompt?

python --version

hello, thank you for the help so far!
i now get an error when I run it fully

  File "C:\Users\georg.LAPTOP-MIF8IBGQ\Mbed Programs\SDMotors\BUILD\NUCLEO_F401RE\ARMC6\crash_log_parser.py", line 195, in <module>
    elfhelper = ElfHelper(args.elffile, args.mapfile)
  File "C:\Users\georg.LAPTOP-MIF8IBGQ\Mbed Programs\SDMotors\BUILD\NUCLEO_F401RE\ARMC6\crash_log_parser.py", line 32, in __init__
    op = check_output([_NM_EXEC, _OPT, elf_file.name]).decode('utf-8')
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1008.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1008.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1008.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1008.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

it appears to be the same error as in the thread you linked previously
unfortunately, I have still been unable to fix it but I am still working on it

many thanks

thank you for all the advice so far!
so I’ve now been able to get the parser to work and have the following output

Crash Info:
        Crash location = SHT$$INIT_ARRAY$$Limit [0xFFFFFFFF] (based on PC value)
        Caller location = SHT$$INIT_ARRAY$$Limit [0xFFFFFFFF] (based on LR value)
        Stack Pointer at the time of crash = [1FFFDBE4]
        Target and Fault Info:
                Processor Arch: ARM-V7M or above
                Processor Variant: C24
                Forced exception, a fault with configurable priority has been escalated to HardFault
                MPU or Execute Never (XN) default memory map access violation on an instruction fetch has occurred

I think I understand the that most important information is:

MPU or Execute Never (XN) default memory map access violation on an instruction fetch has occurred

and the lines of my code it gets angry at are:

 if (diffx[store] >= 0) { dirPin[0] = 1; }
 else if (diffx[store] < 0) { dirPin[0] = 0; }
 if (diffy[store] >= 0) { dirPin[1] = 1; }
 else if (diffy[store] < 0) { dirPin[1] = 0; }

does anyone know why this might cause this error to occur?

many thanks

Most likely either the actual value of the store variable is greater than the declared dimension of the diffx (or diffy) array or the declared dimension of dirPin is less than 2 (that is equal to 1).

  • Format the code to be more debug friendly. For example:
    if (diffx[store] >= 0) {
        dirPin[0] = 1;
    else if (diffx[store] < 0) {
        dirPin[0] = 0;

    if (diffy[store] >= 0) {
        dirPin[1] = 1;
    } else if (diffy[store] < 0) {
        dirPin[1] = 0;
  • Compile using the debug profile.
  • Setup a breakpoint at first line (if (diffx[store] >= 0) {
  • While stepping through the code in debug mode check (monitor) the value of the store variable and notice the line when the program crashes.

NOTE: You can also refactor the code (replace else if (...) { with else { ) as follows:

    if (diffx[store] >= 0) {
        dirPin[0] = 1;
    } else {
        dirPin[0] = 0;

    if (diffy[store] >= 0) {
        dirPin[1] = 1;
    } else {
        dirPin[1] = 0;