feat(esp8266): Avoid to NMI calling ets_printf crash

This commit is contained in:
Dong Heng
2020-09-08 10:54:03 +08:00
parent eb6efa8090
commit 303b047e54
2 changed files with 30 additions and 1 deletions
components/esp8266

@ -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);