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

I'm using an Arduino esp32 DEVKITV1 and recently I bought a plugin from Unity Store called "Uduino Wifi". I already owned the basic one. But he only works with USB cables and I need the WiFi conection for my projects. The thing is, I can't make the code work no matter what. This error keeps printing on the monitor:

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

Core 1 register dump:

PC : 0x40089688 PS : 0x00060530 A0 : 0x800d8f29 A1 : 0x3ffb2160
A2 : 0x00000000 A3 : 0x3ffc3424 A4 : 0x00000004 A5 : 0x3ffc3ccc
A6 : 0x400d4adc A7 : 0x00000000 A8 : 0x00000001 A9 : 0x3ffb2070
A10 : 0x00000000 A11 : 0x3ffcae58 A12 : 0x400915e4 A13 : 0x3ffb81e4

ELF file SHA256: 12e68e183a55770b

Here is the script if you wanna see it:

#include<Uduino_Wifi.h>
Uduino_Wifi uduino("uduinoBoard"); // Declare and name your object

// Servo
#if defined(ESP32)
// Install esp32servo library => Sketch>Include Library>Manager Libraries>Esp32Servo
#include <ESP32Servo.h>
#else
#include <Servo.h>
#endif

#define MAXSERVOS 8

void setup()
{
  Serial.begin(38400);
#if defined (__AVR_ATmega32U4__) // Leonardo
  while (!Serial) {}
#elif defined(__PIC32MX__)
  delay(1000);
#endif

  // Optional functions,  to add BEFORE connectWifi(...)
  uduino.setPort(4222);   // default 4222
  uduino.connectWifi("CLARO_2G6A9384", "726A9384");

  uduino.addCommand("s", SetMode);
  uduino.addCommand("d", WritePinDigital);
  uduino.addCommand("a", WritePinAnalog);
  uduino.addCommand("rd", ReadDigitalPin);
  uduino.addCommand("r", ReadAnalogPin);
  uduino.addCommand("br", BundleReadPin);
  uduino.addCommand("b", ReadBundle);

  uduino.addInitFunction(InitializeServos);
  uduino.addDisconnectedFunction(DisconnectAllServos);
}

void ReadBundle() {
  char *arg = NULL;
  char *number = NULL;
  number = uduino.next();
  int len = 0;
  if (number != NULL)
    len = atoi(number);
  for (int i = 0; i < len; i++) {
    uduino.launchCommand(arg);
  }
}

void SetMode() {
  int pinToMap = 100; //100 is never reached
  char *arg = NULL;
  arg = uduino.next();
  if (arg != NULL)
  {
    pinToMap = atoi(arg);
  }
  int type;
  arg = uduino.next();
  if (arg != NULL)
  {
    type = atoi(arg);
    PinSetMode(pinToMap, type);
  }
}

void PinSetMode(int pin, int type) {
  //TODO : vérifier que ça, ça fonctionne
  if (type != 4)
    DisconnectServo(pin);

  switch (type) {
    case 0: // Output
      pinMode(pin, OUTPUT);
      break;
    case 1: // PWM
      pinMode(pin, OUTPUT);
      break;
    case 2: // Analog
      pinMode(pin, INPUT);
      break;
    case 3: // Input_Pullup
      pinMode(pin, INPUT_PULLUP);
      break;
    case 4: // Servo
      SetupServo(pin);
      break;
  }
}

void WritePinAnalog() {
  int pinToMap = 100;
  char *arg = NULL;
  arg = uduino.next();
  if (arg != NULL)
  {
    pinToMap = atoi(arg);
  }

  int valueToWrite;
  arg = uduino.next();
  if (arg != NULL)
  {
    valueToWrite = atoi(arg);

    if (ServoConnectedPin(pinToMap)) {
      UpdateServo(pinToMap, valueToWrite);
    } else {
      analogWrite(pinToMap, valueToWrite);
    }
  }
}

void WritePinDigital() {
  int pinToMap = -1;
  char *arg = NULL;
  arg = uduino.next();
  if (arg != NULL)
    pinToMap = atoi(arg);

  int writeValue;
  arg = uduino.next();
  if (arg != NULL && pinToMap != -1)
  {
    writeValue = atoi(arg);
    digitalWrite(pinToMap, writeValue);
  }
}

void ReadAnalogPin() {
  int pinToRead = -1;
  char *arg = NULL;
  arg = uduino.next();
  if (arg != NULL)
  {
    pinToRead = atoi(arg);
    if (pinToRead != -1)
      printValue(pinToRead, analogRead(pinToRead));
  }
}

void ReadDigitalPin() {
  int pinToRead = -1;
  char *arg = NULL;
  arg = uduino.next();
  if (arg != NULL)
  {
    pinToRead = atoi(arg);
  }

  if (pinToRead != -1)
    printValue(pinToRead, digitalRead(pinToRead));
}

