Page 1 of 1

New user with "Core 0 panic'ed (StoreProhibited)." error.

Posted: Wed Aug 30, 2023 12:26 am
by elkevo
I am new to the embedded programming world and have been following an amazing book I found on FreeRTOS official documentation "Mastering the FreeRTOS real time kernel". I am programming on a ES WROON 32 board and this books translates really good to ESP-IDF except for some small changes. Anyway, I am following a tutorial about Queues where 2 tasks send data to a queue and a third task with a higher priority reads data from it. I'm attaching my code below.

Code: Select all

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"

QueueHandle_t xQueue;

static void vSender(void *pvParameters)
{
    int32_t IValueToSend;
    BaseType_t xStatus;
    IValueToSend = (int32_t)pvParameters;
    for(;;)
    {   
        xStatus = xQueueSendToBack(xQueue,&IValueToSend,0);
        if(xStatus != pdPASS) printf("Could not send to Queue\n");
        vTaskDelay(pdMS_TO_TICKS(100));
    }
}

static void vReceiver(void *pvParameters)
{
    int32_t IReceivedValue;
    BaseType_t xStatus;
    const TickType_t xTicksToWait = pdMS_TO_TICKS(100);
    for(;;)
    {
        if(uxQueueMessagesWaiting(xQueue)!=0) printf("Queue should be empy what is wrong?");
        xStatus = xQueueReceive(xQueue,&IReceivedValue, xTicksToWait);
        if(xStatus == pdPASS) printf("Received data");
        else printf("Did not receive data");
    }
}

void app_main(void)
{
    xQueue = xQueueCreate(5,sizeof(int32_t));
    if(xQueue != NULL)
    {
        xTaskCreate(vSender,"Sender 1",1000,(void *)100,1,NULL);
        xTaskCreate(vSender,"Sender 2",1000,(void *)200,1,NULL);
        xTaskCreate(vReceiver,"Receiver",1000,NULL,     2,NULL);
        
    }
    for(;;) vTaskDelay(pdMS_TO_TICKS(10));
}
This builds fine but when running the board keeps restarting with the following error.

Code: Select all

I (308) app_start: Starting scheduler on CPU0
I (313) app_start: Starting scheduler on CPU1
I (313) main_task: Started on CPU0
I (323) main_task: Calling app_main()
Guru Meditation Error: Core  0 panic'ed (StoreProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x40088485  PS      : 0x00060033  A0      : 0x80086583  A1      : 0x3ffb6680  
0x40088485: uxListRemove at /home/ktrejo/esp32/esp/esp-idf/components/freertos/FreeRTOS-Kernel/list.c:197

A2      : 0x3ffb638c  A3      : 0x3ffb6388  A4      : 0x3ffb6388  A5      : 0x00000000  
A6      : 0x00000001  A7      : 0x00000000  A8      : 0x3ffb2430  A9      : 0x3ffb2438  
A10     : 0x00060020  A11     : 0x00000000  A12     : 0x80085d0d  A13     : 0x3ffb63c0  
A14     : 0x00000001  A15     : 0x00000000  SAR     : 0x00000000  EXCCAUSE: 0x0000001d  
EXCVADDR: 0x00060028  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xffffffff  
0x400014fd: strlen in ROM

0x4000150d: strlen in ROM



Backtrace: 0x40088482:0x3ffb6680 0x40086580:0x3ffb66a0 0x40086c9e:0x3ffb66c0 0x40088130:0x3ffb66e0 0x400880e2:0x3ffb6694 |<-CORRUPTED
0x40088482: uxListRemove at /home/ktrejo/esp32/esp/esp-idf/components/freertos/FreeRTOS-Kernel/list.c:197

0x40086580: taskSelectHighestPriorityTaskSMP at /home/ktrejo/esp32/esp/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:3672

0x40086c9e: vTaskSwitchContext at /home/ktrejo/esp32/esp/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:3756 (discriminator 3)

0x40088130: _frxt_dispatch at /home/ktrejo/esp32/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/portasm.S:450

0x400880e2: _frxt_int_exit at /home/ktrejo/esp32/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/portasm.S:245





ELF file SHA256: 752fd9e24

Rebooting...
I have been playing with the printf statement before inside a task so I don't think that's the issue. I really can't quite tell what is wrong, found some posts about the same error in different contexts mentioning it could be related to a variable trying to access memory out of reach. Any kind of guidance will be much appreciated. Also if someone knows a book similar to "Mastering the FreeRTOS Real Time Kernel-A Hands On Tutorial Guide" focused specifically on ESP flavoured FreeRTOS it will be much welcome.

Re: New user with "Core 0 panic'ed (StoreProhibited)." error.

Posted: Wed Aug 30, 2023 2:31 am
by ESP_Sprite
If anything, 1000 bytes of stack is way too little if you're using printf. Set that to like 8096 first, see if that solves your issue. For ESP-IDF specifics, we have a page that documents the differences with 'vanilla' FreeRTOS; if you read through that you probably will know enough to know which bits in the book still apply and which don't.

Re: New user with "Core 0 panic'ed (StoreProhibited)." error.

Posted: Wed Aug 30, 2023 3:37 am
by elkevo
Thank you very much @ESP_Sprite! That actually worked perfectly.
ps: Thanks for the documentation as well!