This patch adds xsvf_tools support for parsing the SVF TRST command.
The corresponding patch to xsvf.c is still needed, pending agreement on direction. In its simplest form, the xsvf.c change could merely skip the new XSVF opcode. But if the cable API supports it, we can do better.
The value of the new XTRST opcode is 28 decimal and it takes a single byte argument in the XSVF file, 0-3 corresponding in sequence of the allowed arguments to the TRST command.
Dick
Index: tools/xsvf_tools/xsvfdump.py =================================================================== --- tools/xsvf_tools/xsvfdump.py (revision 1355) +++ tools/xsvf_tools/xsvfdump.py (working copy) @@ -39,7 +39,8 @@ (XCOMPLETE,XTDOMASK,XSIR,XSDR,XRUNTEST,hole0,hole1,XREPEAT,XSDRSIZE,XSDRTDO, XSETSDRMASKS,XSDRINC,XSDRB,XSDRC,XSDRE,XSDRTDOB,XSDRTDOC, - XSDRTDOE,XSTATE,XENDIR,XENDDR,XSIR2,XCOMMENT,XWAIT,XWAITSTATE,LCOUNT,LDELAY,LSDR) = range(28) + XSDRTDOE,XSTATE,XENDIR,XENDDR,XSIR2,XCOMMENT,XWAIT,XWAITSTATE, + LCOUNT,LDELAY,LSDR,XTRST) = range(29) (RESET,IDLE, @@ -51,6 +52,10 @@ "DRSELECT","DRCAPTURE","DRSHIFT","DREXIT1","DRPAUSE","DREXIT2","DRUPDATE", "IRSELECT","IRCAPTURE","IRSHIFT","IREXIT1","IRPAUSE","IREXIT2","IRUPDATE") + +trst_mode_allowed = ('ON', 'OFF', 'Z', 'ABSENT') + + Setsdrmasks = 0 SetsdrmasksOnesCount = 0 @@ -229,6 +234,14 @@ tdo = bytes2hexString( f, Xsdrsize ) print("LSDR 0x%s 0x%s" % (tdi, tdo) ) + elif op == XTRST: + # the argument is a single byte and it is the index into "trst_mode_allowed" + trst_mode = ReadByte(f) + if trst_mode <= 3: + print("TRST %s" % trst_mode_allowed[trst_mode] ) + else: + print("TRST 0x%02X" % trst_mode ); + else: print("UNKNOWN op 0x%02X %d" % (op, op)) exit(1) Property changes on: tools/xsvf_tools/xsvfdump.py ___________________________________________________________________ Added: svn:executable + * Index: tools/xsvf_tools/svf2xsvf.py =================================================================== --- tools/xsvf_tools/svf2xsvf.py (revision 1355) +++ tools/xsvf_tools/svf2xsvf.py (working copy) @@ -57,6 +57,11 @@ doCOMMENTs = True # Save XCOMMENTs in the output xsvf file #doCOMMENTs = False # Save XCOMMENTs in the output xsvf file +# pick your file encoding +file_encoding = 'ISO-8859-1' +#file_encoding = 'utf-8' + + xrepeat = 0 # argument to XREPEAT, gives retry count for masked compares @@ -74,7 +79,8 @@ (XCOMPLETE,XTDOMASK,XSIR,XSDR,XRUNTEST,hole0,hole1,XREPEAT,XSDRSIZE,XSDRTDO, XSETSDRMASKS,XSDRINC,XSDRB,XSDRC,XSDRE,XSDRTDOB,XSDRTDOC, - XSDRTDOE,XSTATE,XENDIR,XENDDR,XSIR2,XCOMMENT,XWAIT,XWAITSTATE,LCOUNT,LDELAY,LSDR) = range(28) + XSDRTDOE,XSTATE,XENDIR,XENDDR,XSIR2,XCOMMENT,XWAIT,XWAITSTATE, + LCOUNT,LDELAY,LSDR,XTRST) = range(29) #Note: LCOUNT, LDELAY, and LSDR are Lattice extensions to SVF and provide a way to loop back # and check a completion status, essentially waiting on a part until it signals that it is done. @@ -90,6 +96,8 @@ TDO (1); """ +#XTRST is an opcode Xilinx seemed to have missed and it comes from the SVF TRST statement. + LineNumber = 1 def s_ident(scanner, token): return ("ident", token.upper(), LineNumber) @@ -127,9 +135,14 @@ re.MULTILINE ) +# open the file using the given encoding +file = open( sys.argv[1], encoding=file_encoding ) + # read all svf file input into string "input" -input = open( sys.argv[1] ).read() +input = file.read() +file.close() + # Lexer: # create a list of tuples containing (tokenType, tokenValue, LineNumber) tokens = scanner.scan( input )[0] @@ -368,6 +381,8 @@ enddr_state_allowed = ('DRPAUSE', 'IDLE') endir_state_allowed = ('IRPAUSE', 'IDLE') +trst_mode_allowed = ('ON', 'OFF', 'Z', 'ABSENT') + enddr_state = IDLE endir_state = IDLE @@ -681,6 +696,19 @@ if tokVal != ';': raise ParseError( tokLn, tokVal, "Expecting ';' after FREQUENCY cycles HZ") + elif tokVal == 'TRST': + nextTok() + if tokVal not in trst_mode_allowed: + raise ParseError( tokLn, tokVal, "Expecting 'ON|OFF|Z|ABSENT' after TRST") + trst_mode = tokVal + nextTok() + if tokVal != ';': + raise ParseError( tokLn, tokVal, "Expecting ';' after TRST trst_mode") + obuf = bytearray( 2 ) + obuf[0] = XTRST + obuf[1] = trst_mode_allowed.index( trst_mode ) # use the index as the binary argument to XTRST opcode + output.write( obuf ) + else: raise ParseError( tokLn, tokVal, "Unknown token '%s'" % tokVal) Property changes on: tools/xsvf_tools/svf2xsvf.py ___________________________________________________________________ Added: svn:executable + *
_______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development