Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add xc3sprog patch

  • Loading branch information...
commit acd8e4a934ba40ac9d132c8b82c897601d63abda 1 parent ad490ac
tmbinc authored
Showing with 844 additions and 0 deletions.
  1. +7 −0 src/xc3sprog/README
  2. +837 −0 src/xc3sprog/xc3sprog_472_crunchy.patch
7 src/xc3sprog/README
View
@@ -0,0 +1,7 @@
+This is a very rough patch to xc3sprog that
+
+- add a very simple makefile,
+- a very simple python wrapper,
+- XC2VP50 support.
+
+
837 src/xc3sprog/xc3sprog_472_crunchy.patch
View
@@ -0,0 +1,837 @@
+diff --git a/xc3sprog/Makefile b/xc3sprog/Makefile
+new file mode 100644
+index 0000000..92d0fb5
+--- /dev/null
++++ b/xc3sprog/Makefile
+@@ -0,0 +1,24 @@
++CFLAGS=-O2 -I /usr/include/python2.5 -g
++LDFLAGS=-lusb -lftdi
++
++.cpp.o:
++ $(CROSS)g++ $(CFLAGS) -c -o $@ $*.cpp
++
++all: xc3sprog jtag.so
++
++OBJS = bitfile.o \
++ devicedb.o iobase.o iodebug.o \
++ ioftdi.o ioparport.o ioxpc.o javr.o \
++ jedecfile.o jtag.o mapfile_xc2c.o progalgavr.o \
++ progalgspiflash.o progalgxc2c.o progalgxc3s.o progalgxc95x.o progalgxcf.o \
++ progalgxcfp.o srecfile.o \
++ utilities.o xc3sprog.o
++
++xc3sprog: $(OBJS)
++ $(CROSS)g++ $(OBJS) $(LDFLAGS) -o xc3sprog
++
++jtag.so: $(OBJS) python.o
++ $(CROSS)g++ $(OBJS) python.o $(LDFLAGS) -o jtag.so -shared
++
++clean:
++ rm -f $(OBJS)
+diff --git a/xc3sprog/config.h b/xc3sprog/config.h
+new file mode 100644
+index 0000000..fc76f3d
+--- /dev/null
++++ b/xc3sprog/config.h
+@@ -0,0 +1 @@
++const char fb_string[]={"${fb_string}"};
+diff --git a/xc3sprog/devlist.txt b/xc3sprog/devlist.txt
+index f50e1e0..e782b0b 100644
+--- a/xc3sprog/devlist.txt
++++ b/xc3sprog/devlist.txt
+@@ -170,6 +170,10 @@
+ 06d7c093 8 0x1 XC2C512_PQ208
+ 06d7e093 8 0x1 XC2C512_FT256
+
++
++1129e093 14 0xffc9 XC2VP50
++
++
+ #unsupported
+ #Virtex2
+ 01020093 6 5 XC2V500
+diff --git a/xc3sprog/ioembedded.cpp b/xc3sprog/ioembedded.cpp
+new file mode 100644
+index 0000000..3f57ebc
+--- /dev/null
++++ b/xc3sprog/ioembedded.cpp
+@@ -0,0 +1,136 @@
++/* JTAG GNU/Linux parport device io
++
++Copyright (C) 2010 Felix Domke
++
++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
++
++*/
++
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <fcntl.h>
++#include <string.h>
++#include "ioembedded.h"
++#include "gpio.h"
++
++using namespace std;
++
++
++IOEmbedded::IOEmbedded() : IOBase(), total(0) {
++ printf("open gpio\n");
++ xgpio_init();
++ printf("init default gpio\n");
++ xgpio_set_oe(GPIO_TDI, 1);
++ xgpio_set_oe(GPIO_TDO, 0);
++ xgpio_set_oe(GPIO_TMS, 1);
++ xgpio_set_oe(GPIO_TCK, 1);
++ printf("ok\n");
++}
++
++bool IOEmbedded::txrx(bool tms, bool tdi)
++{
++ unsigned char ret;
++ bool retval;
++ unsigned char data=0;
++ if(tdi)data|=TDI;
++ if(tms)data|=TMS;
++ set_io(data);
++ data|=TCK;
++ retval = set_io(data);
++ total++;
++ return retval;
++
++}
++
++void IOEmbedded::tx(bool tms, bool tdi)
++{
++ unsigned char data=0; // D4 pin5 TDI enable
++ if(tdi)data|=TDI; // D0 pin2
++ if(tms)data|=TMS; // D2 pin4
++ set_io(data);
++ data|=TCK; // clk high
++ total++;
++ set_io(data);
++}
++
++void IOEmbedded::tx_tdi_byte(unsigned char tdi_byte)
++{
++ int k;
++
++ for (k = 0; k < 8; k++)
++ tx(false, (tdi_byte>>k)&1);
++}
++
++void IOEmbedded::txrx_block(const unsigned char *tdi, unsigned char *tdo,
++ int length, bool last)
++{
++ int i=0;
++ int j=0;
++ unsigned char tdo_byte=0;
++ unsigned char tdi_byte;
++ unsigned char data=0;
++ if (tdi)
++ tdi_byte = tdi[j];
++
++ while(i<length-1){
++ tdo_byte=tdo_byte+(txrx(false, (tdi_byte&1)==1)<<(i%8));
++ if (tdi)
++ tdi_byte=tdi_byte>>1;
++ i++;
++ if((i%8)==0){ // Next byte
++ if(tdo)
++ tdo[j]=tdo_byte; // Save the TDO byte
++ tdo_byte=0;
++ j++;
++ if (tdi)
++ tdi_byte=tdi[j]; // Get the next TDI byte
++ }
++ };
++ tdo_byte=tdo_byte+(txrx(last, (tdi_byte&1)==1)<<(i%8));
++ if(tdo)
++ tdo[j]=tdo_byte;
++ set_io(data); /* Make sure, TCK is low */
++ return;
++}
++
++void IOEmbedded::tx_tms(unsigned char *pat, int length, int force)
++{
++ int i;
++ unsigned char tms;
++ unsigned char data=0;
++ for (i = 0; i < length; i++)
++ {
++ if ((i & 0x7) == 0)
++ tms = pat[i>>3];
++ tx((tms & 0x01), true);
++ tms = tms >> 1;
++ }
++ set_io(data); /* Make sure, TCK is low */
++}
++
++IOEmbedded::~IOEmbedded()
++{
++ if (verbose) fprintf(stderr, "Total bytes sent: %d\n", total>>3);
++}
++
++
++int IOEmbedded::set_io(unsigned char data)
++{
++ xgpio_set(GPIO_TDI, !!(data & TDI));
++ xgpio_set(GPIO_TMS, !!(data & TMS));
++ xgpio_set(GPIO_TCK, !!(data & TCK));
++ return xgpio_get(GPIO_TDO);
++}
+diff --git a/xc3sprog/ioembedded.h b/xc3sprog/ioembedded.h
+new file mode 100644
+index 0000000..bc77951
+--- /dev/null
++++ b/xc3sprog/ioembedded.h
+@@ -0,0 +1,58 @@
++/* JTAG for Embedded devices (using GPIO)
++
++Copyright (C) 2010 Felix Domke
++
++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
++
++Changes:
++Dmitry Teytelman [dimtey@gmail.com] 14 Jun 2006 [applied 13 Aug 2006]:
++ Code cleanup for clean -Wall compile.
++ Changes to support new IOBase interface.
++*/
++
++
++
++#ifndef IOPARPORT_H
++#define IOPARPORT_H
++
++#include "iobase.h"
++
++class IOEmbedded : public IOBase
++{
++ enum {
++ TDI = 1,
++ TDO = 2,
++ TCK = 4,
++ TMS = 8
++ };
++protected:
++ int set_io(unsigned char data);
++
++public:
++ IOEmbedded();
++ ~IOEmbedded();
++ void tx(bool tms, bool tdi);
++ bool txrx(bool tms, bool tdi);
++ void tx_tdi_byte(unsigned char tdi_byte);
++ void tx_tms(unsigned char *pat, int length, int force);
++
++public:
++ void txrx_block(const unsigned char *tdi, unsigned char *tdo, int length, bool last);
++private:
++ int debug, total;
++};
++
++
++#endif // IOPARPORT_H
+diff --git a/xc3sprog/ioftdi.cpp b/xc3sprog/ioftdi.cpp
+index f103616..2be4d24 100644
+--- a/xc3sprog/ioftdi.cpp
++++ b/xc3sprog/ioftdi.cpp
+@@ -35,7 +35,7 @@ IOFtdi::IOFtdi(int vendor, int product, char const *desc, char const *serial,
+
+ unsigned char buf1[5];
+ unsigned char buf[9] = { SET_BITS_LOW, 0x00, 0x0b,
+- TCK_DIVISOR, 0x00, 0x00 ,
++ TCK_DIVISOR, 0x01, 0x00 ,
+ SET_BITS_HIGH, (unsigned char)~0x84, 0x84};
+
+ char *fname = getenv("FTDI_DEBUG");
+@@ -153,7 +153,7 @@ void IOFtdi::txrx_block(const unsigned char *tdi, unsigned char *tdo,
+ /* If we need to shift state, treat the last bit separate*/
+ unsigned int rem = (last)? length - 1: length;
+ unsigned char buf[TX_BUF];
+- unsigned int buflen = TX_BUF - 3 ; /* we need the preamble*/
++ unsigned int buflen = (tdo ? TX_BUF_INPUT : TX_BUF) - 3 ; /* we need the preamble*/
+ unsigned int rembits;
+
+ /*out on -ve edge, in on +ve edge */
+diff --git a/xc3sprog/ioftdi.h b/xc3sprog/ioftdi.h
+index f3a628a..8fea451 100644
+--- a/xc3sprog/ioftdi.h
++++ b/xc3sprog/ioftdi.h
+@@ -48,6 +48,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ #define FTDI_LLIF 6
+
+ #define TX_BUF (4096)
++#define TX_BUF_INPUT (32)
+
+ class IOFtdi : public IOBase
+ {
+diff --git a/xc3sprog/ioxpc.cpp b/xc3sprog/ioxpc.cpp
+index e4b69dc..2f30738 100644
+--- a/xc3sprog/ioxpc.cpp
++++ b/xc3sprog/ioxpc.cpp
+@@ -24,8 +24,8 @@
+ #include <sys/time.h>
+ #include <stdint.h>
+
+-#include <xguff/usrp_interfaces.h>
+-#include <xguff/usrp_commands.h>
++//#include <xguff/usrp_interfaces.h>
++//#include <xguff/usrp_commands.h>
+ #include <string.h>
+ #include <cstdio>
+
+diff --git a/xc3sprog/progalgxc3s.cpp b/xc3sprog/progalgxc3s.cpp
+index 9553cac..e24f76b 100644
+--- a/xc3sprog/progalgxc3s.cpp
++++ b/xc3sprog/progalgxc3s.cpp
+@@ -199,6 +199,7 @@ void ProgAlgXC3S::reconfig(void)
+ switch(family)
+ {
+ case FAMILY_XC2V:
++ case FAMILY_XC2VP:
+ case FAMILY_XC3S:
+ case FAMILY_XC3SE:
+ case FAMILY_XC3SA:
+diff --git a/xc3sprog/progalgxc3s.h b/xc3sprog/progalgxc3s.h
+index 6efdded..ccd3cec 100644
+--- a/xc3sprog/progalgxc3s.h
++++ b/xc3sprog/progalgxc3s.h
+@@ -30,6 +30,7 @@ Dmitry Teytelman [dimtey@gmail.com] 14 Jun 2006 [applied 13 Aug 2006]:
+ #include "jtag.h"
+
+ #define FAMILY_XC2V 0x08
++#define FAMILY_XC2VP 0x09
+ #define FAMILY_XC3S 0x0a
+ #define FAMILY_XC3SE 0x0e
+ #define FAMILY_XC3SA 0x11
+diff --git a/xc3sprog/python.cpp b/xc3sprog/python.cpp
+new file mode 100644
+index 0000000..e05ec9c
+--- /dev/null
++++ b/xc3sprog/python.cpp
+@@ -0,0 +1,337 @@
++#include <Python.h>
++
++#include <stdio.h>
++#include <string.h>
++#include <stdarg.h>
++#include <stdlib.h>
++#include <unistd.h>
++
++
++#include "io_exception.h"
++#include "ioparport.h"
++#ifndef EMBEDDED
++#include "iofx2.h"
++#include "ioftdi.h"
++#include "ioxpc.h"
++#endif
++#include "bitfile.h"
++#include "jtag.h"
++#include "devicedb.h"
++#include "progalgxcf.h"
++#include "progalgxcfp.h"
++#include "javr.h"
++#include "progalgxc3s.h"
++#include "jedecfile.h"
++#include "mapfile_xc2c.h"
++#include "progalgxc95x.h"
++#include "progalgxc2c.h"
++#include "progalgavr.h"
++#include "progalgspiflash.h"
++#include "utilities.h"
++
++#define IDCODE_TO_FAMILY(id) ((id>>21) & 0x7f)
++#define IDCODE_TO_MANUFACTURER(id) ((id>>1) & 0x3ff)
++
++#define MANUFACTURER_ATMEL 0x01f
++#define MANUFACTURER_XILINX 0x049
++
++
++typedef struct {
++ PyObject_HEAD
++ IOBase *io;
++ DeviceDB *db;
++ Jtag *jtag;
++ /* Type-specific fields go here. */
++} JTAG;
++
++static void
++JTAG_dealloc(JTAG* self)
++{
++ delete self->jtag;
++ delete self->io;
++ delete self->db;
++ self->ob_type->tp_free((PyObject*)self);
++}
++
++static PyObject *
++JTAG_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
++{
++ JTAG *self;
++
++ self = (JTAG *)type->tp_alloc(type, 0);
++ if (self != NULL) {
++ self->io = 0;
++ self->db = new DeviceDB(0);
++ self->jtag = 0;
++ }
++
++ return (PyObject *)self;
++}
++
++extern int init_chain(Jtag &jtag, DeviceDB &db);
++extern unsigned long get_id(Jtag &jtag, DeviceDB &db, int chainpos);
++extern int programXC3S(Jtag &g, BitFile &file, bool verify, bool reconfig, int family);
++
++static PyObject *
++JTAG_connect(JTAG *self, PyObject *args, PyObject *keywds)
++{
++ CABLES_TYPES cable = CABLE_NONE;
++
++ cable = CABLE_FTDI;
++#ifndef EMBEDDED
++ int subtype = FTDI_NO_EN;
++#else
++ int subtype = 0;
++#endif
++ int channel = 0;
++ int vendor = 0;
++ int product = 0;
++ char *dev = 0;
++ char *desc = 0;
++ char *serial = 0;
++ int verbose = 2;
++ int chainpos = 0;
++ int res;
++
++ const char *kwlist[] = {"cable", "product", "vendor", NULL};
++ char *s_cable;
++
++ if (!PyArg_ParseTupleAndKeywords(args, keywds, "s|ii", (char**)kwlist, &s_cable, &product, &vendor))
++ return NULL;
++
++#ifndef EMBEDDED
++ if (!strcmp(s_cable, "ftdi"))
++ cable = CABLE_FTDI;
++ else if (!strcmp(s_cable, "xpc"))
++ cable = CABLE_XPC;
++ else
++ {
++ PyErr_SetString(PyExc_TypeError, "Cable type must be {ftdi|xpc}");
++ return NULL;
++ }
++#else
++ cable = CABLE_EMBEDDED;
++#endif
++
++ std::auto_ptr<IOBase> io;
++ res = getIO( &io, cable, subtype, channel, vendor, product, dev, desc, serial);
++ if (res) /* some error happend*/
++ {
++ PyErr_SetString(PyExc_IOError, "Error connecting JTAG");
++ return NULL;
++ }
++
++ self->io = io.release();
++
++ self->io->setVerbose(verbose);
++
++ self->jtag = new Jtag(self->io);
++ self->jtag->setVerbose(verbose);
++
++ int num_devices = init_chain(*self->jtag, *self->db);
++
++ PyObject *result = 0;
++
++ if (num_devices != 0)
++ {
++ result = PyList_New(num_devices);
++ if (!result)
++ return NULL;
++ int i;
++ for (i = 0; i < num_devices; ++i)
++ {
++ int id = get_id(*self->jtag, *self->db, chainpos);
++ PyList_SetItem(result, i, PyLong_FromUnsignedLong(id));
++ }
++ } else
++ {
++ PyErr_SetString(PyExc_IOError, "Error init chain");
++ return NULL;
++ }
++
++ detect_chain(self->jtag, self->db);
++
++ if (!result)
++ {
++ Py_INCREF(Py_None);
++ return Py_None;
++ } else
++ {
++ return result;
++ }
++}
++
++static PyObject *
++JTAG_program(JTAG *self, PyObject *args)
++{
++ int chainpos = 0;
++ int verify = 0;
++ int reconfigure = 0;
++
++ PyObject *file;
++
++ if (!PyArg_ParseTuple(args, "O!|i", &PyFile_Type, &file, &chainpos))
++ return NULL;
++
++ int id = get_id(*self->jtag, *self->db, chainpos);
++
++ if (id == 0)
++ {
++ PyErr_SetString(PyExc_IOError, "Illegal chain position");
++ return NULL;
++ }
++
++ unsigned int family = IDCODE_TO_FAMILY(id);
++ unsigned int manufacturer = IDCODE_TO_MANUFACTURER(id);
++
++ switch (manufacturer)
++ {
++ case MANUFACTURER_XILINX:
++ switch (family)
++ {
++ case FAMILY_XC3S:
++ case FAMILY_XC3SE:
++ case FAMILY_XC3SA:
++ case FAMILY_XC3SAN:
++ case FAMILY_XC3SD:
++ case FAMILY_XC6S:
++ case FAMILY_XCF:
++ case FAMILY_XC2V:
++ case FAMILY_XC2VP:
++ case FAMILY_XC5VLX:
++ case FAMILY_XC5VLXT:
++ case FAMILY_XC5VSXT:
++ case FAMILY_XC5VFXT:
++ case FAMILY_XC5VTXT:
++ {
++ BitFile bitfile;
++ FILE_STYLE in_style = STYLE_BIT;
++ bitfile.readFile(PyFile_AsFile(file), in_style);
++ try
++ {
++ int res = programXC3S(*self->jtag, bitfile, verify, reconfigure, family);
++ printf("result is %d\n", res);
++ }
++ catch (io_exception &e)
++ {
++ PyErr_SetString(PyExc_IOError, e.getMessage().c_str());
++ return NULL;
++ }
++ break;
++ }
++ default:
++ PyErr_SetString(PyExc_IOError, "unknown xilinx device");
++ return NULL;
++ }
++ break;
++ default:
++ PyErr_SetString(PyExc_IOError, "unknown manufacturer");
++ return NULL;
++ }
++ Py_INCREF(Py_None);
++ return Py_None;
++}
++
++static PyObject *
++JTAG_scanuser(JTAG *self, PyObject *args)
++{
++ int chainpos = 0;
++ unsigned char *buffer;
++ Py_ssize_t size;
++ if (!PyArg_ParseTuple(args, "w#|i", &buffer, &size, &chainpos))
++ return NULL;
++
++ unsigned char USER1[] = {0xC2, 0xFF};
++
++ if (self->jtag->selectDevice(chainpos) != chainpos)
++ {
++ PyErr_SetString(PyExc_IOError, "illegal chain position");
++ return NULL;
++ }
++
++ self->jtag->shiftIR(USER1);
++ self->jtag->shiftDR(buffer, buffer, size * 8);
++
++ Py_INCREF(Py_None);
++ return Py_None;
++}
++
++static PyMethodDef JTAG_methods[] = {
++ {"connect", (PyCFunction)JTAG_connect, METH_VARARGS | METH_KEYWORDS,
++ "Connect JTAG"
++ },
++ {"program", (PyCFunction)JTAG_program, METH_VARARGS,
++ "program bitstream"
++ },
++ {"scanuser", (PyCFunction)JTAG_scanuser, METH_VARARGS,
++ "scan user chain"
++ },
++ {NULL} /* Sentinel */
++};
++
++static PyTypeObject jtag_JTAGType = {
++ PyObject_HEAD_INIT(NULL)
++ 0, /*ob_size*/
++ "jtag.JTAG", /*tp_name*/
++ sizeof(JTAG), /*tp_basicsize*/
++ 0, /*tp_itemsize*/
++ (destructor)JTAG_dealloc, /*tp_dealloc*/
++ 0, /*tp_print*/
++ 0, /*tp_getattr*/
++ 0, /*tp_setattr*/
++ 0, /*tp_compare*/
++ 0, /*tp_repr*/
++ 0, /*tp_as_number*/
++ 0, /*tp_as_sequence*/
++ 0, /*tp_as_mapping*/
++ 0, /*tp_hash */
++ 0, /*tp_call*/
++ 0, /*tp_str*/
++ 0, /*tp_getattro*/
++ 0, /*tp_setattro*/
++ 0, /*tp_as_buffer*/
++ Py_TPFLAGS_DEFAULT, /*tp_flags*/
++ "JTAG objects", /* tp_doc */
++ 0, /* tp_traverse */
++ 0, /* tp_clear */
++ 0, /* tp_richcompare */
++ 0, /* tp_weaklistoffset */
++ 0, /* tp_iter */
++ 0, /* tp_iternext */
++ JTAG_methods, /* tp_methods */
++ 0, /* tp_members */
++ 0, /* tp_getset */
++ 0, /* tp_base */
++ 0, /* tp_dict */
++ 0, /* tp_descr_get */
++ 0, /* tp_descr_set */
++ 0, /* tp_dictoffset */
++ 0, /* tp_init */
++ 0, /* tp_alloc */
++ JTAG_new, /* tp_new */
++};
++
++
++static PyMethodDef jtag_methods[] = {
++ {NULL} /* Sentinel */
++};
++
++extern "C" {
++#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
++#define PyMODINIT_FUNC void
++#endif
++PyMODINIT_FUNC
++initjtag(void)
++{
++ PyObject* m;
++
++ if (PyType_Ready(&jtag_JTAGType) < 0)
++ return;
++
++ m = Py_InitModule3("jtag", jtag_methods,
++ "JTAG module.");
++
++ Py_INCREF(&jtag_JTAGType);
++ PyModule_AddObject(m, "JTAG", (PyObject *)&jtag_JTAGType);
++}
++}
+diff --git a/xc3sprog/utilities.cpp b/xc3sprog/utilities.cpp
+index 1f77481..979f9f0 100644
+--- a/xc3sprog/utilities.cpp
++++ b/xc3sprog/utilities.cpp
+@@ -10,10 +10,14 @@
+ #include "io_exception.h"
+ #include "jtag.h"
+ #include "devicedb.h"
++#ifndef EMBEDDED
+ #include "ioparport.h"
+ #include "iofx2.h"
+ #include "ioftdi.h"
+ #include "ioxpc.h"
++#else
++#include "ioembedded.h"
++#endif
+ #include "utilities.h"
+
+ extern char *optarg;
+@@ -40,6 +44,7 @@ void detect_chain(Jtag *jtag, DeviceDB *db)
+
+ CABLES_TYPES getCable(const char *given_name)
+ {
++#ifndef EMBEDDED
+ if (strcasecmp(given_name, "pp") == 0)
+ return CABLE_PP;
+ if (strcasecmp(given_name, "ftdi") == 0)
+@@ -49,6 +54,9 @@ CABLES_TYPES getCable(const char *given_name)
+ if (strcasecmp(given_name, "xpc") == 0)
+ return CABLE_XPC;
+ return CABLE_UNKNOWN;
++#else
++ return CABLE_EMBEDDED;
++#endif
+ }
+
+ const char * getCableName(CABLES_TYPES type)
+@@ -59,6 +67,7 @@ const char * getCableName(CABLES_TYPES type)
+ case CABLE_FTDI: return "ftdi"; break;
+ case CABLE_FX2: return "fx2"; break;
+ case CABLE_XPC: return "xpc"; break;
++ case CABLE_EMBEDDED: return "embedded"; break;
+ default:
+ return "Unknown";
+ }
+@@ -67,6 +76,7 @@ const char * getSubtypeName(int subtype)
+ {
+ switch (subtype)
+ {
++#ifndef EMBEDDED
+ case FTDI_NO_EN: return "No enable"; break;
+ case FTDI_IKDA: return "IKDA"; break;
+ case FTDI_OLIMEX: return "OLIMEX"; break;
+@@ -74,6 +84,7 @@ const char * getSubtypeName(int subtype)
+ case FTDI_FTDIJTAG: return "FTDIJTAG"; break;
+ case FTDI_LLBBC: return "LLBBC"; break;
+ case FTDI_LLIF: return "LLIF"; break;
++#endif
+ default:
+ return "Unknown";
+ }
+@@ -81,6 +92,7 @@ const char * getSubtypeName(int subtype)
+
+ int getSubtype(const char *given_name, CABLES_TYPES *cable, int *channel)
+ {
++#ifndef EMBEDDED
+ if (strcasecmp(given_name, "ikda") == 0)
+ {
+ if (*cable == CABLE_NONE)
+@@ -135,6 +147,7 @@ int getSubtype(const char *given_name, CABLES_TYPES *cable, int *channel)
+ *channel = 2;
+ return FTDI_LLIF;
+ }
++#endif
+ return -1;
+ }
+
+@@ -147,6 +160,7 @@ int getIO( std::auto_ptr<IOBase> *io, CABLES_TYPES cable, int subtype, int chan
+ return 1;
+ }
+
++#ifndef EMBEDDED
+ if (cable == CABLE_PP)
+ {
+ try
+@@ -189,6 +203,7 @@ int getIO( std::auto_ptr<IOBase> *io, CABLES_TYPES cable, int subtype, int chan
+ }
+ io->reset(new IOFtdi(vendor, product, desc, serial, subtype, channel));
+ }
++#if 0
+ else if(cable == CABLE_FX2)
+ {
+ if (vendor == 0)
+@@ -197,6 +212,7 @@ int getIO( std::auto_ptr<IOBase> *io, CABLES_TYPES cable, int subtype, int chan
+ product = USRP_DEVICE;
+ io->reset(new IOFX2(vendor, product, desc, serial));
+ }
++#endif
+ else if(cable == CABLE_XPC)
+ {
+ if (vendor == 0)
+@@ -219,6 +235,12 @@ int getIO( std::auto_ptr<IOBase> *io, CABLES_TYPES cable, int subtype, int chan
+ fprintf(stderr, "Reason: %s\n",e.getMessage().c_str());
+ return 1;
+ }
++#else
++ if (cable == CABLE_EMBEDDED)
++ io->reset(new IOEmbedded());
++ else
++ return 2;
++#endif
+ return 0;
+ }
+
+diff --git a/xc3sprog/utilities.h b/xc3sprog/utilities.h
+index ad516ea..e983926 100644
+--- a/xc3sprog/utilities.h
++++ b/xc3sprog/utilities.h
+@@ -11,7 +11,8 @@ enum CABLES_TYPES
+ CABLE_PP,
+ CABLE_FTDI,
+ CABLE_FX2,
+- CABLE_XPC
++ CABLE_XPC,
++ CABLE_EMBEDDED
+ };
+
+ CABLES_TYPES getCable(const char *given_name);
+diff --git a/xc3sprog/xc3sprog.cpp b/xc3sprog/xc3sprog.cpp
+index c18af14..1af2554 100644
+--- a/xc3sprog/xc3sprog.cpp
++++ b/xc3sprog/xc3sprog.cpp
+@@ -37,9 +37,13 @@ Dmitry Teytelman [dimtey@gmail.com] 14 Jun 2006 [applied 13 Aug 2006]:
+
+ #include "io_exception.h"
+ #include "ioparport.h"
++#ifndef EMBEDDED
+ #include "iofx2.h"
+ #include "ioftdi.h"
+ #include "ioxpc.h"
++#else
++#include "ioembedded.h"
++#endif
+ #include "bitfile.h"
+ #include "jtag.h"
+ #include "devicedb.h"
+@@ -672,6 +688,7 @@ int main(int argc, char **args)
+ (family == FAMILY_XC6S) ||
+ (family == FAMILY_XCF) ||
+ (family == FAMILY_XC2V) ||
++ (family == FAMILY_XC2VP) ||
+ (family == FAMILY_XC5VLX) ||
+ (family == FAMILY_XC5VLXT) ||
+ (family == FAMILY_XC5VSXT) ||
+@@ -763,6 +780,8 @@ int main(int argc, char **args)
+ int size = (id & 0x000ff000)>>13;
+ JedecFile file;
+ ProgAlgXC95X alg(jtag, size);
++ if (erase)
++ return alg.erase();
+ if (!readback)
+ {
+ int res = file.readFile(fpin);
Please sign in to comment.
Something went wrong with that request. Please try again.