ESP32S2 - Touch wake up low duty cycle causes spontaneous reset

scottsh
Posts: 12
Joined: Wed Dec 09, 2020 6:58 am

ESP32S2 - Touch wake up low duty cycle causes spontaneous reset

Postby scottsh » Tue Jan 19, 2021 6:55 pm

<Cross posted to Hardware, but a different angle here... This post is more about the code, less about the Hardware. :)>

I have a problem that is stumping me... I have an ESP32S2 board which uses the ESP32S2 WROOM module.

After I put the ESP32S2 into deep sleep, on MOST boards (I've got one magic one that doesn't repro), after a while, the CPU will randomly reset. I've double checked the esp_reset_reason(), and it returns power on (as you can see from the dump below).

One interesting thing is that it seems to take a while the first sleep. It will sleep for 5-30 seconds the first time before resetting, but then after that it happens quite quickly. Sometimes it's immediate, looks like under a second, and sometimes it takes a couple seconds, but never nearly as long as the first time. That kind of makes me think of a charge building up on something, or a capacitor draining and never getting recharged... But for the life of me, I can't figure out what.

The problem seems to be caused when I changed the sleep time:

Code: Select all

    uint32_t sleep_time_in_ms = 1;
    uint32_t touchpad_sleep_ticks = (uint32_t)((uint64_t)sleep_time_in_ms * rtc_clk_slow_freq_get_hz() / 1000);

// Override the calculation for testing
    touchpad_sleep_ticks = 70;

    uint16_t oldslp, oldmeas;
    touch_pad_get_meas_time(&oldslp, &oldmeas);
    ESP_LOGI(TAG, "oldslp=%d  newslp=%d oldmeas=%d", oldslp, touchpad_sleep_ticks, oldmeas);

    touch_pad_set_meas_time(touchpad_sleep_ticks, 500);

I (5097) Main: AC now:Tue Jan 19 18:33:23 2021
I (6897) Sleep: Enabling timer wakeup, 86400s
I (6997) Sleep: test init: touch pad [13] slp 26538, thresh 2653
I (6997) Sleep: oldslp=15 newslp=60 oldmeas=500
I (6997) Sleep: Enabling touch pad wakeup
I (6997) Sleep: Entering deep sleep
By modifying that touchpad_sleep_ticks variable, I can cause it to repro or not. At 60 ticks (shown above), it doesn't repro. Rock solid. At 72 ticks, it starts to repro and resets itself all the time. SUPER WEIRD!!

I really need to get that ticks number way up (should be 90000) so I can get to a low power sleep.

Any ideas? Any idea what could make it say POWERON as the power reason? Everything within the chip, I thought, had a power on reason if it rebooted because of brownout, or watchdog or whatever... But the fact that I'm getting POWERON strikes me as VERY strange.
I (5417) Sleep: Enabling timer wakeup, 86400s
I (5517) Sleep: test init: touch pad [13] slp 7546, thresh 754
I (5517) Sleep: Enabling touch pad wakeup
I (5517) Sleep: Entering deep sleep

ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6100,len:0x8
load:0x3ffe6108,len:0x14f4
load:0x4004c000,len:0x9d8
load:0x40050000,len:0x2e34
entry 0x4004c1ec
I (46) boot: ESP-IDF v4.3-dev-1903-g83c3e79d8-dirty 2nd stage bootloader
I (46) boot: compile time 12:35:25
I (46) boot: chip revision: 0
I (47) boot.esp32s2: SPI Speed : 80MHz
I (51) boot.esp32s2: SPI Mode : DIO
I (54) boot.esp32s2: SPI Flash Size : 4MB
I (58) boot: Enabling RNG early entropy source...
I (63) boot: Partition Table:
I (65) boot: ## Label Usage Type ST Offset Length
I (71) boot: 0 nvs WiFi data 01 02 00009000 00004000
I (78) boot: 1 otadata OTA data 01 00 0000d000 00002000
I (84) boot: 2 phy_init RF data 01 01 0000f000 00001000
I (91) boot: 3 factory factory app 00 00 00010000 00100000
I (98) boot: 4 ota_0 OTA app 00 10 00110000 00100000
I (104) boot: 5 ota_1 OTA app 00 11 00210000 00100000
I (111) boot: 6 fs Unknown data 01 82 00310000 000f0000
I (117) boot: End of partition table
I (121) boot: Defaulting to factory image
I (124) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f000020 size=0x24ddc (151004) map
I (164) esp_image: segment 1: paddr=0x00034e04 vaddr=0x3ffc6930 size=0x03b40 ( 15168) load
I (168) esp_image: segment 2: paddr=0x0003894c vaddr=0x40022000 size=0x00404 ( 1028) load
0x40022000: _WindowOverflow4 at I:/repos/esp-idf-fork/components/freertos/port/xtensa/xtensa_vectors.S:1730

