Skip to content

Exception 9 in enableSTA() #7016

Closed
Closed
@dalbert2

Description

@dalbert2

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.

Platform

  • Hardware: [ESP-12]
  • Core Version: [Core:2_6_3 SDK:2.2.2-dev(38a443e)] (same issue with 2.6.2)
  • Development Env: [Platformio]
  • Operating System: [Windows]

Settings in IDE

  • Module: [Generic ESP8266 Module]
  • Flash Mode: [qio]
  • Flash Size: [4MB]
  • lwip Variant: [v2 Lower Memory]
  • Reset Method: [nodemcu]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [160MHz]
  • Upload Using: [SERIAL]
  • Upload Speed: [115200] (serial upload only)

Problem Description

On some fielded units, I am getting an exception 9 after WiFi disconnect. On a few units, it happens very frequently. On most units, the same code is not taking an exception at all and my application connects/disconnects every 15 minutes.

This is a long standing defect. The exception address in the current build (using core 2.6.3) is 0xx40207D00, but it looks like the same defect has been happening using 2.5.2 and earlier. The exception address moves around of course, but always decodes to somewhere in ESP8266WiFiGeneric.cpp, and usually to code related to WiFi disconnect/shutdown (which is what is happening when the exception takes place).

Does anyone know what excvaddr means? It has similar values across all of the exceptions in different Core versions: (0x02070231)

The stack trace is short and does not contain anything useful. Consider the following stack trace shown in the debug output below. It decodes as follows:

$ ./esp_addr2line 40207D00
C:\Users\david.platformio\packages\framework-arduinoespressif8266@2.20602.191128\libraries\ESP8266WiFi\src/ESP8266WiFiGeneric.cpp:727

Which is in ESP8266WiFiGenericClass::shutdown (uint32 sleepUs, WiFiState* state)
exception address is this line: state->crc = shutdownCRC(state);

The message "Disconnected from AP\r\n" (see code below) is the last thing printed before the exception (i.e. my disconnect callback is being called).

The rest of the exception stack trace is short and not useful (nothing decodes to useful text-space addresses).

MCVE Sketch

void ICACHE_RAM_ATTR onSTADisconnected(WiFiEventStationModeDisconnected event_info) {
	if (connect_time) {
		// save disconnect time and reason
		disconnect_time = rtc_get();
		disconnect_reason = event_info.reason;
		disconnect_ssid = event_info.ssid;
		connect_time = 0;
		if (config_getDebug() & config_debug_wifi) {
			Serial.printf("Disconnected from AP\r\n");
		}
	}
}

// Registration done elsewhere, before WiFi.begin() is called
WiFi.onStationModeDisconnected(onSTADisconnected);

// Code that shuts down WiFi:
		wifi_station_dhcpc_stop();
		WiFi.mode(WIFI_OFF);

any thoughts would be much appreciated!

Debug Messages


Disconnected from AP       <<<<<<<< output from my disconnect handler
--
Fatal exception 9(LoadStoreAlignmentCause):
epc1=0x40207d00, epc2=0x00000000, epc3=0x00000000, excvaddr=0x02070231, depc=0x00000000
 
Exception (9):
epc1=0x40207d00 epc2=0x00000000 epc3=0x00000000 excvaddr=0x02070231 depc=0x00000000
 
>>>stack>>>
 
ctx: sys
sp: 3ffffdc0 end: 3fffffb0 offset: 01a0
3fffff60:  401021c5 00000000 00000002 3ffefcd0
3fffff70:  3fffdc10 00000000 3fff3014 40261888
3fffff80:  40000f49 3fffdab0 3fffdab0 40000f49
3fffff90:  40000e19 40001878 00000002 3fffffb0
3fffffa0:  3fffff10 aa55aa55 000000c4 40105bd1
<<<stack<<<


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions