X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fflash%2Fnor%2Fkinetis.c;h=396fe42a9c8f3c709993ed7e72cd8869329f3082;hp=dce098ecfea726117cedcca7f382e20a25748c0a;hb=14040c7a57320fd62386e2bbb16cd88044eb282a;hpb=513436a17accbe5494f763055124be594bef0a45 diff --git a/src/flash/nor/kinetis.c b/src/flash/nor/kinetis.c index dce098ecfe..396fe42a9c 100644 --- a/src/flash/nor/kinetis.c +++ b/src/flash/nor/kinetis.c @@ -31,6 +31,7 @@ #include "config.h" #endif +#include "jtag/interface.h" #include "imp.h" #include #include @@ -313,6 +314,14 @@ COMMAND_HANDLER(kinetis_mdm_mass_erase) * Reset Request bit in the MDM-AP control register after * establishing communication... */ + + /* assert SRST */ + if (jtag_get_reset_config() & RESET_HAS_SRST) + adapter_assert_reset(); + else + LOG_WARNING("Attempting mass erase without hardware reset. This is not reliable; " + "it's recommended you connect SRST and use ``reset_config srst_only''."); + dap_ap_select(dap, 1); retval = kinetis_mdm_write_register(dap, MDM_REG_CTRL, MEM_CTRL_SYS_RES_REQ); @@ -364,6 +373,9 @@ COMMAND_HANDLER(kinetis_mdm_mass_erase) if (retval != ERROR_OK) return retval; + if (jtag_get_reset_config() & RESET_HAS_SRST) + adapter_deassert_reset(); + dap_ap_select(dap, original_ap); return ERROR_OK; } @@ -785,20 +797,6 @@ static int kinetis_ftfx_command(struct flash_bank *bank, uint8_t fcmd, uint32_t return ERROR_OK; } -static int kinetis_mass_erase(struct flash_bank *bank) -{ - uint8_t ftfx_fstat; - - if (bank->target->state != TARGET_HALTED) { - LOG_ERROR("Target not halted"); - return ERROR_TARGET_NOT_HALTED; - } - - LOG_INFO("Execute Erase All Blocks"); - return kinetis_ftfx_command(bank, FTFx_CMD_MASSERASE, 0, - 0, 0, 0, 0, 0, 0, 0, 0, &ftfx_fstat); -} - COMMAND_HANDLER(kinetis_securing_test) { int result; @@ -833,9 +831,6 @@ static int kinetis_erase(struct flash_bank *bank, int first, int last) if ((first > bank->num_sectors) || (last > bank->num_sectors)) return ERROR_FLASH_OPERATION_FAILED; - if ((first == 0) && (last == (bank->num_sectors - 1))) - return kinetis_mass_erase(bank); - /* * FIXME: TODO: use the 'Erase Flash Block' command if the * requested erase is PFlash or NVM and encompasses the entire