From 6a4f74946fc717f8c95c43f364290e3e9d2cd2fa Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Thu, 10 Dec 2020 16:48:58 +0530 Subject: [PATCH] reset ota module on every vm run --- ports/esp32s2/common-hal/ota/__init__.c | 3 ++- ports/esp32s2/common-hal/ota/__init__.h | 6 +++--- ports/esp32s2/supervisor/port.c | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ports/esp32s2/common-hal/ota/__init__.c b/ports/esp32s2/common-hal/ota/__init__.c index 4ec1021317..40cfce6769 100644 --- a/ports/esp32s2/common-hal/ota/__init__.c +++ b/ports/esp32s2/common-hal/ota/__init__.c @@ -24,6 +24,7 @@ * THE SOFTWARE. */ +#include "common-hal/ota/__init__.h" #include "shared-bindings/ota/__init__.h" #include @@ -37,7 +38,7 @@ static esp_ota_handle_t update_handle = 0; static bool ota_inited = false; static const char *TAG = "OTA"; -static void ota_reset(void) { +void ota_reset(void) { update_handle = 0; update_partition = NULL; ota_inited = false; diff --git a/ports/esp32s2/common-hal/ota/__init__.h b/ports/esp32s2/common-hal/ota/__init__.h index 317604a8ec..983b57e3f2 100644 --- a/ports/esp32s2/common-hal/ota/__init__.h +++ b/ports/esp32s2/common-hal/ota/__init__.h @@ -24,9 +24,9 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_OTA__INIT__H -#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_OTA__INIT__H +#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_OTA___INIT___H +#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_OTA___INIT___H extern void ota_reset(void); -#endif //MICROPY_INCLUDED_ESP32S2_COMMON_HAL_OTA__INIT__H +#endif //MICROPY_INCLUDED_ESP32S2_COMMON_HAL_OTA___INIT___H diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c index 0841081de8..4cca862d87 100644 --- a/ports/esp32s2/supervisor/port.c +++ b/ports/esp32s2/supervisor/port.c @@ -41,6 +41,7 @@ #include "common-hal/busio/I2C.h" #include "common-hal/busio/SPI.h" #include "common-hal/busio/UART.h" +#include "common-hal/ota/__init__.h" #include "common-hal/ps2io/Ps2.h" #include "common-hal/pulseio/PulseIn.h" #include "common-hal/pwmio/PWMOut.h" @@ -107,6 +108,10 @@ void reset_port(void) { analogout_reset(); #endif +#if CIRCUITPY_OTA + ota_reset(); +#endif + #if CIRCUITPY_PS2IO ps2_reset(); #endif