Example #1
0
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;
  }
}
Example #2
0
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;
  }
}