X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=fx2%2Fcypress_fx2_xilprg.patch;h=23984e075e1b388f4d337dc5fc7433d6575a4178;hb=HEAD;hp=96d9eab1032bc7886914ce1d31f3b2367ee0ecfa;hpb=377aec2d8eaacb1f970ae36154f36a7f2554b7c7;p=my-code%2Ffpga.git diff --git a/fx2/cypress_fx2_xilprg.patch b/fx2/cypress_fx2_xilprg.patch index 96d9eab..23984e0 100644 --- a/fx2/cypress_fx2_xilprg.patch +++ b/fx2/cypress_fx2_xilprg.patch @@ -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 \ $(SRC_DIR)/chip.cpp \ @@ -9,9 +9,9 @@ diff -Nur xilprg-0.5/makefile xilprg-new/makefile $(SRC_DIR)/cable.cpp \ $(SRC_DIR)/digilent.cpp \ $(SRC_DIR)/xilinx.cpp -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" #include "cmdline.h" @@ -30,14 +30,14 @@ diff -Nur xilprg-0.5/src/cable.cpp xilprg-new/src/cable.cpp { msgf(STR_INVALID_CABLE_DEF); return NULL; -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-04-07 17:15:34.000000000 +0200 -@@ -0,0 +1,113 @@ ++++ xilprg-patched/src/onbusb.cpp 2007-09-04 22:12:47.000000000 +0200 +@@ -0,0 +1,124 @@ +/* + * onboard usb + * -+ * author: till & frank zirkelbach ++ * author: till, hunz, koppi, hackbard + * + */ + @@ -45,6 +45,8 @@ diff -Nur xilprg-0.5/src/onbusb.cpp xilprg-new/src/onbusb.cpp +#include "utils.h" +#include "onbusb.h" + ++#define GET_TDO 0x20 ++ +onbusb::onbusb() +{ + handle=NULL; @@ -68,40 +70,42 @@ diff -Nur xilprg-0.5/src/onbusb.cpp xilprg-new/src/onbusb.cpp + dev=bus->devices; + while(dev) { + if(dev->descriptor.idVendor==USB_VENDOR_ID && -+ dev->descriptor.idProduct==USB_PRODUCT_ID) -+ /* found the device */ -+ return 0; -+ dev=dev->next; -+ } -+ bus=bus->next; -+ } ++ dev->descriptor.idProduct==USB_PRODUCT_ID) { + -+ return -1; ++ /* found the device */ ++ handle=usb_open(dev); ++ if(handle==NULL) ++ goto cleanup; + -+ handle=usb_open(dev); -+ if(handle==NULL) -+ goto cleanup; ++ if(usb_set_configuration(handle,1)<0) ++ goto cleanup; + -+ if(usb_set_configuration(handle,1)<0) -+ goto cleanup; ++ if(usb_claim_interface(handle,0)<0) ++ goto cleanup; + -+ if(usb_claim_interface(handle,0)<0) -+ goto cleanup; ++ if(usb_set_altinterface(handle,1)<0) ++ goto cleanup; + -+ if(usb_set_altinterface(handle,1)<0) -+ goto cleanup; ++ data = 0x10; + -+ data = 0x10; ++ reset_tap_state(); + -+ reset_tap_state(); ++ return 0; ++ } ++ dev=dev->next; ++ } ++ bus=bus->next; ++ } + -+ return 0; ++ return -1; + +cleanup: + + close(); + -+ return 1; ++ printf("usb init failed!\n"); ++ ++ return -1; + +} + @@ -116,7 +120,7 @@ diff -Nur xilprg-0.5/src/onbusb.cpp xilprg-new/src/onbusb.cpp +int onbusb::get_description(string& desc) +{ + char s[256]; -+ sprintf(s, "onboard usb bitbanging"); ++ sprintf(s, "onboard usb bitbanging (till, hunz, koppi, hackbard)"); + desc = s; + return 0; +} @@ -124,37 +128,44 @@ diff -Nur xilprg-0.5/src/onbusb.cpp xilprg-new/src/onbusb.cpp +void onbusb::set_tdi(int bit) +{ + if (bit) data |= 0x04; else data &= ~0x04; -+ data|=0xa0; + usb_bulk_write(handle,0x01,&data,1,0); +} + +void onbusb::set_tck(int bit) +{ + if (bit) data |= 0x10; else data &= ~0x10; -+ data|=0xa0; + usb_bulk_write(handle,0x01,&data,1,0); +} + +void onbusb::set_tms(int bit) +{ + if (bit) data |= 0x08; else data &= ~0x08; -+ data|=0xa0; + usb_bulk_write(handle,0x01,&data,1,0); +} + +int onbusb::get_tdo() +{ ++int i; ++ /* send get tdo command */ ++ //data=GET_TDO; ++ //usb_bulk_write(handle,0x01,&data,1,0); ++ /* receive tdo */ ++ // 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); + return data & 0x01 ? 1 : 0; +} -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-04-07 17:14:07.000000000 +0200 ++++ xilprg-patched/src/onbusb.h 2007-09-04 20:59:03.000000000 +0200 @@ -0,0 +1,43 @@ +/* + * onboard usb + * -+ * author: till & frank zirkelbach ++ * author: till, hunz, koppi, hackbard + * + */ + @@ -194,9 +205,9 @@ diff -Nur xilprg-0.5/src/onbusb.h xilprg-new/src/onbusb.h +}; + +#endif -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 "cable\0"