Skip to content

ESP32 board resetting again and again #7072

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
1 task done
Sureshbe opened this issue Aug 1, 2022 · 17 comments
Closed
1 task done

ESP32 board resetting again and again #7072

Sureshbe opened this issue Aug 1, 2022 · 17 comments
Assignees
Labels
Status: Community help needed Issue need help from any member from the Community. Type: Question Only question

Comments

@Sureshbe
Copy link

Sureshbe commented Aug 1, 2022

Board

ESP32 dev module

Device Description

ets Jun 8 2016 00:22:57

rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13516
load:0x40080400,len:3604
entry 0x400805f0
ets Jun 8 2016 00:22:57

rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13516
load:0x40080400,len:3604
entry 0x400805f0
ets Jun 8 2016 00:22:57

rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13516
load:0x40080400,len:3604
entry 0x400805f0
ets Jun 8 2016 00:22:57

rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13516
load:0x40080400,len:3604
entry 0x400805f0
ets Jun 8 2016 00:22:57

rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13516
load:0x40080400,len:3604
entry 0x400805f0
ets Jun 8 2016 00:22:57

Hardware Configuration

LoRa moduole connected to ESP32

Version

v2.0.4

IDE Name

ARDUINO IDE

Operating System

WINDOWS 11

Flash frequency

80MHZ

PSRAM enabled

yes

Upload speed

115200

Description

Board resetting again and again

Sketch

#include <EEPROM.h>
#include <RHRouter.h>
#include <RHMesh.h>
#include <RH_RF95.h>
#define RH_HAVE_SERIAL
#define LED 9
#define N_NODES 4

uint8_t nodeId;
uint8_t routes[N_NODES]; // full routing table for mesh
int16_t rssi[N_NODES]; // signal strength info

// Singleton instance of the radio driver
RH_RF95 rf95;

// Class to manage message delivery and receipt, using the driver declared above
RHMesh *manager;

// message buffer
char buf[RH_MESH_MAX_MESSAGE_LEN];

//int freeMem() {
//  extern int __heap_start, *__brkval;
//  int v;
//  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
//}

void setup() {
  randomSeed(analogRead(0));
  pinMode(LED, OUTPUT);
  Serial.begin(115200);
  while (!Serial) ; // Wait for serial port to be available

  nodeId = EEPROM.read(0);
  if (nodeId > 10) {
    Serial.print(F("EEPROM nodeId invalid: "));
    Serial.println(nodeId);
    nodeId = 1;
  }
  Serial.print(F("initializing node "));

  manager = new RHMesh(rf95, nodeId);

  if (!manager->init()) {
    Serial.println(F("init failed"));
  } else {
    Serial.println("done");
  }
  rf95.setTxPower(23, false);
  rf95.setFrequency(915.0);
  rf95.setCADTimeout(500);

  // Possible configurations:
  // Bw125Cr45Sf128 (the chip default)
  // Bw500Cr45Sf128
  // Bw31_25Cr48Sf512
  // Bw125Cr48Sf4096

  // long range configuration requires for on-air time
  boolean longRange = false;
  if (longRange) {
    RH_RF95::ModemConfig modem_config = {
      0x78, // Reg 0x1D: BW=125kHz, Coding=4/8, Header=explicit
      0xC4, // Reg 0x1E: Spread=4096chips/symbol, CRC=enable
      0x08  // Reg 0x26: LowDataRate=On, Agc=Off.  0x0C is LowDataRate=ON, ACG=ON
    };
    rf95.setModemRegisters(&modem_config);
    if (!rf95.setModemConfig(RH_RF95::Bw125Cr48Sf4096)) {
      Serial.println(F("set config failed"));
    }
  }

  Serial.println("RF95 ready");

  for(uint8_t n=1;n<=N_NODES;n++) {
    routes[n-1] = 0;
    rssi[n-1] = 0;
  }

//  Serial.print(F("mem = "));
//  Serial.println(freeMem());
}

const __FlashStringHelper* getErrorString(uint8_t error) {
  switch(error) {
    case 1: return F("invalid length");
    break;
    case 2: return F("no route");
    break;
    case 3: return F("timeout");
    break;
    case 4: return F("no reply");
    break;
    case 5: return F("unable to deliver");
    break;
  }
  return F("unknown");
}

void updateRoutingTable() {
  for(uint8_t n=1;n<=N_NODES;n++) {
    RHRouter::RoutingTableEntry *route = manager->getRouteTo(n);
    if (n == nodeId) {
      routes[n-1] = 255; // self
    } else {
      routes[n-1] = route->next_hop;
      if (routes[n-1] == 0) {
        // if we have no route to the node, reset the received signal strength
        rssi[n-1] = 0;
      }
    }
  }
}

