# xCreateTask : Core  0 panic'ed (LoadProhibited) on SP32.

**URL:** <https://forums.freertos.org/t/xcreatetask-core-0-paniced-loadprohibited-on-sp32/8057>\
**Category:** Kernel\
**Created:** [September 13, 2019, 4:17am UTC](https://forums.freertos.org/t/xcreatetask-core-0-paniced-loadprohibited-on-sp32/8057 "2019-09-13T04:17:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 13, 2019, 4:17am UTC](https://forums.freertos.org/t/xcreatetask-core-0-paniced-loadprohibited-on-sp32/8057/1 "2019-09-13T04:17:30Z")

</div>

**[azz-zza](https://sourceforge.net/u/azz-zza/)** wrote on [Friday, September 13, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/c680bed7c6/#9dec):

Hello,  
the “blinky” works, until i try to implement it using tasks. BTW i’m running esp32doit-devkit-v1 with espressif32 framework.

```auto

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"
#include "driver/gpio.h"
#include "nvs_flash.h"

#define BLINK_GPIO GPIO_NUM_2

portTickType c_1000ms = 1000 / portTICK_RATE_MS;

extern "C"
{
    void app_main(void);
}

void blinky(void *pvParameter)
{
    gpio_pad_select_gpio(BLINK_GPIO);
    /* Set the GPIO as a push/pull output */
    gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
    while (1)
    {
        gpio_set_level(BLINK_GPIO, 0);
        vTaskDelay(c_1000ms * 2);

        gpio_set_level(BLINK_GPIO, 1);
        vTaskDelay(c_1000ms);
    }
    vTaskDelete(NULL);
}

void app_main(void)
{
    vTaskDelay(c_1000ms * 2);
    printf("Hello world!\n");

    esp_err_t ret = nvs_flash_init();

    if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND)
    {
        ESP_ERROR_CHECK(nvs_flash_erase());
        ret = nvs_flash_init();
    }
    ESP_ERROR_CHECK(ret);

    TaskHandle_t xHandle = NULL;
    BaseType_t xReturned;
    if (xReturned != pdPASS)
    {
        printf("Error in TaskCreate");
        esp_restart();
    }
    vTaskStartScheduler();
}

```

the output is :

```auto
␛[0;32mI (0) cpu_start: Starting scheduler on APP CPU.␛[0m
Hello world!
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x400d1b1f PS : 0x00060430 A0 : 0x800d1227 A1 : 0x3ffb1b00  
A2 : 0xa5a5a5a5 A3 : 0x000000ff A4 : 0x00000042 A5 : 0x00000000  
A6 : 0x3ffb1c70 A7 : 0x3ffb1c50 A8 : 0x0000007e A9 : 0xfffffffa  
A10 : 0x00000001 A11 : 0xffffff01 A12 : 0xffffff43 A13 : 0x00000000  
A14 : 0x00000000 A15 : 0x3ffb1bf0 SAR : 0x00000006 EXCCAUSE: 0x0000001c  
EXCVADDR: 0xa5a5a5b1 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000  

Backtrace: 0x400d1b1f:0x3ffb1b00 0x400d1224:0x3ffb1b60 0x400d14ad:0x3ffb1cb0 0x400d10c0:0x3ffb56e8

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

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee

```

i’ve been looking in FREERTOS guide and in “Internet of Things with SP32” example… clearly missing something essential.  
Thank you.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [September 13, 2019, 4:56am UTC](https://forums.freertos.org/t/xcreatetask-core-0-paniced-loadprohibited-on-sp32/8057/2 "2019-09-13T04:56:11Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, September 13, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/c680bed7c6/#9dec/671b):

app\_main() looks very suspicious. You cannot call vTaskDelay() until the scheduler is running, but you don’t start the scheduler until later in the function. However the output does not seem to show it crashing there so maybe the scheduler is already running at that point (I’m not familiar with this dev environment)? If the scheduler is running then don’t call vTaskStartScheduler() again and be careful not to return from the task. What happens if you replace the call to vTaskStartScheduler() with a call to vTaskDelete( NULL)?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 13, 2019, 4:57am UTC](https://forums.freertos.org/t/xcreatetask-core-0-paniced-loadprohibited-on-sp32/8057/3 "2019-09-13T04:57:18Z")

</div>

**[azz-zza](https://sourceforge.net/u/azz-zza/)** wrote on [Friday, September 13, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/c680bed7c6/#e4b6):

vTaskStartScheduler();  
is not needed.  
resolved …

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 13, 2019, 5:05am UTC](https://forums.freertos.org/t/xcreatetask-core-0-paniced-loadprohibited-on-sp32/8057/4 "2019-09-13T05:05:00Z")

</div>

**[azz-zza](https://sourceforge.net/u/azz-zza/)** wrote on [Friday, September 13, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/c680bed7c6/#9dec/671b/e873):

Richard,  
didn’t see your reply .  
If i just replace the vTaskStartScheduler() with a call to vTaskDelete( NULL) - it happily blinks and prints onto the console.

Another obesrvation is in the hello\_task and is dealing with printing “p” ( the parameter passed to the xTaskCreate):  
`  
void hello\_task(void _pvParameter)  
{  
char p;  
p = (_(char \*)pvParameter);  
const char \*pcTaskName = “Task 1 is running\r\n”;

```
for(;;)
{
    
    printf(pcTaskName);
    // printf("Task : %c : counting .. . \n", p);
    vTaskDelay(1000 / portTICK_RATE_MS);
}
vTaskDelete(NULL);

```

}  
`

if i un=comment the  
printf(“Task : %c : counting … . \n”, p);  
ill get the kernel panic. Eventhough the compiler has no warnings.
