Task usage

Hi there,
I have trouble running a simple application in ESP-32 board.
Here is the code:

void app_main(void)
       BaseType_t baseType=0;
       TaskHandle_t xConsoleHandle = NULL;
       printf("Calling vTaskStartScheduler\n");
       printf("Called vTaskStartScheduler\n");
       * Create tasks
       baseType = xTaskCreate(tskConsole,
                              ( void * ) 1,
       while (1) {
        printf("Main task\n");
        vTaskDelay(1000 / portTICK_PERIOD_MS);


void tskConsole( void *pv )
       printf("Entering in console task\n");
       while (1) {
        printf("Console task\n");
        //vTaskDelay(1000 / portTICK_PERIOD_MS);
        vTaskDelay(1000 / portTICK_PERIOD_MS);

I receive this error:

Calling vTaskStartScheduler
assert failed: lock_release_generic locks.c:186 (h)

What is wrong and how to fix it?

Thanks in advance for your reply.

lock_release_generic locks.c is not one of our files, but the error message tells you an assert failed on line 186, so I suspect looking at that line will tell you a lot about what went wrong.

Of course,
I already take a look to lock.c and around.
My guess is that there is some missing configuration steps I need to do.
Is there something I need to do in FreeRTOSConfig.h?

Seems that vTaskStartScheduler() is called somewhere automatically
before main entry point.
Removing call to vTaskStartScheduler() everything goes well.
Thank you

vTaskStartScheduler() normally called from main entry, not from a task.
I guess ‘void app_main(void)’ is not a boday of a task.
If so, app_main call the task control API(vTaskDelay) maybe not allowed.