test commit
authorhackbard <hackbard@staubsauger.localdomain>
Tue, 4 Sep 2007 19:42:46 +0000 (21:42 +0200)
committerhackbard <hackbard@staubsauger.localdomain>
Tue, 4 Sep 2007 19:42:46 +0000 (21:42 +0200)
fx2/cypress_fx2_xilprg.patch
fx2/fx2.c

index 7d5ace2..8aa0971 100644 (file)
@@ -1,218 +1,6 @@
-diff -Nur xilprg-0.5/cypress_fx2_xilprg.patch xilprg-new/cypress_fx2_xilprg.patch
---- xilprg-0.5/cypress_fx2_xilprg.patch        1970-01-01 01:00:00.000000000 +0100
-+++ xilprg-new/cypress_fx2_xilprg.patch        2007-04-10 10:33:17.000000000 +0200
-@@ -0,0 +1,208 @@
-+diff -Nur xilprg-0.5/makefile xilprg-new/makefile
-+--- xilprg-0.5/makefile       2006-08-23 07:41:20.000000000 +0200
-++++ xilprg-new/makefile       2007-04-07 17:09:16.000000000 +0200
-+@@ -40,6 +40,7 @@
-+      $(SRC_DIR)/prgfile.cpp \\r
-+      $(SRC_DIR)/chip.cpp \\r
-+      $(SRC_DIR)/parport.cpp \\r
-++     $(SRC_DIR)/onbusb.cpp \\r
-+      $(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
-+--- 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
-+@@ -49,6 +49,7 @@
-+ #include "chip.h"\r
-+ #include "cmdline.h"\r
-+ #include "digilent.h"\r
-++#include "onbusb.h"\r
-+ #include "parport.h"\r
-+ \r
-+ cable::cable()\r
-+@@ -587,6 +588,9 @@
-+     if (stricmp(argv[0], "dusb") == 0)\r
-+         cbl = new digilent;\r
-+     else\r
-++    if (stricmp(argv[0], "ousb") ==0)\r
-++     cbl = new onbusb;\r
-++    else\r
-+     {\r
-+         msgf(STR_INVALID_CABLE_DEF);\r
-+         return NULL;\r
-+diff -Nur xilprg-0.5/src/onbusb.cpp xilprg-new/src/onbusb.cpp
-+--- xilprg-0.5/src/onbusb.cpp 1970-01-01 01:00:00.000000000 +0100
-++++ xilprg-new/src/onbusb.cpp 2007-04-07 17:15:34.000000000 +0200
-+@@ -0,0 +1,113 @@
-++/*\r
-++ * onboard usb\r
-++ *\r
-++ * author: till & frank zirkelbach\r
-++ *\r
-++ */\r
-++\r
-++#include "xilprg.h"\r
-++#include "utils.h"\r
-++#include "onbusb.h"\r
-++\r
-++onbusb::onbusb()\r
-++{\r
-++   handle=NULL;\r
-++}\r
-++\r
-++onbusb::~onbusb()\r
-++{\r
-++}\r
-++\r
-++int onbusb::open()\r
-++{\r
-++   \r
-++    struct usb_bus *bus; \r
-++\r
-++    usb_init();\r
-++    usb_find_busses();\r
-++    usb_find_devices();\r
-++\r
-++    bus=usb_get_busses();\r
-++    while(bus) {\r
-++     dev=bus->devices;\r
-++     while(dev) {\r
-++             if(dev->descriptor.idVendor==USB_VENDOR_ID &&\r
-++                dev->descriptor.idProduct==USB_PRODUCT_ID)\r
-++                     /* found the device */\r
-++                     return 0;\r
-++             dev=dev->next;\r
-++     }\r
-++     bus=bus->next;\r
-++    }\r
-++\r
-++    return -1;\r
-++\r
-++    handle=usb_open(dev);\r
-++    if(handle==NULL)\r
-++     goto cleanup;\r
-++\r
-++    if(usb_set_configuration(handle,1)<0)\r
-++     goto cleanup;\r
-++\r
-++    if(usb_claim_interface(handle,0)<0)\r
-++     goto cleanup;\r
-++\r
-++    if(usb_set_altinterface(handle,1)<0)\r
-++     goto cleanup;\r
-++\r
-++    data = 0x10;\r
-++\r
-++    reset_tap_state();\r
-++\r
-++    return 0;\r
-++\r
-++cleanup:\r
-++\r
-++    close();\r
-++\r
-++    return 1;\r
-++\r
-++}\r
-++\r
-++int onbusb::close()\r
-++{\r
-++\r
-++    usb_close(handle);\r
-++\r
-++    return 0;\r
-++}\r
-++\r
-++int onbusb::get_description(string& desc)\r
-++{\r
-++    char s[256];\r
-++    sprintf(s, "onboard usb bitbanging");\r
-++    desc = s;\r
-++    return 0;\r
-++}\r
-++\r
-++void onbusb::set_tdi(int bit)\r
-++{\r
-++    if (bit) data |= 0x04; else data &= ~0x04;\r
-++    data|=0xa0;\r
-++    usb_bulk_write(handle,0x01,&data,1,0);\r
-++}\r
-++\r
-++void onbusb::set_tck(int bit)\r
-++{\r
-++    if (bit) data |= 0x10; else data &= ~0x10;\r
-++    data|=0xa0;\r
-++    usb_bulk_write(handle,0x01,&data,1,0);\r
-++}\r
-++\r
-++void onbusb::set_tms(int bit)\r
-++{\r
-++    if (bit) data |= 0x08; else data &= ~0x08;\r
-++    data|=0xa0;\r
-++    usb_bulk_write(handle,0x01,&data,1,0);\r
-++}\r
-++\r
-++int onbusb::get_tdo()\r
-++{\r
-++    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
-+--- xilprg-0.5/src/onbusb.h   1970-01-01 01:00:00.000000000 +0100
-++++ xilprg-new/src/onbusb.h   2007-04-07 17:14:07.000000000 +0200
-+@@ -0,0 +1,43 @@
-++/*\r
-++ * onboard usb\r
-++ *\r
-++ * author: till & frank zirkelbach\r
-++ *\r
-++ */\r
-++\r
-++#ifndef _ONBUSB_H_INCLUDED_\r
-++#define _ONBUSB_H_INCLUDED_\r
-++\r
-++#include "cable.h"\r
-++\r
-++#include <usb.h>\r
-++\r
-++class onbusb : public cable\r
-++{\r
-++public:\r
-++     onbusb();\r
-++     virtual ~onbusb();\r
-++\r
-++    enum\r
-++    {\r
-++     USB_VENDOR_ID   = 0x04b4,\r
-++     USB_PRODUCT_ID  = 0x8613\r
-++    };\r
-++\r
-++    virtual int open();\r
-++    virtual int close();\r
-++\r
-++    virtual int get_description(string&);\r
-++\r
-++    virtual void set_tdi(int);\r
-++    virtual void set_tck(int);\r
-++    virtual void set_tms(int);\r
-++    virtual int get_tdo();\r
-++\r
-++protected:\r
-++    char data;\r
-++    struct usb_device *dev;\r
-++    usb_dev_handle *handle;\r
-++};\r
-++\r
-++#endif\r
-+diff -Nur xilprg-0.5/src/strtable.cpp xilprg-new/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
-+@@ -137,7 +137,7 @@
-+     //STR_CMD_CABLE\r
-+     "cable\0" \r
-+     "Sets programmer cable\0"\r
-+-    "cable {xil3 [ioaddr]|dusb}\0",\r
-++    "cable {xil3 [ioaddr]|dusb|ousb}\0",\r
-+     //STR_CMD_CHIPS\r
-+     "chips\0"\r
-+     "Prints supported devices\0" \r
 diff -Nur xilprg-0.5/makefile xilprg-new/makefile
 --- xilprg-0.5/makefile        2006-08-23 07:41:20.000000000 +0200
-+++ xilprg-new/makefile        2007-04-10 10:33:28.000000000 +0200
++++ xilprg-new/makefile        2007-04-07 17:09:16.000000000 +0200
 @@ -40,6 +40,7 @@
        $(SRC_DIR)/prgfile.cpp \\r
        $(SRC_DIR)/chip.cpp \\r
@@ -223,7 +11,7 @@ diff -Nur xilprg-0.5/makefile xilprg-new/makefile
        $(SRC_DIR)/xilinx.cpp\r
 diff -Nur xilprg-0.5/src/cable.cpp xilprg-new/src/cable.cpp
 --- xilprg-0.5/src/cable.cpp   2006-08-23 07:38:34.000000000 +0200
-+++ xilprg-new/src/cable.cpp   2007-04-10 10:33:28.000000000 +0200
++++ xilprg-new/src/cable.cpp   2007-04-07 17:20:55.000000000 +0200
 @@ -49,6 +49,7 @@
  #include "chip.h"\r
  #include "cmdline.h"\r
@@ -244,12 +32,12 @@ diff -Nur xilprg-0.5/src/cable.cpp xilprg-new/src/cable.cpp
          return NULL;\r
 diff -Nur xilprg-0.5/src/onbusb.cpp xilprg-new/src/onbusb.cpp
 --- xilprg-0.5/src/onbusb.cpp  1970-01-01 01:00:00.000000000 +0100
-+++ xilprg-new/src/onbusb.cpp  2007-04-21 14:12:15.000000000 +0200
-@@ -0,0 +1,126 @@
++++ xilprg-new/src/onbusb.cpp  2007-09-04 21:39:30.000000000 +0200
+@@ -0,0 +1,119 @@
 +/*\r
 + * onboard usb\r
 + *\r
-+ * author: till & frank zirkelbach\r
++ * author: till, hunz, koppi, hackbard\r
 + *\r
 + */\r
 +\r
@@ -257,6 +45,8 @@ diff -Nur xilprg-0.5/src/onbusb.cpp xilprg-new/src/onbusb.cpp
 +#include "utils.h"\r
 +#include "onbusb.h"\r
 +\r
++#define GET_TDO               0x20\r
++\r
 +onbusb::onbusb()\r
 +{\r
 +   handle=NULL;\r
@@ -280,39 +70,28 @@ diff -Nur xilprg-0.5/src/onbusb.cpp xilprg-new/src/onbusb.cpp
 +      dev=bus->devices;\r
 +      while(dev) {\r
 +              if(dev->descriptor.idVendor==USB_VENDOR_ID &&\r
-+                 dev->descriptor.idProduct==USB_PRODUCT_ID) {
-+
-+                      /* found the device */\r
-+
-+                      printf("found matching usb device\n");
-+
-+                      handle=usb_open(dev);\r
-+                      if(handle==NULL)\r
-+                              goto cleanup;\r
-+
-+                      printf("got handle\n");
-+\r
-+                      if(usb_set_configuration(handle,1)<0)\r
++                 dev->descriptor.idProduct==USB_PRODUCT_ID) {\r
++\r
++                      /* found the device */\r
++                      handle=usb_open(dev);\r
++                      if(handle==NULL)\r
 +                              goto cleanup;\r
-+
-+                      printf("set configuration\n");
 +\r
-+                      if(usb_claim_interface(handle,0)<0)\r
++                      if(usb_set_configuration(handle,1)<0)\r
 +                              goto cleanup;\r
-+
-+                      printf("claimed interface\n");
 +\r
-+                      if(usb_set_altinterface(handle,1)<0)\r
-+                              goto cleanup;\r
-+
-+                      printf("set alt interface\n");
++                      if(usb_claim_interface(handle,0)<0)\r
++                              goto cleanup;\r
 +\r
-+                      data = 0x10;\r
++                      if(usb_set_altinterface(handle,1)<0)\r
++                              goto cleanup;\r
 +\r
-+                      reset_tap_state();\r
++                      data = 0x10;\r
 +\r
-+                      return 0;\r
-+              }
++                      reset_tap_state();\r
++\r
++                      return 0;\r
++              }\r
 +              dev=dev->next;\r
 +      }\r
 +      bus=bus->next;\r
@@ -322,10 +101,10 @@ diff -Nur xilprg-0.5/src/onbusb.cpp xilprg-new/src/onbusb.cpp
 +\r
 +cleanup:\r
 +\r
-+    perror("device open");
-+
 +    close();\r
 +\r
++    printf("usb init failed!\n");\r
++\r
 +    return -1;\r
 +\r
 +}\r
@@ -341,7 +120,7 @@ diff -Nur xilprg-0.5/src/onbusb.cpp xilprg-new/src/onbusb.cpp
 +int onbusb::get_description(string& desc)\r
 +{\r
 +    char s[256];\r
-+    sprintf(s, "onboard usb bitbanging");\r
++    sprintf(s, "onboard usb bitbanging (till, hunz, koppi, hackbard)");\r
 +    desc = s;\r
 +    return 0;\r
 +}\r
@@ -349,37 +128,39 @@ diff -Nur xilprg-0.5/src/onbusb.cpp xilprg-new/src/onbusb.cpp
 +void onbusb::set_tdi(int bit)\r
 +{\r
 +    if (bit) data |= 0x04; else data &= ~0x04;\r
-+    data|=0xa0;\r
++    usb_bulk_write(handle,0x01,&data,1,0);\r
 +}\r
 +\r
 +void onbusb::set_tck(int bit)\r
 +{\r
 +    if (bit) data |= 0x10; else data &= ~0x10;\r
-+    data|=0xa0;\r
 +    usb_bulk_write(handle,0x01,&data,1,0);\r
-+    // if(data&0x10) printf("tms: %d  tdi: %d\n",data&0x08?1:0,data&0x04?1:0);
 +}\r
 +\r
 +void onbusb::set_tms(int bit)\r
 +{\r
 +    if (bit) data |= 0x08; else data &= ~0x08;\r
-+    data|=0xa0;\r
++    usb_bulk_write(handle,0x01,&data,1,0);\r
 +}\r
 +\r
 +int onbusb::get_tdo()\r
 +{\r
++    /* send get tdo command */\r
++    data=GET_TDO;\r
++    usb_bulk_write(handle,0x01,&data,1,0);\r
++\r
++    /* receive tdo */\r
 +    usb_bulk_read(handle,0x81,&data,1,0);\r
-+    // printf(" ----> %d\n",data&0x01?1:0);
 +    return data & 0x01 ? 1 : 0;\r
 +}\r
 diff -Nur xilprg-0.5/src/onbusb.h xilprg-new/src/onbusb.h
 --- xilprg-0.5/src/onbusb.h    1970-01-01 01:00:00.000000000 +0100
-+++ xilprg-new/src/onbusb.h    2007-04-10 10:33:28.000000000 +0200
++++ xilprg-new/src/onbusb.h    2007-09-04 21:17:18.000000000 +0200
 @@ -0,0 +1,43 @@
 +/*\r
 + * onboard usb\r
 + *\r
-+ * author: till & frank zirkelbach\r
++ * author: till, hunz, koppi, hackbard\r
 + *\r
 + */\r
 +\r
@@ -421,7 +202,7 @@ diff -Nur xilprg-0.5/src/onbusb.h xilprg-new/src/onbusb.h
 +#endif\r
 diff -Nur xilprg-0.5/src/strtable.cpp xilprg-new/src/strtable.cpp
 --- xilprg-0.5/src/strtable.cpp        2006-08-23 07:38:34.000000000 +0200
-+++ xilprg-new/src/strtable.cpp        2007-04-10 10:33:28.000000000 +0200
++++ xilprg-new/src/strtable.cpp        2007-04-07 16:56:25.000000000 +0200
 @@ -137,7 +137,7 @@
      //STR_CMD_CABLE\r
      "cable\0" \r
index 3a57b12..a8f0467 100644 (file)
--- a/fx2/fx2.c
+++ b/fx2/fx2.c
  */
 
 /* constant definitions */
-#define TRUE   1
-#define FALSE  0
-#define POWER_ON       1;
-#define POWER_OFF      0;
+#define GET_TDO                0x20
 
 /* type definitions */
 typedef unsigned char u8;
@@ -227,6 +224,9 @@ void ep1_init() {
 
 void fx2_init() {
 
+       /* syncdelay */
+       SYNCDELAY;
+
        /* cpu init */
        cpu_init();
 
@@ -239,11 +239,14 @@ void fx2_init() {
 
        /* ep1 init */
        ep1_init();
+
+       /* jtag init */
+       jtag_init();
 }
 
 void main() {
 
-       u8 buf;
+       u8 buf,set;
 
        /* initialize the fx2 */
        fx2_init();
@@ -252,14 +255,18 @@ void main() {
        while(1) {
                if(!(EP1OUTCS&BUSY)) {
                        buf=EP1OUTBUF[0];
-                       buf&=0x1c;
-                       IOD|=buf;
-                       EP1OUTBC=1;
-               }
-               if(!(EP1INCS&BUSY)) {
-                       buf=IOD&0x01?1:0;
-                       EP1INBUF[0]=buf;
-                       EP1INBC=1;
+                       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;
+                       }
                }
        }