This is an automated email from Gerrit. Spencer Oliver ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/2329
-- gerrit commit a747aac0b30c13308d44f51a41288bd3b61b38a5 Author: Spencer Oliver <[email protected]> Date: Thu Oct 2 21:54:23 2014 +0100 cmsis-dap: add serial number support Change-Id: I66926d1013e2b3a43ce0d18d3599771428706b6a Signed-off-by: Spencer Oliver <[email protected]> diff --git a/src/jtag/drivers/cmsis_dap_usb.c b/src/jtag/drivers/cmsis_dap_usb.c index 79712d0..c24b5fd 100644 --- a/src/jtag/drivers/cmsis_dap_usb.c +++ b/src/jtag/drivers/cmsis_dap_usb.c @@ -61,6 +61,7 @@ static uint16_t cmsis_dap_vid[MAX_USB_IDS + 1] = { 0 }; static uint16_t cmsis_dap_pid[MAX_USB_IDS + 1] = { 0 }; static bool swd_mode; +static wchar_t *serial; #define PACKET_SIZE (64 + 1) /* 64 bytes plus report id */ #define USB_TIMEOUT 1000 @@ -201,7 +202,12 @@ static int cmsis_dap_usb_open(void) if (found) { /* we have found an adapter, so exit further checks */ - break; + /* check serial number matches if given */ + if (serial != NULL) { + if (wcscmp(serial, cur_dev->serial_number) == 0) + break; + } else + break; } cur_dev = cur_dev->next; @@ -1006,6 +1012,27 @@ COMMAND_HANDLER(cmsis_dap_handle_vid_pid_command) return ERROR_OK; } +COMMAND_HANDLER(cmsis_dap_handle_serial_command) +{ + if (CMD_ARGC == 1) { + size_t len = mbstowcs(NULL, CMD_ARGV[0], 0); + serial = calloc(len + 1, sizeof(wchar_t)); + if (serial == NULL) { + LOG_ERROR("unable to allocate memory"); + return ERROR_OK; + } + if (mbstowcs(serial, CMD_ARGV[0], len + 1) == (size_t)-1) { + free(serial); + serial = NULL; + LOG_ERROR("unable to convert serial"); + } + } else { + LOG_ERROR("expected exactly one argument to cmsis_dap_serial <serial-number>"); + } + + return ERROR_OK; +} + static const struct command_registration cmsis_dap_subcommand_handlers[] = { { .name = "info", @@ -1032,6 +1059,13 @@ static const struct command_registration cmsis_dap_command_handlers[] = { .help = "the vendor ID and product ID of the CMSIS-DAP device", .usage = "(vid pid)* ", }, + { + .name = "cmsis_dap_serial", + .handler = &cmsis_dap_handle_serial_command, + .mode = COMMAND_CONFIG, + .help = "set the serial number of the adapter", + .usage = "serial_string", + }, COMMAND_REGISTRATION_DONE }; diff --git a/tcl/interface/cmsis-dap.cfg b/tcl/interface/cmsis-dap.cfg index a8ea92e..ab5c187 100644 --- a/tcl/interface/cmsis-dap.cfg +++ b/tcl/interface/cmsis-dap.cfg @@ -5,3 +5,6 @@ # interface cmsis-dap + +# Optionally specify the serial number of CMSIS-DAP usb device. +#cmsis_dap_serial 02200201E6661E601B98E3B9 -- ------------------------------------------------------------------------------ Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
