diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2018-12-06 14:24:20 -0800 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2018-12-06 14:24:20 -0800 |
| commit | 6ef863997186e1893cdf19c0e04d0a8a3f33ad9d (patch) | |
| tree | 461360ed76e39ca0a534a0dee040fc1cf6848d70 /supervisor/shared/stack.c | |
| parent | 7ad2e6ace34a6d417ec1b84472fa409d5451137b (diff) | |
Rework safe mode and have heap overwrite trigger it.
This creates a common safe mode mechanic that ports can share.
As a result, the nRF52 now has safe mode support as well.
The common safe mode adds a 700ms delay at startup where a reset
during that window will cause a reset into safe mode. This window
is designated by a yellow status pixel and flashing the single led
three times.
A couple NeoPixel fixes are included for the nRF52 as well.
Fixes #1034. Fixes #990. Fixes #615.
Diffstat (limited to 'supervisor/shared/stack.c')
| -rwxr-xr-x | supervisor/shared/stack.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/supervisor/shared/stack.c b/supervisor/shared/stack.c index 8f4da4ce6..71e239c0a 100755 --- a/supervisor/shared/stack.c +++ b/supervisor/shared/stack.c @@ -29,6 +29,7 @@ #include "py/mpconfig.h" #include "py/runtime.h" #include "supervisor/cpu.h" +#include "supervisor/shared/safe_mode.h" extern uint32_t _estack; @@ -38,8 +39,6 @@ supervisor_allocation* stack_alloc = NULL; #define EXCEPTION_STACK_SIZE 1024 -#define STACK_CANARY_VALUE 0x017829ef - void allocate_stack(void) { mp_uint_t regs[10]; mp_uint_t sp = cpu_get_regs_and_sp(regs); @@ -62,9 +61,7 @@ inline bool stack_ok(void) { inline void assert_heap_ok(void) { if (!stack_ok()) { - asm("nop"); - while(true) {} - mp_raise_RuntimeError(translate("Stack clobbered heap.")); + reset_into_safe_mode(HEAP_OVERWRITTEN); } } |
