]> git.sur5r.net Git - openocd/commitdiff
- renamed jtag_interface_t.support_statemove to jtag_interface_t.support_pathmove...
authordrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 17 Aug 2006 14:53:15 +0000 (14:53 +0000)
committerdrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Thu, 17 Aug 2006 14:53:15 +0000 (14:53 +0000)
- fixed small bug in str7x.c that printed an address instead of the target number in an error message
- added support for Olimex ARM-USB-OCD. The new ft2232 layout is called "olimex-jtag"

git-svn-id: svn://svn.berlios.de/openocd/trunk@87 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/flash/str7x.c
src/jtag/amt_jtagaccel.c
src/jtag/bitbang.c
src/jtag/ep93xx.c
src/jtag/ft2232.c
src/jtag/jtag.c
src/jtag/jtag.h
src/jtag/parport.c

index 4d8d02e4f4f9ab9cdb94b7e01d163105574c7dc4..b70812083db79df8d562da0a0f99db88af6d66df 100644 (file)
@@ -166,7 +166,7 @@ int str7x_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char
        str7x_info->target = get_target_by_num(strtoul(args[6], NULL, 0));
        if (!str7x_info->target)
        {
-               ERROR("no target '%i' configured", args[6]);
+               ERROR("no target '%s' configured", args[6]);
                exit(-1);
        }
 
index d788728b1e624a121022ca077860c4b9195039a3..dde09ff55d00a790120a1eb19a747beb2b772cee 100644 (file)
@@ -117,7 +117,7 @@ jtag_interface_t amt_jtagaccel_interface =
        
        .execute_queue = amt_jtagaccel_execute_queue,
 
-       .support_statemove = 0,
+       .support_pathmove = 0,
 
        .speed = amt_jtagaccel_speed,   
        .register_commands = amt_jtagaccel_register_commands,
index 3d49d186dd4603081562976c575fd0aab517700b..2065f62ab07439aa6b6074101a1d535343a00fe1 100644 (file)
@@ -142,7 +142,11 @@ void bitbang_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size)
 
        for (bit_cnt = 0; bit_cnt < scan_size; bit_cnt++)
        {
-               if ((buffer[bit_cnt/8] >> (bit_cnt % 8)) & 0x1) {
+               /* if we're just reading the scan, but don't care about the output
+                * default to outputting 'low', this also makes valgrind traces more readable,
+                * as it removes the dependency on an uninitialised value
+                */ 
+               if ((type != SCAN_IN) && ((buffer[bit_cnt/8] >> (bit_cnt % 8)) & 0x1)) {
                        bitbang_interface->write(0, (bit_cnt==scan_size-1) ? 1 : 0, 1);
                        bitbang_interface->write(1, (bit_cnt==scan_size-1) ? 1 : 0, 1);
                } else {
index e68e3d15893e400aa84f84632d42227fdc6d6366..38763d2ed422505e9b4941c3e8e72d406a9e2760 100644 (file)
@@ -67,7 +67,7 @@ jtag_interface_t ep93xx_interface =
        
        .execute_queue = bitbang_execute_queue,
 
-       .support_statemove = 0,
+       .support_pathmove = 0,
 
        .speed = ep93xx_speed,  
        .register_commands = ep93xx_register_commands,
index 862003f5b292cbaeb1b5bee92ac4e14218278919..7d2fac08900a0f4123d107fb7535d89dce7fe6f5 100644 (file)
@@ -83,19 +83,29 @@ typedef struct ft2232_layout_s
        char* name;
        int(*init)(void);
        void(*reset)(int trst, int srst);
+       void(*blink)(void);
 } ft2232_layout_t;
 
+/* init procedures for supported layouts */
 int usbjtag_init(void);
 int jtagkey_init(void);
+int olimex_jtag_init(void);
+
+/* reset procedures for supported layouts */
 void usbjtag_reset(int trst, int srst);
 void jtagkey_reset(int trst, int srst);
+void olimex_jtag_reset(int trst, int srst);
+
+/* blink procedures for layouts that support a blinking led */
+void olimex_jtag_blink(void);
 
 ft2232_layout_t ft2232_layouts[] =
 {
-       {"usbjtag", usbjtag_init, usbjtag_reset},
-       {"jtagkey", jtagkey_init, jtagkey_reset},
-       {"jtagkey_prototype_v1", jtagkey_init, jtagkey_reset},
-       {"signalyzer", usbjtag_init, usbjtag_reset},
+       {"usbjtag", usbjtag_init, usbjtag_reset, NULL},
+       {"jtagkey", jtagkey_init, jtagkey_reset, NULL},
+       {"jtagkey_prototype_v1", jtagkey_init, jtagkey_reset, NULL},
+       {"signalyzer", usbjtag_init, usbjtag_reset, NULL},
+       {"olimex-jtag", olimex_jtag_init, olimex_jtag_reset, olimex_jtag_blink},
        {NULL, NULL, NULL},
 };
 
@@ -128,7 +138,7 @@ jtag_interface_t ft2232_interface =
        
        .execute_queue = ft2232_execute_queue,
        
-       .support_statemove = 1,
+       .support_pathmove = 1,
        
        .speed = ft2232_speed,
        .register_commands = ft2232_register_commands,
@@ -674,6 +684,40 @@ void jtagkey_reset(int trst, int srst)
        DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction);
 }
 
