Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
esp8266: Handle exceptions in the exception_handler().
When an exception occurs while handling an exception with exception_handler() this function will be called again, increasing the exception stack until the whole stack and the memory before it is exhausted and a DoubleException occurs when trying to use an address in the `0x3ff7ffxx` range, far away from any clue to the initial exception. A common cause for an exception in exception_handler() is to try to execute a function from IROM while the cache is disabled. This normally results in an illegal instruction exception. A few of the functions called from the exception_handler() are in IROM, triggering this situation if an exception occurs while the flash cache is disabled. This patch breaks to the debugger immediately if exception_handler is called twice, so the location of the function causing the double exception can be obtained in frame->pc, and the frame in that context can be inspected too. Second, to address the issue of printing the error message in the terminal this patch enables the flash cache before calling ets_printf(). While exception_handler() is in IRAM, its read-only literal strings are not, so calling ets_printf() will not work. With this patch and without the fix in RIOT-OS#17080, reproducing the conditions in issue RIOT-OS#16281 allows us to quickly identify the PC of the function that was causing the issue (`vTaskEnterCritical`) on the first place.
- Loading branch information