B4R Question ESP8266 - Soft WDT Reset - It fires even with yield();

hatzisn

Well-Known Member
Licensed User
Longtime User
I have got a problem I cannot figure a way to solve it. Here is what's happening:

I have a timer that runs every one second. At certain times a day the timer must be stopped and download new data.
I execute the command "tim.Enabled = False" and try to download the new data. At this point I get a Soft WDT Reset. I got the code full of yield(); commands but the Soft WDT Reset fires again and again. I cannot figure out what is going wrong here. I have coppied the exception and have pasted it in ESP Exception Decoder in Arduino IDE and I see the following. Any Ideas?

B4X:
Decoding stack results
0x4020d416: optimistic_yield(uint32_t) at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266/core_esp8266_features.h line 66
0x4020aadf: BearSSL::WiFiClientSecureCtx::_run_until(unsigned int, bool) at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 548
0x40227134: br_ssl_hs_client_init_main at src/ssl/ssl_hs_client.c line 907
0x40227184: br_ssl_hs_client_run at src/ssl/ssl_hs_client.c line 960
0x40226772: br_ssl_engine_hs_reset at src/ssl/ssl_engine.c line 1319
0x4020ab57: BearSSL::WiFiClientSecureCtx::_wait_for_handshake() at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 585
0x4020ad5b: BearSSL::WiFiClientSecureCtx::_connectSSL(char const*) at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 1164
0x4020d344: __esp_yield() at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_main.cpp line 116
0x4020dcbe: __delay(unsigned long) at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_wiring.cpp line 54
0x40209c9a: WiFiClient::connect(IPAddress, unsigned short) at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\libraries\ESP8266WiFi\src/include/ClientContext.h line 148
0x4020adfd: BearSSL::WiFiClientSecureCtx::connect(char const*, unsigned short) at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 231
0x4020f6d2: BearSSL::WiFiClientSecure::connect(char const*, unsigned short) at c:\users\hatzi\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.3-gcc10.3-9bcba0b\xtensa-lx106-elf\include\c++\10.3.0\bits/shared_ptr_base.h line 1324
0x4020f484: B4R::BufferedWiFiClient::connect(char const*, unsigned short) at C:\B4X\My Code\B4R\DHQIRefrig\Objects\src/BufferedWiFiClient.cpp line 7
0x40208300: B4R::WiFiSSLSocket::ConnectHost(B4R::B4RString*, unsigned short) at C:\B4X\My Code\B4R\DHQIRefrig\Objects\src/rESP8266WiFi.cpp line 111
0x40203dcd: b4r_httpjob::_sendrequest(unsigned char) at C:\B4X\My Code\B4R\DHQIRefrig\Objects\src/b4r_httpjob.cpp line 370
0x4020e500: uart_write(uart_t*, char const*, size_t) at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\uart.cpp line 539
0x4020b700: EspClass::flashWrite(unsigned int, unsigned int const*, unsigned int) at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\Esp.cpp line 706
0x40201e00: B4R::Common::LogHelper(int, ...) at C:\B4X\My Code\B4R\DHQIRefrig\Objects\src/B4RCore.cpp line 186
0x40204559: b4r_httpjob::_download(B4R::Array*) at C:\B4X\My Code\B4R\DHQIRefrig\Objects\src/b4r_httpjob.cpp line 109
0x40201ab2: B4R::B4RString::GetBytes() at C:\B4X\My Code\B4R\DHQIRefrig\Objects\src/B4RCore.cpp line 337
0x40205b7a: b4r_main::_getweather(unsigned char) at C:\B4X\My Code\B4R\DHQIRefrig\Objects\src/b4r_main.cpp line 291
0x4020e52c: uart_write(uart_t*, char const*, size_t) at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\uart.cpp line 546
0x4020b801: HardwareSerial::flush() at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\HardwareSerial.cpp line 128
0x4020c664: Print::print(__FlashStringHelper const*) at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\Print.cpp line 101
0x4020c764: Print::print(double, int) at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\Print.cpp line 173
0x4020c764: Print::print(double, int) at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\Print.cpp line 173
0x4020e564: uart_tx_free(uart_t*) at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\uart.cpp line 559
0x4020d364: init_done() at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_main.cpp line 260
0x4020dc64: micros_overflow_tick(void*) at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_wiring.cpp line 65
0x4020b764: EspClass::flashRead(unsigned int, unsigned int*, unsigned int) at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\Esp.cpp line 951
0x40208601: LiquidCrystal::write(unsigned char) at C:\B4X\Tools\B4R\arduino-1.8.15\libraries\LiquidCrystal\src\LiquidCrystal.cpp line 280
0x40100190: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_main.cpp line 181
0x4020d3e2: __yield() at C:\Users\hatzi\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266\core_esp8266_main.cpp line 116
0x40205c06: b4r_main::_jobloop() at C:\B4X\My Code\B4R\DHQIRefrig\Objects\src/b4r_main.cpp line 442
0x4020608e: b4r_main::_getweatherandtime() at C:\B4X\My Code\B4R\DHQIRefrig\Objects\src/b4r_main.cpp line 305
0x40205491: b4r_lcdgr::_yield() at C:\B4X\My Code\B4R\DHQIRefrig\Objects\src/b4r_lcdgr.cpp line 986
0x4020682d: b4r_main::_tm_tick() at C:\B4X\My Code\B4R\DHQIRefrig\Objects\src/b4r_main.cpp line 1069

