Please help me with ESP32 Guru meditation error core 0

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

Please help me with ESP32 Guru meditation error core 0

Postby FeherAron6 » Mon Mar 18, 2019 6:42 pm

Hello everyone, my name is Fehér Áron.
I've been working with the ESP32 for nearly a year, but this is my first larger project. I've designed a seesaw, and I want to control it, and monitor the variables on the PC.
On the ESP side i'm using a timer interrupt to read the values from an MPU6050 IMU, apply a Kalman filter for the angle denoising. Then I'm using a PID control to generate a duty cycle value, which is fed into the LEDC pwm peripheral. A TCP based MQTT handler is running on another thread, which receives and sends data to/from the PC.
On the PC side I'm using mosquitto broker and node-red to set the control reference, PID coefficients, and to read some angle values.

Everything works separately. I can set the PWM values, I can send and receive PID coeffs, and angle values. The moment I enable the timer interrupt, and I try to send some values to the ESP, I get some strange error messages:

Code: Select all

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_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:0x3fff0018,len:4
load:0x3fff001c,len:5800
load:0x40078000,len:7924
load:0x40080000,len:5916
entry 0x40080314
I (29) boot: ESP-IDF 3.30103.190221 2nd stage bootloader
I (29) boot: compile time 16:42:04
I (29) boot: Enabling RNG early entropy source...
I (34) boot: SPI Speed      : 40MHz
I (38) boot: SPI Mode       : DIO
I (42) boot: SPI Flash Size : 4MB
I (46) boot: Partition Table:
I (50) boot: ## Label            Usage          Type ST Offset   Length
I (57) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (64) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (72) boot:  2 factory          factory app      00 00 00010000 00100000
I (79) boot: End of partition table
I (84) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x1a4cc (107                                                 724) map
I (130) esp_image: segment 1: paddr=0x0002a4f4 vaddr=0x3ffc0000 size=0x02edc ( 1                                                 1996) load
I (135) esp_image: segment 2: paddr=0x0002d3d8 vaddr=0x40080000 size=0x00400 (                                                   1024) load
I (137) esp_image: segment 3: paddr=0x0002d7e0 vaddr=0x40080400 size=0x02830 ( 1                                                 0288) load
I (150) esp_image: segment 4: paddr=0x00030018 vaddr=0x400d0018 size=0x7e164 (51                                                 6452) map
I (333) esp_image: segment 5: paddr=0x000ae184 vaddr=0x40082c30 size=0x0e2f4 ( 5                                                 8100) load
I (366) boot: Loaded app from partition at offset 0x10000
I (366) boot: Disabling RNG early entropy source...
I (367) cpu_start: Pro cpu up.
I (370) cpu_start: Starting app cpu, entry point is 0x40081a98
I (0) cpu_start: App cpu up.
I (381) heap_init: Initializing. RAM available for dynamic allocation:
I (388) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (394) heap_init: At 3FFC9288 len 00016D78 (91 KiB): DRAM
I (400) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (406) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (413) heap_init: At 40090F24 len 0000F0DC (60 KiB): IRAM
I (419) cpu_start: Pro cpu start user code
I (101) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (103) MQTT_EXAMPLE: [APP] Startup..
I (103) MQTT_EXAMPLE: [APP] Free memory: 201440 bytes
I (103) MQTT_EXAMPLE: [APP] IDF version: 3.30103.190221
I (153) gpio: GPIO[12]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldo                                                 wn: 0| Intr:0
I (153) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldo                                                 wn: 0| Intr:0
I (163) gpio: GPIO[18]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldo                                                 wn: 0| Intr:0
I (173) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldo                                                 wn: 0| Intr:0
I (183) gpio: GPIO[23]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldo                                                 wn: 0| Intr:0
I (193) wifi: wifi driver task: 3ffd23cc, prio:23, stack:3584, core=0
I (193) wifi: wifi firmware version: 71d6725
I (203) wifi: config NVS flash: enabled
I (203) wifi: config nano formating: disabled
I (203) system_api: Base MAC address is not set, read default base MAC address f                                                 rom BLK0 of EFUSE
I (213) system_api: Base MAC address is not set, read default base MAC address f                                                 rom BLK0 of EFUSE
I (243) wifi: Init dynamic tx buffer num: 32
I (243) wifi: Init data frame dynamic rx buffer num: 32
I (243) wifi: Init management frame dynamic rx buffer num: 32
I (243) wifi: Init static rx buffer size: 1600
I (243) wifi: Init static rx buffer num: 10
I (253) wifi: Init dynamic rx buffer num: 32
I (253) MQTT_EXAMPLE: start the WIFI SSID:[Gothic]
I (323) phy: phy_version: 4008, c9ae59f, Jan 25 2019, 16:54:06, 0, 0
I (333) wifi: mode : sta (30:ae:a4:0b:07:f0)
I (333) MQTT_EXAMPLE: Waiting for wifi
I (453) wifi: n:1 1, o:1 0, ap:255 255, sta:1 1, prof:1
I (1293) wifi: state: init -> auth (b0)
I (1293) wifi: state: auth -> assoc (0)
I (1303) wifi: state: assoc -> run (10)
I (1313) wifi: connected with Gothic, channel 1
I (1313) wifi: pm start, type: 1

