From 42f459f88b2fc15091ad3e7e025528aebeab8bec Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 5 Oct 2024 20:39:05 +0200 Subject: [PATCH] WIP OTA implementation --- esp32_device/main/ota.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/esp32_device/main/ota.c b/esp32_device/main/ota.c index c254dc8..f33b930 100644 --- a/esp32_device/main/ota.c +++ b/esp32_device/main/ota.c @@ -1,7 +1,26 @@ +#include "esp_log.h" +#include "esp_partition.h" +#include "esp_ota_ops.h" + #include "ota.h" +const char *TAG = "ota"; + bool ota_perform_update(const char *version) { - // TODO + const esp_partition_t *configured = esp_ota_get_boot_partition(); + const esp_partition_t *running = esp_ota_get_running_partition(); + + if (configured != running) + { + ESP_LOGW(TAG, "Configured OTA boot partition at offset 0x%08" PRIx32 ", but running from offset 0x%08" PRIx32, + configured->address, running->address); + ESP_LOGW(TAG, "(This can happen if either the OTA boot data or preferred boot image become corrupted somehow.)"); + } + + ESP_LOGI(TAG, "Running partition type %d subtype %d (offset 0x%08" PRIx32 ")", + running->type, running->subtype, running->address); + + // TODO (from native example) return false; } \ No newline at end of file