📄 usb_jtag.patch
字号:
Index: include/cable.h===================================================================--- include/cable.h (.../vendor/openwince) (Revision 49)+++ include/cable.h (.../branches/openwince-usb_jtag) (Revision 49)@@ -45,6 +45,7 @@ void (*done)( cable_t * ); void (*clock)( cable_t *, int, int ); int (*get_tdo)( cable_t * );+ int (*transfer)( cable_t *, int, char *, char * ); int (*set_trst)( cable_t *, int ); int (*get_trst)( cable_t * ); };@@ -63,6 +64,7 @@ int cable_get_tdo( cable_t *cable ); int cable_set_trst( cable_t *cable, int trst ); int cable_get_trst( cable_t *cable );+int cable_transfer( cable_t *cable, int len, char *in, char *out ); extern uint32_t frequency; void cable_wait( void );Index: src/cmd/cable.c===================================================================--- src/cmd/cable.c (.../vendor/openwince) (Revision 49)+++ src/cmd/cable.c (.../branches/openwince-usb_jtag) (Revision 49)@@ -85,15 +85,19 @@ printf( _( "Usage: %s PORTADDR CABLE\n" "Usage: %s DEV CABLE\n"+ "Usage: %s VID:PID:S/N CABLE\n" "Select JTAG cable connected to parallel port.\n" "\n" "PORTADDR parallel port address (e.g. 0x378)\n" "CABLE cable type\n" "DEV ppdev device (e.g. /dev/parport0)\n"+ "VID empty or USB vendor ID, hex (e.g. 09FB)\n"+ "PID empty or USB product ID, hex (e.g. 6001)\n"+ "S/N empty or USB product serial number, ASCII\n" "\n" "List of supported cables:\n" "%-13s No cable connected\n"- ), "cable parallel", "cable ppdev", "none" );+ ), "cable parallel", "cable ppdev", "cable ftdi", "none" ); for (i = 0; cable_drivers[i]; i++) printf( _("%-13s %s\n"), cable_drivers[i]->name, _(cable_drivers[i]->description) );Index: src/tap/tap.c===================================================================--- src/tap/tap.c (.../vendor/openwince) (Revision 49)+++ src/tap/tap.c (.../branches/openwince-usb_jtag) (Revision 49)@@ -56,11 +56,22 @@ /* Capture-DR, Capture-IR, Shift-DR, Shift-IR, Exit2-DR or Exit2-IR state */ if (tap_state( chain ) & TAPSTAT_CAPTURE) chain_clock( chain, 0, 0 ); /* save last TDO bit :-) */- for (i = 0; i < in->len; i++) {++ i = in->len;+ if(exit) i--;+ if(out && out->len < i) i = out->len;++ if(out)+ cable_transfer( chain->cable, i, in->data, out->data );+ else+ cable_transfer( chain->cable, i, in->data, NULL );++ for (; i < in->len; i++) { if (out && (i < out->len)) out->data[i] = cable_get_tdo( chain->cable ); chain_clock( chain, (exit && ((i + 1) == in->len)) ? 1 : 0, in->data[i] ); /* Shift (& Exit1) */ }+ /* Shift-DR, Shift-IR, Exit1-DR or Exit1-IR state */ if (exit) { chain_clock( chain, 1, 0 ); /* Update-DR or Update-IR */Index: src/tap/cable/ea253.c===================================================================--- src/tap/cable/ea253.c (.../vendor/openwince) (Revision 49)+++ src/tap/cable/ea253.c (.../branches/openwince-usb_jtag) (Revision 49)@@ -105,6 +105,7 @@ generic_done, ea253_clock, ea253_get_tdo,+ generic_transfer, ea253_set_trst, generic_get_trst };Index: src/tap/cable/triton.c===================================================================--- src/tap/cable/triton.c (.../vendor/openwince) (Revision 49)+++ src/tap/cable/triton.c (.../branches/openwince-usb_jtag) (Revision 49)@@ -116,6 +116,7 @@ generic_done, triton_clock, triton_get_tdo,+ generic_transfer, triton_set_trst, generic_get_trst };Index: src/tap/cable/byteblaster.c===================================================================--- src/tap/cable/byteblaster.c (.../vendor/openwince) (Revision 49)+++ src/tap/cable/byteblaster.c (.../branches/openwince-usb_jtag) (Revision 49)@@ -131,6 +131,7 @@ generic_done, byteblaster_clock, byteblaster_get_tdo,+ generic_transfer, byteblaster_set_trst, generic_get_trst };Index: src/tap/cable/ei012.c===================================================================--- src/tap/cable/ei012.c (.../vendor/openwince) (Revision 49)+++ src/tap/cable/ei012.c (.../branches/openwince-usb_jtag) (Revision 49)@@ -107,6 +107,7 @@ generic_done, ei012_clock, ei012_get_tdo,+ generic_transfer, ei012_set_trst, generic_get_trst };Index: src/tap/cable/wiggler.c===================================================================--- src/tap/cable/wiggler.c (.../vendor/openwince) (Revision 49)+++ src/tap/cable/wiggler.c (.../branches/openwince-usb_jtag) (Revision 49)@@ -110,6 +110,7 @@ generic_done, wiggler_clock, wiggler_get_tdo,+ generic_transfer, wiggler_set_trst, generic_get_trst };Index: src/tap/cable/arcom.c===================================================================--- src/tap/cable/arcom.c (.../vendor/openwince) (Revision 49)+++ src/tap/cable/arcom.c (.../branches/openwince-usb_jtag) (Revision 49)@@ -105,6 +105,7 @@ generic_done, arcom_clock, arcom_get_tdo,+ generic_transfer, arcom_set_trst, generic_get_trst };Index: src/tap/cable/generic.h===================================================================--- src/tap/cable/generic.h (.../vendor/openwince) (Revision 49)+++ src/tap/cable/generic.h (.../branches/openwince-usb_jtag) (Revision 49)@@ -40,6 +40,7 @@ void generic_disconnect( cable_t *cable ); void generic_cable_free( cable_t *cable ); void generic_done( cable_t *cable );+int generic_transfer( cable_t *cable, int len, char *in, char *out ); int generic_get_trst( cable_t *cable ); #endif /* GENERIC_H */Index: src/tap/cable/mpcbdm.c===================================================================--- src/tap/cable/mpcbdm.c (.../vendor/openwince) (Revision 49)+++ src/tap/cable/mpcbdm.c (.../branches/openwince-usb_jtag) (Revision 49)@@ -111,6 +111,7 @@ generic_done, mpcbdm_clock, mpcbdm_get_tdo,+ generic_transfer, mpcbdm_set_trst, generic_get_trst };Index: src/tap/cable/keithkoep.c===================================================================--- src/tap/cable/keithkoep.c (.../vendor/openwince) (Revision 49)+++ src/tap/cable/keithkoep.c (.../branches/openwince-usb_jtag) (Revision 49)@@ -114,6 +114,7 @@ generic_done, keithkoep_clock, keithkoep_get_tdo,+ generic_transfer, keithkoep_set_trst, generic_get_trst };Index: src/tap/cable/lattice.c===================================================================--- src/tap/cable/lattice.c (.../vendor/openwince) (Revision 49)+++ src/tap/cable/lattice.c (.../branches/openwince-usb_jtag) (Revision 49)@@ -97,6 +97,7 @@ generic_done, lattice_clock, lattice_get_tdo,+ generic_transfer, lattice_set_trst, generic_get_trst };Index: src/tap/cable/usbblaster.c===================================================================--- src/tap/cable/usbblaster.c (.../vendor/openwince) (Revision 0)+++ src/tap/cable/usbblaster.c (.../branches/openwince-usb_jtag) (Revision 49)@@ -0,0 +1,163 @@+/*+ * $Id: usbblaster.c,v 1.8 2003/08/22 22:42:02 telka Exp $+ *+ * Altera USB-Blaster<tm> Cable Driver+ * Copyright (C) 2006 K. Waschk+ *+ * 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, write to the Free Software+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA+ * 02111-1307, USA.+ *+ * Written by Kolja Waschk, 2006; http://www.ixo.de+ *+ */++#include "sysdep.h"++#include "cable.h"+#include "parport.h"+#include "chain.h"++#include "generic.h"++#define TCK 0+#define TMS 1+#define TDI 4+#define READ 6+#define SHMODE 7+#define OTHERS ((1<<2)|(1<<3)|(1<<5))++#define TDO 0++static int+usbblaster_init( cable_t *cable )+{+ int i;++ if (parport_open( cable->port ))+ return -1;++ for(i=0;i<64;i++)+ parport_set_data( cable->port, 0 );++ parport_set_control( cable->port, 1 ); // flush+ parport_set_control( cable->port, 0 ); // noflush++ return 0;+}++static void+usbblaster_clock( cable_t *cable, int tms, int tdi )+{+ tms = tms ? 1 : 0;+ tdi = tdi ? 1 : 0;++ parport_set_data( cable->port, OTHERS | (0 << TCK) | (tms << TMS) | (tdi << TDI) );+ parport_set_data( cable->port, OTHERS | (1 << TCK) | (tms << TMS) | (tdi << TDI) );+ parport_set_control( cable->port, 1 ); // flush+ parport_set_control( cable->port, 0 ); // noflush+}++static int+usbblaster_get_tdo( cable_t *cable )+{+ parport_set_control( cable->port, 0 ); // noflush+ parport_set_data( cable->port, OTHERS ); /* TCK low */+ parport_set_data( cable->port, OTHERS | (1 << READ) ); /* TCK low */+ parport_set_control( cable->port, 1 ); // flush+ parport_set_control( cable->port, 0 ); // noflush+ return ( parport_get_data( cable->port ) & (1 << TDO)) ? 1 : 0;+}++static int+usbblaster_set_trst( cable_t *cable, int trst )+{+ return 1;+}++static int+usbblaster_transfer( cable_t *cable, int len, char *in, char *out )+{+ int in_offset = 0;+ int out_offset = 0;+ parport_set_control( cable->port, 0 );+ parport_set_data( cable->port, OTHERS ); /* TCK low */++ while(len - in_offset >= 8)+ {+ int i;+ int chunkbytes = ((len-in_offset)>>3);+ if(chunkbytes > 63) chunkbytes = 63;++ if(out)+ parport_set_data( cable->port,(1<<SHMODE)|(1<<READ)|chunkbytes);+ else+ parport_set_data( cable->port,(1<<SHMODE)|(0<<READ)|chunkbytes);++ for(i=0; i<chunkbytes; i++)+ {+ int j;+ unsigned char b = 0;+ for(j=1; j<256; j<<=1) if(in[in_offset++]) b |= j;+ parport_set_data( cable->port, b );+ };++ if(out) + {+ parport_set_control( cable->port, 1 ); // flush+ parport_set_control( cable->port, 0 ); ++ for(i=0; i<chunkbytes; i++)+ {+ int j;+ unsigned char b = parport_get_data( cable->port );+ for(j=1; j<256; j<<=1) out[out_offset++] = (b & j) ? 1:0;+ };+ };+ };++ while(len > in_offset)+ {+ char tdi = in[in_offset++] ? 1 : 0;+ parport_set_data( cable->port, OTHERS ); /* TCK low */+ if(out) parport_set_data( cable->port, OTHERS | (1 << READ) | (tdi << TDI)); + parport_set_data( cable->port, OTHERS | (1 << TCK) | (tdi << TDI));+ }++ if(out)+ {+ parport_set_control( cable->port, 1 ); // flush+ parport_set_control( cable->port, 0 );++ while(len > out_offset)+ out[out_offset++] = ( parport_get_data( cable->port ) & (1 << TDO)) ? 1 : 0;+ }++ return 0;+}++cable_driver_t usbblaster_cable_driver = {+ "UsbBlaster",+ N_("Altera USB-Blaster Cable"),+ generic_connect,+ generic_disconnect,+ generic_cable_free,+ usbblaster_init,+ generic_done,+ usbblaster_clock,+ usbblaster_get_tdo,+ usbblaster_transfer,+ usbblaster_set_trst,+ generic_get_trst+};Index: src/tap/cable/dlc5.c===================================================================--- src/tap/cable/dlc5.c (.../vendor/openwince) (Revision 49)+++ src/tap/cable/dlc5.c (.../branches/openwince-usb_jtag) (Revision 49)@@ -102,6 +102,7 @@ generic_done, dlc5_clock, dlc5_get_tdo,+ generic_transfer, dlc5_set_trst, generic_get_trst };Index: src/tap/cable/generic.c===================================================================--- src/tap/cable/generic.c (.../vendor/openwince) (Revision 49)+++ src/tap/cable/generic.c (.../branches/openwince-usb_jtag) (Revision 49)@@ -71,6 +71,24 @@ } int+generic_transfer( cable_t *cable, int len, char *in, char *out )+{+ int i;++ if(out)+ for(i=0; i<len; i++) {+ out[i] = cable_get_tdo( cable );+ cable_clock( cable, 0, in[i] );+ }+ else+ for(i=0; i<len; i++) {+ cable_clock( cable, 0, in[i] );+ }++ return i;+}++int generic_get_trst( cable_t *cable ) { return PARAM_TRST(cable);Index: src/tap/cable.c===================================================================--- src/tap/cable.c (.../vendor/openwince) (Revision 49)+++ src/tap/cable.c (.../branches/openwince-usb_jtag) (Revision 49)@@ -33,6 +33,7 @@ extern cable_driver_t arcom_cable_driver; extern cable_driver_t byteblaster_cable_driver;+extern cable_driver_t usbblaster_cable_driver; extern cable_driver_t dlc5_cable_driver; extern cable_driver_t ea253_cable_driver; extern cable_driver_t ei012_cable_driver;@@ -47,6 +48,7 @@ cable_driver_t *cable_drivers[] = { &arcom_cable_driver, &byteblaster_cable_driver,+ &usbblaster_cable_driver, &dlc5_cable_driver, &ea253_cable_driver, &ei012_cable_driver,@@ -100,6 +102,14 @@ return cable->driver->get_trst( cable ); } +int+cable_transfer( cable_t *cable, int len, char *in, char *out )+{+ int r;+ r=cable->driver->transfer( cable, len, in, out );+ return r;+}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -