Dual core watchdog reset issue
Posted: Wed Jan 10, 2024 12:43 pm
hello everyone ,
i just wnant to check the condtion . if core1 task is hang up due to some resone ...then it should restart the task of that core (core1).
suggest tha canges in code .
here watchdog is triggered but not restarting the core1 task .
i just wnant to check the condtion . if core1 task is hang up due to some resone ...then it should restart the task of that core (core1).
suggest tha canges in code .
here watchdog is triggered but not restarting the core1 task .
- [/*
- Aim : to test two core working saparetly SPI ,UART 1,UART2 ;
- Result :
- code ruunig fine with all uaret wokring ,Read write togther
- */
- #include "freertos/FreeRTOS.h"
- #include "esp_wifi.h"
- #include "esp_system.h"
- #include "esp_event.h"
- #include "esp_event.h"
- #include "nvs_flash.h"
- #include "driver/gpio.h"
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include "esp_flash.h"
- #include "esp_flash_spi_init.h"
- #include "esp_partition.h"
- #include "esp_vfs.h"
- #include "esp_vfs_fat.h"
- #include "esp_system.h"
- #include "soc/spi_pins.h"
- #include "driver/gpio.h"
- #include "driver/uart.h"
- //-----watchdog
- #include "esp_task_wdt.h"
- #define BUF_SIZE (1024)
- uint32_t count=0 ;
- // h2 and c2 will not support external flash
- #define EXAMPLE_FLASH_FREQ_MHZ 40
- static const char *TAG = "Flash";
- // Pin mapping
- // ESP32 (VSPI)
- #define HOST_ID SPI3_HOST
- #define PIN_MOSI GPIO_NUM_2 //---
- #define PIN_MISO GPIO_NUM_19//---
- #define PIN_CLK GPIO_NUM_4
- #define PIN_CS GPIO_NUM_5
- #define SPI_DMA_CHAN SPI_DMA_CH_AUTO
- esp_flash_t* ext_flash;
- //----MY Variable
- int SR_NO= 1,Read_SR_N0=0;
- float data=100.00,Read_data=0;
- uint32_t address=0x00,Read_add=0x00;
- static esp_flash_t* init_spi_flash(void){
- //-----set spi pin configurataion
- const spi_bus_config_t bus_config = {
- .mosi_io_num = PIN_MOSI,
- .miso_io_num = PIN_MISO,
- .sclk_io_num = PIN_CLK,
- //.quadhd_io_num = PIN_HD,
- //.quadwp_io_num = PIN_WP,
- };
- const esp_flash_spi_device_config_t device_config = {
- .host_id = HOST_ID,
- .cs_id = 0,
- .cs_io_num = PIN_CS,
- .io_mode = SPI_FLASH_DIO,
- .freq_mhz = EXAMPLE_FLASH_FREQ_MHZ,
- };
- ESP_LOGI(TAG, "Initializing...SPI Flash");
- // Initialize the SPI bus
- ESP_ERROR_CHECK(spi_bus_initialize(HOST_ID, &bus_config, SPI_DMA_CHAN));
- // Add device to the SPI bus
- ESP_ERROR_CHECK(spi_bus_add_flash_device(&ext_flash, &device_config));
- // Probe the Flash chip and initialize it
- esp_err_t err = esp_flash_init(ext_flash);
- if (err != ESP_OK) {
- ESP_LOGE(TAG, "Failed to initialize SPI Flash: %s (0x%x)", esp_err_to_name(err), err);
- return NULL;
- }
- // Print out the ID and size
- uint32_t id;
- ESP_ERROR_CHECK(esp_flash_read_id(ext_flash, &id));
- ESP_LOGI(TAG, "Initialized SPI Flash, size=%" PRIu32 " KB, ID=0x%" PRIx32, ext_flash->size / 1024, id);
- return ext_flash;
- }
- void Core_1_Task(void* parameter){
- esp_task_wdt_reset();
- ESP_LOGI("Core1", "Satrt\n");
- esp_task_wdt_add(NULL);
- while(1){
- if(address>Read_add){
- esp_flash_read(ext_flash, &Read_SR_N0, Read_add, sizeof(Read_SR_N0));
- Read_add+=sizeof(Read_SR_N0);
- esp_flash_read(ext_flash, &Read_data, Read_add, sizeof(Read_data));
- Read_add+=sizeof(Read_data);
- Read_add++;
- ESP_LOGI("core1 SPI-R", "SR_NO %d ,data %f\n",Read_SR_N0,Read_data);
- }
- //vTaskDelay(1000 / portTICK_PERIOD_MS);
- //printf("Core0 \n");
- // printf("Core1 \n");
- if(SR_NO==10){
- ESP_LOGI("Core1", "hang tes\n");
- while (1)
- {
- /* code */
- }
- }
- vTaskDelay(2000/ portTICK_PERIOD_MS);
- esp_task_wdt_reset();
- }
- }
- void Core_0_Task(void* parameter){
- while(1){
- esp_flash_write(ext_flash, &SR_NO, address, sizeof(int));
- address+=sizeof(int);
- esp_flash_write(ext_flash, &data, address, sizeof(float));
- address+=sizeof(float);
- ESP_LOGI("Core0 SPI-W", "SR_NO %d ,data %f\n",SR_NO,data);
- address++;
- SR_NO++;
- data++;
- vTaskDelay(2000 / portTICK_PERIOD_MS);
- }
- }
- void app_main(void)
- {
- // Set up SPI bus and initialize the external SPI Flash chip
- esp_flash_t* flash = init_spi_flash();
- if (flash == NULL) {
- return;
- }
- esp_flash_erase_chip(flash);
- ESP_LOGI("Code", "Start\n");
- xTaskCreatePinnedToCore(Core_1_Task, "core1", 1024*5, NULL, 2, NULL, 1);
- xTaskCreatePinnedToCore(Core_0_Task, "core0", 1024*3, NULL, 0, NULL, 0);
- }
- ]
- logs
- E (83268) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:
- E (83268) task_wdt: - core1 (CPU 1)
- E (83268) task_wdt: - IDLE (CPU 1)
- E (83268) task_wdt: Tasks currently running:
- E (83268) task_wdt: CPU 0: IDLE
- E (83268) task_wdt: CPU 1: core1
- E (83268) task_wdt: Print CPU 1 backtrace
- Backtrace: 0x40084E26:0x3FFB13B0 0x400829DD:0x3FFB13D0 0x400D5629:0x3FFB6FD0 0x40088739:0x3FFB7000
- 0x40084e26: esp_crosscore_isr at C:/Users/mohit/esp/esp-idf/components/esp_system/crosscore_int.c:96