firmware: v9 — fix watchdog ESP32 + mitigacion glitch motor OTA
ESP32-CAM: - handshakeTask() corre ahora en tarea FreeRTOS separada. setup() termina de inmediato, el servidor web arranca sin bloqueos. El watchdog de hardware ya no puede dispararse (antes setup() bloqueaba hasta 30s con readStringUntil que no cedia el CPU). ESP8266: - Antes del flash OTA, fuerza ENA=ENB=0 e IN1-IN4=LOW para reducir el glitch de pines GPIO durante el proceso de escritura en flash. (La solucion definitiva es resistencias pull-down en ENA/ENB.) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
// ================================================================
|
// ================================================================
|
||||||
// OTA CONFIG
|
// OTA CONFIG
|
||||||
// ================================================================
|
// ================================================================
|
||||||
#define FW_VERSION 8
|
#define FW_VERSION 9
|
||||||
#define GITEA_HOST "https://git.nacho.myds.me"
|
#define GITEA_HOST "https://git.nacho.myds.me"
|
||||||
#define GITEA_OWNER "Natxo"
|
#define GITEA_OWNER "Natxo"
|
||||||
#define GITEA_REPO "Arduino-Car"
|
#define GITEA_REPO "Arduino-Car"
|
||||||
@@ -86,6 +86,11 @@ static void checkOTA() {
|
|||||||
}
|
}
|
||||||
delay(300);
|
delay(300);
|
||||||
|
|
||||||
|
// Fuerza pines de motor a LOW antes del flash para minimizar glitch de GPIO
|
||||||
|
analogWrite(ENA, 0); analogWrite(ENB, 0);
|
||||||
|
digitalWrite(IN1, LOW); digitalWrite(IN2, LOW);
|
||||||
|
digitalWrite(IN3, LOW); digitalWrite(IN4, LOW);
|
||||||
|
|
||||||
BearSSL::WiFiClientSecure updateClient;
|
BearSSL::WiFiClientSecure updateClient;
|
||||||
updateClient.setInsecure();
|
updateClient.setInsecure();
|
||||||
ESPhttpUpdate.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
ESPhttpUpdate.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
// ================================================================
|
// ================================================================
|
||||||
// OTA CONFIG
|
// OTA CONFIG
|
||||||
// ================================================================
|
// ================================================================
|
||||||
#define FW_VERSION 8
|
#define FW_VERSION 9
|
||||||
#define GITEA_HOST "https://git.nacho.myds.me"
|
#define GITEA_HOST "https://git.nacho.myds.me"
|
||||||
#define GITEA_OWNER "Natxo"
|
#define GITEA_OWNER "Natxo"
|
||||||
#define GITEA_REPO "Arduino-Car"
|
#define GITEA_REPO "Arduino-Car"
|
||||||
@@ -24,24 +24,30 @@ const char *password = "Suprak1llm1ndS23S";
|
|||||||
void startCameraServer();
|
void startCameraServer();
|
||||||
void setupLedFlash();
|
void setupLedFlash();
|
||||||
|
|
||||||
// ── Handshake bidireccional con ESP8266 ─────────────────────────
|
// ── Handshake bidireccional — tarea FreeRTOS (no bloquea setup) ─
|
||||||
// Envía "GO\n" cada 300ms hasta recibir "OK\n".
|
// Corre en paralelo con el servidor web. Envía "GO\n" cada 300ms
|
||||||
// Protege contra basura del bootloader ROM (115200 baud → bytes aleatorios).
|
// hasta recibir "OK\n" o agotar 30s.
|
||||||
static void handshakeEsp8266() {
|
static void handshakeTask(void *) {
|
||||||
unsigned long deadline = millis() + 30000UL; // máx 30s
|
unsigned long deadline = millis() + 30000UL;
|
||||||
|
String buf = "";
|
||||||
while (millis() < deadline) {
|
while (millis() < deadline) {
|
||||||
Serial.print("GO\n");
|
Serial.print("GO\n");
|
||||||
unsigned long t = millis();
|
unsigned long t = millis();
|
||||||
while (millis() - t < 300) {
|
while (millis() - t < 300) {
|
||||||
if (Serial.available()) {
|
while (Serial.available()) {
|
||||||
String resp = Serial.readStringUntil('\n');
|
char c = Serial.read();
|
||||||
resp.trim();
|
if (c == '\n') {
|
||||||
if (resp == "OK") return;
|
buf.trim();
|
||||||
|
if (buf == "OK") { vTaskDelete(NULL); return; }
|
||||||
|
buf = "";
|
||||||
|
} else if (c != '\r' && buf.length() < 8) {
|
||||||
|
buf += c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
delay(5);
|
vTaskDelay(pdMS_TO_TICKS(5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Timeout: continúa sin confirmación
|
vTaskDelete(NULL); // timeout
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── OTA: comprueba si hay firmware nuevo y actualiza si hace falta ──
|
// ── OTA: comprueba si hay firmware nuevo y actualiza si hace falta ──
|
||||||
@@ -167,8 +173,8 @@ void setup() {
|
|||||||
// ── Servidor cámara ───────────────────────────────────────────────
|
// ── Servidor cámara ───────────────────────────────────────────────
|
||||||
startCameraServer();
|
startCameraServer();
|
||||||
|
|
||||||
// Handshake bidireccional: espera ACK del ESP8266
|
// Handshake en tarea separada — no bloquea setup() ni el watchdog
|
||||||
handshakeEsp8266();
|
xTaskCreate(handshakeTask, "handshake", 4096, NULL, 1, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|||||||
Binary file not shown.
@@ -1 +1 @@
|
|||||||
8
|
9
|
||||||
Binary file not shown.
@@ -1 +1 @@
|
|||||||
8
|
9
|
||||||
Reference in New Issue
Block a user