espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
12.93k stars 7.09k forks source link

exclusive use of 1 cpu. (IDFGH-13103) #14050

Open ulao opened 2 weeks ago

ulao commented 2 weeks ago

Answers checklist.

General issue report

Are there any examples or functions that get me closer to exclusively using a cpu? I want all my peripherals and tasks to go on cpu0 and to leave cpu1 as free as possible. If there are some tasks and interrupts that must run, I wonder if they can be block, disabled, for a period of time. And how to do that

o-marshmallow commented 1 week ago

Hello @ulao ,

By default, when you run ESP-IDF, the only tasks that will run on App CPU (CPU1) is the Idle Task and the IPC Tasks. No interrupt, apart from the tick and IPC interrupts, will be bound to the Core 1 since no task on that core will use any peripheral. For tasks related to Wifi or Bluetooth, it is possible to choose on which core they have to run thanks to the menuconfig.

At runtime, when you create tasks, you have to use xTaskCreatePinnedToCore to restrict the core your new Task has to run on.

If you want any of your tasks on any to never be pre-empted by another task, make sure its priority is the highest among all your tasks.

More info about FreeRTOS in ESP-IDF are available in the official documentation: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos.html and https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/freertos_idf.html