Phantom button presses on GPIO36 moving from mos 2.19.1 to 2.20.0

I’ve been running mos 2.19.1 for a while now and only recently moved to 2.20.0
The other day my WiFi network dropped and I noticed some strange behaviour on my device - phantom button presses.

I’ve verified by running an old FW version built with 2.19.1 and then rebuilt that using 2.20.0 and see the issue, so I know it’s not a result of new features added.

How to reproduce issue:

  1. Connect device to WiFi hotspot
  2. Let device boot and connect to mDash
  3. Turn off WiFi hotspot
  4. Device gets phantom button presses at regular intervals on GPIO36

The cycle repeats over and over - the regularity of the phantom buttons presses goes something like:

_____|▔|__|▔|__|▔|__|▔|__|▔▔▔▔▔▔▔▔▔▔|__|▔|__|▔|__|▔|__|▔|__|▔|_______

With the period roughly at 1s and the pause in the middle at 3s.
Due to another issue I’ve only just uncovered I’m not able to turn debug on without my device crapping out on boot.

Would love any ideas to investigate,
thanks.

Well, neither your MCU (whichever it is) nor mOS has buttons, so… what is it exactly that you are seeing ?
Does your firmware have a GPIO handler for GPIO36 and that handler is being called ?
Did you actually put an oscilloscope on GPIO36 and saw that pattern ?
What is your microcontroller ?
In case it is an ESP32, did you see this ? There was a change in the IDF version used, so… anyway, ymmv so dyor

Does your firmware have a GPIO handler for GPIO36 and that handler is being called ?

The button is not physically going low, rather the handler is being invoked.

In case it is an ESP32, did you see this ?

Yes ESP32, no haven’t seen this issue - what a pain! I am using ADC1 as well as WiFi, I see comments about fake interrupts being fired with WiFi.

Thanks for the pointers @scaprile

For reference in the end it was as simple as adding adc_power_acquire(); to the mgos_app_init_result() function

I don’t think it is simple, it is a hardware bug in the chip and that is a workaround.
For general reference, the IDF documentation states this:

ESP32: When the power switch of SARADC1, SARADC2, HALL sensor and AMP sensor is turned on, the input of GPIO36 and GPIO39 will be pulled down for about 80ns. When enabling power for any of these peripherals, ignore input from GPIO36 and GPIO39. Please refer to section 3.11 of ‘ECO_and_Workarounds_for_Bugs_in_ESP32’ for the description of this issue. As a workaround, call adc_power_acquire() in the app. This will result in higher power consumption (by ~1mA), but will remove the glitches on GPIO36 and GPIO39.