Skip to content

Commit 8c16093

Browse files
authored
Merge pull request #7061 from MicroDev1/espressif
Improve `dualbank` errors
2 parents 747e9f9 + e7b25db commit 8c16093

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

locale/circuitpython.pot

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,15 @@ msgid "Filters too complex"
10051005
msgstr ""
10061006

10071007
#: ports/espressif/common-hal/dualbank/__init__.c
1008-
msgid "Firmware image is invalid"
1008+
msgid "Firmware is duplicate"
1009+
msgstr ""
1010+
1011+
#: ports/espressif/common-hal/dualbank/__init__.c
1012+
msgid "Firmware is invalid"
1013+
msgstr ""
1014+
1015+
#: ports/espressif/common-hal/dualbank/__init__.c
1016+
msgid "Firmware is too big"
10091017
msgstr ""
10101018

10111019
#: shared-bindings/bitmaptools/__init__.c
@@ -4155,7 +4163,7 @@ msgstr ""
41554163
msgid "unexpected keyword argument"
41564164
msgstr ""
41574165

4158-
#: py/bc.c py/objnamedtuple.c
4166+
#: py/bc.c py/objnamedtuple.c shared-bindings/traceback/__init__.c
41594167
msgid "unexpected keyword argument '%q'"
41604168
msgstr ""
41614169

ports/espressif/common-hal/dualbank/__init__.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
#include "esp_log.h"
3333
#include "esp_ota_ops.h"
3434

35-
#include "supervisor/flash.h"
36-
3735
static const esp_partition_t *update_partition = NULL;
3836
static esp_ota_handle_t update_handle = 0;
3937

@@ -59,14 +57,13 @@ void common_hal_dualbank_flash(const void *buf, const size_t len, const size_t o
5957

6058
if (update_partition == NULL) {
6159
update_partition = esp_ota_get_next_update_partition(NULL);
60+
assert(update_partition != NULL);
6261

6362
ESP_LOGI(TAG, "Running partition type %d subtype %d (offset 0x%08x)",
6463
running->type, running->subtype, running->address);
6564

6665
ESP_LOGI(TAG, "Writing partition type %d subtype %d (offset 0x%08x)\n",
6766
update_partition->type, update_partition->subtype, update_partition->address);
68-
69-
assert(update_partition != NULL);
7067
}
7168

7269
if (update_handle == 0) {
@@ -88,14 +85,14 @@ void common_hal_dualbank_flash(const void *buf, const size_t len, const size_t o
8885
// check new version with running version
8986
if (memcmp(new_app_info.version, running_app_info.version, sizeof(new_app_info.version)) == 0) {
9087
ESP_LOGW(TAG, "New version is the same as running version.");
91-
task_fatal_error();
88+
mp_raise_RuntimeError(translate("Firmware is duplicate"));
9289
}
9390

9491
// check new version with last invalid partition
9592
if (last_invalid != NULL) {
9693
if (memcmp(new_app_info.version, invalid_app_info.version, sizeof(new_app_info.version)) == 0) {
9794
ESP_LOGW(TAG, "New version is the same as invalid version.");
98-
task_fatal_error();
95+
mp_raise_RuntimeError(translate("Firmware is invalid"));
9996
}
10097
}
10198

@@ -106,7 +103,7 @@ void common_hal_dualbank_flash(const void *buf, const size_t len, const size_t o
106103
}
107104
} else {
108105
ESP_LOGE(TAG, "received package is not fit len");
109-
task_fatal_error();
106+
mp_raise_RuntimeError(translate("Firmware is too big"));
110107
}
111108
}
112109

@@ -130,7 +127,7 @@ void common_hal_dualbank_switch(void) {
130127
if (err != ESP_OK) {
131128
if (err == ESP_ERR_OTA_VALIDATE_FAILED) {
132129
ESP_LOGE(TAG, "Image validation failed, image is corrupted");
133-
mp_raise_RuntimeError(translate("Firmware image is invalid"));
130+
mp_raise_RuntimeError(translate("Firmware is invalid"));
134131
}
135132
ESP_LOGE(TAG, "esp_ota_set_boot_partition failed (%s)!", esp_err_to_name(err));
136133
task_fatal_error();

0 commit comments

Comments
 (0)