These are chat archives for esp8266/Arduino

18th
Aug 2015
Ivan Grokhotkov
@igrr
Aug 18 2015 07:19
looked a bit into the OTA issues (lmac.c stuff), looks like selectively masking individual interrupts works better than disabling all of them. i just did OTA 20 times with WebUpdate sketch and all 20 times were successful (10 using curl, 10 using Chrome) .
will clean everything up and push an update a bit later today
Juppit
@Juppit
Aug 18 2015 08:23
@igrr is there any hope that itwill work with Arduino nightly ide?
Ivan Grokhotkov
@igrr
Aug 18 2015 08:28
it will not work in nightly or 1.6.7
I have tried to discuss this with Arduino team but got no response: https://groups.google.com/a/arduino.cc/forum/m/#!topic/developers/LJg8H6OrAEk
Most likely will have to write a java plugin for the IDE which will do OTA uploads "our way"
Me No Dev
@me-no-dev
Aug 18 2015 08:33
you can also suggest to the arduino team of filtering "upload.via_programmer" to be added and go through the regular routine
that will do the trick to call esptool for upload
for remote console, a new class is required
Juppit
@Juppit
Aug 18 2015 08:36
Yeas I saw your question.
But with these plugin it will work with future IDEs.
Me No Dev
@me-no-dev
Aug 18 2015 08:36
But will require using a menu option to upload
the upload button will not work with tool
Peter Retief
@peterretief
Aug 18 2015 10:09
i have been programming the esp with gedit and my own build and flash script, just started using the arduino ide, very nice
Russ Mathis
@RussMathis
Aug 18 2015 13:34
@probonopd, not sure but the debugger feature is initially only available for X days before having to pay for it.
Michael Miller
@Makuna
Aug 18 2015 17:00
@brutzler I have confirmed the st7335, I original placed in the ReadMe the link to library in GitHub for the esp8266 modified library and it works great.
Michael Miller
@Makuna
Aug 18 2015 17:15
@brutzler I also mean st7735 ;-)
Neil Kolban
@nkolban
Aug 18 2015 17:35

I'm thinking that we need a better community coordination mechanism ... I am reading this thread and it seems we now have THREE independent WebSockets implementations ... http://www.esp8266.com/viewtopic.php?f=29&t=4603

I'm not understanding the overlap.

d-anders
@d-anders
Aug 18 2015 17:40
I use the one by links2004 (sattler) .it works great
Neil Kolban
@nkolban
Aug 18 2015 17:41
I haven't used ANY of them yet ... my comment isn't about which is better ... its more about coordination of time and effort to build a common solution.
d-anders
@d-anders
Aug 18 2015 17:43
agreed
newer and not so well-known libs are not so easy to find
Markus
@Links2004
Aug 18 2015 17:44
not sure why we have so many, at the time i start i find none ( some point in May ).
a global list with working libs are in the git
https://github.com/esp8266/Arduino/blob/esp8266/hardware/esp8266com/esp8266/doc/reference.md#other-libraries-not-included-with-the-ide
d-anders
@d-anders
Aug 18 2015 17:45
so there is big risk of reinventing the wheel
Markus
@Links2004
Aug 18 2015 17:45
but some kind of database where a big help
Neil Kolban
@nkolban
Aug 18 2015 17:47
Ive written to the admin of the ESP8266 community to see if he can create a new forum grouping where we can "advertize" projects that are being started or are already in flight so that we can at least know what is being worked upon so we can collaborate as we can.
bbx10
@bbx10
Aug 18 2015 19:56

A WDT reset problem can be created using the example program ESP8266WebServer/HelloServer with periodic calls to noInterrupts(). The same program works correctly when built with 1.6.4-673-g8cd3697.

Modify the example program to add SSID/PSK. Verify it connects. Ping the ESP server using sudo ping -A <ESP IP addr>. This sends about 1000 pings/sec which the ESP handles correctly. My test was done using a package built from git commit aafacdcb.