// Create a JSON string with the routing info to each node
void getRouteInfoString(char *p, size_t len) {
  p[0] = '\0';
  strcat(p, "[");
  for(uint8_t n=1;n<=N_NODES;n++) {
    strcat(p, "{\"n\":");
    sprintf(p+strlen(p), "%d", routes[n-1]);
    strcat(p, ",");
    strcat(p, "\"r\":");
    sprintf(p+strlen(p), "%d", rssi[n-1]);
    strcat(p, "}");
    if (n<N_NODES) {
      strcat(p, ",");
    }
  }
  strcat(p, "]");
}

void printNodeInfo(uint8_t node, char *s) {
  Serial.print(F("node: "));
  Serial.print(F("{"));
  Serial.print(F("\""));
  Serial.print(node);
  Serial.print(F("\""));
  Serial.print(F(": "));
  Serial.print(s);
  Serial.println(F("}"));
}

void loop() {

  for(uint8_t n=1;n<=N_NODES;n++) {
    if (n == nodeId) continue; // self

    updateRoutingTable();
    getRouteInfoString(buf, RH_MESH_MAX_MESSAGE_LEN);

    Serial.print(F("->"));
    Serial.print(n);
    Serial.print(F(" :"));
    Serial.print(buf);

    // send an acknowledged message to the target node
    uint8_t error = manager->sendtoWait((uint8_t *)buf, strlen(buf), n);
    if (error != RH_ROUTER_ERROR_NONE) {
      Serial.println();
      Serial.print(F(" ! "));
      Serial.println(getErrorString(error));
    } else {
      Serial.println(F(" OK"));
      // we received an acknowledgement from the next hop for the node we tried to send to.
      RHRouter::RoutingTableEntry *route = manager->getRouteTo(n);
      if (route->next_hop != 0) {
        rssi[route->next_hop-1] = rf95.lastRssi();
      }
    }
    if (nodeId == 1) printNodeInfo(nodeId, buf); // debugging

    // listen for incoming messages. Wait a random amount of time before we transmit
    // again to the next node
    unsigned long nextTransmit = millis() + random(3000, 5000);
    while (nextTransmit > millis()) {
      int waitTime = nextTransmit - millis();
      uint8_t len = sizeof(buf);
      uint8_t from;
      if (manager->recvfromAckTimeout((uint8_t *)buf, &len, waitTime, &from)) {
        buf[len] = '\0'; // null terminate string
        Serial.print(from);
        Serial.print(F("->"));
        Serial.print(F(" :"));
        Serial.println(buf);
        if (nodeId == 1) printNodeInfo(from, buf); // debugging
        // we received data from node 'from', but it may have actually come from an intermediate node
        RHRouter::RoutingTableEntry *route = manager->getRouteTo(from);
        if (route->next_hop != 0) {
          rssi[route->next_hop-1] = rf95.lastRssi();
        }
      }
    }
  }

}

Debug Message

