]> git.sur5r.net Git - openocd/commitdiff
hla: add a way to pass arbitrary commands from user to layout and use for ICDI
authorPaul Fertser <fercerpav@gmail.com>
Tue, 19 Aug 2014 17:16:20 +0000 (21:16 +0400)
committerSpencer Oliver <spen@spen-soft.co.uk>
Mon, 6 Oct 2014 12:03:30 +0000 (12:03 +0000)
TI's ICDI adapter supports some additional commands which a user might
want to run for debugging or other purposes, the most useful of them
being "debug unlock" that fully mass-erases the device and unprotects
the flash.

Change-Id: I26990e736094367f92106fa891e9bb8fb0382efb
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2263
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
doc/openocd.texi
src/jtag/drivers/ti_icdi_usb.c
src/jtag/hla/hla_interface.c
src/jtag/hla/hla_layout.h

index 2db8bdd0606925d0226144c268bb09b0ae91f1d8..925eebed2d4406c490b3602d2149e7655ca4808a 100644 (file)
@@ -3100,6 +3100,11 @@ Specifies the adapter layout to use.
 The vendor ID and product ID of the device.
 @end deffn
 
+@deffn {Command} {hla_command} command
+Execute a custom adapter-specific command. The @var{command} string is
+passed as is to the underlying adapter layout handler.
+@end deffn
+
 @deffn {Config Command} {trace} source_clock_hz [output_file_path]
 Enable SWO tracing (if supported). The source clock rate for the
 trace port must be specified, this is typically the CPU clock rate. If
index 2f4af7a42bc32b723dbe0a2ff6004eb4ff882d39..53abbfb4305afc7ac8245a5638f0bff9359f0a9d 100644 (file)
@@ -777,4 +777,5 @@ struct hl_layout_api_s icdi_usb_layout_api = {
        .write_mem = icdi_usb_write_mem,
        .write_debug_reg = icdi_usb_write_debug_reg,
        .override_target = icdi_usb_override_target,
+       .custom_command = icdi_send_remote_cmd,
 };
index 964b074423db4ab1443a6d887babfd987f6154e7..ce914ea0c52204f9fefaa9481ba38c038ade791f 100644 (file)
@@ -268,6 +268,21 @@ COMMAND_HANDLER(interface_handle_trace_command)
        return ERROR_OK;
 }
 
+COMMAND_HANDLER(interface_handle_hla_command)
+{
+       if (CMD_ARGC != 1)
+               return ERROR_COMMAND_SYNTAX_ERROR;
+
+       if (!hl_if.layout->api->custom_command) {
+               LOG_ERROR("The selected adapter doesn't support custom commands");
+               return ERROR_FAIL;
+       }
+
+       hl_if.layout->api->custom_command(hl_if.handle, CMD_ARGV[0]);
+
+       return ERROR_OK;
+}
+
 static const struct command_registration hl_interface_command_handlers[] = {
        {
         .name = "hla_device_desc",
@@ -304,6 +319,13 @@ static const struct command_registration hl_interface_command_handlers[] = {
         .help = "configure trace reception",
         .usage = "source_lock_hz [destination_path]",
         },
+        {
+        .name = "hla_command",
+        .handler = &interface_handle_hla_command,
+        .mode = COMMAND_EXEC,
+        .help = "execute a custom adapter-specific command",
+        .usage = "hla_command <command>",
+        },
        COMMAND_REGISTRATION_DONE
 };
 
index 6d79d58102df3ba3560657cee5fe8895add6d9b7..df93cb69da0dec7a3623c27a633d5e4ab53f3940 100644 (file)
@@ -76,6 +76,8 @@ struct hl_layout_api_s {
        /** */
        int (*override_target) (const char *targetname);
        /** */
+       int (*custom_command) (void *handle, const char *command);
+       /** */
        enum target_state (*state) (void *fd);
 };