Arduino icon indicating copy to clipboard operation
Arduino copied to clipboard

instruction `esp_now_send` causes ESP8266MOD to crash due to hardware watchdog reset

Open lozziboy opened this issue 2 years ago • 1 comments

Basic Infos

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

Platform

  • Hardware: [ESP8266MOD]
  • Core Version: [Release 3.1.2 - Mar20]
  • Development Env: [Arduino IDE]
  • Operating System: [Windows]

Settings in IDE

  • Module: [Wemos D1 R2]
  • Flash Mode: [qio|dio|other]
  • Flash Size: [4MB]
  • lwip Variant: [v2 Lower Memory]
  • Reset Method: [ck|nodemcu]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [80Mhz]
  • Upload Using: [SERIAL]
  • Upload Speed: [921600]

Problem Description

Using instruction esp_now_send causes ESP8266MOD to crash due to hardware watchdog reset. I also found a workaround for that, that is to setup the GPIO16 as OUTPUT during setup (i.e. pinMode(16, OUTPUT) ), but I don't realize why this happens and how this could be related to esp_now_send instruction.

MCVE Sketch

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <espnow.h>

uint8_t targetAddr[] = {0x8C, 0xAA, 0xB5, 0xB5, 0x90, 0x60};

byte myData = 1;
int cnt = 0;

void OnDataSent(uint8_t *mac, uint8_t sendStatus)
{
  if (sendStatus == 0)  {
    Serial.println("Delivery success");
  }
  else  {
    Serial.println("Delivery fail");
  }
}

void setup()
{
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  if (esp_now_init() != 0)  {
    Serial.println("Error initializing ESP-NOW");
    return;
  }
  esp_now_set_self_role(ESP_NOW_ROLE_CONTROLLER);
  esp_now_register_send_cb(OnDataSent);
  esp_now_add_peer(targetAddr, ESP_NOW_ROLE_SLAVE, 1, NULL, 0);
}

void loop()
{
  if (cnt % 10000 == 0)  {
    Serial.println(cnt);
    esp_now_send(targetAddr, (uint8_t *) &myData, sizeof(myData));
  }
  cnt += 1;
}

Debug Messages


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

wdt reset
load 0x4010f000, len 3424, room 16 
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8 
tail 0
chksum 0x2b
csum 0x2b
v00042e70
~ld
⸮⸮n⸮r⸮⸮n|⸮l⸮l`bbrl⸮nb⸮nl`⸮rl⸮l⸮⸮
0


lozziboy avatar Sep 14 '23 09:09 lozziboy

esp-now is not supported by us because this part is closed-source. You can try with another firmware by selecting the "generic esp8266" board and use the firmware option that will be available inside the tools menu.

d-a-v avatar Nov 04 '23 19:11 d-a-v