Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

RichPiano
Posts: 123
Joined: Mon May 18, 2020 2:51 pm

Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Postby RichPiano » Fri Jan 22, 2021 7:32 pm

I can't think of a way to introduce this error. It's pretty much out of the blue for me and I can't really pinpoint it to something:

Code: Select all

I (3637) esp_netif_handlers: sta ip: 192.168.4.34, mask: 255.255.255.0, gw: 192.168.4.1
I (3637) wifi.c: got ip:192.168.4.34
I (3637) wifi.c: connected to ap SSID:aurora_raspi password:somepassword
I (3647) app_main.cpp: sync system time
I (3647) app_main.cpp: starting mqtt event handler
I (3657) mqtts.c: [APP] Free memory: 229256 bytes
I (3667) app_main.cpp: entering dimming cycle
I (3667) mqtts.c: Other event id:7
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x400da3dc  PS      : 0x00060e30  A0      : 0x800d7040  A1      : 0x3ffcac50
0x400da3dc: pin::calc_and_apply_dimming() at C:\dev\aurora-esp32-firmware\build/../components/pin/pin.cpp:205

A2      : 0x00000000  A3      : 0x00000000  A4      : 0x00000001  A5      : 0x00000000
A6      : 0x3ffb45d0  A7      : 0x00060123  A8      : 0x00002f04  A9      : 0x00000000
A10     : 0x00000000  A11     : 0x00000000  A12     : 0x00000017  A13     : 0x0000001f
A14     : 0x0000003b  A15     : 0x3ffbf608  SAR     : 0x00000020  EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xffffffff

Backtrace:0x400da3d9:0x3ffcac50 0x400d703d:0x3ffcaca0 0x4008af3d:0x3ffcacd0
0x400da3d9: pin::calc_and_apply_dimming() at C:\dev\aurora-esp32-firmware\build/../components/pin/pin.cpp:203

0x400d703d: vDimCycle(void*) at C:\dev\aurora-esp32-firmware\build/../main/app_main.cpp:51 (discriminator 2)

0x4008af3d: vPortTaskWrapper at C:/dev/esp/esp-idf/components/freertos/port/xtensa/port.c:168
What is obvious is that it seems to stem from the "calc_and_apply_dimming()" function inside pin.cpp. I have searched the internet already and just found this from the forum:
Check the following:

Do you use String Class and do a lot off String constructions with String c = "a" + "b"
are you creating char arrays on the fly e.g. char d[] = "efg";
are you using delay() - get rid of it its blocking
If there is one Yes than you've found the reason, if its 3x No we need your code (github, pastebin) to do further analysis
1) I'm not using any strings.
2) I do not create char array but an array with structs?
3) Yes I'm using the function calc_and_apply_dimming() in a cyclical loop of a seperate task which is delayed with vTaskDelayUntil() like so:

Code: Select all

void vDimCycle( void * pvParameters )
{
  // Dimming
  portTickType xLastWakeTime; // will be increased each cycle

  // Initialise the xLastWakeTime variable with the current time.
  xLastWakeTime = xTaskGetTickCount ();
  for( ;; ) {
    // Go through every light and dim according to specs
    for (int i=0, len=sizeof(pinList)/sizeof(pinList[0]); i < len; ++i) {
      pinList[i].calc_and_apply_dimming();
    }

    // Wait for the next cycle.
    vTaskDelayUntil( &xLastWakeTime, MAIN_ADJUST_PERIOD / portTICK_PERIOD_MS);
  }
}
Following the leads I have put this function in place instead of Delaying and blocking the main thread. But I have to do this delayed loop somewhere.

Also, I don't really understand what this error is trying to tell me and especially why strings, char arrays and blocking delays seem to cause it?

ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Postby ESP_Dazz » Fri Jan 22, 2021 8:11 pm

The error LoadProhibited means that the CPU tried to load a variable form an illegal address. The offending address is EXCVADDR: 0x00000000 (see docs for more details). The address 0x00000000 looks like some NULL pointer was accessed.

The offending line of the bad load was

Code: Select all

0x400da3d9: pin::calc_and_apply_dimming() at C:\dev\aurora-esp32-firmware\build/../components/pin/pin.cpp:203.
Double check what is being loaded at that line.

RichPiano
Posts: 123
Joined: Mon May 18, 2020 2:51 pm

Re: Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Postby RichPiano » Sun Jan 24, 2021 5:49 pm

Thank you! I checked the lines carefully and indeed, in some cases the program would encounter a null pointer. After I added some extra checks the problem now seems to be gone! :)

aakashteggi96
Posts: 5
Joined: Mon Apr 26, 2021 6:56 am

