drivers: cmsis-dap: print serial if available 05/3405/3
authorKarl Palsson <karlp@tweak.net.au>
Wed, 13 Apr 2016 23:45:12 +0000 (23:45 +0000)
committerMatthias Welwarsky <matthias@welwarsky.de>
Wed, 25 Jul 2018 13:17:00 +0000 (14:17 +0100)
Helpful for sanity checking connections

Change-Id: Ife0d8b4e12d4c03685aac8115c9739a4c1e994fe
Signed-off-by: Karl Palsson <karlp@tweak.net.au>
Reviewed-on: http://openocd.zylin.com/3405
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
src/jtag/drivers/cmsis_dap_usb.c

index 928389f..4ee4836 100644 (file)
@@ -729,6 +729,20 @@ static void cmsis_dap_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_del
        cmsis_dap_swd_queue_cmd(cmd, value, 0);
 }
 
+static int cmsis_dap_get_serial_info(void)
+{
+       uint8_t *data;
+
+       int retval = cmsis_dap_cmd_DAP_Info(INFO_ID_SERNUM, &data);
+       if (retval != ERROR_OK)
+               return retval;
+
+       if (data[0]) /* strlen */
+               LOG_INFO("CMSIS-DAP: Serial# = %s", &data[1]);
+
+       return ERROR_OK;
+}
+
 static int cmsis_dap_get_version_info(void)
 {
        uint8_t *data;
@@ -873,6 +887,10 @@ static int cmsis_dap_init(void)
        if (retval != ERROR_OK)
                return retval;
 
+       retval = cmsis_dap_get_serial_info();
+       if (retval != ERROR_OK)
+               return retval;
+
        if (swd_mode) {
                retval = cmsis_dap_swd_open();
                if (retval != ERROR_OK)