Page 1 of 1

xTaskCreateStatic crashing

Posted: Thu May 12, 2022 10:10 am
by mpulis
Hi,

I'm attempting to start a task with memory allocated in the PSRAM. When using xTaskCreateStaticPinnedToCore to start the task, the ESP32 is crashing.

The code being used to start the task is below. I'm also including a snapshot from sdkconfig and also the crash message.

The chip being used is a WROVER-IE. ESP IDF is version 4.3.1.

Code: Select all

StaticTask_t _x_zigbee_task_buffer;
StackType_t _x_zigbee_task_stack;

_x_zigbee_task_stack = (uint8_t*)malloc(ZIGBEE_STACK_SIZE);
xTaskCreateStaticPinnedToCore(&zigbeeProcessTask, "zigbeeProcessTask", ZIGBEE_STACK_SIZE, (void*)skip_intitialization, 2, _x_zigbee_task_stack, &_x_zigbee_task_buffer, 1);

Re: xTaskCreateStatic crashing

Posted: Thu May 12, 2022 2:31 pm
by BotondColop
You can test it like this.

Code: Select all

StaticTask_t _x_zigbee_task_buffer;
static StackType_t _x_zigbee_task_stack[ZIGBEE_STACK_SIZE];

xTaskCreateStaticPinnedToCore(zigbeeProcessTask, "zigbeeProcessTask", ZIGBEE_STACK_SIZE, NULL, 2, _x_zigbee_task_stack, &_x_zigbee_task_buffer, 1);

Re: xTaskCreateStatic crashing

Posted: Fri May 13, 2022 8:12 am
by mpulis
That does start the task successfully, but is the stack being allocated from the PSRAM? Also, is there a function to check how much memory remains on the internal RAM?

Re: xTaskCreateStatic crashing

Posted: Fri May 13, 2022 8:25 am
by BotondColop
https://docs.espressif.com/projects/esp ... /size.html
You can read here about the memory usage internal ram.

PSRAM is an external Ram, I dont think so that you are able to use it for task stack. The application will use your internal DRAM for the task stack

Re: xTaskCreateStatic crashing

Posted: Fri May 13, 2022 9:50 am
by mpulis
Thanks for the link! But if that's so, then what's this configuration for?

Re: xTaskCreateStatic crashing

Posted: Tue May 17, 2022 11:22 am
by mpulis
Sorry for the bump, but does anyone know what this configuration is for?

Re: xTaskCreateStatic crashing

Posted: Tue May 17, 2022 11:44 am
by BotondColop
I never used this thing before, but I found this in the IDF Documentation:
The option CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY can be used to place task stacks into external memory. In these cases xTaskCreateStatic() must be used to specify a task stack buffer allocated from external memory, otherwise task stacks will still be allocated from internal memory.
Maybe you can not pin to core your task.

https://docs.espressif.com/projects/esp ... l-ram.html
https://docs.espressif.com/projects/esp ... nal-memory

But the explanation is not so clear you can try enable this to cause xTaskCreateStatic to allow tasks stack in external memory. this is funny. :lol:

Sorry but I have no other Idea for you. I tried a lot of thing with ESP but this is something what I never use it.

Which sometimes helped to me to switch to the last idf release, but it isn't easy because a lot of things don't work after that. :?

Re: xTaskCreateStatic crashing

Posted: Wed May 18, 2022 8:13 am
by mpulis
Fair enough, I appreciate the honest response! It doesn't seem to be working, so maybe it's an inaccessible feature :?

For now I'll steer clear of using it.

Re: xTaskCreateStatic crashing

Posted: Wed May 18, 2022 11:56 am
by ESP_Sprite
Fwiw, it sounds like it may be a bug in esp-idf to me... could you perhaps open an issue on our Github for this? If it indeed is a bug, we can deal with it, if not, we need to at least document why this is caused.

Re: xTaskCreateStatic crashing

Posted: Fri May 20, 2022 9:18 am
by fastig
  1. Is there any solution for this issue? Can you please share the link for this ticket?