Chat freely about anything...

User avatar
By mysterion
#89950 Hey there,

I am trying to debug a potential race condition between a library that does some seemingly simple digitalWrite/shiftOut calls and ESP8266WiFi.

The following code:

Code: Select all#include <ESP8266WiFi.h>
#include "LedController.hpp"

LedController lc;

void setup() {
  Serial.begin(115200);
  Serial.println("start");

  lc = LedController(13, 14, 5, 8);
  lc.activateAllSegments();
  lc.setIntensity(0);
  lc.clearMatrix();
  lc.setDigit(0, 0, 0, false);

  delay(100);
  WiFi.mode(WIFI_STA);
  WiFi.begin("SSID", "PASSWORD");

  while(WiFi.status() != WL_CONNECTED) {
    Serial.println("connecting...");
    lc.setDigit(0, 0, 2, true);
    delay(250);
    lc.setDigit(0, 0, 2, false);
    delay(250);
   
  }

  Serial.println("connected!");
}

void loop() {}


generally creates the following exception:

Code: Select allException 29: StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores
PC: 0x4021e5af
EXCVADDR: 0x00000019

Decoding stack results
0x4020fab9: do_memp_malloc_pool at core/memp.c line 255
0x40206b48: loop_task(ETSEvent*) at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/cores/esp8266/core_esp8266_main.cpp line 205
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/cores/esp8266/core_esp8266_main.cpp line 177
0x40100154: ets_post(uint8, ETSSignal, ETSParam) at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/cores/esp8266/core_esp8266_main.cpp line 177
0x4010092f: free(void*) at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/cores/esp8266/umm_malloc/umm_malloc.cpp line 398
0x40202c00: ESP8266WiFiSTAClass::status() at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp line 634
0x40202de1: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp line 211
0x40202dbd: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp line 201
0x40202de7: ESP8266WiFiSTAClass::begin(char const*, char const*, int, unsigned char const*, bool) at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp line 211
0x40100279: __digitalWrite(uint8_t, uint8_t) at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/cores/esp8266/core_esp8266_wiring_digital.cpp line 86
0x4020765c: shiftOut(uint8_t, uint8_t, uint8_t, uint8_t) at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/cores/esp8266/core_esp8266_wiring_shift.cpp line 49
0x40100279: __digitalWrite(uint8_t, uint8_t) at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/cores/esp8266/core_esp8266_wiring_digital.cpp line 86
0x40100279: __digitalWrite(uint8_t, uint8_t) at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/cores/esp8266/core_esp8266_wiring_digital.cpp line 86
0x40204dbc: LedController::spiTransfer(unsigned int, unsigned char, unsigned char) at /Users/mysterion/Documents/Arduino/libraries/LedController/src/LedController.cpp line 285
0x4010092f: free(void*) at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/cores/esp8266/umm_malloc/umm_malloc.cpp line 398
0x40100279: __digitalWrite(uint8_t, uint8_t) at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/cores/esp8266/core_esp8266_wiring_digital.cpp line 86
0x4020765c: shiftOut(uint8_t, uint8_t, uint8_t, uint8_t) at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/cores/esp8266/core_esp8266_wiring_shift.cpp line 49
0x40206bc8: __esp_yield() at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/cores/esp8266/core_esp8266_features.h line 92
0x402071ce: __delay(unsigned long) at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/cores/esp8266/core_esp8266_wiring.cpp line 54
0x4020218f: setup() at /Users/mysterion/Documents/Arduino/robinhood_mini/robinhood_mini.ino line 32
0x40206ce4: loop_wrapper() at /Users/mysterion/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/cores/esp8266/core_esp8266_main.cpp line 194


I have also seen Exception 3 on some occasions.

I'm pretty new to this but some research has shown me that this could be due to attempts to writing or reading from memory you're not supposed to. I tried commenting out the calls to the LedController library and then the exceptions stopped. I looked through the source of the LedController library, all I could find was some calls to "pgm_read_byte_near" on a PROGMEM object. However, the stacktrace does not include that line it only includes calls to digitalWrite which I suspected is a pretty benign call and wouldn't interfere with WiFi or secured memory.

Any idea what might be going on?

Thanks for the help!