1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-15 00:02:49 +03:00

Fix exception handler, add assert, reduce RAM (#4187)

Move all exception strings to IRAM and out of both PMEM (illegal) and add
output of any assert() failinf conditions.

The exception handler may be called while the SPI interface is in a bad
state.  This means no PROGMEM reads are allowed, and all data and functions
used must be in system RAM or IRAM.

Add a new helper macro, ets_printf_P(), which places a constant string in
IRAM and copies it to the stack before calling the real ets_printf().
This makes the code simpler to read as no unwieldy combinations of
ets_putc/ets_printf/... are required to output anything.

The old handler also mistakenly used PSTR() strings in some places, so
fix those with this patch as well.

Gives back ~180 bytes of heap to every sketch built as the exception handler
is always included an application.
This commit is contained in:
Earle F. Philhower, III
2018-03-17 17:53:08 -07:00
committed by Ivan Grokhotkov
parent 4e2e1f268c
commit 855b03ce4d
2 changed files with 46 additions and 23 deletions

View File

@ -15,7 +15,7 @@ extern "C" {
# define assert(__e) ((void)0)
#else
# define assert(__e) ((__e) ? (void)0 : __assert_func (PSTR(__FILE__), __LINE__, \
__ASSERT_FUNC, #__e))
__ASSERT_FUNC, PSTR(#__e)))
# ifndef __ASSERT_FUNC
/* Use g++'s demangled names in C++. */