Next modify the loop() function to add noInterrupts(). The idea for this was derived from a program that updates WS281x/NeoPixel LEDs from network packets received at 30 updates/sec. The LED code has been removed since it was discovered on the NeoPixelBus repo chat that the key factor is disabling interrupts with lots of WiFi traffic.

uint32_t lastTime = 0;

void loop()
{
  server.handleClient();

  // Every 30 ms, disable interupts
  if ((millis() - lastTime) > 30) {
    //uint32_t savedPS;
    lastTime = millis();
    //savedPS = xt_rsil(15);  // does not work either
    noInterrupts();
    delayMicroseconds(2000);
    interrupts();
    //xt_wsr_ps(savedPS);
    Serial.println(lastTime);
  }
}

After downloading the modified example code, do sudo ping -A <ESP IP addr>. On my system this results in WDT reset less than 10 seconds. The rate of pings can be reduced with various ping options but the WDT reset still occurs but less frequently.

Removing noInterrupts/interrupts eliminates the WDT reset but bit banging the WS281x LED protocol requires interrupts off. However, this demonstrates the problem is caused by disabling interrupts and not the addition of 2 ms delay to loop().

After putting the noInterrupts/interrupts back in, build with 1.6.4-673-g8cd3697. On my system, the WDT resets do not occur even when handling 1000 pings/sec for 10 minutes.

sticilface
@sticilface
Aug 18 2015 20:00
I can reproduce this. Also using 1.6.4-673-g8cd3697, I do no seem to get resets using my ws2812s.
Ivan Grokhotkov
@igrr
Aug 18 2015 20:09
i'm sure this will happen even if you use plain SDK, without Arduino wrapper.
Ivan Grokhotkov
@igrr
Aug 18 2015 20:18
I would suggest to try masking out interrupts like ets_isr_mask(B111111)
this will leave CCOMPARE and FRC_TIMER1 enabled
oh, my bad, NeoPixelBus doesn't seem to use CCOMPARE interrupt
this makes it ets_isr_mask(B1111111)
you will obviously get some timing errors due to TIMER1 interrupt kicking in to dispatch some wifi stuff, but it's either this or a reset.
brutzler
@brutzler
Aug 18 2015 20:49
@Makuna: Thx für the hint. There was also the need of the gfx-library. Then I could compile the examples without errors (still warnings -> warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings])
Can you tell me, how you connected the display to the ESP?
brutzler
@brutzler
Aug 18 2015 21:11
Solved: I tried this: adafruit/Adafruit-ST7735-Library#24 -> working
bbx10
@bbx10
Aug 18 2015 21:30
@igrr I will try as you suggest. In the mean time I tried to see what interrupts are pending before enabling interrupts. Unfortunately, before every WDT reset the pending interrupt is WiFi.

The test program has been modified to show the pending interrupt(s) before enabling interrupts. As soon as interrupts are enabled pending interrupt(s) must be handled. In all cases with WDT reset, the pending interrupt is bit 0. However, bit 0 is the pending interrupt in many other cases that do not fail. I assume bit 0 is WiFi since when pinging is stopped, this bit is almost always 0. When pinging starts, it is almost always 1.

uint32_t lastTime = 0;

#define get_ints_pending(ints_pending) __asm__ __volatile__("esync; rsr %0,226; esync":"=a" (ints_pending))

void loop()
{
  server.handleClient();

  // Every 30 ms, disable interupts
  if ((millis() - lastTime) > 30) {
    uint32_t ints_pending_before, ints_pending_after;
    lastTime = millis();

    noInterrupts();
    get_ints_pending(ints_pending_before);
    //Serial.printf("ints pending %lx\r\n", ints_pending_before);

    delayMicroseconds(2000);

    get_ints_pending(ints_pending_after);
    //Serial.printf("ints pending %lx\r\n", ints_pending_after);

    Serial.printf("ints changed %lx\r\n", ints_pending_before ^ ints_pending_after);
    interrupts();
  }
}

An example of a failure.

