improve dualbank errors

This commit is contained in:
microDev 2022-10-15 13:20:10 +05:30
parent 747e9f96b4
commit e7b25dbf73
No known key found for this signature in database
GPG Key ID: 2C0867BE60967730
2 changed files with 15 additions and 10 deletions

View File

@ -1005,7 +1005,15 @@ msgid "Filters too complex"
msgstr "" msgstr ""
#: ports/espressif/common-hal/dualbank/__init__.c #: ports/espressif/common-hal/dualbank/__init__.c
msgid "Firmware image is invalid" msgid "Firmware is duplicate"
msgstr ""
#: ports/espressif/common-hal/dualbank/__init__.c
msgid "Firmware is invalid"
msgstr ""
#: ports/espressif/common-hal/dualbank/__init__.c
msgid "Firmware is too big"
msgstr "" msgstr ""
#: shared-bindings/bitmaptools/__init__.c #: shared-bindings/bitmaptools/__init__.c
@ -4155,7 +4163,7 @@ msgstr ""
msgid "unexpected keyword argument" msgid "unexpected keyword argument"
msgstr "" msgstr ""
#: py/bc.c py/objnamedtuple.c #: py/bc.c py/objnamedtuple.c shared-bindings/traceback/__init__.c
msgid "unexpected keyword argument '%q'" msgid "unexpected keyword argument '%q'"
msgstr "" msgstr ""

View File

@ -32,8 +32,6 @@
#include "esp_log.h" #include "esp_log.h"
#include "esp_ota_ops.h" #include "esp_ota_ops.h"
#include "supervisor/flash.h"
static const esp_partition_t *update_partition = NULL; static const esp_partition_t *update_partition = NULL;
static esp_ota_handle_t update_handle = 0; static esp_ota_handle_t update_handle = 0;
@ -59,14 +57,13 @@ void common_hal_dualbank_flash(const void *buf, const size_t len, const size_t o
if (update_partition == NULL) { if (update_partition == NULL) {
update_partition = esp_ota_get_next_update_partition(NULL); update_partition = esp_ota_get_next_update_partition(NULL);
assert(update_partition != NULL);
ESP_LOGI(TAG, "Running partition type %d subtype %d (offset 0x%08x)", ESP_LOGI(TAG, "Running partition type %d subtype %d (offset 0x%08x)",
running->type, running->subtype, running->address); running->type, running->subtype, running->address);
ESP_LOGI(TAG, "Writing partition type %d subtype %d (offset 0x%08x)\n", ESP_LOGI(TAG, "Writing partition type %d subtype %d (offset 0x%08x)\n",
update_partition->type, update_partition->subtype, update_partition->address); update_partition->type, update_partition->subtype, update_partition->address);
assert(update_partition != NULL);
} }
if (update_handle == 0) { if (update_handle == 0) {
@ -88,14 +85,14 @@ void common_hal_dualbank_flash(const void *buf, const size_t len, const size_t o
// check new version with running version // check new version with running version
if (memcmp(new_app_info.version, running_app_info.version, sizeof(new_app_info.version)) == 0) { if (memcmp(new_app_info.version, running_app_info.version, sizeof(new_app_info.version)) == 0) {
ESP_LOGW(TAG, "New version is the same as running version."); ESP_LOGW(TAG, "New version is the same as running version.");
task_fatal_error(); mp_raise_RuntimeError(translate("Firmware is duplicate"));
} }
// check new version with last invalid partition // check new version with last invalid partition
if (last_invalid != NULL) { if (last_invalid != NULL) {
if (memcmp(new_app_info.version, invalid_app_info.version, sizeof(new_app_info.version)) == 0) { if (memcmp(new_app_info.version, invalid_app_info.version, sizeof(new_app_info.version)) == 0) {
ESP_LOGW(TAG, "New version is the same as invalid version."); ESP_LOGW(TAG, "New version is the same as invalid version.");
task_fatal_error(); mp_raise_RuntimeError(translate("Firmware is invalid"));
} }
} }
@ -106,7 +103,7 @@ void common_hal_dualbank_flash(const void *buf, const size_t len, const size_t o
} }
} else { } else {
ESP_LOGE(TAG, "received package is not fit len"); ESP_LOGE(TAG, "received package is not fit len");
task_fatal_error(); mp_raise_RuntimeError(translate("Firmware is too big"));
} }
} }
@ -130,7 +127,7 @@ void common_hal_dualbank_switch(void) {
if (err != ESP_OK) { if (err != ESP_OK) {
if (err == ESP_ERR_OTA_VALIDATE_FAILED) { if (err == ESP_ERR_OTA_VALIDATE_FAILED) {
ESP_LOGE(TAG, "Image validation failed, image is corrupted"); ESP_LOGE(TAG, "Image validation failed, image is corrupted");
mp_raise_RuntimeError(translate("Firmware image is invalid")); mp_raise_RuntimeError(translate("Firmware is invalid"));
} }
ESP_LOGE(TAG, "esp_ota_set_boot_partition failed (%s)!", esp_err_to_name(err)); ESP_LOGE(TAG, "esp_ota_set_boot_partition failed (%s)!", esp_err_to_name(err));
task_fatal_error(); task_fatal_error();