I (2193) event: sta ip: 192.168.69.103, mask: 255.255.255.0, gw: 192.168.69.69
I (2193) system_api: Base MAC address is not set, read default base MAC address                                                  from BLK0 of EFUSE
I (2203) MQTT_CLIENT: Sending MQTT CONNECT message, type: 1, id: 0000
I (2243) MQTT_EXAMPLE: MQTT_EVENT_CONNECTED
I (2243) MQTT_EXAMPLE: sent subscribe successful, msg_id=13306
I (2243) MQTT_EXAMPLE: sent subscribe successful, msg_id=32539
I (2253) MQTT_EXAMPLE: sent subscribe successful, msg_id=15354
I (2263) MQTT_EXAMPLE: MQTT_EVENT_SUBSCRIBED, msg_id=13306
I (2263) MQTT_EXAMPLE: sent publish successful, msg_id=19467
I (2273) MQTT_EXAMPLE: MQTT_EVENT_SUBSCRIBED, msg_id=32539
I (2273) MQTT_EXAMPLE: sent publish successful, msg_id=30592
I (2313) MQTT_EXAMPLE: MQTT_EVENT_PUBLISHED, msg_id=19467
I (2453) MQTT_EXAMPLE: MQTT_EVENT_PUBLISHED, msg_id=30592
I (25433) MQTT_CLIENT: deliver_publish, message_length_read=18, message_length=18
I (25433) MQTT_EXAMPLE: MQTT_EVENT_DATA
TOPIC=todev/flags
DATA=1
Guru Meditation Error: Core  0 panic'ed (LoadStoreAlignment). Exception was unhandled.
Core 0 register dump:
PC      : 0x4008cfc9  PS      : 0x00060c33  A0      : 0x8008bf8e  A1      : 0x3ffdad40
A2      : 0x24a8b351  A3      : 0x00000000  A4      : 0x000005a1  A5      : 0x3f4124c8
A6      : 0x3ffc1480  A7      : 0x00060023  A8      : 0x0000abab  A9      : 0xb33fffff
A10     : 0x0000cdcd  A11     : 0x00060c20  A12     : 0x00060c20  A13     : 0x00000001
A14     : 0x0000cdcd  A15     : 0x00000000  SAR     : 0x00000000  EXCCAUSE: 0x00000009
EXCVADDR: 0x24a8b351  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0x00000000

Backtrace: 0x4008cfc9:0x3ffdad40 0x4008bf8b:0x3ffdad60 0x400d2470:0x3ffdada0

Rebooting...


At first I've got the impression that I need some mutexes/semaphores, to work with shared resources (PID coeffs, reference value), but even after the mutexes, I get the same value.

I've attached my project where the problematic part is in the mqtt_event_handler() and/or in the timer_evt_example_task() - in the main.c (I think).

By the way, I'm using VisualStudio Code with PlatformIO and esp-idf

Any suggestions, ideas would be greatly appreciated.
Attachments
timer.c
(2.35 KiB) Downloaded 680 times
main.c
(11.51 KiB) Downloaded 692 times
main.h
(1.86 KiB) Downloaded 712 times

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

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

Postby ESP_Sprite » Tue Mar 19, 2019 8:34 am

Any chance you can decode that backtrace? That should tell you exactly what line crashed here. Enabling gdbstub in 'make menuconfig' and using 'make monitor' would normally also be a big help, but I'm not sure if the PlatformIO/VS combo can do that.

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

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

Postby FeherAron6 » Tue Mar 19, 2019 5:20 pm

