File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed
ports/esp32s2/common-hal/ota Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 31
31
#include "esp_log.h"
32
32
#include "esp_ota_ops.h"
33
33
34
+ esp_ota_handle_t update_handle = 0 ;
35
+ const esp_partition_t * update_partition = NULL ;
36
+
34
37
static const char * TAG = "OTA" ;
35
38
36
39
static void __attribute__((noreturn )) task_fatal_error (void ) {
@@ -41,8 +44,6 @@ static void __attribute__((noreturn)) task_fatal_error(void) {
41
44
void common_hal_ota_flash (const void * buf , const size_t len ) {
42
45
esp_err_t err ;
43
46
44
- esp_ota_handle_t update_handle = 0 ;
45
- const esp_partition_t * update_partition = NULL ;
46
47
update_partition = esp_ota_get_next_update_partition (NULL );
47
48
48
49
const esp_partition_t * running = esp_ota_get_running_partition ();
@@ -100,6 +101,10 @@ void common_hal_ota_flash(const void *buf, const size_t len) {
100
101
ESP_LOGE (TAG , "esp_ota_write failed (%s)" , esp_err_to_name (err ));
101
102
task_fatal_error ();
102
103
}
104
+ }
105
+
106
+ void common_hal_ota_finish (void ) {
107
+ esp_err_t err ;
103
108
104
109
err = esp_ota_end (update_handle );
105
110
if (err != ESP_OK ) {
Original file line number Diff line number Diff line change 30
30
//|
31
31
//| The `ota` module implements over-the-air update."""
32
32
33
+ STATIC mp_obj_t ota_finish (void ) {
34
+ common_hal_ota_finish ();
35
+ return mp_const_none ;
36
+ }
37
+ STATIC MP_DEFINE_CONST_FUN_OBJ_0 (ota_finish_obj , ota_finish );
38
+
33
39
STATIC mp_obj_t ota_flash (mp_obj_t program_binary_in ) {
34
40
mp_buffer_info_t bufinfo ;
35
41
mp_get_buffer_raise (program_binary_in , & bufinfo , MP_BUFFER_READ );
@@ -41,6 +47,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(ota_flash_obj, ota_flash);
41
47
42
48
STATIC const mp_rom_map_elem_t ota_module_globals_table [] = {
43
49
{ MP_ROM_QSTR (MP_QSTR___name__ ), MP_ROM_QSTR (MP_QSTR_ota ) },
50
+ { MP_ROM_QSTR (MP_QSTR_finish ), MP_ROM_PTR (& ota_finish_obj ) },
44
51
{ MP_ROM_QSTR (MP_QSTR_flash ), MP_ROM_PTR (& ota_flash_obj ) },
45
52
};
46
53
STATIC MP_DEFINE_CONST_DICT (ota_module_globals , ota_module_globals_table );
Original file line number Diff line number Diff line change 29
29
30
30
#include "py/runtime.h"
31
31
32
+ extern void common_hal_ota_finish (void );
32
33
extern void common_hal_ota_flash (const void * buf , const size_t len );
33
34
34
35
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_OTA___INIT___H
You can’t perform that action at this time.
0 commit comments