FreeRTOS Crash on core 1

grayefx
Posts: 6
Joined: Sun Dec 09, 2018 8:36 pm
Location: Guadalajara, Mexico

FreeRTOS Crash on core 1

Postby grayefx » Thu Oct 03, 2019 2:48 pm

Hello IDF Team

I have a trouble with the usage of the second core with esp-idf:

Board : esp32 v0
esp-idf version : 3.3 (Last stable update)

Problem: 1.- In code esp32 gets reconfigured with an SSID and its Password set by an application
2.- Next, do a measurement and then it send it to a server by HTTPS (Until here everything is OK)
3.- My code has an option of "Full nvs erase" triggered by interrupt in GPIO12 and it works fine only when esp32
is not doing HTTPS request, because when HTTPS is happen, the interrupt is triggered but the nvs is not erased
4.- My solution approach is send that task to other core with FreeRTOS (Enabling FreeRTOS on all cores in "menuconfig") and
Create task pinned to core (1)

Code: Select all

TaskHandle_t xHandle;                                                                       //Handler for device delete task
void eraseNVS_task(void *pvParameter)
{
	printf("Delete button pressed, wait for long press....\n");
	vTaskDelay(10000 / portTICK_PERIOD_MS);                                 //User need to press by 10 secs delete button
	if(gpio_get_level(12)){                                                               //After delay if button still pressed...
		printf("User hard reset by presing 10 seconds reset button...\n");
		if(DeleteConfig()){esp_restart();}	                                //Delete all device configs
	}
	vTaskDelete( NULL );					 //Reset not completed or button press accidentally, delete task

}

static void IRAM_ATTR gpio_isr_handler(void* arg)                           //Interrupt callback atached to GPIO
{
    uint32_t gpio_num = (uint32_t) arg;
	xTaskCreatePinnedToCore(&eraseNVS_task, "eraseNVS_task", configMINIMAL_STACK_SIZE, NULL, 5, &xHandle,1);
}

Code: Select all

bool DeleteConfig()
{
	esp_err_t err = nvs_flash_init();

	nvs_handle my_handle;
	    err = nvs_open("storage", NVS_READWRITE, &my_handle);
	    if (err != ESP_OK) {
	        //printf("Error (%s) opening NVS handle!\n", esp_err_to_name(err));
	    	printf("Error opening NVS handle!\n");
	    } else {
	        printf("Done opening NvS.. \n");
        //Delete records..    
        err = nvs_erase_key(my_handle, key);
		if(err != ESP_OK){
			printf("Error (%s) deleting!\n", esp_err_to_name(err));
		}
		else{ 
			printf("Done erasing..\n");
		}
		err = nvs_erase_key(my_handle, key2);
		if(err != ESP_OK){
			printf("Error (%s) deleting!\n", esp_err_to_name(err));
		}
		else{ 
			printf("Done erasing..\n");
		}
        err = nvs_erase_key(my_handle, key5);
		if(err != ESP_OK){
			printf("Error (%s) deleting!\n", esp_err_to_name(err));
		}
        err = nvs_erase_key(my_handle, key8);
		if(err != ESP_OK){
			printf("Error (%s) deleting!\n", esp_err_to_name(err));
		}
		else{ 
			printf("Done erasing..\n");
            return true;
		}
	        
	    }
	return false;
}
The code above works fine when FreeRTOS run only in core 0, but when it runs in core 1 this error is shown:
User hard reset by presing 10 seconds reset button...
Done opening NvS..
***ERROR*** A stack overflow in task eraseNVS_task has been detected.
abort() was called at PC 0x40089018 on core 1

ELF file SHA256: eeec6bf32b0c2be2ae15239c7677abb7b16e2b566e128bc676ca8bc812065799

Backtrace: 0x40088db4:0x3ffbf8c0 0x40089001:0x3ffbf8e0 0x40089018:0x3ffbf900 0x4008df8c:0x3ffbf920 0x4008ffec:0x3ffbf940 0x4008ffa2:0xcce3e1ae

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


Other point is that i cant find the option to set the WIFI operations to core 1(in menuconfig):
Core 0 (ESP32_WIFI_TASK_PINNED_TO_CORE_0)
Core 1 (ESP32_WIFI_TASK_PINNED_TO_CORE_1)

Any Ideas?

Thanks!!

grayefx
Posts: 6
Joined: Sun Dec 09, 2018 8:36 pm
Location: Guadalajara, Mexico

Re: FreeRTOS Crash on core 1

Postby grayefx » Thu Oct 03, 2019 8:41 pm

I answer to myself:

2 Actions was needed:

1.-Increase the usStackDepth for the FreeRTOS task
2.-In menuconfig-> Component config - > ESP32-specific : increase "Inter-processor call (IPC) task stack size"

Who is online

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