ints changed 1
ints changed 0
ints changed 1
ints changed 1
ints changed 1
ints changed 1
ints changed 401
ints changed 1
ints changed 401
ints changed 1

 ets Jan  8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 1264, room 16 
tail 0
chksum 0x42
csum 0x42
~ld
Ivan Grokhotkov
@igrr
Aug 18 2015 21:40
ok, then I guess B1111110 mask should work
I'll take a look at the SDK code to see what is this interrupt #0 related to
great observation regarding pinging though!
sticilface
@sticilface
Aug 18 2015 21:47
I wonder what changed since g8cd3697 to cause this? For what it is worth the WS2812 function absolutely perfectly with this version. There is no indication (i'm driving 144 of them in a lamp) that any interrupt is interrupting the bit banging. There is no flashing.. they work perfectly. And more importantly I've not had a single crash in 4hrs! This sketch is running wifi, mqtt, webserver, eeprom and it is absolutely fine!
Ivan Grokhotkov
@igrr
Aug 18 2015 21:48
SDK changed
basically this is the only thing that has changed in the sketch by @bbx10
interrupts/nointerrupts, delaymicroseconds, loop are essentially the same
sticilface
@sticilface
Aug 18 2015 21:55
I would be eternally grateful to all you guys for solving this one. I won't lie... I've spent more time that i care too, trying to track down why some of my animations were causing regular crashes.... we're talking weeks here! i've rewritten them all, thought it was due to my crappy coding, tested, tested, tested more... it has been rather frustrating. but at least the problem has now been found :)
bbx10
@bbx10
Aug 18 2015 22:18

Ok, added ets_isr_mask instead of noInterrupts/interrupts. I hope I did it correctly.

uint32_t lastTime = 0;

#define get_ints_pending(ints_pending) __asm__ __volatile__("esync; rsr %0,226; esync":"=a" (ints_pending))

void loop()
{
  server.handleClient();

  // Every 30 ms, disable interupts
  if ((millis() - lastTime) > 30) {
    uint32_t ints_pending_before, ints_pending_after;
    lastTime = millis();

    //noInterrupts();
    ets_isr_mask(B1111110);
    get_ints_pending(ints_pending_before);
    //Serial.printf("ints pending %lx\r\n", ints_pending_before);

    delayMicroseconds(2000);

    get_ints_pending(ints_pending_after);
    //Serial.printf("ints pending %lx\r\n", ints_pending_after);

    Serial.printf("ints changed %lx\r\n", ints_pending_before ^ ints_pending_after);
    //interrupts();
    ets_isr_mask(0);
  }
}

No failures after 7.5 minutes of 1000 pings/second. Note "ints changed" is now always 0. However, allowing WiFi interrupt during this time will throw off the LED bit bang timing. But it does confirm WiFi interrupts cannot be disabled even for a few milliseconds.

Michael Miller
@Makuna
Aug 18 2015 23:36
Could you try both ets_isr_mask and nointerrupts with ets_isr_mask() before the nointerrupts? Maybe some hidden magic sauce in there.
bbx10
@bbx10
Aug 18 2015 23:45
@Makuna Ok, here is the latest version. This results in WDT reset crashes. It behaves the same as if the ets_isr_mask() funtions were not included.
uint32_t lastTime = 0;

#define get_ints_pending(ints_pending) __asm__ __volatile__("esync; rsr %0,226; esync":"=a" (ints_pending))

void loop()
{
  server.handleClient();

  // Every 30 ms, disable interupts
  if ((millis() - lastTime) > 30) {
    uint32_t ints_pending_before, ints_pending_after;
    lastTime = millis();

    ets_isr_mask(B1111110);
    noInterrupts();
    get_ints_pending(ints_pending_before);
    //Serial.printf("ints pending %lx\r\n", ints_pending_before);

    delayMicroseconds(2000);

    get_ints_pending(ints_pending_after);
    //Serial.printf("ints pending %lx\r\n", ints_pending_after);

    Serial.printf("ints changed %lx\r\n", ints_pending_before ^ ints_pending_after);
    interrupts();
    ets_isr_mask(0);
  }
}