From 556cfc8fb43627f6932672a1b110e2afd8a3eaaa Mon Sep 17 00:00:00 2001 From: M Hightower <27247790+mhightower83@users.noreply.github.com> Date: Thu, 15 Dec 2022 19:29:03 -0800 Subject: [PATCH 1/5] fix panic not printing --- cores/esp8266/core_esp8266_main.cpp | 10 ++++++---- cores/esp8266/flash_hal.h | 21 ++++++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/cores/esp8266/core_esp8266_main.cpp b/cores/esp8266/core_esp8266_main.cpp index 0b0c4ddc75..fbd48cca11 100644 --- a/cores/esp8266/core_esp8266_main.cpp +++ b/cores/esp8266/core_esp8266_main.cpp @@ -400,7 +400,7 @@ extern "C" void __disableWiFiAtBootTime (void) #if FLASH_MAP_SUPPORT #include "flash_hal.h" -extern "C" void flashinit (void); +extern "C" const char *flashinit (void); uint32_t __flashindex; #endif @@ -480,6 +480,11 @@ extern "C" void user_init(void) { uart_div_modify(0, UART_CLK_FREQ / (115200)); +#if FLASH_MAP_SUPPORT + const char *err_msg = flashinit(); + if (err_msg) __unhandled_exception(err_msg); +#endif + init(); // in core_esp8266_wiring.c, inits hw regs and sdk timer initVariant(); @@ -502,9 +507,6 @@ extern "C" void user_init(void) { #if defined(MMU_IRAM_HEAP) umm_init_iram(); -#endif -#if FLASH_MAP_SUPPORT - flashinit(); #endif preinit(); // Prior to C++ Dynamic Init (not related to above init() ). Meant to be user redefinable. __disableWiFiAtBootTime(); // default weak function disables WiFi diff --git a/cores/esp8266/flash_hal.h b/cores/esp8266/flash_hal.h index effca0f965..a3d28b7fe6 100644 --- a/cores/esp8266/flash_hal.h +++ b/cores/esp8266/flash_hal.h @@ -33,21 +33,32 @@ extern "C" { #include extern uint32_t spi_flash_get_id (void); // -extern void 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 + +#ifdef DEBUG_ESP_CORE +#define DEBUG_FLASH_MAP_NOT_FOUND " flashinit: configuration not found" +#else +#define DEBUG_FLASH_MAP_NOT_FOUND +#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; \ - void flashinit (void) attr; \ - void 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; \ - panic(); /* configuration not found */ \ + return NULL; \ + static const char fail_msg[] PROGMEM = __FILE__ ":" QUOTE(__LINE__) DEBUG_FLASH_MAP_NOT_FOUND ; \ + return fail_msg; /* configuration not found */ \ } #define EEPROM_start (__flashdesc[__flashindex].eeprom_start) From 1fe2383532e3fc0f846fac9f88db3d34aa86eb92 Mon Sep 17 00:00:00 2001 From: M Hightower <27247790+mhightower83@users.noreply.github.com> Date: Fri, 16 Dec 2022 10:36:01 -0800 Subject: [PATCH 2/5] improve panic to accept 0 lineno --- cores/esp8266/core_esp8266_main.cpp | 2 +- cores/esp8266/core_esp8266_postmortem.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cores/esp8266/core_esp8266_main.cpp b/cores/esp8266/core_esp8266_main.cpp index fbd48cca11..21b777b5ba 100644 --- a/cores/esp8266/core_esp8266_main.cpp +++ b/cores/esp8266/core_esp8266_main.cpp @@ -482,7 +482,7 @@ extern "C" void user_init(void) { #if FLASH_MAP_SUPPORT const char *err_msg = flashinit(); - if (err_msg) __unhandled_exception(err_msg); + if (err_msg) __panic_func(err_msg, 0, NULL); #endif init(); // in core_esp8266_wiring.c, inits hw regs and sdk timer diff --git a/cores/esp8266/core_esp8266_postmortem.cpp b/cores/esp8266/core_esp8266_postmortem.cpp index ce2817aaf6..bd69748815 100644 --- a/cores/esp8266/core_esp8266_postmortem.cpp +++ b/cores/esp8266/core_esp8266_postmortem.cpp @@ -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); } From e92fab591d43ec893af72d800e842cc04af5f420 Mon Sep 17 00:00:00 2001 From: M Hightower <27247790+mhightower83@users.noreply.github.com> Date: Fri, 16 Dec 2022 19:09:34 -0800 Subject: [PATCH 3/5] always present detailed error message --- cores/esp8266/flash_hal.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/cores/esp8266/flash_hal.h b/cores/esp8266/flash_hal.h index a3d28b7fe6..682e1dcfb1 100644 --- a/cores/esp8266/flash_hal.h +++ b/cores/esp8266/flash_hal.h @@ -41,12 +41,6 @@ extern const flash_map_s __flashdesc[]; #define QUOTE(a) __STRINGIFY(a) #endif -#ifdef DEBUG_ESP_CORE -#define DEBUG_FLASH_MAP_NOT_FOUND " flashinit: configuration not found" -#else -#define DEBUG_FLASH_MAP_NOT_FOUND -#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; \ @@ -57,7 +51,7 @@ extern const flash_map_s __flashdesc[]; for (__flashindex = 0; __flashindex < sizeof(__flashdesc) / sizeof(__flashdesc[0]); __flashindex++) \ if (__flashdesc[__flashindex].flash_size_kb == flash_chip_size_kb) \ return NULL; \ - static const char fail_msg[] PROGMEM = __FILE__ ":" QUOTE(__LINE__) DEBUG_FLASH_MAP_NOT_FOUND ; \ + static const char fail_msg[] PROGMEM = __FILE__ ":" QUOTE(__LINE__) " flashinit: configuration not found"; \ return fail_msg; /* configuration not found */ \ } From 825ce98c71de0eacc8e144a8e6b51bf6e6d2664f Mon Sep 17 00:00:00 2001 From: M Hightower <27247790+mhightower83@users.noreply.github.com> Date: Mon, 19 Dec 2022 11:08:10 -0800 Subject: [PATCH 4/5] Added back lost edit --- cores/esp8266/core_esp8266_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cores/esp8266/core_esp8266_main.cpp b/cores/esp8266/core_esp8266_main.cpp index 6206ad0e72..bb4b28d788 100644 --- a/cores/esp8266/core_esp8266_main.cpp +++ b/cores/esp8266/core_esp8266_main.cpp @@ -428,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 From ce16bdc3d4961c1c0a65124f362670d0765a528e Mon Sep 17 00:00:00 2001 From: M Hightower <27247790+mhightower83@users.noreply.github.com> Date: Mon, 19 Dec 2022 19:21:02 -0800 Subject: [PATCH 5/5] For SDK v3.0+, adjust conditional build to remove duplicate call to flashinit from user_init. --- cores/esp8266/core_esp8266_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp8266/core_esp8266_main.cpp b/cores/esp8266/core_esp8266_main.cpp index bb4b28d788..86885318ff 100644 --- a/cores/esp8266/core_esp8266_main.cpp +++ b/cores/esp8266/core_esp8266_main.cpp @@ -627,7 +627,7 @@ extern "C" void user_init(void) { uart_div_modify(0, UART_CLK_FREQ / (115200)); -#if FLASH_MAP_SUPPORT +#if FLASH_MAP_SUPPORT && (NONOSDK < (0x30000)) const char *err_msg = flashinit(); if (err_msg) __panic_func(err_msg, 0, NULL); #endif pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy