Coder Social home page Coder Social logo

Comments (7)

mobizt avatar mobizt commented on May 24, 2024

Actually axTLS was obsoleted and not cause any problem as long as it's set as optional. BearSSL may be the next to update but not this time.

The possible error causes can be ISR.

First, you must not use delay in Interrupt Service Routine (ISR), i.e zcd.

If the incomming interrup takes place and the operation from last interrupt event was not finished, the error can be occured.

The best practice is do all operations inside ISR as fast as possible by set the volatile variable e.g. Boolean flag and check that flag outside ISR.

from firebase-esp8266.

mobizt avatar mobizt commented on May 24, 2024

Please try to remove delay from zcd().
Or try to use volatile variable e.g. declare it as volatile int delayto

Read this about ISR https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/

Be aware for using the macro name D2 for GPIO that different for some NodeMCU board.

from firebase-esp8266.

arushgupta2007 avatar arushgupta2007 commented on May 24, 2024

Hi,

I am trying to control the status and the dimness of a bulb for which I am using 2 triacs and zero cross detection circuit, so removing the delay would not be possible as it is needed for light dimming, I try volitile int in a bit.

from firebase-esp8266.

arushgupta2007 avatar arushgupta2007 commented on May 24, 2024

I tried adding detachInterrupt(digitalPinToInterrupt(D2)); and attachInterrupt(digitalPinToInterrupt(D2), zcd, FALLING); on the start and end of zcd, and it worked for most of the part. I ran it for ~10 mins, and after that I got this error:

Exception 29: StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores
PC: 0x4021ff26
EXCVADDR: 0x00000100
Memory allocation of 520 bytes failed at 0x4022f962: more_comps at crypto/bigint.c line 1072

Decoding stack results
0x4022fb5c: alloc at crypto/bigint.c line 1106
0x402303e0: bi_square at crypto/bigint.c line 958
0x4022fa08: trim at crypto/bigint.c line 1197
0x402304e1: bi_square at crypto/bigint.c line 1016
0x4022ff92: bi_clone at crypto/bigint.c line 263
0x40230989: bi_barrett at crypto/bigint.c line 1285
0x40230bf0: bi_mod_power at crypto/bigint.c line 1414
0x4022fa08: trim at crypto/bigint.c line 1197
0x40231e0d: RSA_encrypt at crypto/rsa.c line 254
0x4022c968: send_client_key_xchg at ssl/tls1_clnt.c line 435
0x4022ce61: do_clnt_handshake at ssl/tls1_clnt.c line 123
0x4022a04c: mem_free at core/mem.c line 237
0x40224c6a: pbuf_free_LWIP2 at core/pbuf.c line 786
0x4020874a: ClientContext::read(char*, unsigned int) at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src/include/ClientContext.h line 554
0x4020e956: __yield() at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 100
0x4022c770: basic_read at ssl/tls1.c line 1607
0x402202c6: operator new(unsigned int) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/new_op.cc line 52
0x4022c8d8: ssl_read at ssl/tls1.c line 314
0x40208db9: axTLS::SSLContext::connect(ClientContext*, char const*, unsigned int) at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src/include/SSLContext.h line 137
0x4020e874: esp_yield() at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 91
0x4020ee53: delay(unsigned long) at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_wiring.cpp line 54
0x40209007: axTLS::WiFiClientSecure::_connectSSL(char const*) at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src/include/SSLContext.h line 341
0x402090ad: axTLS::WiFiClientSecure::connect(char const*, unsigned short) at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src\WiFiClientSecureAxTLS.cpp line 117
0x40207345: FirebaseHTTPClient::http_connect() at C:\Users\...\Documents\Arduino\libraries\Firebase-ESP8266-master\src\FirebaseESP8266HTTPClient.cpp line 82
0x40207380: FirebaseHTTPClient::http_sendRequest(char const*, char const*) at C:\Users\...\Documents\Arduino\libraries\Firebase-ESP8266-master\src\FirebaseESP8266HTTPClient.cpp line 63
0x40207714: ESP8266WiFiSTAClass::status() at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 613
0x402202c6: operator new(unsigned int) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/new_op.cc line 52
0x40203130: FirebaseESP8266::sendFirebaseRequest(FirebaseData&, char const*, unsigned char, unsigned char, char const*, char const*, unsigned int) at C:\Users\...\Documents\Arduino\libraries\Firebase-ESP8266-master\src\FirebaseESP8266.cpp line 3362
0x40211034: free(void*) at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 1764
0x40204c21: FirebaseESP8266::firebaseConnect(FirebaseData&, std::string const&, unsigned char, unsigned char, std::string const&, std::string const&) at C:\Users\...\Documents\Arduino\libraries\Firebase-ESP8266-master\src\FirebaseESP8266.cpp line 1480
0x4022c403: basic_read at ssl/tls1.c line 1374
0x40100532: __attachInterrupt(uint8_t, voidFuncPtr, int) at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_wiring_digital.cpp line 206
0x401000f1: zcd() at C:\Users\...\Documents\Arduino\esp_home_control/esp_home_control.ino line 147
0x40100439: interrupt_handler(void*) at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_wiring_digital.cpp line 169
0x40100428: interrupt_handler(void*) at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_wiring_digital.cpp line 165
0x40207714: ESP8266WiFiSTAClass::status() at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 613
0x402052cc: FirebaseESP8266::firebaseConnect(FirebaseData&, std::string const&, unsigned char, unsigned char, std::string const&, std::string const&) at C:\Users\...\Documents\Arduino\libraries\Firebase-ESP8266-master\src\FirebaseESP8266.cpp line 1718
0x40206ab0: FirebaseESP8266::sendRequest(FirebaseData&, unsigned char, std::string const&, unsigned char, unsigned char, std::string const&, std::string const&, std::string const&) at C:\Users\...\Documents\Arduino\libraries\Firebase-ESP8266-master\src\FirebaseESP8266.cpp line 1828
0x40206fdd: FirebaseESP8266::buildRequest(FirebaseData&, unsigned char, unsigned char, std::string const&, char const*, bool, std::string const&, std::string const&) at C:\Users\...\Documents\Arduino\libraries\Firebase-ESP8266-master\src\FirebaseESP8266.cpp line 199
0x4020da55: Print::write(char const*) at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266/Print.h line 60
0x402202c6: operator new(unsigned int) at ../../../../../dl/gcc-xtensa/libstdc++-v3/libsupc++/new_op.cc line 52
0x40207165: FirebaseESP8266::setBool(FirebaseData&, std::string const&, bool, bool, std::string const&, std::string const&) at C:\Users\...\Documents\Arduino\libraries\Firebase-ESP8266-master\src\FirebaseESP8266.cpp line 728
0x40220bca: std::basic_string  , std::allocator  >::basic_string(char const*, std::allocator  const&) at /workdir/arena/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc line 218
0x4010022c: millis() at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_wiring.cpp line 186
0x402071db: FirebaseESP8266::setBool(FirebaseData&, String const&, bool) at C:\Users\...\Documents\Arduino\libraries\Firebase-ESP8266-master\src\FirebaseESP8266.cpp line 688
0x4020e1fe: String::reserve(unsigned int) at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\WString.cpp line 148
0x4020e25c: String::copy(char const*, unsigned int) at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\WString.cpp line 211
0x4020e3f8: String::operator=(String const&) at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\WString.cpp line 259
0x40201391: loop() at C:\Users\...\Documents\Arduino\esp_home_control/esp_home_control.ino line 85
0x4020e924: loop_wrapper() at C:\Users\...\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266\core_esp8266_main.cpp line 125

Do you why my heap in gradually decreasing over time?

I was printing ESP.getFreeHeap() every 2 sec, and it started with 31984 and ended with 5576.

from firebase-esp8266.

mobizt avatar mobizt commented on May 24, 2024

You NEED to remove delay from ISR, you don't have choices, the resource was pushed in stack every new interrupt occurred causes stack growed bigger and interfered with heap memory then corrupted the heap and finally system error. Any way, nested interrupt must be prevented.

For timing, you can use non-block code as millis() or micros() to get the milliseconds and microseconds counts. Or you can use esp os timer and schedule task library Ticker.

Redesign your program flow, try to not use blocking code (delay), use the ms/us counter comparison, timer or schedule tasks.

from firebase-esp8266.

arushgupta2007 avatar arushgupta2007 commented on May 24, 2024

Hey thanks for your suggestion, I try Ticker in a bit. Through volatile int did not work for me

from firebase-esp8266.

arushgupta2007 avatar arushgupta2007 commented on May 24, 2024

🎉 It worked! 🎉

Thanks @mobizt for your time and support!

from firebase-esp8266.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.