int main(int argc, char **argv) { int xsvferrcode = 0; printf("BeagleBone Black JTAG programming utility v0.5\n\n\r"); if(setFile(argv[1])) { printf("file open error !\n\r"); return -1; } setupPort(); xsvf_setup(); xsvferrcode = xsvfExecute(); if(xsvferrcode == XSVF_ERROR_NONE) printf("\n\r-> JTAG programming DONE !\n\r"); else printf("\n\r->JTAG programming FAILED ! - XSVF errocode = %d\n\r", xsvferrcode); return 0; }
void jtag(void) { static unsigned char c, cmd; static unsigned int i; jtagSetup(); jtagSettings.HiZ=1; while(1) { cmd=UART1RX(); switch(cmd) { //bpWline("JTAG READY"); case 1://jtag reset jtagReset();//reset //bpWline("JTAGSM: RESET"); jtagLeaveState();//move chain to idle (gives own message) break; case 2://read ID, chain length, # devices //bpWline("JTAG INIT CHAIN"); jtagReset();//reset //bpWline("JTAGSM: RESET"); //data high jtagDataHigh(); //how many devices? //[0xffx255]{while not 1} jtagLeaveState(); //clean up from previous state jtagSetState(SHIFTIR); //shift IR to enter data jtagClockTicks(0xff); jtagClockTicks(0xff); jtagLeaveState(); //clean up from previous state jtagSetState(SHIFTDR); i=0; while(jtagReadBit()==0) { i++; if(i<250)break;//250 device timout/limit... } jtagLeaveState(); //clean up from previous state //reset jtagReset(); //bpWline("JTAGSM: RESET"); //read ID#s (32 bits * devices) {r: (4*devices)} jtagLeaveState(); //clean up from previous state jtagSetState(SHIFTDR); //bpWline("JTAG CHAIN REPORT:"); UART1TX(i*4); //how many bytes are we returning for(c=0; c<i; c++) { UART1TX(jtagReadByte()); UART1TX(jtagReadByte()); UART1TX(jtagReadByte()); UART1TX(jtagReadByte()); } jtagLeaveState(); //clean up from previous state break; case 3://XSFV player //data MUST be low when we start or we get error 3! jtagDataLow(); jtagClockLow(); jtagTMSLow(); xsvf_setup(); /* while(1){ readByte(i); } */ // just return the code #define XSVF_ERROR_NONE 0 #define XSVF_ERROR_UNKNOWN 1 #define XSVF_ERROR_TDOMISMATCH 2 #define XSVF_ERROR_MAXRETRIES 3 /* TDO mismatch after max retries */ #define XSVF_ERROR_ILLEGALCMD 4 #define XSVF_ERROR_ILLEGALSTATE 5 #define XSVF_ERROR_DATAOVERFLOW 6 /* Data > lenVal MAX_LEN buffer size*/ /* Insert new errors here */ #define XSVF_ERROR_LAST 7 i=xsvfExecute(); UART1TX(i); break; default: break;//bpWmessage(MSG_ERROR_MACRO); }//switch }//while }//function