ipdbg: fix double free of virtual-ir data
[openocd.git] / src / jtag / drivers / ftdi.c
index e645e9fae1387bfdcca48ea14d76921847f47b9a..58f83af59292896c9a07ab01a5761f82de2ec559 100644 (file)
@@ -1,19 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
 /**************************************************************************
 *   Copyright (C) 2012 by Andreas Fritiofson                              *
 *   andreas.fritiofson@gmail.com                                          *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU General Public License as published by  *
-*   the Free Software Foundation; either version 2 of the License, or     *
-*   (at your option) any later version.                                   *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU General Public License     *
-*   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 ***************************************************************************/
 
 /**
 #endif
 
 /* project specific includes */
-#include <jtag/drivers/jtag_usb_common.h>
+#include <jtag/adapter.h>
 #include <jtag/interface.h>
 #include <jtag/swd.h>
 #include <transport/transport.h>
 #include <helper/time_support.h>
+#include <helper/log.h>
+#include <helper/nvp.h>
 
 #if IS_CYGWIN == 1
 #include <windows.h>
@@ -89,7 +80,6 @@
 #define SWD_MODE (LSB_FIRST | POS_EDGE_IN | NEG_EDGE_OUT)
 
 static char *ftdi_device_desc;
-static char *ftdi_serial;
 static uint8_t ftdi_channel;
 static uint8_t ftdi_jtag_mode = JTAG_MODE;
 
@@ -149,11 +139,11 @@ static struct signal *create_signal(const char *name)
                psig = &(*psig)->next;
 
        *psig = calloc(1, sizeof(**psig));
-       if (*psig == NULL)
+       if (!*psig)
                return NULL;
 
        (*psig)->name = strdup(name);
-       if ((*psig)->name == NULL) {
+       if (!(*psig)->name) {
                free(*psig);
                *psig = NULL;
        }
@@ -192,7 +182,7 @@ static int ftdi_set_signal(const struct signal *s, char value)
                oe = s->invert_oe;
                break;
        default:
-               assert(0 && "invalid signal level specifier");
+               LOG_ERROR("invalid signal level specifier \'%c\'(0x%02x)", value, value);
                return ERROR_FAIL;
        }
 
@@ -213,7 +203,7 @@ static int ftdi_set_signal(const struct signal *s, char value)
        return ERROR_OK;
 }
 
-static int ftdi_get_signal(const struct signal *s, uint16_t * value_out)
+static int ftdi_get_signal(const struct signal *s, uint16_t *value_out)
 {
        uint8_t data_low = 0;
        uint8_t data_high = 0;
@@ -288,7 +278,7 @@ static int ftdi_speed(int speed)
 
        if (!swd_mode && speed >= 10000000 && ftdi_jtag_mode != JTAG_MODE_ALT)
                LOG_INFO("ftdi: if you experience problems at higher adapter clocks, try "
-                        "the command \"ftdi_tdo_sample_edge falling\"");
+                        "the command \"ftdi tdo_sample_edge falling\"");
        return ERROR_OK;
 }
 
@@ -482,7 +472,11 @@ static void ftdi_execute_scan(struct jtag_command *cmd)
                        uint8_t last_bit = 0;
                        if (field->out_value)
                                bit_copy(&last_bit, 0, field->out_value, field->num_bits - 1, 1);
-                       uint8_t tms_bits = 0x01;
+
+                       /* If endstate is TAP_IDLE, clock out 1-1-0 (->EXIT1 ->UPDATE ->IDLE)
+                        * Otherwise, clock out 1-0 (->EXIT1 ->PAUSE)
+                        */
+                       uint8_t tms_bits = 0x03;
                        mpsse_clock_tms_cs(mpsse_ctx,
                                        &tms_bits,
                                        0,
@@ -492,13 +486,24 @@ static void ftdi_execute_scan(struct jtag_command *cmd)
                                        last_bit,
                                        ftdi_jtag_mode);
                        tap_set_state(tap_state_transition(tap_get_state(), 1));