I will try the decode the backtrace. If the PIO won't let it, I'll do it in esp-idf, because porting this project is only copying the files to another folder. Either way, I'll edit this comment with the results.

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

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

Postby ESP_Sprite » Wed Mar 20, 2019 7:36 am

Cool, thanks. In general, you may want to look into the 'make monitor' option of ESP-IDF, as that has a serial console that has a bunch of extra features (like backtrace decoding) that can make your life easier.

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

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

Postby Ritesh » Wed Mar 20, 2019 8:57 am

Hi

Also, you can trace crash dumps using address2line utility which is provided into toolchain in which you need elf file and crash dump registers details.

So, With that also you can trace crash dump whatever you want with code flow.

Let me know if need any help into that.
Regards,
Ritesh Prajapati

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

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

Postby FeherAron6 » Wed Mar 20, 2019 5:09 pm

First of all, thank you for the great starter ideas.
Unfortunately PlatformIO does not support any kind of message decoding at the moment, but as I've said, I've ported the code to Linux/esp-idf, with the suggested options.
Since so far I've been only using FT2232 JTAG debug method, would you be so kind to tell me, what do I have to look for in these lines?

Code: Select all

TOPIC=todev/flags
DATA=601
/home/feher/Documents/esp/esp-idf/components/freertos/queue.c:1443 (xQueueGenericReceivGuru Meditation Error: Core  0 panic'ed (StoreProhibited). Exception was unhandled.
Core 0 register dump:
PC      : 0x4008ecbc  PS      : 0x00060033  A0      : 0x8008df78  A1      : 0x3ffb0610  
0x4008ecbc: uxPortCompareSet at /home/feher/Documents/esp/esp-idf/components/freertos/tasks.c:5093
 (inlined by) vPortCPUAcquireMutexIntsDisabledInternal at /home/feher/Documents/esp/esp-idf/components/freertos/portmux_impl.inc.h:86
 (inlined by) vPortCPUAcquireMutexIntsDisabled at /home/feher/Documents/esp/esp-idf/components/freertos/portmux_impl.h:98
 (inlined by) vTaskEnterCritical at /home/feher/Documents/esp/esp-idf/components/freertos/tasks.c:4231

A2      : 0xc50fe54c  A3      : 0x3ffc8ee0  A4      : 0x80082e14  A5      : 0x3ffc8ed0  
A6      : 0x3ffb42a8  A7      : 0xffffffff  A8      : 0x0000cdcd  A9      : 0x0000cdcd  
A10     : 0xb33fffff  A11     : 0x0000abab  A12     : 0x80082d46  A13     : 0x00000001  
A14     : 0x00060023  A15     : 0x00000000  SAR     : 0x00000016  EXCCAUSE: 0x0000001d  
EXCVADDR: 0xc50fe54c  LBEG    : 0x4000142d  LEND    : 0x4000143a  LCOUNT  : 0xfffffe68  
Core 0 was running in ISR context:
EPC1    : 0x4008ecbc  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x00000000
0x4008ecbc: uxPortCompareSet at /home/feher/Documents/esp/esp-idf/components/freertos/tasks.c:5093
 (inlined by) vPortCPUAcquireMutexIntsDisabledInternal at /home/feher/Documents/esp/esp-idf/components/freertos/portmux_impl.inc.h:86
 (inlined by) vPortCPUAcquireMutexIntsDisabled at /home/feher/Documents/esp/esp-idf/components/freertos/portmux_impl.h:98
 (inlined by) vTaskEnterCritical at /home/feher/Documents/esp/esp-idf/components/freertos/tasks.c:4231


ELF file SHA256: 5a2200a6a7d18c5909fd1c7eef0cce4ac2b121868a00369a9a6f7ae6df74e477

Backtrace: 0x4008ecbc:0x3ffb0610 0x4008df75:0x3ffb0630 0x40082b7f:0x3ffb0650 0x400824f5:0x3ffb0690 0x4000921a:0x3ffc8da0 0x40007d13:0x3ffc8dc0 0x40007c69:0x3ffc8de0 0x40008106:0x3ffc8e00 0x4008e0da:0x3ffc8e90 0x40082d43:0x3ffc8ed0 0x40082e11:0x3ffc8f00 0x400e45f1:0x3ffc8f20 0x40082b8c:0x3ffc8f40 0x400da4e8:0x3ffc8f60 0x400d66e1:0x3ffc8f80 0x400d5231:0x3ffc8fb0 0x4008e375:0x3ffc8fd0
0x4008ecbc: uxPortCompareSet at /home/feher/Documents/esp/esp-idf/components/freertos/tasks.c:5093
 (inlined by) vPortCPUAcquireMutexIntsDisabledInternal at /home/feher/Documents/esp/esp-idf/components/freertos/portmux_impl.inc.h:86
 (inlined by) vPortCPUAcquireMutexIntsDisabled at /home/feher/Documents/esp/esp-idf/components/freertos/portmux_impl.h:98
 (inlined by) vTaskEnterCritical at /home/feher/Documents/esp/esp-idf/components/freertos/tasks.c:4231

0x4008df75: xQueueGenericSendFromISR at /home/feher/Documents/esp/esp-idf/components/freertos/queue.c:2038

0x40082b7f: timer_group0_isr at /home/feher/Documents/esp/projects/PenduCopter/main/timer.c:36

0x400824f5: _xt_lowint1 at /home/feher/Documents/esp/esp-idf/components/freertos/xtensa_vectors.S:1154

0x4008e0da: xQueueGenericReceive at /home/feher/Documents/esp/esp-idf/components/freertos/queue.c:2038

0x40082d43: lock_acquire_generic at /home/feher/Documents/esp/esp-idf/components/newlib/locks.c:159

0x40082e11: _lock_acquire at /home/feher/Documents/esp/esp-idf/components/newlib/locks.c:167

0x400e45f1: get_adjusted_boot_time at /home/feher/Documents/esp/esp-idf/components/newlib/time.c:220

0x40082b8c: _gettimeofday_r at /home/feher/Documents/esp/esp-idf/components/newlib/time.c:220

0x400da4e8: gettimeofday at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/syscalls/../../../.././newlib/libc/syscalls/sysgettod.c:12

0x400d66e1: platform_tick_get_ms at /home/feher/Documents/esp/esp-idf/components/mqtt/esp-mqtt/lib/platform_esp32_idf.c:30

0x400d5231: esp_mqtt_task at /home/feher/Documents/esp/esp-idf/components/mqtt/esp-mqtt/mqtt_client.c:951

0x4008e375: vPortTaskWrapper at /home/feher/Documents/esp/esp-idf/components/freertos/port.c:403


Entering gdb stub now.
$T0b#e6


As I understand this is some task sync problem, but I've treated every commonly used resource (as far as I'm aware).

