David Brownell <david-b@pacbell.net>:
[openocd.git] / src / jtag / arm-jtag-ew.c
index 4acea8d600c04053dcbd6bf74913b36a5e32bd47..98fd0d6229258fbd80892aa6a60c403044cc7ecb 100644 (file)
@@ -1,4 +1,4 @@
-// vim:ts=4 sw=4: 
+// vim:ts=4 sw=4:
 
 /***************************************************************************
  *   Copyright (C) 2009 by Dimitar Dimitrov <dinuxbg@gmail.com>            *
 #include "config.h"
 #endif
 
-#include "replacements.h"
-
-#include "jtag.h"
+#include "interface.h"
+#include "commands.h"
 #include <usb.h>
-#include <string.h>
-#include <ctype.h>
-
-/* system includes */
 
-#include "log.h"
-
-/* enable this to debug communication
- */
-#if 1
-#define _DEBUG_USB_COMMS_
-#define _DEBUG_JTAG_IO_
-#endif
-
-#ifdef _DEBUG_JTAG_IO_
-#define DEBUG_JTAG_IO(expr ...)        LOG_DEBUG(expr)
-#else
-#define DEBUG_JTAG_IO(expr ...)
-#endif
 
 #define USB_VID                                                0x15ba
 #define USB_PID                                                0x001e
@@ -92,7 +73,7 @@ static void armjtagew_end_state(tap_state_t state);
 static void armjtagew_state_move(void);
 static void armjtagew_path_move(int num_states, tap_state_t *path);
 static void armjtagew_runtest(int num_cycles);
-static void armjtagew_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command);
+static void armjtagew_scan(bool ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command);
 static void armjtagew_reset(int trst, int srst);
 //static void armjtagew_simple_command(u8 command);
 static int armjtagew_get_status(void);
@@ -153,33 +134,18 @@ static int armjtagew_execute_queue(void)
        {
                switch (cmd->type)
                {
-                       case JTAG_END_STATE:
-                               DEBUG_JTAG_IO("end_state: %i", cmd->cmd.end_state->end_state);
-
-                               if (cmd->cmd.end_state->end_state != TAP_INVALID)
-                               {
-                                       armjtagew_end_state(cmd->cmd.end_state->end_state);
-                               }
-                               break;
-
                        case JTAG_RUNTEST:
                                DEBUG_JTAG_IO( "runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, \
                                        cmd->cmd.runtest->end_state);
 
-                               if (cmd->cmd.runtest->end_state != TAP_INVALID)
-                               {
-                                       armjtagew_end_state(cmd->cmd.runtest->end_state);
-                               }
+                               armjtagew_end_state(cmd->cmd.runtest->end_state);
                                armjtagew_runtest(cmd->cmd.runtest->num_cycles);
                                break;
 
                        case JTAG_STATEMOVE:
                                DEBUG_JTAG_IO("statemove end in %i", cmd->cmd.statemove->end_state);
 
-                               if (cmd->cmd.statemove->end_state != TAP_INVALID)
-                               {
-                                       armjtagew_end_state(cmd->cmd.statemove->end_state);
-                               }
+                               armjtagew_end_state(cmd->cmd.statemove->end_state);
                                armjtagew_state_move();
                                break;
 
@@ -194,10 +160,7 @@ static int armjtagew_execute_queue(void)
                        case JTAG_SCAN:
                                DEBUG_JTAG_IO("scan end in %i", cmd->cmd.scan->end_state);
 
-                               if (cmd->cmd.scan->end_state != TAP_INVALID)
-                               {
-                                       armjtagew_end_state(cmd->cmd.scan->end_state);
-                               }
+                               armjtagew_end_state(cmd->cmd.scan->end_state);
 
                                scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
                                DEBUG_JTAG_IO("scan input, length = %d", scan_size);
@@ -259,14 +222,14 @@ static int armjtagew_speed(int speed)
        usb_out_buffer[0] = CMD_GET_TCK_FREQUENCY;
     result = armjtagew_usb_message(armjtagew_jtag_handle, 1, 4);
        speed_real = (int)buf_get_u32(usb_in_buffer,0,32);
-       if(result < 0) 
+       if(result < 0)
        {
         LOG_ERROR("ARM-JTAG-EW getting speed failed (%d)", result);
         return ERROR_JTAG_DEVICE_ERROR;
-       } 
+       }
        else
        {
-       LOG_INFO("Requested speed %dkHz, emulator reported %dkHz.", speed, speed_real);
+       LOG_INFO("Requested speed %dkHz, emulator reported %dkHz.", speed, speed_real);
        }
 
     return ERROR_OK;
@@ -353,8 +316,9 @@ static void armjtagew_state_move(void)
        int i;
        int tms = 0;
        u8 tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state());
+       int tms_count = tap_get_tms_path_len(tap_get_state(), tap_get_end_state());
 
-       for (i = 0; i < 7; i++)
+       for (i = 0; i < tms_count; i++)
        {
                tms = (tms_scan >> i) & 1;
                armjtagew_tap_append_step(tms, 0);
@@ -370,7 +334,7 @@ static void armjtagew_path_move(int num_states, tap_state_t *path)
        for (i = 0; i < num_states; i++)
        {
                /*
-                * TODO: The ARM-JTAG-EW hardware delays TDI with 3 TCK cycles when in RTCK mode. 
+                * TODO: The ARM-JTAG-EW hardware delays TDI with 3 TCK cycles when in RTCK mode.
                 * Either handle that here, or update the documentation with examples
                 * how to fix that in the configuration files.
                 */
@@ -421,7 +385,7 @@ static void armjtagew_runtest(int num_cycles)
        }
 }
 
-static void armjtagew_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command)
+static void armjtagew_scan(bool ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command)
 {
        tap_state_t saved_end_state;
 
@@ -540,7 +504,7 @@ static int armjtagew_get_version_info(void)
        usb_out_buffer[0] = CMD_GET_VERSION;
        result = armjtagew_usb_message(armjtagew_jtag_handle, 1, 4+15+256);
 
-       if (result != 0) 
+       if (result != 0)
        {
                LOG_ERROR("ARM-JTAG-EW command CMD_GET_VERSION failed (%d)\n", result);
                return ERROR_JTAG_DEVICE_ERROR;
@@ -827,7 +791,7 @@ static int armjtagew_usb_message(armjtagew_jtag_t *armjtagew_jtag, int out_lengt
        if (result == out_length)
        {
                result = armjtagew_usb_read(armjtagew_jtag, in_length);
-               if (result != in_length) 
+               if (result != in_length)
                {
                        LOG_ERROR("usb_bulk_read failed (requested=%d, result=%d)", in_length, result);
                        return -1;

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)