This is an automated email from Gerrit.

Tomas Vanek ([email protected]) just uploaded a new patch set to Gerrit, which you 
can find at http://openocd.zylin.com/4044

-- gerrit

commit 256fd3ec90db8da422c728b65204f8e21f34a879
Author: Tomas Vanek <[email protected]>
Date:   Fri Mar 3 21:58:39 2017 +0100

    jtag/drivers/cmsis-dap: hack to attach a secured SAMD/R/L/C
    
    Without the change a secured SAMD/R/L/C device cannot be attached
    and therefore neither erased.
    
    Hack in CMSIS-DAP optionally issues a cold-plug reset sequence at OpenOCD
    init. It enables limited access to DSU of the device and makes chip
    erase possible.
    
    Change-Id: I9aa78b7bcc23909732d1d4555178139533130a14
    Signed-off-by: Tomas Vanek <[email protected]>
    Reported-by: Thomas Irmen <[email protected]>

diff --git a/doc/openocd.texi b/doc/openocd.texi
index 45b341c..ea74cba 100644
--- a/doc/openocd.texi
+++ b/doc/openocd.texi
@@ -2390,6 +2390,11 @@ Specifies the @var{serial} of the CMSIS-DAP device to 
use.
 If not specified, serial numbers are not considered.
 @end deffn
 
+@deffn {Config Command} {cmsis_dap_init_samd_cold_plug}
+Issues cold-plug reset sequence during OpenOCD init.
+Use for attaching to a secured Atmel SAMD/R/L/C device.
+@end deffn
+
 @deffn {Command} {cmsis-dap info}
 Display various device information, like hardware version, firmware version, 
current bus status.
 @end deffn
@@ -4999,13 +5004,18 @@ processor to be halted.
 @deffn Command {at91samd set-security}
 Secures the Flash via the Set Security Bit (SSB) command. This prevents access
 to the Flash and can only be undone by using the chip-erase command which
-erases the Flash contents and turns off the security bit. Warning: at this
-time, openocd will not be able to communicate with a secured chip and it is
-therefore not possible to chip-erase it without using another tool.
+erases the Flash contents and turns off the security bit.
 
 @example
 at91samd set-security enable
 @end example
+
+To erase a secured device using a CMSIS-DAP adapter run:
+@example
+openocd -f interface/cmsis-dap.cfg -c "transport select swd" -f at91samdXX.cfg 
\
+  -c cmsis_dap_init_samd_cold_plug -c "reset_config srst_only" -c init \
+  -c "at91samd chip-erase" -c shutdown
+@end example
 @end deffn
 
 @deffn Command {at91samd eeprom}
diff --git a/src/jtag/drivers/cmsis_dap_usb.c b/src/jtag/drivers/cmsis_dap_usb.c
index dd37522..c59549e 100644
--- a/src/jtag/drivers/cmsis_dap_usb.c
+++ b/src/jtag/drivers/cmsis_dap_usb.c
@@ -208,6 +208,9 @@ static int queued_retval;
 
 static struct cmsis_dap *cmsis_dap_handle;
 
+static bool samd_cold_plug;
+
+
 static int cmsis_dap_usb_open(void)
 {
        hid_device *dev = NULL;
@@ -974,6 +977,18 @@ static int cmsis_dap_init(void)
                }
        }
 
+       if (samd_cold_plug) {
+               retval = cmsis_dap_cmd_DAP_SWJ_Pins(0, SWJ_PIN_SRST | 
SWJ_PIN_TCK, 100, NULL);
+               if (retval != ERROR_OK)
+                       return ERROR_FAIL;
+
+               retval = cmsis_dap_cmd_DAP_SWJ_Pins(SWJ_PIN_SRST, SWJ_PIN_SRST 
| SWJ_PIN_TCK, 100, NULL);
+               if (retval != ERROR_OK)
+                       return ERROR_FAIL;
+
+               LOG_INFO("SAMD reset cold-plug sequence issued, device is held 
in reset.");
+       }
+
        cmsis_dap_cmd_DAP_LED(0x00);                    /* Both LEDs off */
 
        LOG_INFO("CMSIS-DAP: Interface ready");
@@ -1586,6 +1601,13 @@ COMMAND_HANDLER(cmsis_dap_handle_serial_command)
        return ERROR_OK;
 }
 
+
+COMMAND_HANDLER(cmsis_dap_handle_samd_cold_plug_command)
+{
+       samd_cold_plug = true;
+       return ERROR_OK;
+}
+
 static const struct command_registration cmsis_dap_subcommand_handlers[] = {
        {
                .name = "info",
@@ -1619,6 +1641,13 @@ static const struct command_registration 
cmsis_dap_command_handlers[] = {
                .help = "set the serial number of the adapter",
                .usage = "serial_string",
        },
+       {
+               .name = "cmsis_dap_init_samd_cold_plug",
+               .handler = &cmsis_dap_handle_samd_cold_plug_command,
+               .mode = COMMAND_CONFIG,
+               .help = "issue SAMD/R/L/C cold-plug sequence during init to 
attach a secured device",
+               .usage = "",
+       },
        COMMAND_REGISTRATION_DONE
 };
 

-- 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to