+void olimex_jtag_reset(int trst, int srst)
+{
+       if (trst == 1)
+       {
+               cur_state = TAP_TLR;
+               if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
+                       high_output &= ~nTRSTnOE;
+               else
+                       high_output &= ~nTRST;
+       }
+       else if (trst == 0)
+       {
+               if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
+                       high_output |= nTRSTnOE;
+               else
+                       high_output |= nTRST;
+       }
+
+    if (srst == 1)
+    {
+        high_output |= nSRST;
+    }
+    else if (srst == 0)
+    {
+        high_output &= ~nSRST;
+    }
+
+    /* command "set data bits high byte" */
+    BUFFER_ADD = 0x82;
+    BUFFER_ADD = high_output;
+    BUFFER_ADD = high_direction;
+    DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction);
+}
+
 int ft2232_execute_queue()
 {
        jtag_command_t *cmd = jtag_command_queue; /* currently processed command */
@@ -687,6 +731,10 @@ int ft2232_execute_queue()
 
        ft2232_buffer_size = 0;
        ft2232_expect_read = 0;
+       
+       /* blink, if the current layout has that feature */
+       if (layout->blink)
+               layout->blink();
 
        while (cmd)
        {
@@ -1170,7 +1218,7 @@ int jtagkey_init(void)
        }
        
        /* initialize high port */
-       buf[0] = 0x82; /* command "set data bits low byte" */
+       buf[0] = 0x82; /* command "set data bits high byte" */
        buf[1] = high_output; /* value */
        buf[2] = high_direction;   /* all outputs (xRST and xRSTnOE) */
        DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
@@ -1184,6 +1232,93 @@ int jtagkey_init(void)
        return ERROR_OK;
 }
 
+int olimex_jtag_init(void)
+{
+       u8 buf[3];
+       u32 bytes_written;
+       
+       low_output = 0x08;
+       low_direction = 0x1b;
+       
+       /* initialize low byte for jtag */
+       buf[0] = 0x80; /* command "set data bits low byte" */
+       buf[1] = low_output; /* value (TMS=1,TCK=0, TDI=0, nOE=0) */
+       buf[2] = low_direction; /* dir (output=1), TCK/TDI/TMS=out, TDO=in, nOE=out */
+       DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
+       
+       if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3))
+       {
+               ERROR("couldn't initialize FT2232 with 'JTAGkey' layout"); 
+               return ERROR_JTAG_INIT_FAILED;
+       }
+       
+       nTRST = 0x01;
+       nTRSTnOE = 0x4;
+       nSRST = 0x02;
+       nSRSTnOE = 0x00; /* no output enable for nSRST */
+
+       high_output = 0x0;
+       high_direction = 0x0f;
+
+       if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
+       {
+               high_output |= nTRSTnOE;
+               high_output &= ~nTRST;
+       }
+       else
+       {
+               high_output &= ~nTRSTnOE;
+               high_output |= nTRST;
+       }
+       
+       if (jtag_reset_config & RESET_SRST_PUSH_PULL)
+       {
+               ERROR("can't set nSRST to push-pull on the Olimex ARM-USB-OCD");
+       }
+       else
+       {
+               high_output &= ~nSRST;
+       }
+       
+       /* turn red LED on */
+       high_output |= 0x08;
+       
+       /* initialize high port */
+       buf[0] = 0x82; /* command "set data bits high byte" */
+       buf[1] = high_output; /* value */
+       buf[2] = high_direction;   /* all outputs (xRST and xRSTnOE) */
+       DEBUG("%2.2x %2.2x %2.2x", buf[0], buf[1], buf[2]);
+       
+       if (((ft2232_write(buf, 3, &bytes_written)) != ERROR_OK) || (bytes_written != 3))
+       {
+               ERROR("couldn't initialize FT2232 with 'JTAGkey' layout"); 
+               return ERROR_JTAG_INIT_FAILED;
+       }
+       
+       return ERROR_OK;
+}
+
+void olimex_jtag_blink(void)
+{
+       /* Olimex ARM-USB-OCD has a LED connected to ACBUS3
+        * ACBUS3 is bit 3 of the GPIOH port
+        */
+       if (high_output & 0x08)
+       {
+               /* set port pin high */
+               high_output &= 0x07;
+       }
+       else
+       {
+               /* set port pin low */
+               high_output |= 0x08;
+       }
+       
+       BUFFER_ADD = 0x82;
+       BUFFER_ADD = high_output;
+       BUFFER_ADD = high_direction;
+}
+
 int ft2232_quit(void)
 {
 #if BUILD_FT2232_FTD2XX == 1
index a60aacd0a4c37464054107ee48b4bdc9a92d1739..95818f0781637bc7629ddc1dd0cd333a142aed89 100644 (file)
@@ -694,7 +694,7 @@ int jtag_add_pathmove(int num_states, enum tap_state *path)
                return ERROR_JTAG_NOT_IMPLEMENTED;
        }
        
-       if (jtag->support_statemove)
+       if (jtag->support_pathmove)
        {
                /* allocate memory for a new list member */
                *last_cmd = cmd_queue_alloc(sizeof(jtag_command_t));
index 0d71301f90c30be760478a4020eab0bbabc64b67..19f81ce63579773501e2fc53db160da9b4c7c008 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "command.h"
 
-#if 0
+#if 1
 #define _DEBUG_JTAG_IO_
 #endif
 
@@ -180,7 +180,7 @@ typedef struct jtag_interface_s
        
        /* optional command support 
         */
-       int support_statemove;
+       int support_pathmove;
        
        /* interface initalization
         */
index 4b0b193cd0aa899d7a110000c8f45787b5ae41d7..c87f98e4ae6a5ed5eeb9b2e10fb6361429e098b7 100644 (file)
@@ -138,7 +138,7 @@ jtag_interface_t parport_interface =
        
        .execute_queue = bitbang_execute_queue,
 
-       .support_statemove = 0,
+       .support_pathmove = 1,
 
        .speed = parport_speed, 
        .register_commands = parport_register_commands,