ThisSmartHouse / CoogleIOT

A ESP8266 Library for easy IOT device development
https://www.thissmarthouse.net/coogleiot/
Other
120 stars 29 forks source link

Exception 28 crash after first config #16

Open flohoff opened 5 years ago

flohoff commented 5 years ago

A stripped down garagedooropener crashes after first config via integrate AP. I set the MQTT port and after joining the WIFI the ESP Crashes:

[INFO UKWN] Coogle IOT v1.3.1 initializing..
09:35:44.372 -> [DEBUG UKWN] Introspecting on-board Flash Memory:
09:35:44.372 -> [DEBUG UKWN] Flash ID: 00164020
09:35:44.372 -> [DEBUG UKWN] Flash real size: 4194304
09:35:44.372 -> [DEBUG UKWN] Flash IDE Size: 4194304
09:35:44.372 -> [DEBUG UKWN] Flash IDE Speed: 40000000
09:35:44.372 -> [DEBUG UKWN] Flash IDE Mode: 1073645354
09:35:44.372 -> [DEBUG UKWN] Flash Chip Configuration Verified: OK
[INFO UKWN] EEPROM not initialized for platform, erasing..
[INFO UKWN] Log file successfully opened
[INFO UKWN] Cannot connect WiFi client, no remote AP specified
09:35:59.582 -> [ERROR UKWN] Failed to connect to remote AP
09:35:59.582 -> [INFO UKWN] Enabling Configuration Mode
09:35:59.582 -> [INFO UKWN] No AP Password found in memory
09:35:59.582 -> [INFO UKWN] Setting to default password: coogleiot
[INFO UKWN] No AP Name found in memory. Auto-generating AP name.
09:35:59.615 -> [INFO UKWN] Setting AP Name To: 
09:35:59.615 -> [INFO UKWN] COOGLEIOT_893542
[INFO UKWN] Intiailzing Access Point
[INFO UKWN] Local IP Address: 
[INFO UKWN] 192.168.0.1
09:36:01.503 -> [INFO UKWN] Initializing DNS Server
09:36:01.503 -> [INFO UKWN] Creating Configuration Web Server
09:36:01.503 -> [INFO UKWN] Initializing Webserver
09:36:01.503 -> [INFO UKWN] Webserver Initiailized!
[INFO UKWN] Not connected to WiFi. Attempting reconnection.
[INFO UKWN] Connecting to remote AP
[INFO UKWN] Connected to Remote Access Point!
09:37:01.796 -> [INFO UKWN] Our IP Address is:
09:37:01.796 -> [INFO UKWN] 192.168.227.159

09:37:01.995 -> Exception (28):
09:37:01.995 -> epc1=0x4021605b epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000008 depc=0x00000000
09:37:01.995 -> 
09:37:01.995 -> >>>stack>>>
09:37:01.995 -> 
09:37:01.995 -> ctx: cont
09:37:01.995 -> sp: 3ffffc60 end: 3fffffc0 offset: 01a0
09:37:02.028 -> 3ffffe00:  3fffdad0 3ffe9894 3fff0cb4 402093ee  
09:37:02.028 -> 3ffffe10:  401039a2 0000007f 7fffffff 00000000  
09:37:02.028 -> 3ffffe20:  0000007f 4010379e 00040000 4010233a  
09:37:02.028 -> 3ffffe30:  40102817 00080000 4010277a 00000100  
09:37:02.028 -> 3ffffe40:  00000000 0000007f 00000000 4000050c  
09:37:02.028 -> 3ffffe50:  00000000 00000000 0000001f 40105135  
09:37:02.028 -> 3ffffe60:  4000050c 00080000 00000000 4000050c  
09:37:02.028 -> 3ffffe70:  4021596b 00000030 00000010 ffffffff  
09:37:02.061 -> 3ffffe80:  40214adf 00000000 3fff1c40 ffff8000  
09:37:02.061 -> 3ffffe90:  000000f2 3fff26b8 00000000 fffffffe  
09:37:02.061 -> 3ffffea0:  00000190 3fffc6fc 00000001 3ffefeb0  
09:37:02.061 -> 3ffffeb0:  00000000 3fffdad0 3ffefee0 00000030  
09:37:02.061 -> 3ffffec0:  00000000 00000000 00000000 fffffffe  
09:37:02.061 -> 3ffffed0:  ffffffff 3fffc6fc 00000001 3ffefeb0  
09:37:02.061 -> 3ffffee0:  00000000 3fffdad0 3ffefee0 00000030  
09:37:02.155 -> 3ffffef0:  00000000 3fffdad0 3ffefee0 00000030  
09:37:02.155 -> 3fffff00:  00000000 3fffdad0 3ffefee0 00000030  
09:37:02.155 -> 3fffff10:  3ffef710 3fff0d58 00000000 40213de8  
09:37:02.155 -> 3fffff20:  00000001 006ab885 3fff0d58 40213e04  
09:37:02.155 -> 3fffff30:  3ffefd50 3ffeff58 3ffe95d4 402097f3  
09:37:02.155 -> 3fffff40:  3ffeff74 00000147 00000147 40100630  
09:37:02.155 -> 3fffff50:  00000000 00000000 00000000 3fff26bc  
09:37:02.155 -> 3fffff60:  0000000f 00000000 3fff1c44 0000000f  
09:37:02.155 -> 3fffff70:  00000000 00000000 3fff0cb4 40213e04  
09:37:02.155 -> 3fffff80:  3fffdad0 00000000 3fff0cb4 3ffefee0  
09:37:02.155 -> 3fffff90:  3fffdad0 00000000 3ffefeb0 402073e7  
09:37:02.155 -> 3fffffa0:  3fffdad0 00000000 3ffefeb0 40214adc  
09:37:02.155 -> 3fffffb0:  feefeffe feefeffe 3ffe8544 40100ad1  
09:37:02.155 -> <<<stack<<<
09:37:02.155 -> 
09:37:02.155 ->  ets Jan  8 2013,rst cause:2, boot mode:(1,6)
09:37:02.155 -> 

