From dbd95cb8a27ebe04ab7b788adbb83291bffb3e4f Mon Sep 17 00:00:00 2001 From: drath Date: Tue, 31 Jul 2007 10:07:32 +0000 Subject: - calculate cycles since last executed instruction when cycle-accurate tracing is enabled - increase memory pseudo-image cache size to 1024 byte for improved trace analysis performance - added OpenOCD+trace as an ETM capture driver example implementation - new usbprog driver (thanks to Benedikt Sauter) git-svn-id: svn://svn.berlios.de/openocd/trunk@186 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/jtag/usbprog.c | 77 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 27 deletions(-) (limited to 'src/jtag') diff --git a/src/jtag/usbprog.c b/src/jtag/usbprog.c index 4f7cfdd6..cdf32704 100644 --- a/src/jtag/usbprog.c +++ b/src/jtag/usbprog.c @@ -1,6 +1,14 @@ /*************************************************************************** * Copyright (C) 2007 by Benedikt Sauter sauter@ixbat.de * - * based on Dominic Rath's usbprog.c * + * based on Dominic Rath's amt_jtagaccel.c * + * * + * usbprog is a free programming adapter. You can easily install * + * different firmware versions from an "online pool" over USB. * + * The adapter can be used for programming and debugging AVR and ARM * + * processors, as USB to RS232 converter, as JTAG interface or as * + * simple I/O interface (5 lines). * + * * + * http://www.embedded-projects.net/usbprog * * * * 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 * @@ -17,6 +25,7 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -33,6 +42,12 @@ #define VID 0x1781 #define PID 0x0c62 +// Pins at usbprog +#define TDO_BIT 0 +#define TDI_BIT 3 +#define TCK_BIT 2 +#define TMS_BIT 1 + int usbprog_execute_queue(void); int usbprog_speed(int speed); int usbprog_register_commands(struct command_context_s *cmd_ctx); @@ -49,23 +64,14 @@ void usbprog_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size); jtag_interface_t usbprog_interface = { .name = "usbprog", - .execute_queue = usbprog_execute_queue, - .support_pathmove = 0, - .speed = usbprog_speed, .register_commands = usbprog_register_commands, .init = usbprog_init, .quit = usbprog_quit }; -// pins from avr -#define TDO_BIT 0 -#define TDI_BIT 3 -#define TCK_BIT 2 -#define TMS_BIT 1 - #define UNKOWN_COMMAND 0x00 #define PORT_DIRECTION 0x01 #define PORT_SET 0x02 @@ -76,6 +82,7 @@ jtag_interface_t usbprog_interface = #define READ_TDO 0x07 #define WRITE_AND_READ 0x08 #define WRITE_TMS 0x09 +#define WRITE_TMS_CHAIN 0x0A struct usbprog_jtag { @@ -95,6 +102,11 @@ void usbprog_jtag_write_tdi(struct usbprog_jtag *usbprog_jtag, char * buffer, in void usbprog_jtag_write_and_read(struct usbprog_jtag *usbprog_jtag, char * buffer, int size); void usbprog_jtag_write_tms(struct usbprog_jtag *usbprog_jtag, char tms_scan); +char tms_chain[64]; +int tms_chain_index; +void usbprog_jtag_tms_collect(char tms_scan); +void usbprog_jtag_tms_send(struct usbprog_jtag *usbprog_jtag); + void usbprog_write(int tck, int tms, int tdi); void usbprog_reset(int trst, int srst); @@ -201,6 +213,7 @@ int usbprog_init(void) { usbprog_jtag_handle = usbprog_jtag_open(); + tms_chain_index=0; if(usbprog_jtag_handle==0){ ERROR("Can't find USB JTAG Interface! Please check connection and permissions."); return ERROR_JTAG_INIT_FAILED; @@ -245,11 +258,6 @@ void usbprog_state_move(void) { tms = (tms_scan >> i) & 1; } - // moved into firmware - // INFO("4"); - // koennte man in tms verlagern - //usbprog_write(0, tms, 0); - cur_state = end_state; } @@ -295,23 +303,25 @@ void usbprog_runtest(int num_cycles) enum tap_state saved_end_state = end_state; - /* only do a state_move when we're not already in RTI */ + + /* only do a state_move when we're not already in RTI */ if (cur_state != TAP_RTI) { usbprog_end_state(TAP_RTI); - //INFO("6"); usbprog_state_move(); } /* execute num_cycles */ if(num_cycles>0) { - INFO("5"); usbprog_write(0, 0, 0); } + else { + usbprog_jtag_tms_send(usbprog_jtag_handle); + } + for (i = 0; i < num_cycles; i++) { - INFO("3"); usbprog_write(1, 0, 0); usbprog_write(0, 0, 0); } @@ -336,10 +346,11 @@ void usbprog_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size) else usbprog_end_state(TAP_SD); - //INFO("7"); usbprog_state_move(); usbprog_end_state(saved_end_state); + usbprog_jtag_tms_send(usbprog_jtag_handle); + if (type == SCAN_OUT) { usbprog_jtag_write_tdi(usbprog_jtag_handle,buffer, scan_size); } @@ -363,8 +374,6 @@ void usbprog_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size) void usbprog_write(int tck, int tms, int tdi) { - //INFO("->USBPROG SLICE"); - //DEBUG("slice tck %i tms %i tdi %i",tck,tms,tdi); unsigned char output_value=0x00; if (tms) @@ -380,7 +389,6 @@ void usbprog_write(int tck, int tms, int tdi) /* (1) assert or (0) deassert reset lines */ void usbprog_reset(int trst, int srst) { - //INFO("->USBPROG RESET"); DEBUG("trst: %i, srst: %i", trst, srst); if(trst) @@ -574,10 +582,7 @@ void usbprog_jtag_write_tdi(struct usbprog_jtag *usbprog_jtag, char * buffer, in void usbprog_jtag_write_tms(struct usbprog_jtag *usbprog_jtag, char tms_scan) { - char tmp[2]; // fastes packet size for usb controller - tmp[0] = WRITE_TMS; - tmp[1] = tms_scan; - usb_bulk_write(usbprog_jtag->usb_handle,3,tmp,2,1000); + usbprog_jtag_tms_collect(tms_scan); } @@ -630,3 +635,21 @@ int usbprog_jtag_get_bit(struct usbprog_jtag *usbprog_jtag, int bit) return 0; } +void usbprog_jtag_tms_collect(char tms_scan){ + tms_chain[tms_chain_index]=tms_scan; + tms_chain_index++; +} + +void usbprog_jtag_tms_send(struct usbprog_jtag *usbprog_jtag){ + int i; + if(tms_chain_index>0) { + char tmp[tms_chain_index+2]; + tmp[0] = WRITE_TMS_CHAIN; + tmp[1] = (char)(tms_chain_index); + for(i=0;iusb_handle,3,tmp,tms_chain_index+2,1000); + tms_chain_index=0; + } +} + -- cgit v1.2.3