Guru Meditation Error: Core 1 panic'ed (Cache disabled but cached memory region accessed)

MinePro120
Posts: 2
Joined: Tue Sep 15, 2020 5:32 pm

Guru Meditation Error: Core 1 panic'ed (Cache disabled but cached memory region accessed)

Postby MinePro120 » Tue Sep 15, 2020 6:08 pm

Hello there! Here's my code :

#include <WiFi.h>
#include <driver/adc.h>

#define AUDIO_BUFFER_MAX 1600
#define SSID "***"
#define PASSWD "***"
#define PORT 6120 // IANA unassigned port

uint8_t audioBuffer[AUDIO_BUFFER_MAX];
uint8_t transmitBuffer[AUDIO_BUFFER_MAX];
uint32_t bufferPointer = 0;
int sleepCounter = 0;
bool transmitNow = false;
WiFiClient client;
IPAddress host;
hw_timer_t * timer = NULL; // Timer
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;


void IRAM_ATTR onTimer()
{
portENTER_CRITICAL_ISR (&timerMux); // ISR start
int adcVal = adc1_get_voltage (ADC1_CHANNEL_0); // Reads the ADC
uint8_t value = map (adcVal, 0 , 4096, 0, 255); // Converts the value to 0..255 (8bit)
audioBuffer[bufferPointer] = value; // Stores the value
bufferPointer++;
if (bufferPointer == AUDIO_BUFFER_MAX) // When the buffer is full
{
bufferPointer = 0;
memcpy (transmitBuffer, audioBuffer, AUDIO_BUFFER_MAX); // Copies buffer into a second buffer
transmitNow = true; // Sets the value true so we know that we can transmit now
}
portEXIT_CRITICAL_ISR (&timerMux); // ISR end
}


void deepSleep (int sec) // Deep sleep in seconds
{
Serial.print ("[DEBUG/ESP32] Going to sleep for ");
Serial.print (sec);
Serial.println (" seconds");
Serial.flush ();
esp_sleep_enable_timer_wakeup (sec * 1000000);
esp_deep_sleep_start ();
}


void setup()
{
Serial.begin (115200);
WiFi.mode (WIFI_STA);
adc1_config_width (ADC_WIDTH_12Bit); // Configures the ADC
adc1_config_channel_atten (ADC1_CHANNEL_0, ADC_ATTEN_0db); // Connects the ADC 1 with channel 0 (GPIO 36)
timer = timerBegin (0, 80, true); // 80 Prescaler
timerAttachInterrupt (timer, &onTimer, true); // Binds the handling function to our timer
timerAlarmWrite (timer, 125, true);
timerAlarmEnable (timer);
pinMode (LED_BUILTIN, OUTPUT); // Status LED
}


void loop()
{
if ((WiFi.status () != WL_CONNECTED) || !client.connected ())
{
digitalWrite (LED_BUILTIN, LOW);
if (sleepCounter == 30) // Sleeps 30min after 15min of inactivity
deepSleep (1800);
int timeoutCounter = 0;
if (WiFi.status () != WL_CONNECTED)
{
Serial.print ("[DEBUG/WIFI] (Re)connecting to network");
WiFi.begin (SSID, PASSWD);
while ((WiFi.status () != WL_CONNECTED) && (timeoutCounter < 30))
{
delay (1000);
Serial.print ('.');
timeoutCounter++;
}
if (timeoutCounter == 30)
{
Serial.println ("\n[DEBUG/WIFI] Connection timeout");
sleepCounter++;
}
else
{
Serial.print ("\n[DEBUG/WIFI] Connected with IP : ");
Serial.print (WiFi.localIP ());
Serial.print (", at ");
Serial.print (WiFi.RSSI ());
Serial.print (" dBm");
}
}
else
{
host = WiFi.gatewayIP ();
Serial.print ("[DEBUG/WIFI] (Re)connecting to host at ");
Serial.println (host);
while (!client.connect (host, PORT) && (timeoutCounter < 30))
{
delay (1000);
Serial.print ('.');
timeoutCounter++;
}
if (timeoutCounter == 30)
{
Serial.println ("\n[DEBUG/WIFI] Connection timeout");
sleepCounter++;
}
else
{
digitalWrite (LED_BUILTIN, HIGH);
Serial.println ("\n[DEBUG/WIFI] Connected to host");
}
}
}
else
{
sleepCounter = 0;
if (transmitNow) // Checks if the buffer is full
{
transmitNow = false;
client.write ((const uint8_t *) audioBuffer, sizeof (audioBuffer)); // Sends the buffer to the host
}
}
}

,which is a modified version of the code found here : https://www.hackster.io/julianso/esp32- ... mer-52bd7e, that works fine. So, whenever I upload the code to my WeMos WiFi&Bluetooth Battery, the esp32 restarts almost immediately with the following log :

[DEBUG/WIFI] (Re)connecting to networkGuru Meditation Error: Core 1 panic'ed (Cache disabled but cached memory region accessed)
Core 1 register dump:
PC : 0x40129e5c PS : 0x00060034 A0 : 0x80081440 A1 : 0x3ffbe790
A2 : 0x3ffbebe8 A3 : 0x20000000 A4 : 0x00000400 A5 : 0x00000000
A6 : 0x3ffc21e0 A7 : 0xffffffff A8 : 0x8008104f A9 : 0x3ffbe760
A10 : 0x00000000 A11 : 0x3ffba264 A12 : 0x00000001 A13 : 0x00000001
A14 : 0x00060021 A15 : 0x00000000 SAR : 0x00000014 EXCCAUSE: 0x00000007
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
Core 1 was running in ISR context:
EPC1 : 0x40086fff EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x40129e5c

Backtrace: 0x40129e5c:0x3ffbe790 0x4008143d:0x3ffbe7b0 0x40084d49:0x3ffbe7d0 0x40086ffc:0x3ffba190 0x40083167:0x3ffba1b0 0x40089155:0x3ffba1d0

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

rst:0x3 (SW_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:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac

The backtrace is different in each crash. I tried using backtrace decoder with no results. But I found out that if I uncomment the line "WiFi.begin (SSID, PASSWD);" the sketch works as expected. Things I tried based on google search results :
1) Checking the power supply (my board comes with a 18650 battery I could use to power it without using my PC).
2) Using ESP.eraseConfig () (the ESP class did not contain this function though)
3) Using WiFi.persistent (false)
Last edited by MinePro120 on Wed Sep 16, 2020 11:17 am, edited 1 time in total.

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: Guru Meditation Error: Core 1 panic'ed (Cache disabled but cached memory region accessed)

Postby ESP_Sprite » Wed Sep 16, 2020 8:42 am

If the crash is different but goes away if you disable WiFi, it probably still is a power supply issue. Can you check the LDO on your WiFi board? There's a known issue where some boards only have a LDO that can deliver 150mA or so, causing the ESP32 to crash when you turn on WiFi.

MinePro120
Posts: 2
Joined: Tue Sep 15, 2020 5:32 pm

Re: Guru Meditation Error: Core 1 panic'ed (Cache disabled but cached memory region accessed)

Postby MinePro120 » Wed Sep 16, 2020 11:23 am

I did some more testing. I moved the WiFi.begin() to setup() and used only WiFi.recconect to loop(). Works fine now. So I guess it's not power related.

Who is online

Users browsing this forum: Google [Bot] and 52 guests