Beispiel #1
0
int main(int argc, char **args)
{
  // Produce release info from CVS tags
  char release[]={"$Name: Release-0-5 $"};
  char *loc0=strchr(release,'-');
  if(loc0>0){
    loc0++;
    char *loc=loc0;
    do{
      loc=strchr(loc,'-');
      if(loc)*loc='.';
    }while(loc);
    release[strlen(release)-1]='\0'; // Strip off $
  }
  printf("Release %s\n",loc0);

  sakcXCProgrammer io;
  int chainpos=0;
  if(io.checkError()){
    fprintf(stderr,"Can map physical address into virtual space! or can not open '%s'.\n",MEMDEV);
  }
  if(argc<=1){
    fprintf(stderr,"\nUsage: %s infile.bit [POS]\n\n",args[0]);
    fprintf(stderr,"\tPOS  position in JTAG chain, 0=closest to TDI (default)\n\n",args[0]);
    return 1;
  }
  if(argc>2)chainpos=atoi(args[2]);
  BitFile file;
  if(file.load(args[1]))process(io,file,chainpos);
  else return 1;
  return 0;
}
int main(int argc, char**args)
{
  BitFile file;
  if(argc>1){
    int length=file.load(args[1]);
    
    file.getData();
    if(length>0){
      printf("Created from NCD file: %s\n",file.getNCDFilename());
      printf("Target device: %s\n",file.getPartName());
      printf("Created: %s %s\n",file.getDate(),file.getTime());
      printf("Bitstream length: %d bits\n",length);
    }
    else return 1;
  }
  if(argc>2)if(file.saveAsBin(args[2])>0)printf("Bitstream saved in binary format in file: %s\n",args[2]);
  if(argc<2){
    fprintf(stderr,"Usage: %s infile.bit [outfile.bin]\n",args[0]);
  }
}
int main(int argc, char **args)
{
  char release[]={"$Name: Release-0-3 $"};
  char *loc0=strchr(release,'-');
  if(loc0>0){
    loc0++;
    char *loc=loc0;
    do{
      loc=strchr(loc,'-');
      if(loc)*loc='.';
    }while(loc);
    release[strlen(release)-1]='\0'; // Strip off $
  }

  printf("Release %s\n",loc0);

  
  
  IOParport io(PPDEV);
  int chainpos=0;
  if(io.checkError()){
    fprintf(stderr,"Could not access parallel device '%s'.\n",PPDEV);
    fprintf(stderr,"You may need to set permissions of '%s' ",PPDEV);
    fprintf(stderr,"by issuing the following command as root:\n\n# chmod 666 %s\n\n",PPDEV);
  }
  if(argc<=1){
    fprintf(stderr,"\nUsage: %s infile.bit [POS]\n\n",args[0]);
    fprintf(stderr,"\tPOS  position in JTAG chain, 0=closest to TDI (default)\n\n",args[0]);
    return 1;
  }
  if(argc>2)chainpos=atoi(args[2]);
  BitFile file;
  if(file.load(args[1]))process(io,file,chainpos);
  else return 1;
  return 0;
}
int main(int argc, char **args)
{
  bool verbose = false;
  char *device = NULL;
  int ch, ll_driver = DRIVER_PARPORT;
  IOBase *io;
  IOParport io_pp;
  IOFtdi io_ftdi;

  // Produce release info from CVS tags
  char release[]={"$Name: Release-0-5 $"};
  char *loc0=strchr(release,'-');
  if(loc0>0){
    loc0++;
    char *loc=loc0;
    do{
      loc=strchr(loc,'-');
      if(loc)*loc='.';
    }while(loc);
    release[strlen(release)-1]='\0'; // Strip off $
  }
  printf("Release %s\n",loc0);

  // Start from parsing command line arguments
  while ((ch = getopt(argc, args, "c:d:v")) != -1)
    switch ((char)ch)
    {
      case 'c':
        if (strcmp(optarg, "pp") == 0)
          ll_driver = DRIVER_PARPORT;
        else if (strcmp(optarg, "ftdi") == 0)
          ll_driver = DRIVER_FTDI;
        else
          usage();
        break;
      case 'd':
        device = strdup(optarg);
        break;
      case 'v':
        verbose = true;
        break;
      default:
        usage();
    }
  
  if ((device == NULL) && (ll_driver == DRIVER_PARPORT))
    if(getenv("XCPORT"))
      device = strdup(getenv("XCPORT"));
    else
      device = strdup(PPDEV);

  switch (ll_driver)
  {
    case DRIVER_PARPORT:
      io = &io_pp;
      break;
    case DRIVER_FTDI:
      io = &io_ftdi;
      break;
    default:
      usage();
  }
  
  io->setVerbose(verbose);

  printf("argc: %d\n", argc);

  // Get rid of options
  argc -=  optind;
  args +=  optind;

  printf("argc: %d\n", argc);
  
  if(argc<1) usage();

  io->dev_open(device);
  
  if(io->checkError()){
    if (ll_driver == DRIVER_FTDI)
      fprintf(stderr, "Could not access USB device (%s).\n", 
              (device == NULL) ? "*" : device);
    else
    {
      fprintf(stderr,"Could not access parallel device '%s'.\n", device);
      fprintf(stderr,"You may need to set permissions of '%s' \n", device);
      fprintf(stderr,
              "by issuing the following command as root:\n\n# chmod 666 %s\n\n",
              device);
    }
    return 1;
  }

  free(device);
  
  
  int chainpos=0;

  if(argc>1)chainpos=atoi(args[1]);
  if(verbose)
    printf("JTAG chainpos: %d\n", chainpos);

  int length;
  BitFile file;
  if((length = file.load(args[0])))
  {
    if (verbose)
    {
      printf("Created from NCD file: %s\n",file.getNCDFilename());
      printf("Target device: %s\n",file.getPartName());
      printf("Created: %s %s\n",file.getDate(),file.getTime());
      printf("Bitstream length: %d bits\n",length);
    }      
    process(*io, file, chainpos, verbose);
  }
  else
    return 1;
  return 0;
}