I (169) esp_image: segment 3: paddr=0x00038d58 vaddr=0x40022404 size=0x072c0 ( 29376) load
0x40022404: _coredump_iram_start at ??:?

I (184) esp_image: segment 4: paddr=0x00040020 vaddr=0x40080020 size=0xab1a0 (700832) map
0x40080020: _stext at ??:?

I (331) esp_image: segment 5: paddr=0x000eb1c8 vaddr=0x400296c4 size=0x0d268 ( 53864) load
0x400296c4: rtc_sleep_pd at I:/repos/esp-idf-fork/components/esp_hw_support/port/esp32s2/rtc_sleep.c:50

I (346) esp_image: segment 6: paddr=0x000f8438 vaddr=0x40070000 size=0x0002c ( 44) load
0x40070000: _rtc_code_start at ??:?

I (346) esp_image: segment 7: paddr=0x000f846c vaddr=0x50000000 size=0x01810 ( 6160) load
I (365) boot: Loaded app from partition at offset 0x10000
I (365) boot: Disabling RNG early entropy source...
I (375) cache: Instruction cache : size 8KB, 4Ways, cache line size 32Byte
I (375) cpu_start: Pro cpu up.
I (429) cpu_start: Pro cpu start user code
I (429) cpu_start: cpu freq: 160000000
I (429) cpu_start: Application information:
I (429) cpu_start: Project name: remote-scale
I (433) cpu_start: App version: 0.0.4.104
I (437) cpu_start: Compile time: Jan 18 2021 12:35:20
I (442) cpu_start: ELF file SHA256: 98e8d8eb49897e92...
I (447) cpu_start: ESP-IDF: v4.3-dev-1903-g83c3e79d8-dirty
I (453) heap_init: Initializing. RAM available for dynamic allocation:
I (460) heap_init: At 3FF9E02C len 00001FD4 (7 KiB): RTCRAM
I (465) heap_init: At 3FFCE9A8 len 0002D658 (181 KiB): DRAM
I (470) heap_init: At 3FFFC000 len 00003A10 (14 KiB): DRAM
I (476) spi_flash: detected chip: generic
I (479) spi_flash: flash io: dio
I (486) cpu_start: Starting scheduler on PRO CPU.
I (487) Sleep: esp_reset_reason=1 Timespent in deep sleep=1106ms
I (487) Sleep: Not a deep sleep reset
I (487) Main: Wake reason=0
Any ideas? Any thoughts about what could be causing it to Reset from deep sleep?

Thanks,

- Scott

scottsh
Posts: 12
Joined: Wed Dec 09, 2020 6:58 am

Re: ESP32S2 - Touch wake up low duty cycle causes spontaneous reset

Postby scottsh » Thu Jan 28, 2021 8:09 pm

Circling back to provide the conclusion of the issue on this thread. It looks like the cause of the spontaneous resets is the brownout detector circuit. Disabling it (not through menuconfig, but through the registers) looks to resolve the issue.

Further discussion on this thread:

https://www.esp32.com/viewtopic.php?f=13&t=19208

And a bit more on these threads:

https://www.esp32.com/viewtopic.php?f=12&t=19084
https://github.com/espressif/esp-idf/issues/6179
https://github.com/adafruit/circuitpyth ... -767419836

Thanks,

- Scott

Who is online

Users browsing this forum: No registered users and 117 guests