espressif / esp-aws-iot

AWS IoT SDK for ESP32 based chipsets
Apache License 2.0
256 stars 154 forks source link

OTA MQTT example reports errors at the end of a successful update (CA-238) #135

Open andrew-elder opened 1 year ago

andrew-elder commented 1 year ago

This test was run on a ESP32-S3-DevKitM-1.

ESP-IDF

8153bfe412 (HEAD, tag: v4.4) versions: Update version to 4.4.0

esp-aws-iot 8153bfe412 (HEAD, tag: v4.4) versions: Update version to 4.4.0

with this patch for ESP32S3 compilation

diff --git a/port/ota/aws_esp_ota_ops.c b/port/ota/aws_esp_ota_ops.c
index e6fac6a..d9eb0b9 100644
--- a/port/ota/aws_esp_ota_ops.c
+++ b/port/ota/aws_esp_ota_ops.c
@@ -34,7 +34,6 @@
 #include "aws_esp_ota_ops.h"
 #include "sys/queue.h"
 #include "esp32/rom/crc.h"
-#include "soc/dport_reg.h"
 #include "esp_log.h"
 #include "esp_flash_partitions.h"
 #include "esp_efuse.h"
diff --git a/port/ota/ota_pal.c b/port/ota/ota_pal.c
index 173c021..c505070 100644
--- a/port/ota/ota_pal.c
+++ b/port/ota/ota_pal.c
@@ -32,7 +32,7 @@
 #include "esp_system.h"
 #include "esp_log.h"
 #include "soc/rtc_cntl_reg.h"
-#include "soc/rtc_wdt.h"
+#include "hal/wdt_hal.h"

 #include "esp_partition.h"
 #include "esp_spi_flash.h"
@@ -650,7 +650,11 @@ OtaPalImageState_t otaPal_GetPlatformImageState( OtaFileContext_t * const pFileC
 static void disable_rtc_wdt()
 {
     LogInfo( ( "Disabling RTC hardware watchdog timer" ) );
-    rtc_wdt_disable();
+    wdt_hal_context_t rtc_wdt_ctx= {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0};
+    wdt_hal_write_protect_disable(&rtc_wdt_ctx);
+    wdt_hal_disable(&rtc_wdt_ctx);
+    wdt_hal_write_protect_enable(&rtc_wdt_ctx);
+

Using example esp-aws-iot/examples/ota/ota_mqtt

Building and running it ends up with

W (693480) wifi:idx W (693480) wifi:idx I (693480) wifi:new:<2,0>, old:<2,0>, ap:<255,255>, sta:<2,0>, prof:1 E (693490) TRANSPORT_BASE: poll_read select error 113, errno = Software caused connection abort, fd = 54 E (693500) tls_freertos: Reading failed, errno= 119 E (693500) DEMO: MQTT_ProcessLoop returned with status = MQTTRecvFailed. I (693510) DEMO: Disconnecting the MQTT connection with aojzzp6jejodz-ats.iot.us-east-1.amazonaws.com. E (693520) TRANSPORT_BASE: poll_write select error 0, errno = Success, fd = 54 W (693530) TRANSPORT_BASE: Poll timeout or error, errno=Connection already in progress, fd=54, timeout_ms=1500 E (693540) tls_freertos: Writing failed, errno= 119 I (693570) wifi:flush txq I (693570) wifi:stop sw txq I (693570) wifi:lmac stop hw txq I (693570) wifi:Deinit lldesc rx mblock:10 ESP-ROM:esp32s3-20210327 Build:Mar 27 2021 rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)

Note that the OTA update is successful.

I tried the latest branch of esp-aws-iot but was unable to get the codesigning confirmation at the end of download to work correctly.