From cc6737272679ed1d2131ad8b571ec32443520456 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Wed, 6 Apr 2016 02:29:39 +0200 Subject: [PATCH] Add fw_dump --- src/omv/py/py_winc.c | 21 ++++++++++++++++---- src/omv/py/qstrdefsomv.h | 1 + src/winc1500/include/programmer/programmer.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/omv/py/py_winc.c b/src/omv/py/py_winc.c index 10f77c806..b72d9c89b 100644 --- a/src/omv/py/py_winc.c +++ b/src/omv/py/py_winc.c @@ -785,6 +785,17 @@ static mp_obj_t winc_fw_version(mp_obj_t self_in) return t_fwver; } +static mp_obj_t winc_fw_dump(mp_obj_t self_in) +{ + // Erase the WINC1500 flash. + printf("Dumping firmware...\n"); + if (dump_firmware() != M2M_SUCCESS) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Failed to erase entire flash!")); + } + + return mp_const_none; +} + static mp_obj_t winc_fw_update(mp_obj_t self_in) { // Erase the WINC1500 flash. @@ -812,10 +823,10 @@ static mp_obj_t winc_fw_update(mp_obj_t self_in) } // Verify the certificates on the WINC1500 flash. - //printf("Reading certificates from flash...\n"); - //if (dump_certificate_section() != M2M_SUCCESS) { - // nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Failed to dump certificate section!")); - //} + printf("Reading certificates from flash...\n"); + if (verify_certificates() != M2M_SUCCESS) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "Failed to dump certificate section!")); + } printf("All task completed successfully.\n"); return mp_const_none; @@ -828,6 +839,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(winc_ifconfig_obj, winc_ifconfig); static MP_DEFINE_CONST_FUN_OBJ_1(winc_scan_obj, winc_scan); static MP_DEFINE_CONST_FUN_OBJ_1(winc_rssi_obj, winc_rssi); static MP_DEFINE_CONST_FUN_OBJ_1(winc_fw_version_obj, winc_fw_version); +static MP_DEFINE_CONST_FUN_OBJ_1(winc_fw_dump_obj, winc_fw_dump); static MP_DEFINE_CONST_FUN_OBJ_1(winc_fw_update_obj, winc_fw_update); static const mp_map_elem_t winc_locals_dict_table[] = { @@ -838,6 +850,7 @@ static const mp_map_elem_t winc_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_scan), (mp_obj_t)&winc_scan_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_rssi), (mp_obj_t)&winc_rssi_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_fw_version), (mp_obj_t)&winc_fw_version_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_fw_dump), (mp_obj_t)&winc_fw_dump_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_fw_update), (mp_obj_t)&winc_fw_update_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_OPEN), MP_OBJ_NEW_SMALL_INT(M2M_WIFI_SEC_OPEN) }, // Network is not secured. diff --git a/src/omv/py/qstrdefsomv.h b/src/omv/py/qstrdefsomv.h index 3c755e60e..f10e0bb3c 100644 --- a/src/omv/py/qstrdefsomv.h +++ b/src/omv/py/qstrdefsomv.h @@ -261,6 +261,7 @@ Q(disconnect) Q(isconnected) Q(ifconfig) Q(fw_version) +Q(fw_dump) Q(fw_update) Q(scan) Q(rssi) diff --git a/src/winc1500/include/programmer/programmer.h b/src/winc1500/include/programmer/programmer.h index 57c679df7..9c52cd5d4 100644 --- a/src/winc1500/include/programmer/programmer.h +++ b/src/winc1500/include/programmer/programmer.h @@ -56,6 +56,7 @@ int burn_firmware(void); int verify_firmware(void); +int dump_firmware(void); int burn_certificates(void); int verify_certificates(void); #endif /* IMAGE_DOWNLOADER_H_INCLUDED */