-                       mpsse_clock_tms_cs_out(mpsse_ctx,
-                                       &tms_bits,
-                                       1,
-                                       1,
-                                       last_bit,
-                                       ftdi_jtag_mode);
-                       tap_set_state(tap_state_transition(tap_get_state(), 0));
+                       if (tap_get_end_state() == TAP_IDLE) {
+                               mpsse_clock_tms_cs_out(mpsse_ctx,
+                                               &tms_bits,
+                                               1,
+                                               2,
+                                               last_bit,
+                                               ftdi_jtag_mode);
+                               tap_set_state(tap_state_transition(tap_get_state(), 1));
+                               tap_set_state(tap_state_transition(tap_get_state(), 0));
+                       } else {
+                               mpsse_clock_tms_cs_out(mpsse_ctx,
+                                               &tms_bits,
+                                               2,
+                                               1,
+                                               last_bit,
+                                               ftdi_jtag_mode);
+                               tap_set_state(tap_state_transition(tap_get_state(), 0));
+                       }
                } else
                        mpsse_clock_data(mpsse_ctx,
                                field->out_value,
@@ -524,17 +529,19 @@ static int ftdi_reset(int trst, int srst)
 
        LOG_DEBUG_IO("reset trst: %i srst %i", trst, srst);
 
-       if (trst == 1) {
-               if (sig_ntrst)
-                       ftdi_set_signal(sig_ntrst, '0');
-               else
-                       LOG_ERROR("Can't assert TRST: nTRST signal is not defined");
-       } else if (sig_ntrst && jtag_get_reset_config() & RESET_HAS_TRST &&
-                       trst == 0) {
-               if (jtag_get_reset_config() & RESET_TRST_OPEN_DRAIN)
-                       ftdi_set_signal(sig_ntrst, 'z');
-               else
-                       ftdi_set_signal(sig_ntrst, '1');
+       if (!swd_mode) {
+               if (trst == 1) {
+                       if (sig_ntrst)
+                               ftdi_set_signal(sig_ntrst, '0');
+                       else
+                               LOG_ERROR("Can't assert TRST: nTRST signal is not defined");
+               } else if (sig_ntrst && jtag_get_reset_config() & RESET_HAS_TRST &&
+                               trst == 0) {
+                       if (jtag_get_reset_config() & RESET_TRST_OPEN_DRAIN)
+                               ftdi_set_signal(sig_ntrst, 'z');
+                       else
+                               ftdi_set_signal(sig_ntrst, '1');
+               }
        }
 
        if (srst == 1) {
@@ -550,17 +557,16 @@ static int ftdi_reset(int trst, int srst)
                        ftdi_set_signal(sig_nsrst, 'z');
        }
 
-       LOG_DEBUG_IO("trst: %i, srst: %i", trst, srst);
-       return ERROR_OK;
+       return mpsse_flush(mpsse_ctx);
 }
 
 static void ftdi_execute_sleep(struct jtag_command *cmd)
 {
-       LOG_DEBUG_IO("sleep %" PRIi32, cmd->cmd.sleep->us);
+       LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us);
 
        mpsse_flush(mpsse_ctx);
        jtag_sleep(cmd->cmd.sleep->us);
-       LOG_DEBUG_IO("sleep %" PRIi32 " usec while in %s",
+       LOG_DEBUG_IO("sleep %" PRIu32 " usec while in %s",
                cmd->cmd.sleep->us,
                tap_state_name(tap_get_state()));
 }
@@ -619,14 +625,14 @@ static void ftdi_execute_command(struct jtag_command *cmd)
        }
 }
 