void BundleReadPin() {
  int pinToRead = -1;
  char *arg = NULL;
  arg = uduino.next();
  if (arg != NULL)
  {
    pinToRead = atoi(arg);
    if (pinToRead != -1)
      printValue(pinToRead, analogRead(pinToRead));
  }
}

void loop()
{
  uduino.update();
  //delay(10);
}

void printValue(int pin, int targetValue) {
  uduino.print(pin);
  uduino.print(" "); //<- Todo : Change that with Uduino delimiter
  uduino.println(targetValue);
}



/* SERVO CODE */
Servo servos[MAXSERVOS];
int servoPinMap[MAXSERVOS];

void InitializeServos() {
#if defined(ESP32)
  ESP32PWM::allocateTimer(0);
  ESP32PWM::allocateTimer(1);
  ESP32PWM::allocateTimer(2);
  ESP32PWM::allocateTimer(3);
#else
#endif

  for (int i = 0; i < MAXSERVOS - 1; i++ ) {
    servoPinMap[i] = -1;
    servos[i].detach();
  }
}

void SetupServo(int pin) {
  if (ServoConnectedPin(pin))
    return;

  int nextIndex = GetAvailableIndexByPin(-1);
  if (nextIndex == -1)
    nextIndex = 0;
#if defined(ESP32)
  servos[nextIndex].setPeriodHertz(50);
#endif
  servos[nextIndex].attach(pin);

  servoPinMap[nextIndex] = pin;
}


void DisconnectServo(int pin) {
  servos[GetAvailableIndexByPin(pin)].detach();
  servoPinMap[GetAvailableIndexByPin(pin)] = 0;
}

bool ServoConnectedPin(int pin) {
  if (GetAvailableIndexByPin(pin) == -1) return false;
  else return true;
}

int GetAvailableIndexByPin(int pin) {
  for (int i = 0; i < MAXSERVOS - 1; i++ ) {
    if (servoPinMap[i] == pin) {
      return i;
    } else if (pin == -1 && servoPinMap[i] < 0) {
      return i; // return the first available index
    }
  }
  return -1;
}

void UpdateServo(int pin, int targetValue) {
  int index = GetAvailableIndexByPin(pin);
  servos[index].write(targetValue);
  delay(10);
}

void DisconnectAllServos() {
  for (int i = 0; i < MAXSERVOS; i++) {
    servos[i].detach();
    digitalWrite(servoPinMap[i], LOW);
    servoPinMap[i] = -1;
  }
}

Anyone have any ideas how to solve this ?

Something in your code is attempting to read from an invalid memory address. Use the ESP exception decoder to decode the error message, which will give you a stack trace that will point to something close to the actual problem source. With the MANY pointers in that code, you are almost certainly dereferencing a NULL pointer, dereferencing a pointer whose value is incorrect, or reading or writing outside the bounds of an array.

1 Like

Sorry for the wait. I was trying to put ESP exception decoder to work on the IDE 2.3.2. I put the error message there and got this in return.

PC: 0x40089688: memcmp at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/string\memcmp.c:81
EXCVADDR: 0x00000000

Decoding stack results
0x40089685: memcmp at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/string\memcmp.c:73
0x400d8f26:  is in IPAddress::operator==(unsigned char const*) const (C:\Users\vdave\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\cores\esp32\IPAddress.cpp:275).
0x400d3391:  is in Uduino_Wifi::connectWifi(char const*, char const*) (c:\Users\vdave\OneDrive\Documentos\Arduino\libraries\Uduino_Wifi\Uduino_Wifi.cpp:56).
0x400d2c4e: setup() at C:\Users\vdave\APX Canoa 2\Assets\Uduino\Arduino\libraries\Uduino_Wifi\examples\Uduino_WiFi\Uduino_Wifi\Uduino_Wifi.ino:25
0x400dc4bf: loopTask(void*) at C:\Users\vdave\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.1\cores\esp32\main.cpp:58

It is failing in the call to Udiono_Wifi::connect WiFi() on line 25 of your setup() function. It is failing because when it attempts to do a compare to the IPAdress object, memcmp() is accessing invalid memory. I know nothing about Uduino_WiFi, but I would guess it is attempting to access a non-existant IPAddress object because no IPAdress has been specified. Or, perhaps the network it is connecting to is not providing an IP address via DHCP?

It is failing right off the bat in setup(), so I would start by making a test program that deletes EVERYTHING from loop(). and EVERYTHING from setup() AFTER the call to connectWiFi(), and see if that works or not. If it does not, then it appears there is something in Uduiono_Wifi that is either badly broken, or not compatible with your hardware.

1 Like

Alright thanks for the help. I will try do this things but I think is a problem with the program like you said. If doens't work I will try another aprouch.......