void testDebug() { IOBase *io; io=new IODebug(); unsigned char tdi[]={0x3a,0xa3}; unsigned char tdo[10]; io->setTapState(IOBase::SHIFT_DR); io->shiftTDITDO(tdi,tdo,16,false); for(int i=0; i<2; i++)printf("TDO %02x\n",tdo[i]); delete io; }
void testPP() { IOBase *io; io=new IOParport("/dev/parport0"); unsigned char tdi[]={0,0,0,0,0,0,0,0}; unsigned char tdo[100]; io->setTapState(IOBase::SHIFT_DR); io->shiftTDITDO(tdi,tdo,64); for(int i=0; i<8; i++)printf("TDO %02x\n",tdo[i]); printf("\n"); getSwitches(io); getID(io); delete io; }
void process(IOBase &io, BitFile &file, int chainpos) { const byte IDCODE=0x09; const byte XCF_IDCODE=0xfe; Jtag jtag(&io); int num=jtag.getChain(); 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{ byte *id=jtag.getDeviceID(i); fprintf(stderr,"Cannot find device having IDCODE=%02x%02x%02x%02x\n",id[0],id[1],id[2],id[3]); return; } } byte tdo[4]; if(jtag.selectDevice(chainpos)<0){ fprintf(stderr,"Invalid chain position %d, position must be less than <%d.\n",chainpos,num); return; } jtag.shiftIR(&IDCODE); jtag.shiftDR(0,tdo,32); printf("IDCODE: 0x%02x%02x%02x%02x\tDesc: %s\n",tdo[0],tdo[1],tdo[2],tdo[3],db.getDeviceDescription(chainpos)); const byte JPROGRAM=0x0b; const byte CFG_IN=0x05; const byte JSHUTDOWN=0x0d; const byte JSTART=0x0c; const byte BYPASS=0x3f; jtag.shiftIR(&JPROGRAM); jtag.shiftIR(&CFG_IN); byte init[]={0x00, 0x00, 0x00, 0x00, // Flush 0x00, 0x00, 0x00, 0x00, // Flush 0xe0, 0x00, 0x00, 0x00, // Clear CRC 0x80, 0x01, 0x00, 0x0c, // CMD 0x66, 0xAA, 0x99, 0x55, // Sync 0xff, 0xff, 0xff, 0xff // Sync }; jtag.shiftDR(init,0,192,32); // Align to 32 bits. jtag.shiftIR(&JSHUTDOWN); io.cycleTCK(12); jtag.shiftIR(&CFG_IN); byte hdr[]={0x00, 0x00, 0x00, 0x00, // Flush 0x10, 0x00, 0x00, 0x00, // Assert GHIGH 0x80, 0x01, 0x00, 0x0c // CMD }; jtag.shiftDR(hdr,0,96,32,false); // Align to 32 bits and do not goto EXIT1-DR jtag.shiftDR(file.getData(),0,file.getLength()); io.tapTestLogicReset(); io.setTapState(IOBase::RUN_TEST_IDLE); jtag.shiftIR(&JSTART); io.cycleTCK(12); jtag.shiftIR(&BYPASS); // Don't know why, but without this the FPGA will not reconfigure from Flash when PROG is asserted. }