Enter Light Sleep Mode cause reset

JacksonLv
Posts: 7
Joined: Thu Aug 10, 2017 11:06 am

Enter Light Sleep Mode cause reset

Postby JacksonLv » Fri Nov 02, 2018 2:08 pm

I'm trying out to enter light sleep mode in a timer interrupt function,but it will crash and reset as it do sleep sometimes.I found when it is in smart config mode ,it won't crash.If it's in station mode and connected to the AP,it will have this matter.Here is my code and log ,PLS help!! MY SDK version is NONOS 3.0.0

Code: Select all

sleep_time_cnt: 60

enter sleep mode

wifi disconnected

pm close 7
fpm open,type:1 0
fpm 758

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 2408, room 16
tail 8
chksum 0xe5
load 0x3ffe8000, len 776, room 0
tail 8
chksum 0x84
load 0x3ffe8310, len 632, room 0
tail 8
chksum 0xd8
csum 0xd8


Code: Select all

   void ICACHE_FLASH_ATTR user_init(){
   PIN_FUNC_SELECT(RED_LIGHT_IO_MUX, RED_LIGHT_IO_FUNC);

   drv_Switch_Init();
   sleep_init();

   os_printf("Firmware Version: 20181101\n");

   wifi_set_opmode(STATION_MODE);

   wifi_station_get_config_default(&stationConf);

   if (os_strlen(stationConf.ssid) != 0) {
      os_printf("user_scan\n");
      //net_status   = 1;
      os_timer_disarm(&check_ip_timer);
      os_timer_setfn(&check_ip_timer, (os_timer_func_t *) user_check_ip, NULL);
      os_timer_arm(&check_ip_timer, 100, 0);

   } else {
       os_printf("smartcfg\n");

       smartconfig_start(smartconfig_done);
       net_status  = 0;
       WIFI_DISCONNTED_FLAG;

   }

   os_timer_disarm(&light_status_timer);
   os_timer_setfn(&light_status_timer, (os_timer_func_t *)led_status_timer_func , NULL);
   os_timer_arm(&light_status_timer,MAIN_TIMER_PERIOD,1);

   os_timer_disarm(&sleep_timer);
   os_timer_setfn(&sleep_timer, (os_timer_func_t *)sleep_timer_func , NULL);
   os_timer_arm(&sleep_timer,SLEEP_TIMER_PERIOD,1);
   }



Code: Select all

void sleep_init(void){
   wifi_fpm_set_sleep_type(LIGHT_SLEEP_T);     //set force sleep type, clsoe rf&cpu
   wifi_fpm_set_wakeup_cb(fpm_wakup_cb_func1); //Set fpm wakeup callback function

}


Code: Select all

void sleep_start(void )
{
   os_printf("enter sleep mode\n\n");

   if(wifi_station_get_connect_status() == STATION_GOT_IP){
      while(!wifi_station_disconnect()){
         os_delay_us(10);
      }
      os_printf("wifi disconnected\n\n");
   } else {
      smartconfig_stop();
      os_printf("wifi not connected\n\n");
   }
   os_delay_ms(200);
   RED_LIGHT_OFF;
   wifi_set_opmode(NULL_MODE);               //set wifi mode to null mode.
   wifi_fpm_open();                        //enable force sleep fucntion

   int rst =  wifi_fpm_do_sleep(FPM_SLEEP_MAX_TIME);      // do sleep
   os_printf("sleep rst : %d",rst);


}



Code: Select all

void ICACHE_FLASH_ATTR
sleep_timer_func(void )
{
   static uint8_t cnt = 0;
   if(sleep_time_cnt < SLEEP_TIME_CNT){
      sleep_time_cnt++;
      os_printf("sleep_time_cnt: %d\n\n",sleep_time_cnt);
   }else {//2 min
      sleep_time_cnt = 0;
      os_timer_disarm(&check_ip_timer);
      os_timer_disarm(&light_status_timer);
      os_timer_disarm(&KeyScan_timer);
      os_timer_disarm(&sleep_timer);
      sleep_start();
   }

}

JacksonLv
Posts: 7
Joined: Thu Aug 10, 2017 11:06 am

Re: Enter Light Sleep Mode cause reset

Postby JacksonLv » Fri Nov 02, 2018 4:04 pm

I add code in the user init to check the reset reason,it seems the wdt cause the reset,how can I fix this?all the timers are already turn off.

Code: Select all

   struct rst_info *rst_info = system_get_rst_info();
   os_printf("reset reason: %x\n", rst_info->reason);
   if(rst_info->reason == REASON_WDT_RST || rst_info->reason == REASON_EXCEPTION_RST || rst_info->reason == REASON_SOFT_WDT_RST)
   {
         if (rst_info->reason == REASON_EXCEPTION_RST)
         {
            os_printf("Fatal exception (%d):\n", rst_info->exccause);
         }
         os_printf("epc1=0x%08x, epc2=0x%08x, epc3=0x%08x, excvaddr=0x%08x, depc=0x%08x\n",rst_info->epc1, rst_info->epc2, rst_info->epc3, rst_info->excvaddr, rst_info->depc);
   }


Code: Select all

reset reason: 3
epc1=0x40232284, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000


Code: Select all

40232284:   ffff06           j   40232284 <fpm_do_sleep+0x20>

Who is online

Users browsing this forum: No registered users and 2 guests