These are chat archives for esp8266/Arduino

28th
Mar 2016
Michael Miller
@Makuna
Mar 28 2016 01:20
Gitter failed on me, I posted the above heads up to another group but it showed up here and I can't delete it or edit it. Sorry.
Krzysztof
@krzychb
Mar 28 2016 07:39
@bobcroft - I believe your issue is discussed and resolved in this entry by tim-in-oakton - https://github.com/esp8266/Arduino/issues/95#issuecomment-96399149
Ivan Grokhotkov
@igrr
Mar 28 2016 07:46
this might also happen if the flash mode is not correct (i.e. DIO vs QIO)
FWeinb
@FWeinb
Mar 28 2016 10:53
Have you seen this ESP8266 Smartwatch? It is looking really great.
Victor Tseng
@Palatis
Mar 28 2016 14:13
hmm... when I call enableAP(false) or enableSTA(false) when there is still a connection the mcu throws exception 0...
Victor Tseng
@Palatis
Mar 28 2016 14:19
i start the esp in STA+AP, and when user hits a button it should disable AP and go into smartconfig.
the interrupt handler only sets a flag, WiFi.enableAP(false) and WiFi.beginSmartConfig() is inside loop().
Victor Tseng
@Palatis
Mar 28 2016 14:27
trying to narrow down the prob.
bad thing is, it doesn't always fail, and everytime the exception is a bit different XD
Victor Tseng
@Palatis
Mar 28 2016 14:38
damn I can't copy text in the exception decoder = =
looks like wDev tries to process the data, but since wifi is disabled it frees the buffer, and inet_checksum_pbuf() just fails.
Juppit
@Juppit
Mar 28 2016 14:47
@Palatis @me-no-dev changed this 20 days before in exception decoder
Victor Tseng
@Palatis
Mar 28 2016 14:48
kool
@Juppit thx, i'll update it.
Victor Tseng
@Palatis
Mar 28 2016 15:06
dunno, maybe i should just put a flag in eeprom and reboot...
Victor Tseng
@Palatis
Mar 28 2016 15:39
strange... isn't calling delay() resets the wdt timer?
Aditya Tannu
@AdySan
Mar 28 2016 16:08
@FWeinb that soldering technique! he didn't even stabilize the board.
Ivan Grokhotkov
@igrr
Mar 28 2016 16:13
@Palatis not directly
Victor Tseng
@Palatis
Mar 28 2016 16:13
?
@igrr what do you mean?
ohh the delay()?
Ivan Grokhotkov
@igrr
Mar 28 2016 16:14
It switches execution context to the task scheduler, which, in turn, will feed the watchdog.
But on itself, it doesn't touch wdt.
Victor Tseng
@Palatis
Mar 28 2016 16:16
yeah, but I called delay() and it still gets a wdt reboot
doesn't work in setup()?
Ivan Grokhotkov
@igrr
Mar 28 2016 16:18
It does work in setup. What's your sketch?
(Something else may cause the chip to lock up, even if you call delay)
Victor Tseng
@Palatis
Mar 28 2016 16:18
    WiFi.beginSmartConfig();
    boolean success = false;
    for (long now = millis(), i = 1; millis() - now < 60000; ++i) {
      if (WiFi.smartConfigDone()) {
        success = true;
        Persist::setBeginSmartConfig(0);
        Persist::setWifiStationSSID(WiFi.SSID());
        Persist::setWifiStationPassphrase(WiFi.psk());
        Serial.println();
        Serial.println("SmartConfig success");
        // wait for smartconfig stuff to transfer back to device
        for (int i = 0; i < 10; ++i) {
          wdt_reset();
          delay(1000);
        }
        break;
      }
      Serial.print('.');
      if ((i % 80) == 0)
        Serial.println();
      wdt_reset();
      delay(500);
    }