With regards,
Áron.

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

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

Postby ESP_Sprite » Thu Mar 21, 2019 7:37 am

It smells like something overwriting an esp-idf task; the error you get is most likely because a pointer to a spinlock is overwritten... unfortunately I couldn't immediately spot something 'off' in your code that causes that.

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

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

Postby Ritesh » Thu Mar 21, 2019 10:47 am

FeherAron6 wrote:
Wed Mar 20, 2019 5:09 pm
First of all, thank you for the great starter ideas.
Unfortunately PlatformIO does not support any kind of message decoding at the moment, but as I've said, I've ported the code to Linux/esp-idf, with the suggested options.
Since so far I've been only using FT2232 JTAG debug method, would you be so kind to tell me, what do I have to look for in these lines?

Code: Select all

TOPIC=todev/flags
DATA=601
/home/feher/Documents/esp/esp-idf/components/freertos/queue.c:1443 (xQueueGenericReceivGuru Meditation Error: Core  0 panic'ed (StoreProhibited). Exception was unhandled.
Core 0 register dump:
PC      : 0x4008ecbc  PS      : 0x00060033  A0      : 0x8008df78  A1      : 0x3ffb0610  
0x4008ecbc: uxPortCompareSet at /home/feher/Documents/esp/esp-idf/components/freertos/tasks.c:5093
 (inlined by) vPortCPUAcquireMutexIntsDisabledInternal at /home/feher/Documents/esp/esp-idf/components/freertos/portmux_impl.inc.h:86
 (inlined by) vPortCPUAcquireMutexIntsDisabled at /home/feher/Documents/esp/esp-idf/components/freertos/portmux_impl.h:98
 (inlined by) vTaskEnterCritical at /home/feher/Documents/esp/esp-idf/components/freertos/tasks.c:4231

A2      : 0xc50fe54c  A3      : 0x3ffc8ee0  A4      : 0x80082e14  A5      : 0x3ffc8ed0  
A6      : 0x3ffb42a8  A7      : 0xffffffff  A8      : 0x0000cdcd  A9      : 0x0000cdcd  
A10     : 0xb33fffff  A11     : 0x0000abab  A12     : 0x80082d46  A13     : 0x00000001  
A14     : 0x00060023  A15     : 0x00000000  SAR     : 0x00000016  EXCCAUSE: 0x0000001d  
EXCVADDR: 0xc50fe54c  LBEG    : 0x4000142d  LEND    : 0x4000143a  LCOUNT  : 0xfffffe68  
Core 0 was running in ISR context:
EPC1    : 0x4008ecbc  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x00000000
0x4008ecbc: uxPortCompareSet at /home/feher/Documents/esp/esp-idf/components/freertos/tasks.c:5093
 (inlined by) vPortCPUAcquireMutexIntsDisabledInternal at /home/feher/Documents/esp/esp-idf/components/freertos/portmux_impl.inc.h:86
 (inlined by) vPortCPUAcquireMutexIntsDisabled at /home/feher/Documents/esp/esp-idf/components/freertos/portmux_impl.h:98
 (inlined by) vTaskEnterCritical at /home/feher/Documents/esp/esp-idf/components/freertos/tasks.c:4231


ELF file SHA256: 5a2200a6a7d18c5909fd1c7eef0cce4ac2b121868a00369a9a6f7ae6df74e477

Backtrace: 0x4008ecbc:0x3ffb0610 0x4008df75:0x3ffb0630 0x40082b7f:0x3ffb0650 0x400824f5:0x3ffb0690 0x4000921a:0x3ffc8da0 0x40007d13:0x3ffc8dc0 0x40007c69:0x3ffc8de0 0x40008106:0x3ffc8e00 0x4008e0da:0x3ffc8e90 0x40082d43:0x3ffc8ed0 0x40082e11:0x3ffc8f00 0x400e45f1:0x3ffc8f20 0x40082b8c:0x3ffc8f40 0x400da4e8:0x3ffc8f60 0x400d66e1:0x3ffc8f80 0x400d5231:0x3ffc8fb0 0x4008e375:0x3ffc8fd0
0x4008ecbc: uxPortCompareSet at /home/feher/Documents/esp/esp-idf/components/freertos/tasks.c:5093
 (inlined by) vPortCPUAcquireMutexIntsDisabledInternal at /home/feher/Documents/esp/esp-idf/components/freertos/portmux_impl.inc.h:86
 (inlined by) vPortCPUAcquireMutexIntsDisabled at /home/feher/Documents/esp/esp-idf/components/freertos/portmux_impl.h:98
 (inlined by) vTaskEnterCritical at /home/feher/Documents/esp/esp-idf/components/freertos/tasks.c:4231

0x4008df75: xQueueGenericSendFromISR at /home/feher/Documents/esp/esp-idf/components/freertos/queue.c:2038

0x40082b7f: timer_group0_isr at /home/feher/Documents/esp/projects/PenduCopter/main/timer.c:36

0x400824f5: _xt_lowint1 at /home/feher/Documents/esp/esp-idf/components/freertos/xtensa_vectors.S:1154

0x4008e0da: xQueueGenericReceive at /home/feher/Documents/esp/esp-idf/components/freertos/queue.c:2038

0x40082d43: lock_acquire_generic at /home/feher/Documents/esp/esp-idf/components/newlib/locks.c:159

0x40082e11: _lock_acquire at /home/feher/Documents/esp/esp-idf/components/newlib/locks.c:167

0x400e45f1: get_adjusted_boot_time at /home/feher/Documents/esp/esp-idf/components/newlib/time.c:220

0x40082b8c: _gettimeofday_r at /home/feher/Documents/esp/esp-idf/components/newlib/time.c:220

0x400da4e8: gettimeofday at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/syscalls/../../../.././newlib/libc/syscalls/sysgettod.c:12

0x400d66e1: platform_tick_get_ms at /home/feher/Documents/esp/esp-idf/components/mqtt/esp-mqtt/lib/platform_esp32_idf.c:30

0x400d5231: esp_mqtt_task at /home/feher/Documents/esp/esp-idf/components/mqtt/esp-mqtt/mqtt_client.c:951

0x4008e375: vPortTaskWrapper at /home/feher/Documents/esp/esp-idf/components/freertos/port.c:403


Entering gdb stub now.
$T0b#e6


As I understand this is some task sync problem, but I've treated every commonly used resource (as far as I'm aware).