-static int ftdi_execute_queue(void)
+static int ftdi_execute_queue(struct jtag_command *cmd_queue)
 {
        /* blink, if the current layout has that feature */
        struct signal *led = find_signal_by_name("LED");
        if (led)
                ftdi_set_signal(led, '1');
 
-       for (struct jtag_command *cmd = jtag_command_queue; cmd; cmd = cmd->next) {
+       for (struct jtag_command *cmd = cmd_queue; cmd; cmd = cmd->next) {
                /* fill the write buffer with the desired command */
                ftdi_execute_command(cmd);
        }
@@ -648,13 +654,13 @@ static int ftdi_initialize(void)
        else
                LOG_DEBUG("ftdi interface using shortest path jtag state transitions");
 
-       for (int i = 0; ftdi_vid[i] || ftdi_pid[i]; i++) {
-               mpsse_ctx = mpsse_open(&ftdi_vid[i], &ftdi_pid[i], ftdi_device_desc,
-                               ftdi_serial, jtag_usb_get_location(), ftdi_channel);
-               if (mpsse_ctx)
-                       break;
+       if (!ftdi_vid[0] && !ftdi_pid[0]) {
+               LOG_ERROR("Please specify ftdi vid_pid");
+               return ERROR_JTAG_INIT_FAILED;
        }
 
+       mpsse_ctx = mpsse_open(ftdi_vid, ftdi_pid, ftdi_device_desc,
+                               adapter_get_required_serial(), adapter_usb_get_location(), ftdi_channel);
        if (!mpsse_ctx)
                return ERROR_JTAG_INIT_FAILED;
 
@@ -677,7 +683,7 @@ static int ftdi_initialize(void)
 
        mpsse_loopback_config(mpsse_ctx, false);
 
-       freq = mpsse_set_frequency(mpsse_ctx, jtag_get_speed_khz() * 1000);
+       freq = mpsse_set_frequency(mpsse_ctx, adapter_get_speed_khz() * 1000);
 
        return mpsse_flush(mpsse_ctx);
 }
@@ -695,7 +701,6 @@ static int ftdi_quit(void)
        }
 
        free(ftdi_device_desc);
-       free(ftdi_serial);
 
        free(swd_cmd_queue);
 
@@ -705,24 +710,10 @@ static int ftdi_quit(void)
 COMMAND_HANDLER(ftdi_handle_device_desc_command)
 {
        if (CMD_ARGC == 1) {
-               if (ftdi_device_desc)
-                       free(ftdi_device_desc);
+               free(ftdi_device_desc);
                ftdi_device_desc = strdup(CMD_ARGV[0]);
        } else {
-               LOG_ERROR("expected exactly one argument to ftdi_device_desc <description>");
-       }
-
-       return ERROR_OK;
-}
-
-COMMAND_HANDLER(ftdi_handle_serial_command)
-{
-       if (CMD_ARGC == 1) {
-               if (ftdi_serial)
-                       free(ftdi_serial);
-               ftdi_serial = strdup(CMD_ARGV[0]);
-       } else {
-               return ERROR_COMMAND_SYNTAX_ERROR;
+               LOG_ERROR("expected exactly one argument to ftdi device_desc <description>");
        }
 
        return ERROR_OK;
@@ -846,7 +837,7 @@ COMMAND_HANDLER(ftdi_handle_set_signal_command)
                /* fallthrough */
        default:
                LOG_ERROR("unknown signal level '%s', use 0, 1 or z", CMD_ARGV[1]);
-               return ERROR_COMMAND_SYNTAX_ERROR;
+               return ERROR_COMMAND_ARGUMENT_INVALID;
        }
 
        return mpsse_flush(mpsse_ctx);
@@ -877,12 +868,12 @@ COMMAND_HANDLER(ftdi_handle_get_signal_command)
 COMMAND_HANDLER(ftdi_handle_vid_pid_command)
 {
        if (CMD_ARGC > MAX_USB_IDS * 2) {
-               LOG_WARNING("ignoring extra IDs in ftdi_vid_pid "
+               LOG_WARNING("ignoring extra IDs in ftdi vid_pid "
                        "(maximum is %d pairs)", MAX_USB_IDS);
                CMD_ARGC = MAX_USB_IDS * 2;
        }
        if (CMD_ARGC < 2 || (CMD_ARGC & 1)) {
-               LOG_WARNING("incomplete ftdi_vid_pid configuration directive");
+               LOG_WARNING("incomplete ftdi vid_pid configuration directive");
                if (CMD_ARGC < 2)
                        return ERROR_COMMAND_SYNTAX_ERROR;
                /* remove the incomplete trailing id */
@@ -897,7 +888,7 @@ COMMAND_HANDLER(ftdi_handle_vid_pid_command)
 
        /*
         * Explicitly terminate, in case there are multiples instances of
-        * ftdi_vid_pid.
+        * ftdi vid_pid.
         */
        ftdi_vid[i >> 1] = ftdi_pid[i >> 1] = 0;
 
@@ -906,51 +897,44 @@ COMMAND_HANDLER(ftdi_handle_vid_pid_command)
 
 COMMAND_HANDLER(ftdi_handle_tdo_sample_edge_command)
 {
-       Jim_Nvp *n;
-       static const Jim_Nvp nvp_ftdi_jtag_modes[] = {
+       const struct nvp *n;
+       static const struct nvp nvp_ftdi_jtag_modes[] = {
                { .name = "rising", .value = JTAG_MODE },
                { .name = "falling", .value = JTAG_MODE_ALT },
                { .name = NULL, .value = -1 },
        };
 
        if (CMD_ARGC > 0) {
-               n = Jim_Nvp_name2value_simple(nvp_ftdi_jtag_modes, CMD_ARGV[0]);
-               if (n->name == NULL)
+               n = nvp_name2value(nvp_ftdi_jtag_modes, CMD_ARGV[0]);
+               if (!n->name)
                        return ERROR_COMMAND_SYNTAX_ERROR;
                ftdi_jtag_mode = n->value;
 
        }
 
-       n = Jim_Nvp_value2name_simple(nvp_ftdi_jtag_modes, ftdi_jtag_mode);
+       n = nvp_value2name(nvp_ftdi_jtag_modes, ftdi_jtag_mode);
        command_print(CMD, "ftdi samples TDO on %s edge of TCK", n->name);
 
        return ERROR_OK;
 }
 
-static const struct command_registration ftdi_command_handlers[] = {
+static const struct command_registration ftdi_subcommand_handlers[] = {
        {
-               .name = "ftdi_device_desc",
+               .name = "device_desc",
                .handler = &ftdi_handle_device_desc_command,
                .mode = COMMAND_CONFIG,
                .help = "set the USB device description of the FTDI device",
                .usage = "description_string",
        },
        {
-               .name = "ftdi_serial",
-               .handler = &ftdi_handle_serial_command,
-               .mode = COMMAND_CONFIG,
-               .help = "set the serial number of the FTDI device",
-               .usage = "serial_string",
-       },
-       {
-               .name = "ftdi_channel",
+               .name = "channel",
                .handler = &ftdi_handle_channel_command,
                .mode = COMMAND_CONFIG,
                .help = "set the channel of the FTDI device that is used as JTAG",
                .usage = "(0-3)",
        },
        {
-               .name = "ftdi_layout_init",
+               .name = "layout_init",
                .handler = &ftdi_handle_layout_init_command,
                .mode = COMMAND_CONFIG,
                .help = "initialize the FTDI GPIO signals used "
@@ -958,7 +942,7 @@ static const struct command_registration ftdi_command_handlers[] = {
                .usage = "data direction",
        },
        {
-               .name = "ftdi_layout_signal",
+               .name = "layout_signal",
                .handler = &ftdi_handle_layout_signal_command,
                .mode = COMMAND_ANY,
                .help = "define a signal controlled by one or more FTDI GPIO as data "
@@ -966,28 +950,28 @@ static const struct command_registration ftdi_command_handlers[] = {
                .usage = "name [-data mask|-ndata mask] [-oe mask|-noe mask] [-alias|-nalias name]",
        },
        {
-               .name = "ftdi_set_signal",
+               .name = "set_signal",
                .handler = &ftdi_handle_set_signal_command,
                .mode = COMMAND_EXEC,
                .help = "control a layout-specific signal",
                .usage = "name (1|0|z)",
        },
        {
-               .name = "ftdi_get_signal",
+               .name = "get_signal",
                .handler = &ftdi_handle_get_signal_command,
                .mode = COMMAND_EXEC,
                .help = "read the value of a layout-specific signal",
                .usage = "name",
        },
        {
-               .name = "ftdi_vid_pid",
+               .name = "vid_pid",
                .handler = &ftdi_handle_vid_pid_command,
                .mode = COMMAND_CONFIG,
                .help = "the vendor ID and product ID of the FTDI device",
-               .usage = "(vid pid)* ",
+               .usage = "(vid pid)*",
        },
        {
-               .name = "ftdi_tdo_sample_edge",
+               .name = "tdo_sample_edge",
                .handler = &ftdi_handle_tdo_sample_edge_command,
                .mode = COMMAND_ANY,
                .help = "set which TCK clock edge is used for sampling TDO "
@@ -998,6 +982,17 @@ static const struct command_registration ftdi_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
+static const struct command_registration ftdi_command_handlers[] = {
+       {
+               .name = "ftdi",
+               .mode = COMMAND_ANY,
+               .help = "perform ftdi management",
+               .chain = ftdi_subcommand_handlers,
+               .usage = "",
+       },
+       COMMAND_REGISTRATION_DONE
+};
+
 static int create_default_signal(const char *name, uint16_t data_mask)
 {
        struct signal *sig = create_signal(name);
@@ -1037,7 +1032,7 @@ static int ftdi_swd_init(void)
        swd_cmd_queue_alloced = 10;
        swd_cmd_queue = malloc(swd_cmd_queue_alloced * sizeof(*swd_cmd_queue));
 
-       return swd_cmd_queue != NULL ? ERROR_OK : ERROR_FAIL;
+       return swd_cmd_queue ? ERROR_OK : ERROR_FAIL;
 }
 
 static void ftdi_swd_swdio_en(bool enable)
@@ -1060,7 +1055,6 @@ static void ftdi_swd_swdio_en(bool enable)
 
 /**
  * Flush the MPSSE queue and process the SWD transaction queue
- * @param dap
  * @return
  */
 static int ftdi_swd_run_queue(void)
@@ -1091,19 +1085,24 @@ static int ftdi_swd_run_queue(void)
        for (size_t i = 0; i < swd_cmd_queue_length; i++) {
                int ack = buf_get_u32(swd_cmd_queue[i].trn_ack_data_parity_trn, 1, 3);
 
-               LOG_DEBUG_IO("%s %s %s reg %X = %08"PRIx32,
+               /* Devices do not reply to DP_TARGETSEL write cmd, ignore received ack */
+               bool check_ack = swd_cmd_returns_ack(swd_cmd_queue[i].cmd);
+
+               LOG_CUSTOM_LEVEL((check_ack && ack != SWD_ACK_OK) ? LOG_LVL_DEBUG : LOG_LVL_DEBUG_IO,
+                               "%s%s %s %s reg %X = %08" PRIx32,
+                               check_ack ? "" : "ack ignored ",
                                ack == SWD_ACK_OK ? "OK" : ack == SWD_ACK_WAIT ? "WAIT" : ack == SWD_ACK_FAULT ? "FAULT" : "JUNK",
-                               swd_cmd_queue[i].cmd & SWD_CMD_APnDP ? "AP" : "DP",
-                               swd_cmd_queue[i].cmd & SWD_CMD_RnW ? "read" : "write",
+                               swd_cmd_queue[i].cmd & SWD_CMD_APNDP ? "AP" : "DP",
+                               swd_cmd_queue[i].cmd & SWD_CMD_RNW ? "read" : "write",
                                (swd_cmd_queue[i].cmd & SWD_CMD_A32) >> 1,
                                buf_get_u32(swd_cmd_queue[i].trn_ack_data_parity_trn,
-                                               1 + 3 + (swd_cmd_queue[i].cmd & SWD_CMD_RnW ? 0 : 1), 32));
+                                               1 + 3 + (swd_cmd_queue[i].cmd & SWD_CMD_RNW ? 0 : 1), 32));
 
-               if (ack != SWD_ACK_OK) {
-                       queued_retval = ack == SWD_ACK_WAIT ? ERROR_WAIT : ERROR_FAIL;
+               if (ack != SWD_ACK_OK && check_ack) {
+                       queued_retval = swd_ack_to_error_code(ack);
                        goto skip;
 
-               } else if (swd_cmd_queue[i].cmd & SWD_CMD_RnW) {
+               } else if (swd_cmd_queue[i].cmd & SWD_CMD_RNW) {
                        uint32_t data = buf_get_u32(swd_cmd_queue[i].trn_ack_data_parity_trn, 1 + 3, 32);
                        int parity = buf_get_u32(swd_cmd_queue[i].trn_ack_data_parity_trn, 1 + 3 + 32, 1);
 
@@ -1113,7 +1112,7 @@ static int ftdi_swd_run_queue(void)
                                goto skip;
                        }
 
-                       if (swd_cmd_queue[i].dst != NULL)
+                       if (swd_cmd_queue[i].dst)
                                *swd_cmd_queue[i].dst = data;
                }
        }
@@ -1138,7 +1137,7 @@ static void ftdi_swd_queue_cmd(uint8_t cmd, uint32_t *dst, uint32_t data, uint32
                 * pointers into the queue which may be invalid after the realloc. */
                queued_retval = ftdi_swd_run_queue();
                struct swd_cmd_queue_entry *q = realloc(swd_cmd_queue, swd_cmd_queue_alloced * 2 * sizeof(*swd_cmd_queue));
-               if (q != NULL) {
+               if (q) {
                        swd_cmd_queue = q;
                        swd_cmd_queue_alloced *= 2;
                        LOG_DEBUG("Increased SWD command queue to %zu elements", swd_cmd_queue_alloced);
@@ -1153,7 +1152,7 @@ static void ftdi_swd_queue_cmd(uint8_t cmd, uint32_t *dst, uint32_t data, uint32
 
        mpsse_clock_data_out(mpsse_ctx, &swd_cmd_queue[i].cmd, 0, 8, SWD_MODE);
 
-       if (swd_cmd_queue[i].cmd & SWD_CMD_RnW) {
+       if (swd_cmd_queue[i].cmd & SWD_CMD_RNW) {
                /* Queue a read transaction */
                swd_cmd_queue[i].dst = dst;
 
@@ -1178,20 +1177,20 @@ static void ftdi_swd_queue_cmd(uint8_t cmd, uint32_t *dst, uint32_t data, uint32
        }
 
        /* Insert idle cycles after AP accesses to avoid WAIT */
-       if (cmd & SWD_CMD_APnDP)
+       if (cmd & SWD_CMD_APNDP)
                mpsse_clock_data_out(mpsse_ctx, NULL, 0, ap_delay_clk, SWD_MODE);
 
 }
 
 static void ftdi_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_delay_clk)
 {
-       assert(cmd & SWD_CMD_RnW);
+       assert(cmd & SWD_CMD_RNW);
        ftdi_swd_queue_cmd(cmd, value, 0, ap_delay_clk);
 }
 
 static void ftdi_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_delay_clk)
 {
-       assert(!(cmd & SWD_CMD_RnW));
+       assert(!(cmd & SWD_CMD_RNW));
        ftdi_swd_queue_cmd(cmd, NULL, value, ap_delay_clk);
 }
 
@@ -1208,11 +1207,31 @@ static int ftdi_swd_switch_seq(enum swd_special_seq seq)
                ftdi_swd_swdio_en(true);
                mpsse_clock_data_out(mpsse_ctx, swd_seq_jtag_to_swd, 0, swd_seq_jtag_to_swd_len, SWD_MODE);
                break;
+       case JTAG_TO_DORMANT:
+               LOG_DEBUG("JTAG-to-DORMANT");
+               ftdi_swd_swdio_en(true);
+               mpsse_clock_data_out(mpsse_ctx, swd_seq_jtag_to_dormant, 0, swd_seq_jtag_to_dormant_len, SWD_MODE);
+               break;
        case SWD_TO_JTAG:
                LOG_DEBUG("SWD-to-JTAG");
                ftdi_swd_swdio_en(true);
                mpsse_clock_data_out(mpsse_ctx, swd_seq_swd_to_jtag, 0, swd_seq_swd_to_jtag_len, SWD_MODE);
                break;
+       case SWD_TO_DORMANT:
+               LOG_DEBUG("SWD-to-DORMANT");
+               ftdi_swd_swdio_en(true);
+               mpsse_clock_data_out(mpsse_ctx, swd_seq_swd_to_dormant, 0, swd_seq_swd_to_dormant_len, SWD_MODE);
+               break;
+       case DORMANT_TO_SWD:
+               LOG_DEBUG("DORMANT-to-SWD");
+               ftdi_swd_swdio_en(true);
+               mpsse_clock_data_out(mpsse_ctx, swd_seq_dormant_to_swd, 0, swd_seq_dormant_to_swd_len, SWD_MODE);
+               break;
+       case DORMANT_TO_JTAG:
+               LOG_DEBUG("DORMANT-to-JTAG");
+               ftdi_swd_swdio_en(true);
+               mpsse_clock_data_out(mpsse_ctx, swd_seq_dormant_to_jtag, 0, swd_seq_dormant_to_jtag_len, SWD_MODE);
+               break;
        default:
                LOG_ERROR("Sequence %d not supported", seq);
                return ERROR_FAIL;
@@ -1231,18 +1250,23 @@ static const struct swd_driver ftdi_swd = {
 
 static const char * const ftdi_transports[] = { "jtag", "swd", NULL };
 
-struct jtag_interface ftdi_interface = {
-       .name = "ftdi",
+static struct jtag_interface ftdi_interface = {
        .supported = DEBUG_CAP_TMS_SEQ,
-       .commands = ftdi_command_handlers,
+       .execute_queue = ftdi_execute_queue,
+};
+
+struct adapter_driver ftdi_adapter_driver = {
+       .name = "ftdi",
        .transports = ftdi_transports,
-       .swd = &ftdi_swd,
+       .commands = ftdi_command_handlers,
 
        .init = ftdi_initialize,
        .quit = ftdi_quit,
        .reset = ftdi_reset,
        .speed = ftdi_speed,
-       .speed_div = ftdi_speed_div,
        .khz = ftdi_khz,
-       .execute_queue = ftdi_execute_queue,
+       .speed_div = ftdi_speed_div,
+
+       .jtag_ops = &ftdi_interface,
+       .swd_ops = &ftdi_swd,
 };

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)