Re: Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Postby aakashteggi96 » Wed May 19, 2021 2:01 pm

make sure that you dump code of gatt_client in client and gatt_server in server. And make sure that if the esp32 is new do not directly plug it in without loading server code into it....cause we dont know which code is currently running in the new esp32 which we are using as server...that might give error in the client.....

kanimba01
Posts: 1
Joined: Thu Aug 19, 2021 2:01 pm

Re: Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Postby kanimba01 » Wed Aug 25, 2021 10:03 am

I am having a similar error during monitoring which i cant seem to resolve or understand why its occuring, composed my error on stackoverflow if someone would mind checking it and give a feedback on such a problem and how to resolve it, it would be highly appreciated.
https://stackoverflow.com/questions/689 ... g-function

newguyesp32ble
Posts: 1
Joined: Mon Jun 06, 2022 3:24 pm

Re: Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Postby newguyesp32ble » Mon Jun 06, 2022 3:32 pm

Hey guys, I have the same error. I do not know which of my code causes this error.
This thing appears when my Client is connecting to my Server:
Forming a connection to Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.

Core 1 register dump:
PC : 0x4008fd17 PS : 0x00060a30 A0 : 0x800d217c A1 : 0x3ffc6f40
A2 : 0x3ffc6f5a A3 : 0x00000005 A4 : 0x00000006 A5 : 0x3ffc6f5a
A6 : 0x3ffd8774 A7 : 0x00000000 A8 : 0x800d67ee A9 : 0x3ffc6f20
A10 : 0x00000018 A11 : 0x3f400152 A12 : 0x00000018 A13 : 0x0000ff00
A14 : 0x00ff0000 A15 : 0xff000000 SAR : 0x00000018 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000005 LBEG : 0x400903dd LEND : 0x400903ed LCOUNT : 0xfffffffa


Backtrace:0x4008fd14:0x3ffc6f400x400d2179:0x3ffc6f50 0x400d1df7:0x3ffc6f80 0x400d1f2e:0x3ffc6fd0 0x400d6b4d:0x3ffc7010


ELF file SHA256: 0000000000000000

Rebooting...

What should be the error in my code?

