mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-21 00:56:38 +08:00
feat(esp8266): Avoid to NMI calling ets_printf crash
This commit is contained in:
@ -92,6 +92,21 @@ config LINK_ETS_PRINTF_TO_IRAM
|
||||
|
||||
Note: Bootloader can't use this function.
|
||||
|
||||
config ETS_PRINTF_EXIT_WHEN_FLASH_RW
|
||||
bool "ets_printf exits when flash R/W"
|
||||
default y
|
||||
depends on !LINK_ETS_PRINTF_TO_IRAM
|
||||
help
|
||||
By default option, we link the ets_printf function and its calling functions
|
||||
in SPI Flash. So when the SPI Flash is working in read/write mode, and we
|
||||
call ets_printf in high level interrupt like NMI, this behavior will cause a
|
||||
crash, and the EXCCAUSE=0.
|
||||
|
||||
Enable this option, we link the ets_printf in IRAM, and its calling functions
|
||||
in SPI Flash. In the entry of ets_printf, we check if the SPI Flash is working
|
||||
in read/write mode, and exit if it is. So that ets_printf will not call functions
|
||||
in SPI Flash.
|
||||
|
||||
config SOC_FULL_ICACHE
|
||||
bool "Enable full cache mode"
|
||||
default n
|
||||
|
@ -24,6 +24,12 @@
|
||||
#include "esp8266/uart_register.h"
|
||||
#include "esp8266/rom_functions.h"
|
||||
|
||||
#ifdef CONFIG_ETS_PRINTF_EXIT_WHEN_FLASH_RW
|
||||
#define ETS_PRINTF_ATTR IRAM_ATTR
|
||||
#else
|
||||
#define ETS_PRINTF_ATTR
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_ESP_CONSOLE_UART_NONE
|
||||
static void uart_putc(int c)
|
||||
{
|
||||
@ -285,11 +291,19 @@ int ets_vprintf(const char *fmt, va_list ap)
|
||||
* "%s": 172 Bytes
|
||||
* "%p", "%d, "%i, "%u", "%x": 215 Bytes
|
||||
*/
|
||||
int ets_printf(const char *fmt, ...)
|
||||
int ETS_PRINTF_ATTR ets_printf(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_ETS_PRINTF_EXIT_WHEN_FLASH_RW
|
||||
extern uint8_t FlashIsOnGoing;
|
||||
|
||||
if (FlashIsOnGoing) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
va_start(ap, fmt);
|
||||
ret = ets_vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
|
Reference in New Issue
Block a user