diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-11-02 15:47:37 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-11-02 15:47:37 +0100 |
commit | a2ce5dc436999bebc3172bd9a01914a96006b949 (patch) | |
tree | 9a749757c17ce1007c4675b2de03b04797250cce /nuttx | |
parent | b492c8ac9ea659e4421554ab4a343357f35bafaa (diff) | |
download | px4-nuttx-a2ce5dc436999bebc3172bd9a01914a96006b949.tar.gz px4-nuttx-a2ce5dc436999bebc3172bd9a01914a96006b949.tar.bz2 px4-nuttx-a2ce5dc436999bebc3172bd9a01914a96006b949.zip |
Force a hardfault on stack overflows to make the fault condition obvious once it occurs
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/arch/arm/src/armv7-m/up_stackcheck.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/nuttx/arch/arm/src/armv7-m/up_stackcheck.c b/nuttx/arch/arm/src/armv7-m/up_stackcheck.c index e8f02a863..eb4f93830 100644 --- a/nuttx/arch/arm/src/armv7-m/up_stackcheck.c +++ b/nuttx/arch/arm/src/armv7-m/up_stackcheck.c @@ -1,4 +1,9 @@ +#include <nuttx/config.h> +#include <stdint.h> + +#include "up_arch.h" +#include "nvic.h" void __cyg_profile_func_enter(void *func, void *caller) __attribute__((naked, no_instrument_function)); void __cyg_profile_func_exit(void *func, void *caller) __attribute__((naked, no_instrument_function)); @@ -7,8 +12,21 @@ void __stack_overflow_trap(void) __attribute__((naked, no_instrument_function void __stack_overflow_trap(void) { - /* if we get here, the stack has overflowed */ - asm ( "b ."); + /* if we get here, the stack has overflowed */ + + /* force hard fault */ + uint32_t regval; + + /* Set up for the system reset, retaining the priority group from the + * the AIRCR register. + */ + + regval = getreg32(NVIC_INTCTRL); + regval |= NVIC_INTCTRL_NMIPENDSET; + putreg32(regval, NVIC_INTCTRL); + + /* trap */ + //asm ( "b ."); } void |