Here is the code on the client side:(After the Client, I also pasted the Server's Code) ps. I'm sorry about my crowded post, I am new to this platform..

#include "BLEDevice.h"
#include <BLEScan.h>

const int pin = 17;


/* Specify the Service UUID of Server */
static BLEUUID serviceUUID("4fafc201-1fb5-459e-8fcc-c5c9c331914b");
/* Specify the Characteristic UUID of Server */
static BLEUUID charUUID("beb5483e-36e1-4688-b7f5-ea07361b26a8");

static boolean doConnect = false;
/*static boolean connected = false;*/
static boolean doScan = false;
//boolean doScan2 = false;

BLEClient* pClient;

BLEScan* pBLEScan;

static BLERemoteCharacteristic* pRemoteCharacteristic;

static BLEAdvertisedDevice* myDevice;


class MyClientCallback : public BLEClientCallbacks{
void onConnect(BLEClient* pclient){
}
void onDisconnect(BLEClient* pclient){
//connected = false;
Serial.println("onDisconnect");
}
};

/* Start connection to the BLE Server */
bool connectToServer(){

Serial.print("Forming a connection to ");
Serial.println(myDevice->getAddress().toString().c_str());

//pClient = BLEDevice::createClient(); for notify client creation

pClient = BLEDevice::createClient();
Serial.println("client created.");

pClient->setClientCallbacks(new MyClientCallback());

/* Connect to the remote BLE Server */
pClient->connect(myDevice);
/* if you pass BLEAdvertisedDevice instead of address,it will
be recognized type of peer device address (public or private)*/
Serial.println(" - Connected to server");

for(int a = 0; a < 10; a++){
delay(1000);
Serial.print(a + " seconds");

int signalStrength = (pClient->getRssi());

if(signalStrength > -52){
Serial.println("");
digitalWrite(pin,HIGH);
}
else if(signalStrength < -51){
pClient->disconnect();
Serial.println("");
doScan = true;
digitalWrite(pin,LOW);
}

if(a == 10){


//Obtain a reference to the service we are after in the remote BLE server
BLERemoteService* pRemoteService = pClient->getService(serviceUUID);
if (pRemoteService == nullptr){
Serial.print("Failed to find our service UUID: ");
Serial.println(serviceUUID.toString().c_str());
pClient->disconnect();
return false;
}
Serial.println(" - We found our service");

// Obtain a reference to the characteristic in the service of the remote BLE server
pRemoteCharacteristic = pRemoteService->getCharacteristic(charUUID);
if (pRemoteCharacteristic == nullptr){
Serial.print("Failed to find our characteristic UUID: ");
Serial.println(charUUID.toString().c_str());
pClient->disconnect();
return false;
}

Serial.println(" - We found our characteristic");

if(pRemoteCharacteristic->canRead()){
std::string value = pRemoteCharacteristic->readValue();
Serial.print("The characteristic value is: ");
Serial.println(value.c_str());

if (value != ""){

pClient->disconnect();
Serial.println("We are disconnected");
delay(3000);
value = "";
doScan = true;
}
}
}

}

//return true;
}
/* Scan for BLE servers and find the first one that advertises the service we are
looking for. */
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks{

/* Called for each advertising BLE server. */
void onResult(BLEAdvertisedDevice advertisedDevice){
Serial.print("A BLE Advertising Device has found: ");
Serial.println(advertisedDevice.toString().c_str());//print the device's name

// We have found a device, let us now see if it contains the service we are looking for.
if (advertisedDevice.haveServiceUUID() && advertisedDevice.isAdvertisingService(serviceUUID)){
BLEDevice::getScan()->stop();

doConnect = true;

doScan = true;
}
}
};

void setup(){
Serial.begin(115200);
Serial.println("Starting Arduino BLE Client application...");
BLEDevice::init("ESP32-BLE-Client");
pinMode(pin,OUTPUT);
/* Retrieve a Scanner and set the callback we want to use to be informed when we
have detected a new device. Specify that we want active scanning and start the
scan to run for 5 seconds. */
pBLEScan = BLEDevice::getScan();
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setInterval(1349);
pBLEScan->setWindow(449);
pBLEScan->setActiveScan(true);
pBLEScan->start(30, false);//scan for 30 seconds then clear the

}

void loop(){
if (doConnect){

if (connectToServer()){
Serial.println("We are now connected to the BLE Server.");
}
else{
Serial.println("We have failed to connect to the server; there is nothin more we will do.");
doScan = true;
}
doConnect = false;
}


if(doScan){

BLEDevice::getScan()->start(0); // this is just example to start scan after disconnect, most likely there is better way to do it in arduino
pBLEScan->setActiveScan(true);

}

}


Server's Code:

#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>

BLEServer* pServer = NULL;
BLECharacteristic* pCharacteristic = NULL;
bool deviceConnected = false;
bool oldDeviceConnected = false;

#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"

class MyServerCallbacks: public BLEServerCallbacks {
void onConnect(BLEServer* pServer) {
deviceConnected = true;
};

void onDisconnect(BLEServer* pServer) {
deviceConnected = false;
}
};


void setup() {
Serial.begin(115200);

// Create the BLE Device
BLEDevice::init("ESP32");

// Create the BLE Server
pServer = BLEDevice::createServer();
pServer->setCallbacks(new MyServerCallbacks());

// Create the BLE Service
BLEService *pService = pServer->createService(SERVICE_UUID);

// Create a BLE Characteristic
pCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ /*|
BLECharacteristic::PROPERTY_WRITE |
BLECharacteristic::PROPERTY_INDICATE |
BLECharacteristic::PROPERTY_NOTIFY*/
);

pCharacteristic->addDescriptor(new BLE2902());

// Start the service
pService->start();

// Start advertising
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
pAdvertising->addServiceUUID(SERVICE_UUID);
pAdvertising->setScanResponse(false);
pAdvertising->setMinPreferred(0x0); // set value to 0x00 to not advertise this parameter
BLEDevice::startAdvertising();
Serial.println("Waiting a client connection to notify...");
}

void loop() {
// notify changed value
if (deviceConnected) {
Serial.println("We are connected");
pCharacteristic->setValue("VALUE111");
//pCharacteristic->notify();
//delay(1000);
}

//disconnecting
if (!deviceConnected && oldDeviceConnected) {
delay(500); // give the bluetooth stack the chance to get things ready
pServer->startAdvertising(); // restart advertising
Serial.println("start advertising");
oldDeviceConnected = deviceConnected; //if the condition of deviceconnected is false and olddeviceconnected is true, we'll do the stuffs above and then
} //copy the state of deviceconnected(which is false) to olddeviceconnected

// connecting
if (deviceConnected && !oldDeviceConnected) { //if the condition is if deviceconnected is true and olddeviceconnected is false (false by default),
// do stuff here on connecting //olddeviceconnected will copy the state of deviceconnected (which is true).
oldDeviceConnected = deviceConnected;
}

//disconnected
if (!deviceConnected) { //outputs in the screen of we are not connected to a client
Serial.println("We are not connected");
}
}

Who is online

Users browsing this forum: No registered users and 82 guests