void process(IOBase &io, BitFile &file, int chainpos, bool verbose) { char *devicedb = NULL; unsigned id; Jtag jtag(&io); int num=jtag.getChain(); // Synchronise database with chain of devices. if(getenv("XCDB")) devicedb = strdup(getenv("XCDB")); else devicedb = strdup(DEVICEDB); DeviceDB db(devicedb); for(int i=0; i<num; i++){ int length=db.loadDevice(jtag.getDeviceID(i)); if(length>0)jtag.setDeviceIRLength(i,length); else{ id=jtag.getDeviceID(i); fprintf(stderr,"Cannot find device having IDCODE=%08x\n",id); return; } } if(jtag.selectDevice(chainpos)<0){ fprintf(stderr,"Invalid chain position %d, position must be less than %d (but not less than 0).\n",chainpos,num); return; } // Find the programming algorithm required for device const char *dd=db.getDeviceDescription(chainpos); if (verbose) { id = jtag.getDeviceID(chainpos); printf("Device IDCODE = 0x%08x\tDesc: %s\nProgramming: ", id, dd); fflush(stdout); } if(strncmp("XC3S",dd,4)==0) programXC3S(jtag,io,file); else if(strncmp("XC2V",dd,4)==0) programXC3S(jtag,io,file); else if(strncmp("XCF",dd,3)==0) { int bs=(dd[4]-'0'==1) ? 2048 : 4096; if (verbose) printf("Device block size is %d.\n", bs); programXCF(jtag,io,file, bs); } else{ fprintf(stderr,"Sorry, cannot program '%s', a later release may be able to.\n",dd); return; } }
void process(IOBase &io, BitFile &file, int chainpos) { Jtag jtag(&io); int num=jtag.getChain(); // Synchronise database with chain of devices. DeviceDB db(DEVICEDB); for(int i=0; i<num; i++){ printf("ID=%x\n", jtag.getDeviceID(i)); int length=db.loadDevice(jtag.getDeviceID(i)); if(length>0)jtag.setDeviceIRLength(i,length); else{ unsigned id=jtag.getDeviceID(i); fprintf(stderr,"Cannot find device having IDCODE=%08x\n",id); return; } } if(jtag.selectDevice(chainpos)<0){ fprintf(stderr,"Invalid chain position %d, position must be less than %d (but not less than 0).\n",chainpos,num); return; } // Find the programming algorithm required for device const char *dd=db.getDeviceDescription(chainpos); if(strncmp("XC3S",dd,4)==0) { printf("Programming..\n"); programXC3S(jtag,io,file); } else if(strncmp("XCF",dd,3)==0) programXCF(jtag,io,file); else{ fprintf(stderr,"Sorry, cannot program '%s', a later release may be able to.\n",dd); return; } }
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; }