mobizt / Firebase-ESP-Client

[DEPRECATED]🔥Firebase Arduino Client Library for ESP8266, ESP32 and RP2040 Pico. The complete, fast, secured and reliable Firebase Arduino client library that supports RTDB, Cloud Firestore, Firebase and Google Cloud Storage, Cloud Messaging and Cloud Functions for Firebase.
MIT License
471 stars 100 forks source link

ESP8266 reboot issue during Firebase OTA firmware update from stogare #595

Closed vanquang297 closed 10 months ago

vanquang297 commented 10 months ago

I am using the Firebase-ESP-Client library on ESP8266 and encountering an issue during OTA firmware from Firebase Stogare. When the config.database_url is initialized with the value of DATABASE_URL, the OTA update process leads to the ESP8266 restarting. However, if no value is assigned to config.database_url, the OTA update process works normally.

Successful case

config.api_key = API_KEY;
auth.user.email = USER_EMAIL;
auth.user.password = USER_PASSWORD;
//config.database_url = DATABASE_URL;
config.token_status_callback = tokenStatusCallback;
18:15:34.631 -> 
18:15:34.631 -> Download firmware file...
18:15:34.677 -> 
18:15:36.895 -> Downloading firmware firmware.bin (463696)
18:15:36.895 -> Downloaded 0%, Elapsed time 11458 ms
18:15:37.393 -> Downloaded 2%, Elapsed time 11961 ms
18:15:37.778 -> Downloaded 4%, Elapsed time 12358 ms
18:15:38.304 -> Downloaded 6%, Elapsed time 12869 ms
18:15:38.806 -> Downloaded 8%, Elapsed time 13367 ms
18:15:39.334 -> Downloaded 10%, Elapsed time 13901 ms
18:15:39.752 -> Downloaded 12%, Elapsed time 14339 ms
18:15:40.188 -> Downloaded 14%, Elapsed time 14767 ms
18:15:40.693 -> Downloaded 16%, Elapsed time 15282 ms
18:15:41.102 -> Downloaded 18%, Elapsed time 15692 ms
18:15:41.607 -> Downloaded 20%, Elapsed time 16175 ms
18:15:42.190 -> Downloaded 22%, Elapsed time 16786 ms

In case of failure

