TG0WDT_SYS_RESET after two DEEPSLEEP_RESET

Dav_FR
Posts: 14
Joined: Mon Mar 27, 2017 8:14 am

TG0WDT_SYS_RESET after two DEEPSLEEP_RESET

Postby Dav_FR » Thu Mar 30, 2017 2:58 pm

Hi all,

Not sure if this is the correct site, since is due to an "strange behaviour" which occurs after get the latest commits from master, not in a release.

I did a deep-sleep test when I started to develop with ESP32 at the commit 5f3b9876b8088f89f5223484ad000cb4480d03f6 and all was working ok.

Today I retrieved a lot of new commits from master repository, and found that after the second Deep-sleep, the Task Group 0 watchdog is being triggered during the deep sleep. This was solved rolling back to the mentioned commit. Not sure which commit introduces this behaviour or if the problem is related just with my device but I thought could be interesting share with the community and developers.

Notes:
- I'm using 1000 as value in "Extra delay in deep sleep wake stub" configuration.
- Observed using DevKitC device using a simple code as shown next.
- I tested by removing watchdogs (interrupt and task) in menuconfig and occurs the same.
- I tested also by removing watchdog task with "esp_task_wdt_delete()" after enable it with "esp_task_wdt_init" and occurs the same.

Best regards and sorry for the inconvenience,
Dav

Code: Select all

RTC_DATA_ATTR int wake_count = 0;

void RTC_IRAM_ATTR esp_wake_deep_sleep(void) {
    esp_default_wake_deep_sleep();
    wake_count++;
}

void app_main(void)
{

	///esp_task_wdt_init();
	//esp_task_wdt_feed();
	esp_deep_sleep_wakeup_cause_t cause = esp_deep_sleep_get_wakeup_cause();

	if (cause == ESP_DEEP_SLEEP_WAKEUP_UNDEFINED) {

		ESP_LOGI(tagg,"First start (%d)",wake_count);
	} else {

		ESP_LOGI(tagg,"Woken from deep sleep (%d)",wake_count);
	}

	//esp_task_wdt_delete();
	esp_deep_sleep(3*1000000);

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: TG0WDT_SYS_RESET after two DEEPSLEEP_RESET

Postby ESP_igrr » Fri Mar 31, 2017 4:50 am

Thanks for the report, I was able to reproduce this. RTC FAST memory seems to be getting disabled, looking into it.

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: TG0WDT_SYS_RESET after two DEEPSLEEP_RESET

Postby rudi ;-) » Fri Mar 31, 2017 8:30 am

confirm too ivan. same is in the ulp example after first wakeup -
if the board is disconnect from power supply then get the first wake up the right counter result.
next wakeup is then again TG0WDT until the board is not disconnect and connect again.
best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

Davide
Posts: 2
Joined: Fri Mar 31, 2017 9:44 am

Re: TG0WDT_SYS_RESET after two DEEPSLEEP_RESET

Postby Davide » Fri Mar 31, 2017 9:47 am

Hi
I confirm the problem is present. Neither the deep_sleep example is working.
Do you know when it will be fixed?
Best Regards
Davide

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: TG0WDT_SYS_RESET after two DEEPSLEEP_RESET

Postby ESP_igrr » Fri Mar 31, 2017 9:56 am

Incidentally we do have a change which fixes the issue here (and also opens the source of rtc_clk and rtc_pm libs), but we'd like to take a bit more time to understand this issue, because it was triggered by some very unrelated changes. I expect that the fix will be rolled in by the end of next week (Mon and Tue are holidays here). Sorry about that, in the meantime you may roll back the the commit mentioned in the OP, or use the release/v2.0 branch.

Davide
Posts: 2
Joined: Fri Mar 31, 2017 9:44 am

Re: TG0WDT_SYS_RESET after two DEEPSLEEP_RESET

Postby Davide » Fri Mar 31, 2017 11:38 am

OK. Thanks! I rolled back to the mentioned commit and it works perfectly.
Bye
Davide

