Chat freely about anything...

User avatar
By paritosharya007
#27413 I have run into an strange problem where my ESP throws Fatal Exception(29) error while switching the mode from station to softap when the user provides wrong password during connection.

My logic is that the ESP would try connecting to an Access Point as station for 5 times. It 5 connection attempts fail (wrong password or any other reason), it would switch over to SoftAP mode. Here's my code:

Code: Select all#define WIFI_STATUS_NAME(status)                                    \
   (STATION_IDLE          == status ?  "STATION_IDLE"            :          \
   (STATION_CONNECTING    == status ?  "STATION_CONNECTING"      :          \
   (STATION_WRONG_PASSWORD == status ?  "STATION_WRONG_PASSWORD"   :          \
   (STATION_NO_AP_FOUND    == status ?  "STATION_NO_AP_FOUND"      :          \
   (STATION_CONNECT_FAIL    == status ?  "STATION_CONNECT_FAIL"      :          \
   (STATION_GOT_IP       == status ?  "STATION_GOT_IP"         : "Unknown"    ))))))
   
   
/******************************************************************************
 * FunctionName : wifi_event_handler
 * Description  : handles the event of wifi connection state change
 * Parameters   : System_Event_t
 * Returns      : none
 *******************************************************************************/
void ICACHE_FLASH_ATTR
wifi_event_handler(System_Event_t *evt) {

   uint8 wifi_status = wifi_station_get_connect_status();

   switch (evt->event) {
      case EVENT_STAMODE_DISCONNECTED: {

         os_printf("-> wifi status : (%d) - ", wifi_status );

         switch (wifi_status) {
            case STATION_CONNECTING: {
               wifi_connect_tries++;
               if ( wifi_connect_tries >= wifi_connect_max_tries ) {
                  os_printf("STATION_CONNECTING..timeout!!!\n");
                  if (wifi_get_opmode()==STATION_MODE) {
                     wifi_set_opmode(SOFTAP_MODE);
                     wifi_connect_tries = 0;
                  }
                  else if (wifi_get_opmode()==STATIONAP_MODE) {

                  }
               }
               else
                  os_printf("STATION_CONNECTING..%d\n", wifi_connect_tries);
               break;
            }
            default: {
               os_printf("-> %s\n",WIFI_STATUS_NAME(wifi_status));
               wifi_connect_tries = 0;
               wifi_set_opmode(SOFTAP_MODE);
               break;
            }
         }
         break;
      }   // end EVENT_STAMODE_DISCONNECTED

      case EVENT_STAMODE_GOT_IP: {
         if (wifi_get_opmode() != STATION_MODE) {      // get current mode, if not station
            wifi_set_opmode(STATION_MODE);             // set current mode to station and save to flash

            wifi_connect_tries = 0;
         }
         break;
      }
   }


The error I get is

mode : sta(18:fe:34:9d:2b:b3) + softAP(1a:fe:34:9d:2b:b3)
add if1
pm close 7 0 0/175059131
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
f 0, beacon timeout
state: 5 -> 0 (1)
-> wifi status : (4) - -> STATION_CONNECT_FAIL
scandone
del if0
mode : softAP(1a:fe:34:9d:2b:b3)
Fatal exception (29):
epc1=0x4025ca65, epc2=0x00000000, epc3=0x400043e6, excvaddr=0x000000b8, depc=0x00000000

ets Jan 8 2013,rst cause:1, boot mode:(1,7)


ets Jan 8 2013,rst cause:4, boot mode:(1,7)

wdt reset


The same code works on my home wifi network, but throws exception on other wifi networks.



Any pointers or clue will be much appreciated.
User avatar
By kolban
#27434 From the exception, you can find the program counter where the exception was thrown ... 0x4025ca65 in your case. Using "objdump", you can then dump your ELF based binary into source code (assembly). From there you can look for the PC address where the exception happened. If we are lucky, that will tell us where the error was encountered and then we will be closer to diagnosis. Failing that, put os_printf() statements throughout the code until we find the failing statement.
User avatar
By PaulTsai
#48041 Here is one example that I encounter Fatal Exception 29 , I try to use objdump commands , but it shows file format can not recognized ? I do not know how to do ?

esp8266@esp8266-VirtualBox:~/ESP8266_NONSDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/bin$ cd upgrade/
esp8266@esp8266-VirtualBox:~/ESP8266_NONSDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/bin/upgrade$ ls
user1.1024.new.2.bin user1.1024.new.2.S user2.1024.new.2.dump
user1.1024.new.2.dump user2.1024.new.2.bin user2.1024.new.2.S
esp8266@esp8266-VirtualBox:~/ESP8266_NONSDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/bin/upgrade$ xtensa-lx106-elf-objdump -x user1.1024.new.2.bin -d
xtensa-lx106-elf-objdump: user1.1024.new.2.bin: File format not recognized
esp8266@esp8266-VirtualBox:~/ESP8266_NONSDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/bin/upgrade$ objdump -x user1.1024.new.2.bin -d
objdump: user1.1024.new.2.bin: File format not recognized
esp8266@esp8266-VirtualBox:~/ESP8266_NONSDK_V1.5.3_16_04_18/ESP8266_NONOS_SDK/bin/upgrade$ objdump user1.1024.new.2.bin