jtag: cmsis-dap: developer tool - enter a command by hex nuber 03/3103/2
authorTomas Vanek <vanekt@fbl.cz>
Sun, 8 Nov 2015 08:22:42 +0000 (09:22 +0100)
committerSpencer Oliver <spen@spen-soft.co.uk>
Tue, 11 Dec 2018 13:24:55 +0000 (13:24 +0000)
Handy to test vendor commands in a CMSIS-DAP adapter.

Change-Id: Ieeaa276edf770b1a3076a186e9056b4e5180362a
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/3103
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
src/jtag/drivers/cmsis_dap_usb.c

index 035cc44..9d6bf7f 100644 (file)
@@ -1670,6 +1670,30 @@ COMMAND_HANDLER(cmsis_dap_handle_info_command)
        return ERROR_OK;
 }
 
+COMMAND_HANDLER(cmsis_dap_handle_cmd_command)
+{
+       int retval;
+       unsigned i;
+       uint8_t *buffer = cmsis_dap_handle->packet_buffer;
+
+       buffer[0] = 0;  /* report number */
+
+       for (i = 0; i < CMD_ARGC; i++)
+               buffer[i + 1] = strtoul(CMD_ARGV[i], NULL, 16);
+
+       retval = cmsis_dap_usb_xfer(cmsis_dap_handle, CMD_ARGC + 1);
+
+       if (retval != ERROR_OK) {
+               LOG_ERROR("CMSIS-DAP command failed.");
+               return ERROR_JTAG_DEVICE_ERROR;
+       }
+
+       LOG_INFO("Returned data %02" PRIx8 " %02" PRIx8 " %02" PRIx8 " %02" PRIx8,
+               buffer[1], buffer[2], buffer[3], buffer[4]);
+
+       return ERROR_OK;
+}
+
 COMMAND_HANDLER(cmsis_dap_handle_vid_pid_command)
 {
        if (CMD_ARGC > MAX_USB_IDS * 2) {
@@ -1729,6 +1753,13 @@ static const struct command_registration cmsis_dap_subcommand_handlers[] = {
                .usage = "",
                .help = "show cmsis-dap info",
        },
+       {
+               .name = "cmd",
+               .handler = &cmsis_dap_handle_cmd_command,
+               .mode = COMMAND_EXEC,
+               .usage = "",
+               .help = "issue cmsis-dap command",
+       },
        COMMAND_REGISTRATION_DONE
 };