diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 17807450a9..6c5e5ee585 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -1005,7 +1005,15 @@ msgid "Filters too complex" msgstr "" #: 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 "" #: shared-bindings/bitmaptools/__init__.c @@ -4155,7 +4163,7 @@ msgstr "" msgid "unexpected keyword argument" msgstr "" -#: py/bc.c py/objnamedtuple.c +#: py/bc.c py/objnamedtuple.c shared-bindings/traceback/__init__.c msgid "unexpected keyword argument '%q'" msgstr "" diff --git a/ports/espressif/common-hal/dualbank/__init__.c b/ports/espressif/common-hal/dualbank/__init__.c index 29b15a3e30..9e3fb38627 100644 --- a/ports/espressif/common-hal/dualbank/__init__.c +++ b/ports/espressif/common-hal/dualbank/__init__.c @@ -32,8 +32,6 @@ #include "esp_log.h" #include "esp_ota_ops.h" -#include "supervisor/flash.h" - static const esp_partition_t *update_partition = NULL; 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) { 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)", running->type, running->subtype, running->address); ESP_LOGI(TAG, "Writing partition type %d subtype %d (offset 0x%08x)\n", update_partition->type, update_partition->subtype, update_partition->address); - - assert(update_partition != NULL); } 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 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."); - task_fatal_error(); + mp_raise_RuntimeError(translate("Firmware is duplicate")); } // check new version with last invalid partition if (last_invalid != NULL) { 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."); - 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 { 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_ERR_OTA_VALIDATE_FAILED) { 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)); task_fatal_error();