Edit: ESP Exception Decoder is an AddIn that you can find on GitHub if I recall correctly and there are instructions on how to install it.
 

hatzisn

Well-Known Member
Licensed User
Longtime User
I narrowed the problem. Consider the following code:

B4X:
Sub Process_Globals
    Private bSeq(3) As Byte
    Private bc As ByteConverter
End Sub

Sub GetAllData
    bc.ArrayCopy(Array As Byte(1, 2, 3), bSeq)
    iCountSeq = 0
    JobLoop
End Sub

Sub GetWeatherAndTime
    bc.ArrayCopy(Array As Byte(2, 3), bSeq)
    iCountSeq = 0
    JobLoop
End Sub

Sub JobLoop
    LCDGR.Yield  'This just calls the yield(); function which is located in another module
    Log("bSeq pointer and Length: ", iCountSeq, bSeq.Length)
  
    If iCountSeq = bSeq.Length Then
        Return
    End If
  
    Dim iJb As UInt = bSeq(iCountSeq)
    'GetRefr, GetWeather and GetTime are subs that call different Http links
    Select Case iJb
        Case 1
            GetRefr(iCountSeq)
        Case 2
            GetWeather(iCountSeq)
        Case 3
            GetTime(iCountSeq)
    End Select
  
End Sub

Sub JobDone(Job As JobResult)
    .
    .
    .
    .
    iCountSeq = iCountSeq + 1
    JobLoop
End Sub

When the MCU boots it calls the GetAllData sub/void and everything works fine. It gets in the Job loop and starts executing one job after the other until the final job. Everything until this moment works correctly. Then the timer starts and at certain times a day (lets call them R-times) I need to download new data. If I call in an R-Time the sub GetWeatherAndTime then the "Soft WDT Reset occurs" BUT if I call GetAllData then everything works fine again and no problem occurs. I would suppose that something happens in GetRefr(iCountSeq) that feels right to the MCU. Nothing is special about this sub. The code is the same as with GetWeather and GetTime but with different http link. What can you all make out of this?
 
Last edited:
Upvote 0

MbedAndroid

Active Member
Licensed User
Longtime User
it's a old thread already. You found something.? I got something simular. Using Mqtt the WDT comes op when publishing some string where the length is aboven 50 chars. It can happen once a day, once a hour or 30x times a hour. Yield function didnt help. Dropped the Mqtt lib and back to code with a UDP package with the same payload: solved....
 
Upvote 0
Top