From 4b33eba7511ff955fc7e3cb8237cec7a9c4c7f50 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 3 May 2023 13:33:41 +0100 Subject: [PATCH] ESP32: Fix reset() causing meditation error (ref #1777) --- ChangeLog | 1 + make/targets/ESP32.make | 7 ++++++- src/jsinteractive.c | 3 ++- src/jsvar.h | 8 +++++--- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7fa48584e8..93c38fe934 100644 --- a/ChangeLog +++ b/ChangeLog @@ -154,6 +154,7 @@ Correctly handle parsing of template literals inside template literals Don't store command history if echo=off (eg for Web IDE/App Loader uploads) E.defrag now kicks the watchdog (on Bangle.js 2 it can take long enough that the watchdog fires) + ESP32: Fix reset() causing meditation error (ref #1777) 2v14 : Bangle.js2: Fix issue with E.showMenu creating a global `s` variable Bangle.js2: Recheck string wrapping after font change inside E.showMenu diff --git a/make/targets/ESP32.make b/make/targets/ESP32.make index 301823e31a..4d588d88bd 100644 --- a/make/targets/ESP32.make +++ b/make/targets/ESP32.make @@ -2,8 +2,10 @@ ESP_ZIP = $(PROJ_NAME).tgz COMPORT?=/dev/ttyUSB0 -$(PROJ_NAME).bin: $(OBJS) +$(PROJ_NAME).elf: $(OBJS) $(LD) $(LDFLAGS) -o $(PROJ_NAME).elf -Wl,--start-group $(LIBS) $(OBJS) -Wl,--end-group + +$(PROJ_NAME).bin: $(PROJ_NAME).elf python $(ESP_IDF_PATH)/components/esptool_py/esptool/esptool.py \ --chip esp32 \ elf2image \ @@ -12,6 +14,9 @@ $(PROJ_NAME).bin: $(OBJS) -o $(PROJ_NAME).bin \ $(PROJ_NAME).elf +$(PROJ_NAME).lst : $(PROJ_NAME).elf + $(OBJDUMP) -d -l -x $(PROJ_NAME).elf > $(PROJ_NAME).lst + $(ESP_ZIP): $(PROJ_NAME).bin $(Q)rm -rf $(PROJ_NAME) $(Q)mkdir -p $(PROJ_NAME) diff --git a/src/jsinteractive.c b/src/jsinteractive.c index 7bf1814b0c..db802e0de0 100644 --- a/src/jsinteractive.c +++ b/src/jsinteractive.c @@ -2236,10 +2236,11 @@ void jsiIdle() { JsiStatus s = jsiStatus; if ((s&JSIS_TODO_RESET) == JSIS_TODO_RESET) { // shut down everything and start up again + unsigned int oldJsVarsSize = jsVarsSize; // we must remember the old vars size - mainly for ESP32 where it can change jsiKill(); jsvKill(); jshReset(); - jsvInit(0); + jsvInit(oldJsVarsSize); jsiSemiInit(false, NULL/* no filename */); // don't autoload jsiStatus &= (JsiStatus)~JSIS_TODO_RESET; } diff --git a/src/jsvar.h b/src/jsvar.h index 8de7edd248..5976e0b0e8 100644 --- a/src/jsvar.h +++ b/src/jsvar.h @@ -789,9 +789,11 @@ void jsvFree(void *ptr); } \ } -#endif /* JSVAR_H_ */ - -#if defined(JSVAR_MALLOC) && defined(ESPR_EMBED) +#if defined(JSVAR_MALLOC) extern unsigned int jsVarsSize; extern JsVar *jsVars; #endif + +#endif /* JSVAR_H_ */ + +