this is in setup()
Ivan Grokhotkov
@igrr
Mar 28 2016 16:19
What does wdt_reset do?
Victor Tseng
@Palatis
Mar 28 2016 16:20
if I don't manually call it (ESP.wdtFeed()), it reboots.
Ivan Grokhotkov
@igrr
Mar 28 2016 16:22
In general, I don't think you need to interact with the watchdog. Just call delay or yield :)
Reset may also be caused by an exception. Do you have debug output enabled?
Victor Tseng
@Palatis
Mar 28 2016 16:23
i didn't think so, either.
This message was deleted
hmm it doesn't reboot this time...
dunno.................. it just happens randomly
last time it rebooted by wdt when printing the "......"s
Victor Tseng
@Palatis
Mar 28 2016 16:29
the only user code over there is delay(500) (if not WiFi.smartConfigDone() took too much time...)
but that function just checking flags, so shouldn't take long enough to trigger wdt timeout
okay i managed to crash it again
Begin SmartConfig...
SC version: V2.5.3
scandone
f r0, .....scandone
f r0, ....scandone
........��*促*V﹛ET帖揖T囿K岩u帽+UZ武枚5T答物Eu��T冊Q帘jP�短炙T�(E囿Q��(ZV��/汀
Hardware Watchdog
Fatal exception:4 flag:1 (WDT) epc1:0x40000f68 epc2:0x00000000 epc3:0x00000000 excvaddr:0x00000000 depc:0x00000000
Victor Tseng
@Palatis
Mar 28 2016 16:35
the dots are still printing, tho.
Ivan Grokhotkov
@igrr
Mar 28 2016 16:47
No stack trace?
Victor Tseng
@Palatis
Mar 28 2016 16:47
nope
Ivan Grokhotkov
@igrr
Mar 28 2016 16:47
Is this 2.1.0 core?
Victor Tseng
@Palatis
Mar 28 2016 16:47
git
Ivan Grokhotkov
@igrr
Mar 28 2016 16:48
Can you drop me the full sketch so I can repro?
Victor Tseng
@Palatis
Mar 28 2016 16:48
it's a super huge sketch, tho... I'll try make a smaller one and file an issue on github.
i think that junk string is the stack
Victor Tseng
@Palatis
Mar 28 2016 17:03
okay it's due to the Task library
#include <ESP8266WiFi.h>
#include <Task.h>

TaskManager Tasks;

void setup() {
  Serial.begin(74880);
  Serial.setDebugOutput(true);
  Serial.println();
  Serial.println(ESP.getResetReason());
  Serial.println(ESP.getResetInfo());

  for (long now = millis(), i = 1; millis() - now < 60000; ++i) {
    Serial.print('.');
    if ((i % 80) == 0)
      Serial.println();
    //wdt_reset();
    delay(500);
  }
}

void loop() {

}
looks like it disables wdt in TaskManager::TaskManager()...
TaskManager::TaskManager() :
        _pFirstTask( NULL ),
        _pLastTask( NULL )
{
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_AVR) && !defined(__arm__)
    wdt_reset();
    wdt_disable();
#endif

    _lastTick = GetTaskTime();
}
Ivan Grokhotkov
@igrr
Mar 28 2016 17:16
What the
Victor Tseng
@Palatis
Mar 28 2016 17:23
nvm, i'll go post the issue to the Task library tracker.
Martin Ayotte
@martinayotte
Mar 28 2016 17:32
It seems that those lines were uncommented 6 days ago ... Makuna/Task@7d105ce
Victor Tseng
@Palatis
Mar 28 2016 17:35
anyway, i don't think it's a good idea to mess around with the wdt stuff in a library, unless it really absolutely have to.
Michael Miller
@Makuna
Mar 28 2016 18:32
The task library abstracts WatchDog for all platforms, its goal is stop people from using delay() in their code and instead use timing tasks, so it has to feed the dog. It also manages sleep. But looking at that line I suspect I copied and pasted the #if line when it should be only done for AVR.
Michael Miller
@Makuna
Mar 28 2016 19:12
@igrr Is the issue that wdt_ functions can't be called before setup()? I am trying to understand why this would cause an reset as the taskmanager setups the watchdog again shortly after. For AVR that code is required as too many examples using delay() an on AVR it does not feed the dog. This makes the esp8266 inconsistent with AVR Arduino.
Michael Miller
@Makuna
Mar 28 2016 19:25
@Palatis You are incorrectly using the Task library in your example. First, you are missing the taskManager.Loop() in your void loop() and second you are using delay(); delay is not meant to be used AT ALL with my task library.
Michael Miller
@Makuna
Mar 28 2016 19:56
@Palatis Ok, the reason I have the disable even for esp8266, was to help enforce the DONT USE DELAY() in the Setup(). There are better ways to layout code, like putting pieces of the setup into a task and have that task when its done start the other tasks. My Task Library was not meant to work "following all the bad habits" from Arduino samples. On am really on the fence of even reverting that change, as if you don't use delay() it works fine.