Page 1 of 1

ESP32 hangs when using core 1

Posted: Sun Apr 08, 2018 6:47 am
by Foxtrot813
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? :?

Re: ESP32 hangs when using core 1

Posted: Sun Apr 08, 2018 8:49 am
by WiFive
&blink_task

Re: ESP32 hangs when using core 1

Posted: Sun Apr 08, 2018 5:22 pm
by Foxtrot813
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?

Re: ESP32 hangs when using core 1

Posted: Mon Apr 09, 2018 3:01 am
by ESP_Sprite
Perhaps in 'make menuconfig', you have set freertos to unicore mode? (Component config -> FreeRTOS -> Run FreeRTOS only on first core)?

Re: ESP32 hangs when using core 1

Posted: Mon Apr 09, 2018 5:21 am
by WiFive
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?

Re: ESP32 hangs when using core 1

Posted: Mon Apr 09, 2018 10:24 am
by Foxtrot813
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...

Re: ESP32 hangs when using core 1

Posted: Mon Apr 09, 2018 11:13 am
by ESP_Sprite
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.