HelTecAutomation / Heltec_ESP32

Arduino library for Heltec ESP32 (or ESP32+LoRa) based boards
Other
632 stars 226 forks source link

Coprocessor exception on release 1.1.1 (LoRa SNR and RSSI) #86

Open Lohkdesgds opened 2 years ago

Lohkdesgds commented 2 years ago

If I try to get RSSI and SNR (I can't test exactly which, but I'm pretty sure it's one of them, or both), this happens:

Guru Meditation Error: Core  1 panic'ed (Coprocessor exception)
Core 1 register dump:
PC      : 0x400d195d  PS      : 0x00060c31  A0      : 0x800d10d0  A1      : 0x3ffbe630  
A2      : 0x00000012  A3      : 0x00000001  A4      : 0x0000009d  A5      : 0x00000000  
A6      : 0x3ffc0438  A7      : 0x00060d23  A8      : 0x800d1954  A9      : 0x3ffbe6d0  
A10     : 0x00000047  A11     : 0x0000001b  A12     : 0x40000000  A13     : 0x41bf4add  
A14     : 0x7ff00000  A15     : 0x00000000  SAR     : 0x0000000e  EXCCAUSE: 0x00000004  
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  
Core 1 was running in ISR context:
EPC1    : 0x400d195d  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x40086e4f

Backtrace: 0x400d195d:0x3ffbe630 0x400d10cd:0x3ffbe6f0 0x400d10cd:0x3ffbe710 0x400d1f54:0x3ffbe770 0x400d1f6a:0x3ffbe790 0x40080ef1:0x3ffbe7b0 0x40084db1:0x3ffbe7d0 0x400ebe3f:0x3ffbc5c0 0x400d6a03:0x3ffbc5e0 0x4008a17a:0x3ffbc600 0x400889d9:0x3ffbc620

This was on a function set with LoRa.onReceive(). This doesn't happen on 1.1.0 (I literally downgraded to check)

The simple project I was working on: project.ino

I added Serial later on each step, that's why I know it's between the packetRssi() and packetSnr(). I just don't have the computer right now to test again, sorry.

IsaacAmante commented 1 year ago

I'm having a similar problem. On PlatformIO, with this library, using the "examples/Factory_Test/WiFi_LoRa_32FactoryTest", with Heltec Lora 32 V2 915Mz, the boards reboot every time a packet is send from the other board. The monitor shows: `Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1).

Core 1 register dump: PC : 0x4008fafa PS : 0x00060035 A0 : 0x8008e79e A1 : 0x3ffbf35c A2 : 0x3ffb8314 A3 : 0x3ffb81a4 A4 : 0x00000004 A5 : 0x00060023 A6 : 0x00060023 A7 : 0x00000001 A8 : 0x3ffb81a4 A9 : 0x00000018 A10 : 0x3ffb81a4 A11 : 0x00000018 A12 : 0x3ffc5194 A13 : 0x00060023 A14 : 0x007bf578 A15 : 0x003fffff SAR : 0x0000000e EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x40089d60 LEND : 0x40089d6a LCOUNT : 0x00000000 Core 1 was running in ISR context: EPC1 : 0x400e1897 EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x00000000

Backtrace: 0x4008faf7:0x3ffbf35c |<-CORRUPTED

Core 0 register dump: PC : 0x4008fc97 PS : 0x00060935 A0 : 0x8008e827 A1 : 0x3ffbec0c A2 : 0x3ffbf578 A3 : 0xb33fffff A4 : 0x0000abab A5 : 0x00060023 A6 : 0x00060023 A7 : 0x0000cdcd A8 : 0x0000abab A9 : 0xffffffff
A10 : 0x00000001 A11 : 0x00000001 A12 : 0x4014d0f2 A13 : 0x3ffbed2c A14 : 0x007bf578 A15 : 0x003fffff SAR : 0x0000001d EXCCAUSE: 0x00000006 EXCVADDR: 0x00000000 LBEG : 0x40089db4 LEND : 0x40089dca LCOUNT : 0xffffffff

Backtrace: 0x4008fc94:0x3ffbec0c |<-CORRUPTED

ELF file SHA256: aed7d63942598a82

Rebooting... ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_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:2 load:0x3fff0030,len:1184 load:0x40078000,len:13192 load:0x40080400,len:3028 entry 0x400805e4 Serial initial done you can see OLED printed OLED initial done! LoRa Initial success! ESP32ChipID=E813651C5210 hello 0`

My code: `/*

include "Arduino.h"

include "heltec.h"

include "WiFi.h"

include "images.h"

// Prototipos das funções void send(); void displaySendReceive(); void onReceive(int packetSize); // LoRa receiver interrupt service void logo(); // Show the Heltec logo void WIFIScan(unsigned int value); // Show the WIFI networks void WIFISetUp(void); // Conects to a WIFI network void interrupt_GPIO0(); // Called on button press

define BAND 915E6 // you can set band here directly,e.g. 868E6,915E6

String rssi = "RSSI --"; String packSize = "--"; String packet;

unsigned int counter = 0;

bool receiveflag = false; // software flag for LoRa receiver, received data makes it true.

long lastSendTime = 0; // last send time int interval = 1000; // interval between sends uint64_t chipid; int16_t RssiDetection = 0;

bool resendflag = false; bool deepsleepflag = false;

void setup() { Heltec.begin(true /DisplayEnable Enable/, true /LoRa Enable/, true /Serial Enable/, true /LoRa use PABOOST/, BAND /LoRa RF working band/);

logo(); delay(300); Heltec.display->clear();

WIFISetUp(); WiFi.disconnect(); // Reinitialize WiFi WiFi.mode(WIFI_STA); delay(100);

WIFIScan(1);

chipid = ESP.getEfuseMac(); // The chip ID is essentially its MAC address(length: 6 bytes). Serial.printf("ESP32ChipID=%04X", (uint16_t)(chipid >> 32)); // print High 2 bytes Serial.printf("%08X\n", (uint32_t)chipid); // print Low 4bytes.

attachInterrupt(0, interrupt_GPIO0, FALLING); LoRa.onReceive(onReceive); send(); LoRa.receive(); displaySendReceive(); }

void loop() { if (deepsleepflag) { LoRa.end(); LoRa.sleep(); delay(100); pinMode(4, INPUT); pinMode(5, INPUT); pinMode(14, INPUT); pinMode(15, INPUT); pinMode(16, INPUT); pinMode(17, INPUT); pinMode(18, INPUT); pinMode(19, INPUT); pinMode(26, INPUT); pinMode(27, INPUT); digitalWrite(Vext, HIGH); delay(2); esp_deep_sleep_start(); } if (resendflag) { resendflag = false; send(); LoRa.receive(); displaySendReceive(); } if (receiveflag) { // digitalWrite(25,HIGH); displaySendReceive(); delay(1000); receiveflag = false; send(); LoRa.receive(); displaySendReceive(); } }

void logo() { Heltec.display->clear(); Heltec.display->drawXbm(0, 5, logo_width, logo_height, (const unsigned char *)logo_bits); Heltec.display->display(); }

void WIFIScan(unsigned int value) { unsigned int i; WiFi.mode(WIFI_STA);

for (i = 0; i < value; i++) { Heltec.display->drawString(0, 20, "Starting scan."); Heltec.display->display();

int n = WiFi.scanNetworks();
Heltec.display->drawString(0, 30, "Scan done");
Heltec.display->display();
delay(500);
Heltec.display->clear();

if (n == 0)
{
  Heltec.display->clear();
  Heltec.display->drawString(0, 0, "No network found");
  Heltec.display->display();
  // while(1);
}
else
{
  Heltec.display->drawString(0, 0, (String)n);
  Heltec.display->drawString(14, 0, "Networks found:");
  Heltec.display->display();
  delay(500);

  for (int i = 0; i < n; ++i)
  {
    // Print SSID and RSSI for each network found
    Heltec.display->drawString(0, (i + 1) * 9, (String)(i + 1));
    Heltec.display->drawString(6, (i + 1) * 9, ":");
    Heltec.display->drawString(12, (i + 1) * 9, (String)(WiFi.SSID(i)));
    Heltec.display->drawString(90, (i + 1) * 9, " (");
    Heltec.display->drawString(98, (i + 1) * 9, (String)(WiFi.RSSI(i)));
    Heltec.display->drawString(114, (i + 1) * 9, ")");
    // display.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
    delay(10);
  }
}

Heltec.display->display();
delay(800);
Heltec.display->clear();

} }

void interrupt_GPIO0() { delay(10); if (digitalRead(0) == 0) { if (digitalRead(LED) == LOW) { resendflag = true; } else { deepsleepflag = true; } } }

void WIFISetUp(void) { // Set WiFi to station mode and disconnect from an AP if it was previously connected WiFi.disconnect(true); delay(100); WiFi.mode(WIFI_STA); WiFi.setAutoConnect(true); WiFi.begin("Your WiFi SSID", "Your Password"); // fill in "Your WiFi SSID","Your Password" delay(100);

byte count = 0; while (WiFi.status() != WL_CONNECTED && count < 10) { count++; delay(500); Heltec.display->drawString(0, 0, "Connecting..."); Heltec.display->display(); }

Heltec.display->clear(); if (WiFi.status() == WL_CONNECTED) { Heltec.display->drawString(0, 0, "Connected."); Heltec.display->display(); // delay(500); } else { Heltec.display->clear(); Heltec.display->drawString(0, 0, "Failed to connect."); Heltec.display->display(); // while(1); } Heltec.display->drawString(0, 10, "WiFi setup done"); Heltec.display->display(); delay(500); }

void send() { LoRa.beginPacket(); LoRa.print("hello "); LoRa.print(counter++); LoRa.endPacket(); } void displaySendReceive() { Heltec.display->drawString(0, 50, "Packet " + (String)(counter - 1) + " sent done"); Heltec.display->drawString(0, 0, "Received Size " + packSize + " packages:"); Heltec.display->drawString(0, 10, packet); Heltec.display->drawString(0, 20, "With " + rssi + "db"); Heltec.display->display(); delay(100); Heltec.display->clear(); } void onReceive(int packetSize) // LoRa receiver interrupt service { // if (packetSize == 0) return; packet = ""; packSize = String(packetSize, DEC);

while (LoRa.available()) { packet += (char)LoRa.read(); }

Serial.println(packet); rssi = "RSSI: " + String(LoRa.packetRssi(), DEC); RssiDetection = abs(LoRa.packetRssi()); if (RssiDetection < 65) { digitalWrite(25, HIGH); } else { digitalWrite(25, LOW); } receiveflag = true; }`

The PlatformIo.ini config: [env:heltec_wifi_lora_32_V2] platform = espressif32 board = heltec_wifi_lora_32_V2 framework = arduino monitor_speed = 115200 lib_deps = heltecautomation/Heltec ESP32 Dev-Boards @ 1.0.9