Decoding the crash returns:

Exception 28: LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads
PC: 0x4021605b: PubSubClient::connected() at /home/flo/Arduino/libraries/PubSubClient/src/PubSubClient.cpp line 603
EXCVADDR: 0x00000008

Decoding stack results
0x402093ee: CoogleIOT::loop() at /home/flo/Arduino/libraries/CoogleIOT/src/CoogleIOT.cpp line 323
0x4021596b: run_scheduled_functions() at /home/flo/.arduino15/packages/esp8266/hardware/esp8266/2.5.0/cores/esp8266/Schedule.cpp line 68
0x40214adf: loop_wrapper() at /home/flo/.arduino15/packages/esp8266/hardware/esp8266/2.5.0/cores/esp8266/core_esp8266_main.cpp line 126
0x40213de8: String::invalidate() at /home/flo/.arduino15/packages/esp8266/hardware/esp8266/2.5.0/cores/esp8266/WString.cpp line 141
0x40213e04: String::~String() at /home/flo/.arduino15/packages/esp8266/hardware/esp8266/2.5.0/cores/esp8266/WString.cpp line 125
0x402097f3: CoogleIOT::initialize() at /home/flo/Arduino/libraries/CoogleIOT/src/CoogleIOT.cpp line 605
0x40100630: _umm_free at /home/flo/.arduino15/packages/esp8266/hardware/esp8266/2.5.0/cores/esp8266/umm_malloc/umm_malloc.c line 1300
0x40213e04: String::~String() at /home/flo/.arduino15/packages/esp8266/hardware/esp8266/2.5.0/cores/esp8266/WString.cpp line 125
0x402073e7: loop() at /home/flo/projects/arduino/tempsensor/tempsensor.ino line 144
0x40214adc: loop_wrapper() at /home/flo/.arduino15/packages/esp8266/hardware/esp8266/2.5.0/cores/esp8266/core_esp8266_main.cpp line 125

The line is

601 boolean PubSubClient::connected() {
602     boolean rc;
603     if (_client == NULL ) {
604         rc = false;
605     } else {

Which is interesting - As _client is a private object pointer in the PubSubClient Class it seems there is no PubSubClient object instantiated or the pointer is NULL.

And no there is not a valid MQTT endpoint configured and yes i have increased the MAX packet size in MQTT.

Flo

flohoff commented 5 years ago

Hi, i guess this is broken - mqttClient can be zero - So calling mqttClient->connected() causes the above crash.

 338                 wifiFailuresCount = 0;
 339 
 340                 if(!mqttClient->connected()) {
 341                         yield();
 342                         if(!connectToMQTT()) {
 343                                 mqttFailuresCount++;
 344                         }
 345                 }
 346 
 347                 if(mqttClientActive) {
 348                         mqttFailuresCount = 0;
 349                         yield();

With this fix it at least does not crash anymore. It comes up and falls back to config mode as there is no mqtt hostname:

 340                 if(mqttClient) {
 341                         if(!mqttClient->connected()) {
 342                                 yield();
 343                                 if(!connectToMQTT()) {
 344                                         mqttFailuresCount++;
 345                                 }
 346                         }
 347 
 348                         if(mqttClientActive) {
 349                                 mqttFailuresCount = 0;
 350                                 yield();
 351                                 mqttClient->loop();
 352                         }
 353                 }