Usually Espruino doesn't load code if a button is pressed at boot, but unfortunately it looks like on the normal ESP32 build no pin has been defined for this, so I'm not really sure there's a way.
You could always boot to the bootloader mode and then erase the first page of Storage (at 0x320000 I think?)
Any hints how to set-up a "button" pin?
I ended up checking for certain pin in my code which I short or pull up when needed.
bool buttonState = false; [#ifdef](http://forum.espruino.com/search/?q=%23ifdef) BTN1_PININDEX buttonState = jshPinInput(BTN1_PININDEX) == BTN1_ONSTATE; [#endif](http://forum.espruino.com/search/?q=%23endif) jsvInit(0); jsiInit(!buttonState); // pressing USER button skips autoload
The code is for the stm32, but it could be replicated for ESP32. Define BTN1_PININDEX (maybe jshardware.c?) and use this code. Actually it would be nice to have it in every board.
Button can be defined in board file, see other boards for BTN1. this 'check button and skip load' is there for nrf52 too so that's basically all boards except ESP. could be added here https://github.com/espruino/Espruino/blob/master/targets/esp32/main.c#L69
I have code that runs endless loop:
do some work in the onInit() method, deepSleep, wake-up and over again
it works fine, but I need to be able to stop this endless loop so that I can gain access to the terminal and reset or change code.