Skip to content

Unstable AP_Mode, terminated after connection & Exception 29 Error #7597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 of 6 tasks
Devilscave opened this issue Sep 13, 2020 · 2 comments
Closed
5 of 6 tasks

Unstable AP_Mode, terminated after connection & Exception 29 Error #7597

Devilscave opened this issue Sep 13, 2020 · 2 comments

Comments

@Devilscave
Copy link

Devilscave commented Sep 13, 2020

#7384 # Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below. (i hope)

Platform

  • Hardware: [ESP-12E]
  • Core Version: [2.7.2]
  • Development Env: [Arduino IDE]
  • Operating System: [Windows]

Settings in IDE

  • Module: [Generic ESP8266 Module|Nodemcu]
  • Flash Mode: [fixed by IDE]
  • Flash Size: [4MB]
  • lwip Variant: [v2_lower_Memory]
  • Reset Method: [nodemcu]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [80Mhz]
  • Upload Using: [SERIAL]
  • Upload Speed: [921600]

Problem Description

I'm using a sketch that was originally written for WiFi_STA, in WiFi_AP mode. This is the "webinterface" example from the "ws2812fx" library. Now the problem is that it works but after a short time the connection breaks and then takes 2-3 minutes until the ESP does a reset by itself with the message "Exception 29".
I have tried this with the "ESP Exception Decoder" tool to find out why the ESP is doing this and where exactly the error is. Unfortunately without success, but many references go to "core_esp8266_main.cpp" I have attached my error output, can someone tell me a little more about what could be the cause? The sketch also includes an "index.html.cpp" and "main.js.cpp" file. You can simply load this via the example and then insert my sketch into the original.
I also asked by "ws2812fx", but got no answer except for "AP_Mode" which seems to be very unstable. (OHH really?)

MCVE Sketch

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <WS2812FX.h>
 
extern const char index_html[];
extern const char main_js[];
 
#ifndef APSSID
#define APSSID "ws2812fx"                                                     // WLan Name des ESP
#define APPSK  "ledmagic"                                                     // WLan Password    ### NOT NEEDED ###
#endif
 
// QUICKFIX...See https://github.com./esp8266/Arduino/issues/263
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
 
#define LED_PIN 5                                // LED PIN
#define LED_COUNT 100                      // LED Menge
 
#define WIFI_TIMEOUT 30000              // checks WiFi every ...ms. Reset after this time, if WiFi cannot reconnect.
#define HTTP_PORT 80
 
#define DEFAULT_COLOR 0xFF5900
#define DEFAULT_BRIGHTNESS 128
#define DEFAULT_SPEED 1000
#define DEFAULT_MODE FX_MODE_STATIC
 
const char *ssid = APSSID;
const char *password = APPSK;
 
unsigned long auto_last_change = 0;
unsigned long last_wifi_check_time = 0;
String modes = "";
uint8_t myModes[] = {}; // *** optionally create a custom list of effect/mode numbers
boolean auto_cycle = false;
 
WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
ESP8266WebServer server(HTTP_PORT);
 
void setup(){
  Serial.begin(115200);
  //delay(500);
  Serial.println("\n\nStarting...");
 
  modes.reserve(5000);
  modes_setup();
 
  Serial.println("WS2812FX setup");
  ws2812fx.init();
  ws2812fx.setMode(DEFAULT_MODE);
  ws2812fx.setColor(DEFAULT_COLOR);
  ws2812fx.setSpeed(DEFAULT_SPEED);
  ws2812fx.setBrightness(DEFAULT_BRIGHTNESS);
  ws2812fx.start();
 
  WiFi.mode(WIFI_AP);                                                     // start in Access_Point Mode
  WiFi.softAP(ssid);                                                          // only SSID 
  //WiFi.softAP(ssid, password);                                         // SSID and Password

  Serial.println("HTTP server setup");
  server.on("/", srv_handle_index_html);
  server.on("/main.js", srv_handle_main_js);
  server.on("/modes", srv_handle_modes);
  server.on("/set", srv_handle_set);
  server.onNotFound(srv_handle_not_found);
 
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("IP Addresse: ");
  Serial.println(myIP);
 
  server.begin();
  Serial.println("HTTP server started.");
 
  Serial.println("ready!");
}
  
