somehow dirty still accurate fix
authorhackbard <hackbard@hackdaworld.org>
Tue, 4 Sep 2007 20:17:03 +0000 (22:17 +0200)
committerhackbard <hackbard@hackdaworld.org>
Tue, 4 Sep 2007 20:17:03 +0000 (22:17 +0200)
fx2/cypress_fx2_xilprg.patch
fx2/fx2.c

index 8aa0971..23984e0 100644 (file)
@@ -1,6 +1,6 @@
-diff -Nur xilprg-0.5/makefile xilprg-new/makefile
+diff -Nur xilprg-0.5/makefile xilprg-patched/makefile
 --- xilprg-0.5/makefile        2006-08-23 07:41:20.000000000 +0200
-+++ xilprg-new/makefile        2007-04-07 17:09:16.000000000 +0200
++++ xilprg-patched/makefile    2007-09-04 20:59:03.000000000 +0200
 @@ -40,6 +40,7 @@
        $(SRC_DIR)/prgfile.cpp \\r
        $(SRC_DIR)/chip.cpp \\r
@@ -9,9 +9,9 @@ diff -Nur xilprg-0.5/makefile xilprg-new/makefile
        $(SRC_DIR)/cable.cpp \\r
        $(SRC_DIR)/digilent.cpp \\r
        $(SRC_DIR)/xilinx.cpp\r
-diff -Nur xilprg-0.5/src/cable.cpp xilprg-new/src/cable.cpp
+diff -Nur xilprg-0.5/src/cable.cpp xilprg-patched/src/cable.cpp
 --- xilprg-0.5/src/cable.cpp   2006-08-23 07:38:34.000000000 +0200
-+++ xilprg-new/src/cable.cpp   2007-04-07 17:20:55.000000000 +0200
++++ xilprg-patched/src/cable.cpp       2007-09-04 20:59:03.000000000 +0200
 @@ -49,6 +49,7 @@
  #include "chip.h"\r
  #include "cmdline.h"\r
@@ -30,10 +30,10 @@ diff -Nur xilprg-0.5/src/cable.cpp xilprg-new/src/cable.cpp
      {\r
          msgf(STR_INVALID_CABLE_DEF);\r
          return NULL;\r
-diff -Nur xilprg-0.5/src/onbusb.cpp xilprg-new/src/onbusb.cpp
+diff -Nur xilprg-0.5/src/onbusb.cpp xilprg-patched/src/onbusb.cpp
 --- xilprg-0.5/src/onbusb.cpp  1970-01-01 01:00:00.000000000 +0100
-+++ xilprg-new/src/onbusb.cpp  2007-09-04 21:39:30.000000000 +0200
-@@ -0,0 +1,119 @@
++++ xilprg-patched/src/onbusb.cpp      2007-09-04 22:12:47.000000000 +0200
+@@ -0,0 +1,124 @@
 +/*\r
 + * onboard usb\r
 + *\r
@@ -145,17 +145,22 @@ diff -Nur xilprg-0.5/src/onbusb.cpp xilprg-new/src/onbusb.cpp
 +\r
 +int onbusb::get_tdo()\r
 +{\r
++int i;
 +    /* send get tdo command */\r
-+    data=GET_TDO;\r
-+    usb_bulk_write(handle,0x01,&data,1,0);\r
-+\r
++    //data=GET_TDO;\r
++    //usb_bulk_write(handle,0x01,&data,1,0);\r
 +    /* receive tdo */\r
++    // dirty! 1 dummy read is enough. my guess:
++    //  - either we have to wait that time for correct state at tdi
++    //  - or/and it's due to the EP1INBUF=1 (buf size?) todo: ez-usb doc!
++    //  - initial wrong states don't harm
++    for(i=0;i<1;i++) usb_bulk_read(handle,0x81,&data,1,1);
 +    usb_bulk_read(handle,0x81,&data,1,0);\r
 +    return data & 0x01 ? 1 : 0;\r
 +}\r
-diff -Nur xilprg-0.5/src/onbusb.h xilprg-new/src/onbusb.h
+diff -Nur xilprg-0.5/src/onbusb.h xilprg-patched/src/onbusb.h
 --- xilprg-0.5/src/onbusb.h    1970-01-01 01:00:00.000000000 +0100
-+++ xilprg-new/src/onbusb.h    2007-09-04 21:17:18.000000000 +0200
++++ xilprg-patched/src/onbusb.h        2007-09-04 20:59:03.000000000 +0200
 @@ -0,0 +1,43 @@
 +/*\r
 + * onboard usb\r
@@ -200,9 +205,9 @@ diff -Nur xilprg-0.5/src/onbusb.h xilprg-new/src/onbusb.h
 +};\r
 +\r
 +#endif\r
-diff -Nur xilprg-0.5/src/strtable.cpp xilprg-new/src/strtable.cpp
+diff -Nur xilprg-0.5/src/strtable.cpp xilprg-patched/src/strtable.cpp
 --- xilprg-0.5/src/strtable.cpp        2006-08-23 07:38:34.000000000 +0200
-+++ xilprg-new/src/strtable.cpp        2007-04-07 16:56:25.000000000 +0200
++++ xilprg-patched/src/strtable.cpp    2007-09-04 20:59:03.000000000 +0200
 @@ -137,7 +137,7 @@
      //STR_CMD_CABLE\r
      "cable\0" \r
index a8f0467..49f0da5 100644 (file)
--- a/fx2/fx2.c
+++ b/fx2/fx2.c
@@ -252,21 +252,17 @@ void main() {
        fx2_init();
 
        /* jtag by polling ep1 */
+
        while(1) {
                if(!(EP1OUTCS&BUSY)) {
+                       set=IOD;
                        buf=EP1OUTBUF[0];
-                       if(buf!=GET_TDO) {
-                               set=(IOD&(~0x1c))|(buf&0x1c);
-                               IOD=set;
-                               EP1OUTBC=1;
-                       }
-                       else {
-                               while(EP1INCS&BUSY)
-                                       continue;
-                               buf=IOD&0x01?1:0;
-                               EP1INBUF[0]=buf;
-                               EP1INBC=1;
-                       }
+                       IOD=(IOD&(~0x1c))|(buf&0x1c);
+                       EP1OUTBC=1;
+               }
+               if(!(EP1INCS&BUSY)) {
+                       EP1INBUF[0]=IOD&0x01;
+                       EP1INBC=1;
                }
        }