mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Fix flashinit panic not printing (#8762)
* fix panic not printing * improve panic to accept 0 lineno * always present detailed error message * Added back lost edit * For SDK v3.0+, adjust conditional build to remove duplicate call to flashinit from user_init.
This commit is contained in:
parent
edfde6ba1a
commit
137d421fdd
@ -400,13 +400,9 @@ extern "C" void __disableWiFiAtBootTime (void)
|
||||
|
||||
#if FLASH_MAP_SUPPORT
|
||||
#include "flash_hal.h"
|
||||
extern "C" bool flashinit (void);
|
||||
#if (NONOSDK >= (0x30000))
|
||||
uint32_t __flashindex __attribute__((section(".noinit")));
|
||||
#else
|
||||
extern "C" const char *flashinit (void);
|
||||
uint32_t __flashindex;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (NONOSDK >= (0x30000))
|
||||
#undef ETS_PRINTF
|
||||
@ -432,8 +428,8 @@ extern "C" void ICACHE_FLASH_ATTR user_pre_init(void)
|
||||
|
||||
do {
|
||||
#if FLASH_MAP_SUPPORT
|
||||
if (!flashinit()) {
|
||||
flash_map_str = PSTR("flashinit: flash size missing from FLASH_MAP table\n");
|
||||
flash_map_str = flashinit();
|
||||
if (flash_map_str) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
@ -631,6 +627,11 @@ extern "C" void user_init(void) {
|
||||
|
||||
uart_div_modify(0, UART_CLK_FREQ / (115200));
|
||||
|
||||
#if FLASH_MAP_SUPPORT && (NONOSDK < (0x30000))
|
||||
const char *err_msg = flashinit();
|
||||
if (err_msg) __panic_func(err_msg, 0, NULL);
|
||||
#endif
|
||||
|
||||
init(); // in core_esp8266_wiring.c, inits hw regs and sdk timer
|
||||
|
||||
initVariant();
|
||||
@ -653,11 +654,6 @@ extern "C" void user_init(void) {
|
||||
|
||||
#if defined(MMU_IRAM_HEAP)
|
||||
umm_init_iram();
|
||||
#endif
|
||||
#if FLASH_MAP_SUPPORT && (NONOSDK < 0x30000)
|
||||
if (!flashinit()) {
|
||||
panic();
|
||||
}
|
||||
#endif
|
||||
preinit(); // Prior to C++ Dynamic Init (not related to above init() ). Meant to be user redefinable.
|
||||
__disableWiFiAtBootTime(); // default weak function disables WiFi
|
||||
|
@ -140,6 +140,9 @@ void __wrap_system_restart_local() {
|
||||
}
|
||||
ets_putc('\n');
|
||||
}
|
||||
else if (s_panic_file) {
|
||||
ets_printf_P(PSTR("\nPanic %S\n"), s_panic_file);
|
||||
}
|
||||
else if (s_unhandled_exception) {
|
||||
ets_printf_P(PSTR("\nUnhandled C++ exception: %S\n"), s_unhandled_exception);
|
||||
}
|
||||
|
@ -33,21 +33,26 @@ extern "C" {
|
||||
#include <FlashMap.h>
|
||||
|
||||
extern uint32_t spi_flash_get_id (void); // <user_interface.h>
|
||||
extern bool flashinit(void);
|
||||
extern const char *flashinit(void);
|
||||
extern uint32_t __flashindex;
|
||||
extern const flash_map_s __flashdesc[];
|
||||
|
||||
#ifndef QUOTE
|
||||
#define QUOTE(a) __STRINGIFY(a)
|
||||
#endif
|
||||
|
||||
#define FLASH_MAP_SETUP_CONFIG(conf) FLASH_MAP_SETUP_CONFIG_ATTR(,conf)
|
||||
#define FLASH_MAP_SETUP_CONFIG_ATTR(attr, conf...) \
|
||||
const flash_map_s __flashdesc[] PROGMEM = conf; \
|
||||
bool flashinit (void) attr; \
|
||||
bool flashinit (void) \
|
||||
const char *flashinit (void) attr; \
|
||||
const char *flashinit (void) \
|
||||
{ \
|
||||
uint32_t flash_chip_size_kb = 1 << (((spi_flash_get_id() >> 16) & 0xff) - 10); \
|
||||
for (__flashindex = 0; __flashindex < sizeof(__flashdesc) / sizeof(__flashdesc[0]); __flashindex++) \
|
||||
if (__flashdesc[__flashindex].flash_size_kb == flash_chip_size_kb) \
|
||||
return true; \
|
||||
return false; /* configuration not found */ \
|
||||
return NULL; \
|
||||
static const char fail_msg[] PROGMEM = __FILE__ ":" QUOTE(__LINE__) " flashinit: configuration not found"; \
|
||||
return fail_msg; /* configuration not found */ \
|
||||
}
|
||||
|
||||
#define EEPROM_start (__flashdesc[__flashindex].eeprom_start)
|
||||
|
Loading…
x
Reference in New Issue
Block a user