diff --git a/README_BuildProcess.md b/README_BuildProcess.md index 8afd82121..2c7e55151 100644 --- a/README_BuildProcess.md +++ b/README_BuildProcess.md @@ -146,6 +146,7 @@ This is a partial list of definitions that can be added in a `BOARD.py` file's ` * `ESPR_MIN_WFI_TIME_MS` - STM32: default 0.1ms, but if set, Espruino won't enter __WFI sleep unless the next setInterval is more than this number of milliseconds away * `ESPR_GRAPHICS_SELF_INIT` - Should the Graphics library instantiate itself with its own `g` instance? * `ESPR_LCD_MANUAL_BACKLIGHT` - STM32/FSMC: Don't turn the backlight on and leave code to do this manually +* `ESPR_DISABLE_KICKWATCHDOG_PIN=BTN1_PININDEX` - If this pin is 1, skip kickWatchdog calls (which would eventually force a reboot if WDT enabled) There are some specifically that are useful for cutting a few bytes out of the build: diff --git a/boards/PIPBOY.py b/boards/PIPBOY.py index 0d0543182..a889b6735 100644 --- a/boards/PIPBOY.py +++ b/boards/PIPBOY.py @@ -49,6 +49,7 @@ 'DEFINES+=-DESPR_RTC_ALWAYS_TRY_LSE', # If we boot and RTC is initialised but using LSI, try again at starting LSE 'DEFINES+=-DESPR_FS_LARGE_WRITE_BUFFER', # speeds up SD card writes ~3x 'DEFINES+=-DESPR_LCD_MANUAL_BACKLIGHT', # Pipboy handles LCD backlight on/off so we can reduce flicker + 'DEFINES+=-DESPR_DISABLE_KICKWATCHDOG_PIN=BTN10_PININDEX', # If the power button is held, don't kick watchdog so we reboot 'DEFINES+=-DESPR_OFFICIAL_BOARD', # Don't display the donations nag screen 'STLIB=STM32F407xx', '-DHSE_VALUE=9000000', diff --git a/libs/pipboy/jswrap_pipboy.c b/libs/pipboy/jswrap_pipboy.c index fe204b089..3a230411b 100644 --- a/libs/pipboy/jswrap_pipboy.c +++ b/libs/pipboy/jswrap_pipboy.c @@ -24,6 +24,7 @@ #include "jshardware.h" #include "jswrap_graphics.h" #include "jswrap_interactive.h" +#include "jswrap_espruino.h" #include "jspin.h" #include "jsflags.h" #include "jshardware.h" @@ -1219,6 +1220,8 @@ JsVar *jswrap_pb_streamPlaying() { "generate" : "jswrap_pb_init" }*/ void jswrap_pb_init() { + // Enable watchdog + jswrap_espruino_enableWatchdog(15, NULL); // init watchdog, auto mode // splash screen const unsigned char img_raw[] = {199, 17, 2, 0, 0, 31, 255, 255, 255, 255, 255, 255, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 255, 255, 255, 255, 255, 255, 233, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 255, 255, 255, 255, 255, 255, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 91, 255, 213, 85, 85, 111, 255, 192, 11, 255, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 86, 255, 249, 85, 85, 85, 255, 252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191, 253, 0, 0, 0, 191, 253, 0, 127, 255, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 255, 128, 0, 0, 7, 255, 208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 255, 224, 0, 0, 7, 255, 224, 127, 255, 224, 2, 255, 255, 255, 255, 255, 233, 0, 0, 0, 0, 0, 0, 0, 0, 255, 248, 0, 0, 0, 63, 254, 0, 107, 255, 255, 255, 232, 0, 191, 255, 255, 224, 127, 255, 255, 248, 0, 0, 63, 255, 255, 255, 255, 255, 254, 7, 255, 255, 192, 47, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 15, 255, 255, 255, 255, 255, 255, 224, 127, 255, 255, 255, 255, 253, 91, 255, 255, 255, 131, 255, 255, 255, 224, 0, 3, 255, 255, 255, 255, 255, 255, 224, 26, 255, 252, 0, 107, 255, 250, 170, 170, 255, 248, 0, 170, 170, 170, 170, 168, 0, 191, 255, 255, 255, 255, 255, 248, 7, 255, 250, 170, 171, 255, 255, 255, 255, 255, 252, 47, 255, 255, 254, 0, 0, 47, 255, 191, 255, 255, 234, 80, 0, 7, 255, 192, 0, 47, 255, 0, 0, 11, 255, 192, 11, 255, 255, 255, 255, 224, 11, 255, 234, 170, 170, 171, 255, 240, 63, 253, 0, 0, 31, 255, 255, 253, 191, 255, 0, 127, 255, 208, 0, 0, 2, 255, 244, 0, 0, 0, 0, 0, 0, 127, 253, 0, 1, 255, 244, 0, 0, 191, 252, 0, 21, 85, 85, 85, 85, 0, 127, 254, 0, 0, 0, 31, 255, 67, 255, 224, 0, 0, 255, 245, 85, 64, 255, 253, 31, 255, 244, 0, 0, 0, 31, 255, 128, 0, 0, 0, 0, 0, 3, 255, 208, 0, 31, 255, 64, 0, 7, 255, 208, 0, 0, 0, 0, 0, 0, 7, 255, 224, 0, 0, 0, 255, 248, 47, 255, 0, 0, 15, 255, 128, 0, 1, 255, 255, 255, 248, 0, 0, 0, 85, 255, 248, 0, 0, 0, 0, 0, 0, 127, 254, 81, 20, 255, 249, 64, 5, 127, 255, 213, 64, 0, 0, 0, 0, 17, 127, 255, 64, 0, 5, 95, 255, 130, 255, 245, 85, 85, 255, 248, 0, 0, 2, 255, 255, 254, 0, 0, 0, 15, 255, 255, 192, 0, 0, 0, 0, 1, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 64, 0, 0, 0, 3, 255, 255, 255, 255, 255, 255, 255, 248, 15, 255, 255, 255, 255, 255, 128, 0, 0, 3, 255, 255, 128, 0, 0, 0, 127, 255, 252, 0, 0, 0, 0, 0, 11, 255, 255, 255, 255, 255, 255, 255, 255, 255, 250, 255, 224, 0, 0, 0, 0, 31, 255, 255, 255, 255, 255, 255, 249, 0, 11, 255, 255, 255, 255, 144, 0, 0, 0, 127, 255, 208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 255, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 255, 244, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 47, 255, 253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 255, 253, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 255, 255, 208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 255, 254, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 170, 128, 0, 0, 0, 0, 0, 0}; JsVar *img = jsvNewNativeString((char*)&img_raw[0], sizeof(img_raw)); diff --git a/targets/esp32/jshardware.c b/targets/esp32/jshardware.c index bc619ebf5..601340c34 100644 --- a/targets/esp32/jshardware.c +++ b/targets/esp32/jshardware.c @@ -462,6 +462,9 @@ void jshEnableWatchDog(JsVarFloat timeout) { // Kick the watchdog void jshKickWatchDog() { +#ifdef ESPR_DISABLE_KICKWATCHDOG_PIN // if this pin is asserted, don't kick the watchdog + if (jshPinGetValue(ESPR_DISABLE_KICKWATCHDOG_PIN)) return; +#endif if (wdt_enabled) esp_task_wdt_reset(); } diff --git a/targets/nrf5x/jshardware.c b/targets/nrf5x/jshardware.c index b6232ff37..e18955b1b 100644 --- a/targets/nrf5x/jshardware.c +++ b/targets/nrf5x/jshardware.c @@ -1749,6 +1749,9 @@ void jshEnableWatchDog(JsVarFloat timeout) { } void jshKickWatchDog() { +#ifdef ESPR_DISABLE_KICKWATCHDOG_PIN // if this pin is asserted, don't kick the watchdog + if (jshPinGetValue(ESPR_DISABLE_KICKWATCHDOG_PIN)) return; +#endif NRF_WDT->RR[0] = 0x6E524635; } diff --git a/targets/stm32/jshardware.c b/targets/stm32/jshardware.c index b9a6e30a6..f06ce8a34 100644 --- a/targets/stm32/jshardware.c +++ b/targets/stm32/jshardware.c @@ -3007,6 +3007,9 @@ void jshEnableWatchDog(JsVarFloat timeout) { // Kick the watchdog void jshKickWatchDog() { +#ifdef ESPR_DISABLE_KICKWATCHDOG_PIN // if this pin is asserted, don't kick the watchdog + if (jshPinGetValue(ESPR_DISABLE_KICKWATCHDOG_PIN)) return; +#endif IWDG_ReloadCounter(); }