void loop() {
  unsigned long now = millis();
 
  server.handleClient();
  ws2812fx.service();
 
  if(auto_cycle && (now - auto_last_change > 10000)) { // cycle effect mode every 10 seconds
    uint8_t next_mode = (ws2812fx.getMode() + 1) % ws2812fx.getModeCount();
    if(sizeof(myModes) > 0) { // if custom list of modes exists
      for(uint8_t i=0; i < sizeof(myModes); i++) {
        if(myModes[i] == ws2812fx.getMode()) {
          next_mode = ((i + 1) < sizeof(myModes)) ? myModes[i + 1] : myModes[0];
          break;
        }
      }
    }
    ws2812fx.setMode(next_mode);
    Serial.print("mode is "); Serial.println(ws2812fx.getModeName(ws2812fx.getMode()));
    auto_last_change = now;
  }
}
 
/*
 * Build <li> string for all modes.
 */
void modes_setup() {
  modes = "";
  uint8_t num_modes = sizeof(myModes) > 0 ? sizeof(myModes) : ws2812fx.getModeCount();
  for(uint8_t i=0; i < num_modes; i++) {
    uint8_t m = sizeof(myModes) > 0 ? myModes[i] : i;
    modes += "<li><a href='#'>";
    modes += ws2812fx.getModeName(m);
    modes += "</a></li>";
  }
}
 
/* #####################################################
#  Webserver Functions
##################################################### */
 
void srv_handle_not_found() {
  server.send(404, "text/plain", "File Not Found");
}
 
void srv_handle_index_html() {
  server.send_P(200,"text/html", index_html);
}
 
void srv_handle_main_js() {
  server.send_P(200,"application/javascript", main_js);
}
 
void srv_handle_modes() {
  server.send(200,"text/plain", modes);
}
 
void srv_handle_set() {
  for (uint8_t i=0; i < server.args(); i++){
    if(server.argName(i) == "c") {
      uint32_t tmp = (uint32_t) strtol(server.arg(i).c_str(), NULL, 10);
      if(tmp >= 0x000000 && tmp <= 0xFFFFFF) {
        ws2812fx.setColor(tmp);
      }
    }
 
    if(server.argName(i) == "m") {
      uint8_t tmp = (uint8_t) strtol(server.arg(i).c_str(), NULL, 10);
      //ws2812fx.setMode(tmp % ws2812fx.getModeCount());     <<<<---- OLD version whit BUG
      uint8_t new_mode = sizeof(myModes) > 0 ? myModes[tmp % sizeof(myModes)] : tmp % ws2812fx.getModeCount();  // new line
      ws2812fx.setMode(new_mode);                                                      // second new line
      Serial.print("mode is "); Serial.println(ws2812fx.getModeName(ws2812fx.getMode()));
    }
 
    if(server.argName(i) == "b") {
      if(server.arg(i)[0] == '-') {
        ws2812fx.setBrightness(ws2812fx.getBrightness() * 0.8);
      } else if(server.arg(i)[0] == ' ') {
        ws2812fx.setBrightness(min(max(ws2812fx.getBrightness(), 5) * 1.2, 255));
      } else { // set brightness directly
        uint8_t tmp = (uint8_t) strtol(server.arg(i).c_str(), NULL, 10);
        ws2812fx.setBrightness(tmp);
      }
      Serial.print("brightness is "); Serial.println(ws2812fx.getBrightness());
    }
 
    if(server.argName(i) == "s") {
      if(server.arg(i)[0] == '-') {
        ws2812fx.setSpeed(max(ws2812fx.getSpeed(), 5) * 1.2);
      } else if(server.arg(i)[0] == ' ') {
        ws2812fx.setSpeed(ws2812fx.getSpeed() * 0.8);
      } else {
        uint16_t tmp = (uint16_t) strtol(server.arg(i).c_str(), NULL, 10);
        ws2812fx.setSpeed(tmp);
      }
      Serial.print("speed is "); Serial.println(ws2812fx.getSpeed());
    }
 
    if(server.argName(i) == "a") {
      if(server.arg(i)[0] == '-') {
        auto_cycle = false;
      } else {
        auto_cycle = true;
        auto_last_change = 0;
      }
    }
  }
  server.send(200, "text/plain", "OK");
}

