Page 1 of 1

ESP32 pinned Core "CPU reeboot"

Posted: Tue Jan 28, 2025 10:14 am
by UserJMTHK2025
Hello everyone,
I'm new here and I have a problem using the two cores of the ESP32 Dev Module.
I want to create project were one of the two cores is exclusively for one scpecific task which i will program by my self.
Using the Arduino IDE (2.3.4) I have set "Events Run On: "Core 0" " and "Arduino Run On: "Core 0" ". I set those to core 0 since esp-now, which I'm planning to use later on, and stuff runs natively on core 0 and my hope is that core 1 is then completely free.
My final application shall be an PID controller with 10-1000 Hz bandwith, so i need the complete cpu power of one core and it shall not be interrupted by any other task or event etc.
Testing my approach i testet the core zero in the main loop (arduino loop) and no all is fine.
Here is wher my problem is. Testing "task0function" to check if core 1 runs correctely i have like 5 second where there is no problem and the serial.print is as expected, but periodically every 5 to 10 second there is this error:

...
Task0 runs on Core: 1
Task0 runs on Core: 1
Task0 runs on Core: 1
Task0 runs on Core: 1
Task0 runsE (10217) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:
E (10217) task_wdt: - IDLE0 (CPU 0)
E (10217) task_wdt: Tasks currently running:
E (10217) task_wdt: CPU 0: loopTask
E (10217) task_wdt: CPU 1: IDLE1
E (10217) task_wdt: Aborting.
E (10217) task_wdt: Print CPU 0 (current core) backtrace

Rebooting...
ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_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:1
load:0x3fff0030,len:4832
load:0x40078000,len:16460
load:0x40080400,len:4
load:0x40080404,len:3504
entry 0x400805cc
Task0 runs on Core: 1
Task0 runs on Core: 1
Task0 runs on Core: 1
Task0 runs on Core: 1
....

I tried putting in some load in the task and delay etc. nothing changes and the cpu gets rebooted...
I've tried a lot and searched the documentation and the web a few hours now aked GPT but couldn'T solve the issue.

Here is my code:

Code: Select all

// create ESP32 RTOS tasks (RTOS - RealTimeOperatingSystem)
TaskHandle_t Task0;

void setup() {
  Serial.begin(115200);  //setting baudrate

  // RTOS setting: 

  // RTOS Task0 (core 1): 
  xTaskCreatePinnedToCore(
    task0function, /* Function to implement the task */
    "Task0",   /* Name of the task */
    10000,     /* Stack size in words */
    NULL,      /* Task input parameter */
    1,         /* Priority of the task */
    &Task0,    /* Task handle. */
    1);        /* Core where the task does run */

}

void loop() {
  // Print the core ID where the main loop is running
  // Serial.print("Main Loop running on Core: ");
  // Serial.println(xPortGetCoreID());
}

// Task0 (core 1):
void task0function(void *pvParameter) {

  while (1) {
    // task debugging start: -----------------------------------------------------------------------------------
    // // Print the core ID where the main loop is running
    Serial.print("Task0 runs on Core: ");
    Serial.println(xPortGetCoreID());
    
    // // Monitor stack and heap usage
    // Serial.print("Task0 Stack High Water Mark: ");
    // Serial.println(uxTaskGetStackHighWaterMark(NULL)); // gives the minimum of unused stack memory
    // Serial.print("Free Heap: ");
    // Serial.println(esp_get_free_heap_size()); // gives the ammount of unallocated heap memory

    vTaskDelay(10 / portTICK_PERIOD_MS);

    // task debugging end: -----------------------------------------------------------------------------------
  }
}
I appreciate every help and comment.
Thanks

Re: ESP32 pinned Core "CPU reeboot"

Posted: Thu Feb 06, 2025 7:27 am
by MicroController
Try

Code: Select all

void loop() {
  vTaskDelay(10 / portTICK_PERIOD_MS);
}
to give the IDLE task on core 0 a chance to run.