xTaskCreateStatic crashing

mpulis
Posts: 57
Joined: Mon Aug 07, 2017 7:53 am

xTaskCreateStatic crashing

Postby mpulis » Thu May 12, 2022 10:10 am

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);
Attachments
sdkconfig.PNG
sdkconfig.PNG (41.57 KiB) Viewed 6102 times
capture.PNG
capture.PNG (57.19 KiB) Viewed 6102 times

BotondColop
Posts: 19
Joined: Tue May 10, 2022 6:46 am

Re: xTaskCreateStatic crashing

Postby BotondColop » Thu May 12, 2022 2:31 pm

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);

mpulis
Posts: 57
Joined: Mon Aug 07, 2017 7:53 am

Re: xTaskCreateStatic crashing

Postby mpulis » Fri May 13, 2022 8:12 am

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?

BotondColop
Posts: 19
Joined: Tue May 10, 2022 6:46 am

Re: xTaskCreateStatic crashing

Postby BotondColop » Fri May 13, 2022 8:25 am

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

mpulis
Posts: 57
Joined: Mon Aug 07, 2017 7:53 am

Re: xTaskCreateStatic crashing

Postby mpulis » Fri May 13, 2022 9:50 am

Thanks for the link! But if that's so, then what's this configuration for?
Attachments
Capture.PNG
Capture.PNG (19.58 KiB) Viewed 6000 times

mpulis
Posts: 57
Joined: Mon Aug 07, 2017 7:53 am

Re: xTaskCreateStatic crashing

Postby mpulis » Tue May 17, 2022 11:22 am

Sorry for the bump, but does anyone know what this configuration is for?

BotondColop
Posts: 19
Joined: Tue May 10, 2022 6:46 am

Re: xTaskCreateStatic crashing

Postby BotondColop » Tue May 17, 2022 11:44 am

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. :?

mpulis
Posts: 57
Joined: Mon Aug 07, 2017 7:53 am

Re: xTaskCreateStatic crashing

Postby mpulis » Wed May 18, 2022 8:13 am

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.

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

Re: xTaskCreateStatic crashing

Postby ESP_Sprite » Wed May 18, 2022 11:56 am

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.

fastig
Posts: 1
Joined: Fri May 20, 2022 9:12 am

Re: xTaskCreateStatic crashing

Postby fastig » Fri May 20, 2022 9:18 am

  1. Is there any solution for this issue? Can you please share the link for this ticket?

Who is online

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