flash/nor/kinetis: pull SRST low during mass erase 24/2424/2
authorPaul Fertser <fercerpav@gmail.com>
Fri, 5 Dec 2014 10:18:36 +0000 (13:18 +0300)
committerPaul Fertser <fercerpav@gmail.com>
Fri, 30 Jan 2015 08:54:25 +0000 (08:54 +0000)
Mass erase operation might be impacted by different factors,
apparently the most reliable way is to do it while asserting the chip
reset line.

Change-Id: Id6ab57eaec86e402ffdf4f5c8843e7735640f03e
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2424
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
src/flash/nor/kinetis.c

index dce098ecfea726117cedcca7f382e20a25748c0a..a392a17ba30df713abedd9d5cca5a03d9e510066 100644 (file)
@@ -31,6 +31,7 @@
 #include "config.h"
 #endif
 
 #include "config.h"
 #endif
 
+#include "jtag/interface.h"
 #include "imp.h"
 #include <helper/binarybuffer.h>
 #include <target/algorithm.h>
 #include "imp.h"
 #include <helper/binarybuffer.h>
 #include <target/algorithm.h>
@@ -313,6 +314,14 @@ COMMAND_HANDLER(kinetis_mdm_mass_erase)
         * Reset Request bit in the MDM-AP control register after
         * establishing communication...
         */
         * 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);
        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 (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;
 }
        dap_ap_select(dap, original_ap);
        return ERROR_OK;
 }

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)