ESP32 hangs when using core 1

User avatar
Foxtrot813
Posts: 8
Joined: Sun Apr 08, 2018 6:37 am

ESP32 hangs when using core 1

Postby Foxtrot813 » Sun Apr 08, 2018 6:47 am

Hello all,

I'm having a problem executing blink on Core 1. My ESP is the WeMos Lolin32 Lite. Tried to modify the priority, the task handler, add vTaskStartScheduler() in the end of code, all without success. Here's the code:

Code: Select all

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "sdkconfig.h"

#define BLINK_GPIO 22

void blink_task(void *param)
{
    gpio_pad_select_gpio(BLINK_GPIO);
    gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);

    while(1)
     {

        gpio_set_level(BLINK_GPIO, 0);
        vTaskDelay(500 / portTICK_PERIOD_MS);

        gpio_set_level(BLINK_GPIO, 1);
        vTaskDelay(500 / portTICK_PERIOD_MS);
    }
}

void app_main()
{
	xTaskCreatePinnedToCore(blink_task, "Blink", 1000, NULL, 20, NULL, 0);
}
I'm using Eclipse Oxygen to program the ESP32. When I change it to core 1, it does not blink. There's something that I'm missing? :?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: ESP32 hangs when using core 1

Postby WiFive » Sun Apr 08, 2018 8:49 am

&blink_task

User avatar
Foxtrot813
Posts: 8
Joined: Sun Apr 08, 2018 6:37 am

Re: ESP32 hangs when using core 1

Postby Foxtrot813 » Sun Apr 08, 2018 5:22 pm

Putting &blink_task in xTaskCreatePinnedToCore didn't solve the problem. The ESP32 still hangs, without blinking. Tried to increase stack size this time, also without results. If I change to core 0, it works, so apparently the problem is with core 1...but why?

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

Re: ESP32 hangs when using core 1

Postby ESP_Sprite » Mon Apr 09, 2018 3:01 am

Perhaps in 'make menuconfig', you have set freertos to unicore mode? (Component config -> FreeRTOS -> Run FreeRTOS only on first core)?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: ESP32 hangs when using core 1

Postby WiFive » Mon Apr 09, 2018 5:21 am

ESP_Sprite wrote:Perhaps in 'make menuconfig', you have set freertos to unicore mode? (Component config -> FreeRTOS -> Run FreeRTOS only on first core)?
Shouldn't xtaskcreatepinnedtocore do something other than fail silently like pick a valid core or print an error?

User avatar
Foxtrot813
Posts: 8
Joined: Sun Apr 08, 2018 6:37 am

Re: ESP32 hangs when using core 1

Postby Foxtrot813 » Mon Apr 09, 2018 10:24 am

ESP_Sprite wrote:Perhaps in 'make menuconfig', you have set freertos to unicore mode? (Component config -> FreeRTOS -> Run FreeRTOS only on first core)?
Gosh, that was the problem. ESP32 is running fine on two cores now that I've changed that. Thank you!
WiFive wrote:
ESP_Sprite wrote:Perhaps in 'make menuconfig', you have set freertos to unicore mode? (Component config -> FreeRTOS -> Run FreeRTOS only on first core)?
Shouldn't xtaskcreatepinnedtocore do something other than fail silently like pick a valid core or print an error?
It printed this for me:

C:/msys32/home/f813/esp/esp-idf/components/freertos/tasks.c:1072 (prvAddNewTaskToReadyList)- assert failed!
abort() was called at PC 0x40083d4a on core 0


But I had no clue what that meant...

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

Re: ESP32 hangs when using core 1

Postby ESP_Sprite » Mon Apr 09, 2018 11:13 am

Yes, it should respond better to that and from memory, esp-idf also used to check this. We'll put a check for this back in.

Who is online

Users browsing this forum: Google [Bot] and 256 guests