Add watchdog timer to miner task
Set a 120s timeout for the watchdog to catch a starving miner task. If the miner task fails to reset the watchdog, the ESP32 will reboot.
This commit is contained in:
parent
35474c1bc5
commit
146d0497d6
@ -20,6 +20,8 @@
|
||||
|
||||
//3 seconds WDT
|
||||
#define WDT_TIMEOUT 3
|
||||
//120 seconds WDT for miner task
|
||||
#define WDT_MINER_TIMEOUT 120
|
||||
OneButton button1(PIN_BUTTON_1);
|
||||
OneButton button2(PIN_BUTTON_2);
|
||||
|
||||
@ -56,6 +58,7 @@ void setup()
|
||||
Serial.setTimeout(0);
|
||||
delay(100);
|
||||
|
||||
esp_task_wdt_init(WDT_MINER_TIMEOUT, true);
|
||||
// Idle task that would reset WDT never runs, because core 0 gets fully utilized
|
||||
disableCore0WDT();
|
||||
//disableCore1WDT();
|
||||
@ -137,8 +140,11 @@ void setup()
|
||||
|
||||
// Start mining tasks
|
||||
//BaseType_t res = xTaskCreate(runWorker, name, 35000, (void*)name, 1, NULL);
|
||||
xTaskCreate(runMiner, "Miner0", 15000, NULL, 1, NULL);
|
||||
xTaskCreate(runMiner, "Miner1", 15000, NULL, 1, NULL);
|
||||
TaskHandle_t minerTask1, minerTask2 = NULL;
|
||||
xTaskCreate(runMiner, "Miner0", 15000, NULL, 1, &minerTask1);
|
||||
xTaskCreate(runMiner, "Miner1", 15000, NULL, 1, &minerTask2);
|
||||
esp_task_wdt_add(minerTask1);
|
||||
esp_task_wdt_add(minerTask2);
|
||||
|
||||
/******** MONITOR SETUP *****/
|
||||
setup_monitor();
|
||||
@ -164,4 +170,4 @@ void loop() {
|
||||
wifiManagerProcess(); // avoid delays() in loop when non-blocking and other long running code
|
||||
|
||||
vTaskDelay(50 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <Arduino.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <WiFi.h>
|
||||
#include <esp_task_wdt.h>
|
||||
#include <TFT_eSPI.h> // Graphics and font library for ILI9341 driver chip
|
||||
#include <wolfssl/wolfcrypt/sha256.h>
|
||||
#include "media/Free_Fonts.h"
|
||||
@ -338,6 +339,8 @@ void runMiner(void * name){
|
||||
}
|
||||
|
||||
uint32_t duration = micros() - startT;
|
||||
if (esp_task_wdt_reset() == ESP_OK)
|
||||
Serial.print(">>> Resetting watchdog timer");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user