How do you made the double tap reset to dfu working on Arduino Nano ESP32?

I looked up the code in the nano esp32 variant. It put magic tokens on ram but the ram should be initialized after chip level reset using rst button. is this a w106 module feature?

Hello @serendo, and welcome to the Arduino forums!

Good catch! Yes, the ESP32 loses all state with a RESET pulse (including the RTC!), and the bootloaders in the core are shared among all boards with similar CPUs, so adding double tap detection was especially tricky.
We were lucky to have, in the W106 module, an additional PSRAM chip which holds the state even across RESET. The trick is we store the magic tokens there, and switch to a dedicated binary (whose sources are in the variant's extras/nora_recovery folder) when double tap is detected.
Also, the magic tokens set/check/clear operations are strategically placed among the sketch and recovery to avoid issues with e.g. multiple taps (one forum user mentioned "to enter recovery, keep tapping for 30 seconds and it works!" :sweat_smile:) or extraneous activations (if you enter recovery then power down, you don't expect it to run again, but it does - that's why sometimes you see the LED dance twice). Oh, did I mention it also needs to work with MicroPython?

Way more complex than it looks on the surface! :slight_smile:

2 Likes