HardFault_Handler() collects full MPU context #201
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With this PR we have the
HardFault_Handler()
collect and save in non volatile RAM the full context of the MPU, so that at the restart the board sends this information over diagnostic messages.This behaviour applies to ems, mc4plus and mc2plus.
There is an associated PR for the binaries in robotology/icub-firmware-build#35
Behaviour of the improved diagnostics
The
HardFault_Handler()
now sends improved information which contains:Here is an example of what the board sends when we induce a HF by some sample code which access not existing RAM.
Listing. Offending code
Listing. Diagnostics messages
The interpretation of the diagnostic messages is not trivial. We need to refer to the ARM Cortex M4 documentation (see here) and we also need the .map file of the running application for mapping the hex addresses of the program counter for instance to the assembly and C code. We very likely will also need to re-run the very same project on the debugger. As a fact, post mortem diagnosis w/out a debugger is very complicate.
As an example for the above situation:
eo_fatalerror_AtStartup()
as expectedhowever, only w/ the debugger running we can find the offending instruction inside the C function
by looking at the system registers we can for instance see that address
0xcccccccc
is the one giving problems.Tests
The code was tested on an ems on a dedicated testbench where we caused several HF faults such as divide by zero, access to not-existing addresses but also others such as missing memory for RTOS.
The binaries of the mc4plus have been validated also with tests on icub3 (see here), hence we can merge the PR
Note
This PR addresses the problem in #174