Please help me with ESP32 Guru meditation error core 0

FeherAron6
Posts: 10
Joined: Mon Mar 18, 2019 5:03 pm

Re: Please help me with ESP32 Guru meditation error core 0

Postby FeherAron6 » Thu Mar 21, 2019 2:24 pm

The strings are global variables
  1. char str_data[5], str_topic[11];
  2. char flag_topic[11] = {'t','o','d','e','v','/','f','l','a','g','s'};
  3. char ref_topic[9] = {'t','o','d','e','v','/','r','e','f'};
.

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

Re: Please help me with ESP32 Guru meditation error core 0

Postby ESP_Sprite » Mon Mar 25, 2019 4:07 am

Just guessing here, as I'm not that familiar with the mqtt code, but are you sure the topic and data are zero-terminated? If not, the strcpy will copy lots of bytes, overwriting lots of static data.

FeherAron6
Posts: 10
Joined: Mon Mar 18, 2019 5:03 pm

Re: Please help me with ESP32 Guru meditation error core 0

Postby FeherAron6 » Mon Mar 25, 2019 10:16 am

It is not zero terminated - or at least the payload is certainly not. When I send the data "todev/flags" from node-red, the esp32 sees it as a char array of length 11. That is why I had to compare it to the string shown in the previous reply, but I've used strncmp for the most part.

Are you saying that I should change the topic and data copy lines from strcpy to strncpy? I could measure the maximum string length in node-red, and use that value for every copy.

FeherAron6
Posts: 10
Joined: Mon Mar 18, 2019 5:03 pm

Re: Please help me with ESP32 Guru meditation error core 0

Postby FeherAron6 » Tue Mar 26, 2019 4:01 pm

ESP_Sprite wrote:
Mon Mar 25, 2019 4:07 am
Just guessing here, as I'm not that familiar with the mqtt code, but are you sure the topic and data are zero-terminated? If not, the strcpy will copy lots of bytes, overwriting lots of static data.
This was the problem. I've replaced the
  1. strcpy(str_topic, event->topic);
  2. strcpy(str_data, event->data);
lines with
  1. strncpy(str_topic, event->topic, event->topic_len);
  2. strncpy(str_data, event->data, event->data_len);
and everything works as intended.

Thank you so much for these invaluable responses. I've learnt a lot in these few days.

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

Re: Please help me with ESP32 Guru meditation error core 0

Postby ESP_Sprite » Wed Mar 27, 2019 2:22 am

Nice. Note that if you use strncpy, str_topic and str_data themselves also won't be null-terminated, so if your later code assumes they are, you'll have the same issues all over again. Perhaps it's an idea to null-terminate them yourself so you'll at least not have that trap to fall down in.

Alan Collins
Posts: 1
Joined: Wed Apr 10, 2019 2:58 pm

Re: Please help me with ESP32 Guru meditation error core 0

Postby Alan Collins » Wed Apr 10, 2019 3:02 pm

I have the same issue, while using simple "Hello World" example from platformIO. This is part of the LOG I get from console:

Guru Meditation Error: Core 0 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x400d2c40: 775f2289 dd55d557 57f7d755
Core 0 register dump:
PC : 0x400d2c47 PS : 0x00060130 A0 : 0x800d2cb5 A1 : 0x3ffe3930
A2 : 0x3ffe3970 A3 : 0x3ffc0000 A4 : 0x3ffc3050 A5 : 0x3ffe3970
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x0000002c A9 : 0x3ffe3bb0
A10 : 0x0000000a A11 : 0x00000000 A12 : 0x00000000 A13 : 0x00002000
A14 : 0x3ffe3ba7 A15 : 0x00000200 SAR : 0x00000005 EXCCAUSE: 0x00000000
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000

As, you can see PC is located in 0x400d2c47

Looking into my .map file, I see the code is happening inside the .pioenvs\esp32dev\libheap.a(heap_caps_init.o)

This data is persistent if I use the HelloWorld, or my application. Both fail with Ilegal instruction at the Lebheap library.

This problem is not happened in the ESP32-WROOM-32, but happens with ESP32-WROOM-32D, which is supposed to be the same.

I continue my debug. I´ll keep you posted in my findings.

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

Re: Please help me with ESP32 Guru meditation error core 0

Postby ESP_Sprite » Thu Apr 11, 2019 5:33 am

You may want to investigate your power supply; sometimes these errors originate in a brownout.

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Please help me with ESP32 Guru meditation error core 0

Postby Ritesh » Sat Apr 13, 2019 9:58 am

ESP_Sprite wrote:
Thu Apr 11, 2019 5:33 am
You may want to investigate your power supply; sometimes these errors originate in a brownout.
Hi,

We are also recomanding to use at least 5V 1 Amp into our device in which we have used ESP32 Module.
Regards,
Ritesh Prajapati

Who is online

Users browsing this forum: No registered users and 364 guests