Dav_FR
Posts: 14
Joined: Mon Mar 27, 2017 8:14 am

Re: TG0WDT_SYS_RESET after two DEEPSLEEP_RESET

Postby Dav_FR » Fri Mar 31, 2017 12:47 pm

Hi all,

Thanks you all for the support and replicate the bug, I already did the rollback, so we can continue in the development while the fix is published. :D

Br,
David

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: TG0WDT_SYS_RESET after two DEEPSLEEP_RESET

Postby rudi ;-) » Fri Mar 31, 2017 2:09 pm

1+
no hurry ivan, and thanks for try this out.
best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

ginodecock
Posts: 30
Joined: Thu Jun 29, 2017 7:10 pm

Re: TG0WDT_SYS_RESET after two DEEPSLEEP_RESET

Postby ginodecock » Thu Jun 29, 2017 7:13 pm

Hi,

I also experience WDT reset when enabling a custom Deepsleep stub.

Do I have the same bug here:

Code: Select all

static void RTC_IRAM_ATTR sensor_reading(void) {

	REG_WRITE(TIMG_WDTFEED_REG(0), 1);
    if (mcount > 1023){								//prevent array overflow
        	mcount = 0;
        }
    if ((mcount * 300) < mnextlog){					//Check when next log report is required
      	mtempesp[mcount] = temprature_sens_read();
      	static RTC_RODATA_ATTR const char fmt_str[] = "Wake count %d\n";
      	ets_printf(fmt_str, mcount);
      	mcount++;
       	while (REG_GET_FIELD(UART_STATUS_REG(0), UART_ST_UTX_OUT)) {
       		REG_WRITE(TIMG_WDTFEED_REG(0), 1);
       	}
       	REG_WRITE(RTC_ENTRY_ADDR_REG, (uint32_t)&sensor_reading);
       	CLEAR_PERI_REG_MASK(RTC_CNTL_STATE0_REG, RTC_CNTL_SLEEP_EN);
       	SET_PERI_REG_MASK(RTC_CNTL_STATE0_REG, RTC_CNTL_SLEEP_EN);
       	while (true) {
       		REG_WRITE(TIMG_WDTFEED_REG(0), 1);
       	}
    }else{
    	esp_default_wake_deep_sleep();
    }
}


void app_main()
{

    ESP_LOGI(TAG, "---------- Intialization started ----------");
    ESP_LOGI(TAG, "---------- Software version: %2d -----------", SOFTWARE_VERSION);
    esp_deep_sleep_enable_timer_wakeup(WAKEUP_TIME * 1000000);
    ESP_LOGI(TAG, "preparing deep sleep");
    gettimeofday(&sleep_enter_time, NULL);
    //esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_ON);
    esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_ON);
    gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT);
    struct timeval now;
    gettimeofday(&now, NULL);
    int sleep_time_ms = (now.tv_sec - sleep_enter_time.tv_sec) * 1000 + (now.tv_usec - sleep_enter_time.tv_usec) / 1000;
    switch (esp_deep_sleep_get_wakeup_cause()) {
        case ESP_DEEP_SLEEP_WAKEUP_TIMER: {
                printf("Wake up from timer. Time spent in deep sleep: %dms\n", sleep_time_ms);
                break;
        }
        case ESP_DEEP_SLEEP_WAKEUP_UNDEFINED:
                default:
                printf("Not a deep sleep reset\n");
        }
    // Set the wake stub function
    esp_set_deep_sleep_wake_stub(&sensor_reading);

 ..... ...... ......

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: TG0WDT_SYS_RESET after two DEEPSLEEP_RESET

Postby ESP_igrr » Thu Jun 29, 2017 11:59 pm

Please take a look at http://esp-idf.readthedocs.io/en/latest ... wake-stubs, specifically the sentence which says that only functions from ROM or RTC fast memory may be called in wake stubs. 'temprature_sens_read' is a function stored in flash, it can't be called from wake stubs.

Who is online

Users browsing this forum: No registered users and 47 guests