With regards,
Áron.
Hi,

Would you please provide few more informations like when you are facing issue with some more details?

So that we can help you to provide support for that.
Regards,
Ritesh Prajapati

FeherAron6
Posts: 7
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 10:59 am

I've done some other tests in the meanwhile. The error message said it was a panic on core 0, so I've used xTaskCreatePinnedToCore instead of xTascCreate, so the timer thread would be on core 1 - same core 0 panic.
Next I've commented out the timer routines, so only the mqtt was present - same core 0 panic. This narrows down the whole problem to the mqtt_event_handler routine, MQTT_EVENT_DATA case:
  1. ESP_LOGI(TAG, "MQTT_EVENT_DATA");
  2. printf("TOPIC=%.*s\r\n", event->topic_len, event->topic);
  3. printf("DATA=%.*s\r\n", event->data_len, event->data);
  4. strcpy(str_topic, event->topic);
  5. strcpy(str_data, event->data);
  6.  
  7. if(!strncmp(str_topic, flag_topic, sizeof(flag_topic))){
  8.     ESP_LOGI(TAG, "Flag received");
  9.     if(str_data[0]- 48 == 0)
  10.         if(xSemaphoreTake(binary_flag_semaphore, 200)){
  11.             device_power_on = false;
  12.             SetOffLED(LED_1);
  13.             xSemaphoreGive(binary_flag_semaphore);
  14.         }
  15.     if(str_data[0]- 48 == 1)
  16.         if(xSemaphoreTake(binary_flag_semaphore, 200)){
  17.             device_power_on = true;
  18.             SetOnLED(LED_1);
  19.             xSemaphoreGive(binary_flag_semaphore);
  20.         }
  21.     if(str_data[0]-48 == 3)
  22.         SetOffLED(LED_2);
  23.     if(str_data[0]-48 == 2)
  24.         SetOnLED(LED_2);
  25.     if(str_data[0]-48 == 5)
  26.         if(xSemaphoreTake(binary_flag_semaphore, 200)){
  27.             control_algorithm_on = false;
  28.             SetOffLED(LED_4);
  29.             xSemaphoreGive(binary_flag_semaphore);
  30.         }
  31.     if(str_data[0]-48 == 4)
  32.         if(xSemaphoreTake(binary_flag_semaphore, 200)){
  33.             control_algorithm_on = true;
  34.             SetOnLED(LED_4);
  35.             xSemaphoreGive(binary_flag_semaphore);
  36.         }              
  37.     if(str_data[0] - 48 == 6)
  38.         if(xSemaphoreTake(control_semaphore, 200)){
  39.             kp = (float)((str_data[1] - 48)*10.0 + (str_data[2] - 48))/10.0;
  40.             xSemaphoreGive(control_semaphore);
  41.         }
  42.            
  43.     if(str_data[0] - 48 == 7)
  44.         if(xSemaphoreTake(control_semaphore, 200)){
  45.             ki = (float)((str_data[1] - 48)*10.0 + (str_data[2] - 48))/10.0;
  46.             xSemaphoreGive(control_semaphore);
  47.         }
  48.     if(str_data[0] - 48 == 8)
  49.         if(xSemaphoreTake(control_semaphore, 200)){
  50.             kd = (float)((str_data[1] - 48)*10.0 + (str_data[2] - 48))/100000.0;
  51.             xSemaphoreGive(control_semaphore);
  52.         }
  53.     if(str_data[0] - 48 == 9)
  54.         if(xSemaphoreTake(control_semaphore, 200)){
  55.             bc_const = (float)((str_data[1] - 48)*10.0 + (str_data[2] - 48))/1000.0;
  56.             xSemaphoreGive(control_semaphore);
  57.         }
  58.    
  59. }
  60. if(!strncmp(str_topic, ref_topic, sizeof(ref_topic))){
  61.     ESP_LOGI(TAG, "Reference received");
  62.     string2ref(str_data,event->data_len, &reference);
  63.  
  64. }
  65. break;
Now here if I am only changing the GPIO (str_data[0]-48 == 3 or str_data[0]-48 == 2) everything is OK, similarly with the reference. Any other data, and the exception occurs.

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

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

Postby ESP_Sprite » Thu Mar 21, 2019 12:30 pm

How are your strings (like str_topic) allocated?

Who is online

Users browsing this forum: Bing [Bot] and 132 guests