Debug Messages

Exception 29: StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores
PC: 0x4000e1c3
EXCVADDR: 0x00000018

Decoding stack results
0x4021b328: ip4_output_if_opt_src at core/ipv4/ip4.c line 1764
0x40100a14: malloc(size_t) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 552
0x40100c72: calloc(size_t, size_t) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 908
0x40100c64: calloc(size_t, size_t) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 902
0x402092e0: loop_wrapper() at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 189
0x40213269: sys_timeout_abs at core/timeouts.c line 189
0x4020915c: loop_task(ETSEvent*) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 205
0x401001f8: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 177
0x401001f8: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 177
0x40211ab1: glue2esp_linkoutput at glue-esp/lwip-esp.c line 301
0x4021183b: _svfprintf_r at /home/earle/src/esp-quick-toolchain/repo/newlib/newlib/libc/stdio/nano-vfprintf.c line 667
0x4020b48c: String::setLen(int) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266/WString.h line 304
0x40211d3e: new_linkoutput at glue-lwip/lwip-git.c line 260
0x4021215c: ethernet_output at netif/ethernet.c line 312
0x402198e0: etharp_output_to_arp_index at core/ipv4/etharp.c line 770
0x4010075b: umm_free_core(void*) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 351
0x40100a14: malloc(size_t) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\umm_malloc\umm_malloc.cpp line 552
0x4021be20: mem_malloc at core/mem.c line 210
0x40216759: tcp_create_segment at core/tcp_out.c line 190
0x401001f8: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 177
0x40211ab1: glue2esp_linkoutput at glue-esp/lwip-esp.c line 301
0x401001f8: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 177
0x401001f8: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 177
0x401001f8: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 177
0x401001f8: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 177
0x401001f8: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 177
0x401001f8: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 177
0x40100277: millis() at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_wiring.cpp line 185
0x40100274: millis() at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_wiring.cpp line 185
0x402092ec: loop_wrapper() at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 192
0x402092ec: loop_wrapper() at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 192
0x401002a4: millis() at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_wiring.cpp line 188
0x40205902: WiFiServer::available(unsigned char*) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\libraries\ESP8266WiFi\src\WiFiServer.cpp line 140
0x40205b1e: WS2812FX::service() at C:\Users\Devilscave\Documents\Arduino\libraries\WS2812FX\src\WS2812FX.cpp line 72
0x4020aea8: std::_Function_handler ::_M_invoke(std::_Any_data const&) at c:\users\devilscave\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506\xtensa-lx106-elf\include\c++\4.8.2/functional line 2069
0x401001f8: ets_post(uint8, ETSSignal, ETSParam) at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 177
0x40100219: esp_schedule() at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 125
0x40209309: loop_wrapper() at C:\Users\Devilscave\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.2\cores\esp8266\core_esp8266_main.cpp line 199
@Tech-TX
Copy link
Contributor

Tech-TX commented Sep 13, 2020

Looks to me like the stack blew up, but I don't know the built-in WiFi libraries well enough to know whether your example is valid.

Your MCVE shouldn't include third-party libraries, as that only muddies the waters.

edit: The only test I've done with the webserver code was in station mode (not AP), so I don't have experience with your issue. The example I tried worked OK without going down in flames, and it ran for several hours:
https://circuits4you.com/2019/03/28/esp8266-iot-rgb-led-strip-mood-lamp-controller/ (the 'Mood-Lamp' one)
That's for strip LEDs, not the individually-addressable ones, so I didn't need a ws2812 library.

@earlephilhower
Copy link
Collaborator

The MCVE you attached isn't possible for others to use, @Devilscave , as @Tech-TX said. We need MCVEs without external dependencies so the team can actually run them.

Your problem is most likely an Out of Memory (OOM) error because your code is . Enable all the debug options in the IDE and you'll get more info, including a note where the OOM happened. The EXCADDR of 0x18 means some structure was attempted to be allocated, got a NULL, and then the app ignore the NULL and tried to access a field in the structure at offset NULL+0x18.

Also you should at least upgrade to 2.7.4 from 2.7.2 because there were several important fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants