32
32
#include "esp_log.h"
33
33
#include "esp_ota_ops.h"
34
34
35
- #include "supervisor/flash.h"
36
-
37
35
static const esp_partition_t * update_partition = NULL ;
38
36
static esp_ota_handle_t update_handle = 0 ;
39
37
@@ -59,14 +57,13 @@ void common_hal_dualbank_flash(const void *buf, const size_t len, const size_t o
59
57
60
58
if (update_partition == NULL ) {
61
59
update_partition = esp_ota_get_next_update_partition (NULL );
60
+ assert (update_partition != NULL );
62
61
63
62
ESP_LOGI (TAG , "Running partition type %d subtype %d (offset 0x%08x)" ,
64
63
running -> type , running -> subtype , running -> address );
65
64
66
65
ESP_LOGI (TAG , "Writing partition type %d subtype %d (offset 0x%08x)\n" ,
67
66
update_partition -> type , update_partition -> subtype , update_partition -> address );
68
-
69
- assert (update_partition != NULL );
70
67
}
71
68
72
69
if (update_handle == 0 ) {
@@ -88,14 +85,14 @@ void common_hal_dualbank_flash(const void *buf, const size_t len, const size_t o
88
85
// check new version with running version
89
86
if (memcmp (new_app_info .version , running_app_info .version , sizeof (new_app_info .version )) == 0 ) {
90
87
ESP_LOGW (TAG , "New version is the same as running version." );
91
- task_fatal_error ( );
88
+ mp_raise_RuntimeError ( translate ( "Firmware is duplicate" ) );
92
89
}
93
90
94
91
// check new version with last invalid partition
95
92
if (last_invalid != NULL ) {
96
93
if (memcmp (new_app_info .version , invalid_app_info .version , sizeof (new_app_info .version )) == 0 ) {
97
94
ESP_LOGW (TAG , "New version is the same as invalid version." );
98
- task_fatal_error ( );
95
+ mp_raise_RuntimeError ( translate ( "Firmware is invalid" ) );
99
96
}
100
97
}
101
98
@@ -106,7 +103,7 @@ void common_hal_dualbank_flash(const void *buf, const size_t len, const size_t o
106
103
}
107
104
} else {
108
105
ESP_LOGE (TAG , "received package is not fit len" );
109
- task_fatal_error ( );
106
+ mp_raise_RuntimeError ( translate ( "Firmware is too big" ) );
110
107
}
111
108
}
112
109
@@ -130,7 +127,7 @@ void common_hal_dualbank_switch(void) {
130
127
if (err != ESP_OK ) {
131
128
if (err == ESP_ERR_OTA_VALIDATE_FAILED ) {
132
129
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" ));
134
131
}
135
132
ESP_LOGE (TAG , "esp_ota_set_boot_partition failed (%s)!" , esp_err_to_name (err ));
136
133
task_fatal_error ();
0 commit comments