Sketch uses 263169 bytes (20%) of program storage space. Maximum is 1310720 bytes.
Global variables use 18352 bytes (5%) of dynamic memory, leaving 309328 bytes for local variables. Maximum is 327680 bytes.
esptool.py v3.3
Serial port COM7
Connecting..............
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 8c:aa:b5:96:45:30
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00050fff...
Compressed 18560 bytes to 12759...
Writing at 0x00001000... (100 %)
Wrote 18560 bytes (12759 compressed) at 0x00001000 in 0.6 seconds (effective 268.8 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.1 seconds (effective 195.1 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.2 seconds (effective 324.4 kbit/s)...
Hash of data verified.
Compressed 263552 bytes to 142322...
Writing at 0x00010000... (11 %)
Writing at 0x0001e01e... (22 %)
Writing at 0x00025119... (33 %)
Writing at 0x0002a737... (44 %)
Writing at 0x0002fbad... (55 %)
Writing at 0x00035ea8... (66 %)
Writing at 0x00040663... (77 %)
Writing at 0x0004718d... (88 %)
Writing at 0x0004c72a... (100 %)
Wrote 263552 bytes (142322 compressed) at 0x00010000 in 2.8 seconds (effective 747.9 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Other Steps to Reproduce

I tried on 2 more boards

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@Sureshbe Sureshbe added the Status: Awaiting triage Issue is waiting for triage label Aug 1, 2022
@VojtechBartoska VojtechBartoska added Type: Question Only question Status: Community help needed Issue need help from any member from the Community. and removed Status: Awaiting triage Issue is waiting for triage labels Aug 1, 2022
@SuGlider
Copy link
Collaborator

SuGlider commented Aug 1, 2022

@Sureshbe - It sounds like your sketch is using one of the Flash assigned pins.

Flash SPI QIO pins are: GPIO 6, 7, 8, 9, 10 and 11
If you change to DIO instead of QIO, you may use pins 9 and 10.

GPIO 9 is used for the LED and set as OUPUT by the Sketch. In QIO mode, it will reset the board.

#define LED 9

...

void setup() {
  randomSeed(analogRead(0));
  pinMode(LED, OUTPUT);
...

@SuGlider SuGlider self-assigned this Aug 1, 2022
@Jason2866
Copy link
Collaborator

Jason2866 commented Aug 3, 2022

I am not sure if using mode DIO solves the reboot. Isnt there still activity on this GPIO (2nd stage bootloader)? And if this is not the case, the are still electrical connected to flash and will end in issues when connecting additional hardware (led) here.
Gpios 6, 7, 8, 9, 10 and 11 are a no go for ESP32 to use

@SuGlider
Copy link
Collaborator

SuGlider commented Aug 3, 2022

I tested setting DIO, and I can use GPIO 9 and 10.
Those 2 pins are the default pins for Serial1, but it only works with DIO.
Otherwise, using QIO, it is necessary to change Serial1 RX/TX in begin().

@Jason2866
Copy link
Collaborator

Jason2866 commented Aug 3, 2022

Ahh yes, nice trap. All newer boards have connected the flash to GPIO 9 / 10.
Imho at least it would be good to assign "other" unrestricted Gpios for serial1 by default when flash mode qio is used.
Still have a bad feeling to connect hardware to GPIO 9/10 when the flash chip is connected there too.

@dbhaig
Copy link

dbhaig commented Aug 4, 2022

ESP32-S3-DEVKITC-1-N8

I have the same issue when programming an ESP32-S3-DEVKITC-1-N8 v1.8 board. The only connection to the board is a USB cable connected to the UART port.

Compile

I compiled the BareMinimum example using : arduino-cli compile -b esp32:esp32:esp32s3 -v
Resulting in:
. . .
esp32/tools/xtensa-esp32s3-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/xtensa-esp32s3-elf-size -A /tmp/arduino-sketch-08CF0556BB4284CF461BE2005A5EA1D0/BareMinimum.ino.elf
Sketch uses 208601 bytes (15%) of program storage space. Maximum is 1310720 bytes.
Global variables use 12824 bytes (3%) of dynamic memory, leaving 314856 bytes for local variables. Maximum is 327680 bytes.

Used platform Version Path
esp32:esp32 2.0.4

Upload

I uploaded sketch using: arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:esp32s3 -v
BareMinimum$ esp32-s3_upload.sh
python3 "/home/don/.arduino15/packages/esp32/tools/esptool_py/3.3.0/esptool.py" --chip esp32s3 --port "/dev/ttyUSB0" --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x0 "/tmp/arduino-sketch-08CF0556BB4284CF461BE2005A5EA1D0/BareMinimum.ino.bootloader.bin" 0x8000 "/tmp/arduino-sketch-08CF0556BB4284CF461BE2005A5EA1D0/BareMinimum.ino.partitions.bin" 0xe000 "/home/don/.arduino15/packages/esp32/hardware/esp32/2.0.4/tools/partitions/boot_app0.bin" 0x10000 "/tmp/arduino-sketch-08CF0556BB4284CF461BE2005A5EA1D0/BareMinimum.ino.bin"
esptool.py v3.3-dev
Serial port /dev/ttyUSB0
Connecting.....
Chip is ESP32-S3
Features: WiFi, BLE
Crystal is 40MHz
MAC: 34:b4:72:70:07:90
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00003fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00043fff...
Compressed 15008 bytes to 10328...
Wrote 15008 bytes (10328 compressed) at 0x00000000 in 0.3 seconds (effective 374.9 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.0 seconds (effective 511.0 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 686.1 kbit/s)...
Hash of data verified.
Compressed 208992 bytes to 116565...
Wrote 208992 bytes (116565 compressed) at 0x00010000 in 1.8 seconds (effective 919.2 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Result

Connecting to the UART port with picocom reveals:

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x10 (RTCWDT_RTC_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:QIO, clock div:2
load:0x3fce3808,len:0x43c
ets_loader.c 78
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x7 (TG0WDT_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x400454d5
SPIWP:0xee
mode:QIO, clock div:2
load:0x3fce3808,len:0x43c
ets_loader.c 78
(repeats)

Compiling with the arduino IDE yields the same result.
Previously, I had success uploading and running sketches on this board. (That was before I upgraded arduino-cli from version 0.21.1 to 0.25.1)

@Jason2866
Copy link
Collaborator

@dbhaig i think same as #6980 (comment)
I do not use Arduino IDE nor CLI. With Platformio it does work

@SuGlider SuGlider closed this as completed Nov 5, 2022
@Rob58329
Copy link
Contributor

Rob58329 commented May 1, 2023

Re. ArduinoIDE:

(1) I note that you are trying to use the EEPROM before you have done an "EEPROM.begin(EEPROM_SIZE);"

(2) I often get ESP32 "rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)" crashes when doing “EEPROM.commit” or similar EEPROM activities when other processes are using interrupts (both external interrupts and also internal timer-interrupts). [The solution for me was to specifically disable the offending interrupt before the crashing EEPROM activity.]

Under these circumstances I have seen an EEPROM activity at the top of setup() causing repeated boot-crashes similar to the one shown above.

(I have also seen the use of "SerialM.setDebugOutput(true)" causing the above crash on a subsequent “EEPROM.commit()” when an error message is generated from any other interrupt process during the “EEPROM.commit()” – in instances where removing the "SerialM.setDebugOutput(true)" is sufficient to allow the error-message (eg. “cam_hal: EV-EOF-OVF”) to be printing during the “EEPROM.commit()” without crashing it.)

@bmedici
Copy link

bmedici commented Aug 6, 2023

Same crash here with ESP32-S3, 16MB Flash. Not using SPI0 pins it seems.
rst:0x8 (TG1WDT_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40378325
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x3ac
load:0x403c9700,len:0x9b4
load:0x403cc700,len:0x28fc
entry 0x403c98bc

@jenschr
Copy link

jenschr commented Nov 8, 2023

Gpios 6, 7, 8, 9, 10 and 11 are a no go for ESP32 to use

I have a related issue on a new PCB and what @Jason2866 says here does scare me a bit? According to the documentation from Espressif, the pins 6, 7, 8, 9, 10 and 11 are all perfectly good? But for modules with PSRAM, you must absolutely not use pins 35, 36 and 37 since that's connected to the PSRAM (at the end of section 3.2 in ESP32S3-WROOM-1 datasheet). In my case, that is what caused this (and lots of other issues).

Or maybe the statement was for a very specific board?

@Jason2866
Copy link
Collaborator

ESP32-S3 != ESP32 so the forbidden GPIOs are different.
For ESP32 Page 15 https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf

@jenschr
Copy link

jenschr commented Nov 8, 2023

Thanks for clarifying @Jason2866 !

@Shayantika-Dhar
Copy link

what can we do to resolve the issue of the serial monitor output

rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13964
load:0x40080400,len:3600
entry 0x400805f0
ets Jun 8 2016 00:22:57

@Bendikos
Copy link

esp32-devkitC-v4-pinout
Some pins of ESP32 cannot be used as GPIO, such as GPIO9, GPIO10, and GPIO11 as shown in the figure

@devitalii
Copy link

what can we do to resolve the issue of the serial monitor output

rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0030,len:1344 load:0x40078000,len:13964 load:0x40080400,len:3600 entry 0x400805f0 ets Jun 8 2016 00:22:57

I had similar issue, ESP32 C3 -----

PROBLEM was that I tried to use wrong PIN numbers.
Some pins you can not use as they are RESET or dedicated to FLASH memory. See posts above/

I accidentally tried to use these pins on ESP32 c3 mini (some are not even wired out for usage, 18,23,16,4,5,17 in TFT_eSPI library as DIO pins. (Hate that User_Setup.h that you need to redefine for each ESP32-Screen combo).
However my sketch was using pin 4 as A4.
I think it was conflict of pins.

This gave me error:
rst:0x8 (TG1WDT_SYS_RST),boot:0xf (SPI_FAST_FLASH_BOOT)

@gpena208777
Copy link

Bump

@Focus06
Copy link

Focus06 commented Oct 20, 2024

I had something similar in my XIAO ESP32S3, I was really confused because I do not use "forbidden" pins.
Solution was to set "Disable" USB CDC On Boot

@NikInoxsys
Copy link

Hi, my 5 cents, for me this problem was if there is mismatch between past and new partition.csv and partition offset in menuconfig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Community help needed Issue need help from any member from the Community. Type: Question Only question
Projects
None yet
Development

No branches or pull requests