config.api_key = API_KEY;
auth.user.email = USER_EMAIL;
auth.user.password = USER_PASSWORD;
config.database_url = DATABASE_URL;
config.token_status_callback = tokenStatusCallback; 
17:02:03.321 -> Download firmware file...
17:02:03.321 -> 
17:02:04.118 -> 
17:02:04.118 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
17:02:04.118 -> 
17:02:04.118 -> Exception (29):
17:02:04.118 -> epc1=0x4000e0de epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000008 depc=0x00000000
17:02:04.118 -> 
17:02:04.118 -> >>>stack>>>
17:02:04.118 -> 
17:02:04.118 -> ctx: cont
17:02:04.118 -> sp: 3ffffa80 end: 3fffffd0 offset: 0150
17:02:04.164 -> 3ffffbd0:  3ffefa08 00000000 3ffe8660 3ffffee0  
17:02:04.164 -> 3ffffbe0:  00000098 3ffffd08 40220e64 3ffffd08  
17:02:04.164 -> 3ffffbf0:  00000098 3ffffee0 3ffefa08 4021c721  
17:02:04.164 -> 3ffffc00:  3ffffd30 3ffffd60 3fff09ac 4023d588  
17:02:04.164 -> 3ffffc10:  00000000 00000000 00000000 00000000  
17:02:04.164 -> 3ffffc20:  00000000 00000000 00000000 00000000  
17:02:04.164 -> 3ffffc30:  00000000 3fff0680 00000000 00000000  
17:02:04.164 -> 3ffffc40:  00000000 00000000 00000000 00000000  
17:02:04.164 -> 3ffffc50:  00000000 00000000 00000000 00000000  
17:02:04.164 -> 3ffffc60:  00000000 00000000 00000000 00000000  
17:02:04.210 -> 3ffffc70:  00000000 00000000 00000000 00000000  
17:02:04.210 -> 3ffffc80:  00000000 00000000 00000000 00000000  
17:02:04.210 -> 3ffffc90:  00000000 00000000 00000000 00000000  
17:02:04.210 -> 3ffffca0:  00000000 00000218 00000007 00000006  
17:02:04.210 -> 3ffffcb0:  00000000 00000000 00000800 00003000  
17:02:04.210 -> 3ffffcc0:  3f010000 00000800 00000000 00000000  
17:02:04.210 -> 3ffffcd0:  ffffffff 3fff60b4 00000804 0059fc9c  
17:02:04.210 -> 3ffffce0:  3ffffd58 00000800 00000000 00000000  
17:02:04.210 -> 3ffffcf0:  00000000 00000000 3ffefa08 00000000  
17:02:04.210 -> 3ffffd00:  00000000 00000000 3fffa914 00000804  
17:02:04.257 -> 3ffffd10:  00000001 00187169 cb020c49 1c432252  
17:02:04.257 -> 3ffffd20:  40275496 3ffefa08 3ffefef4 00000001  
17:02:04.257 -> 3ffffd30:  00000000 00000000 00000000 00000000  
17:02:04.257 -> 3ffffd40:  00000000 00000000 00000000 00000000  
17:02:04.257 -> 3ffffd50:  3fff3ddc 0000002d 00000000 00002004  
17:02:04.257 -> 3ffffd60:  00000000 00000000 3ffeff78 4020cefd  
17:02:04.257 -> 3ffffd70:  3ffefdb8 00000000 3ffeff24 00000007  
17:02:04.257 -> 3ffffd80:  00000000 00000001 3fff3ddc 3ffffd30  
17:02:04.257 -> 3ffffd90:  ffffffff 3ffeff24 3ffefa08 4021c811  
17:02:04.257 -> 3ffffda0:  3ffffee0 3ffffe08 0000002d 00000000  
17:02:04.303 -> 3ffffdb0:  3ffef380 3ffefa08 3ffffee0 4021cf48  
17:02:04.303 -> 3ffffdc0:  4027667b 00000020 00000014 40221cf6  
17:02:04.303 -> 3ffffdd0:  00000000 00000000 3fff13ac 4021e0a4  
17:02:04.303 -> 3ffffde0:  00003450 0000068a 3ffe8664 40100ace  
17:02:04.303 -> 3ffffdf0:  3fff4000 3ffeff78 3ffefa08 00000000  
17:02:04.303 -> 3ffffe00:  00000000 00000020 00000000 00000000  
17:02:04.303 -> 3ffffe10:  3ffeff24 00000000 3ffffe40 40207188  
17:02:04.303 -> 3ffffe20:  3fff3fe4 0000001e 3ffefa44 00000000  
17:02:04.303 -> 3ffffe30:  00000000 3ffeff24 3ffefa08 4021c015  
17:02:04.350 -> 3ffffe40:  00000000 00000000 3ffeff78 00000000  
17:02:04.350 -> 3ffffe50:  00000000 3ffffee0 3ffefa08 4021d181  
17:02:04.350 -> 3ffffe60:  00000000 f4240000 00000000 00000000  
17:02:04.350 -> 3ffffe70:  00007237 f4240000 00000000 3fff0358  
17:02:04.350 -> 3ffffe80:  3ffe8a57 00000020 00000020 40100f2f  
17:02:04.350 -> 3ffffe90:  ffffffff ffffffff 3ffffef0 402071cd  
17:02:04.350 -> 3ffffea0:  00000001 0018708f 0f1a9fbe 1c422569  
17:02:04.350 -> 3ffffeb0:  3ffeff24 3ffffef0 00000020 3fff0358  
17:02:04.350 -> 3ffffec0:  3ffeff78 3ffefa08 3ffefb68 00001000  
17:02:04.350 -> 3ffffed0:  3ffeff24 3ffefe08 3ffefa08 4021d2e2  
17:02:04.397 -> 3ffffee0:  3fff30ac 00000010 00000000 00000000  
17:02:04.397 -> 3ffffef0:  3fff3a8c 00000020 00000000 00000000  
17:02:04.397 -> 3fffff00:  00000000 00000000 00000000 ffffffff  
17:02:04.397 -> 3fffff10:  00000000 00000007 00000000 00000000  
17:02:04.397 -> 3fffff20:  00000000 40206e60 3ffeff78 4022a268  
17:02:04.397 -> 3fffff30:  0000000c ffffffff 3ffe8a57 3fff0358  
17:02:04.397 -> 3fffff40:  3ffe8630 0000001b 3fff01b0 3fff0358  
17:02:04.397 -> 3fffff50:  3ffefa08 00000000 3fff01b0 4020776a  
17:02:04.397 -> 3fffff60:  0000000c ffffffff 3ffe8a76 00000000  
17:02:04.397 -> 3fffff70:  40206e60 3fff01f8 00000001 4021fc88  
17:02:04.443 -> 3fffff80:  00000001 00000002 3ffe9028 ffffffff  
17:02:04.443 -> 3fffff90:  0000000c 3ffffe60 3ffffe44 3ffffe20  
17:02:04.443 -> 3fffffa0:  3fffdad0 00000000 3fff032c 3fff0358  
17:02:04.443 -> 3fffffb0:  3fffdad0 00000000 3fff032c 402210a0  
17:02:04.443 -> 3fffffc0:  feefeffe feefeffe 3fffdab0 401002d5  
17:02:04.443 -> <<<stack<<<
17:02:04.443 -> 
17:02:04.443 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
17:02:04.443 -> 

I am hopeful to receive guidance or assistance regarding this issue, aiming to identify a resolution that allows for the utilization of config.database_url without triggering the ESP8266 restart during the OTA update process.

I greatly appreciate your feedback and any support you can provide in addressing this matter.

mobizt commented 10 months ago

The error is about stack overflow (out of memory) which is not related to something you assumed.

I am already tested it and it works normally with option config.database_url.

Please make sure you read this.

You should have at least 20k free memory to perform the OTA download because of the SSL Client required 16k buffer memory to handle full frame SSL data for large payload download especially in case OTA which the memory will be reserved as much as this amount.

For ESP8266, you should stop doing everything that consumed memory and your device free Heap should be more than 18-20k before calling the OTA functions.