parser = argparse.ArgumentParser(description='Load FX2LP firmware, load the FPGA, interact with the FPGA.') parser.add_argument('-v', action="store", nargs=1, required=True, metavar="<VID:PID>", help="VID, PID and opt. dev ID (e.g 1D50:602B:0001)") parser.add_argument('-q', action="store", nargs=1, required=True, metavar="<jtagPorts>", help="query the JTAG chain") argList = parser.parse_args() vp = argList.v[0] jtagPorts = argList.q[0] handle = fl.FLHandle() try: fl.flInitialise(0) handle = fl.flOpen(vp) fl.progOpen(handle, jtagPorts) # Try special-purpose enum: fl.jtagClockFSM(handle, 0x0000005F, 9) bs = fl.jtagShiftInOut(handle, 64, fl.SHIFT_ZEROS) print("TDO data, given 64 zeros:\n {}".format( " ".join(["{:02X}".format(b) for b in bs]))) # Try explicit bytes: fl.jtagClockFSM(handle, 0x0000005F, 9) bs = fl.jtagShiftInOut(handle, 128, b"\xFF\xFF\xFF\xFF\x00\x00\x00\x00\xCA\xFE\xBA\xBE\xDE\xAD\xBE\xEF") print("TDO data, given 128 explicit bits:\n {}".format( " ".join(["{:02X}".format(b) for b in bs]))) fl.progClose(handle) except fl.FLException as ex: print(ex) finally:
print("flIsNeroCapable(): {}".format(fl.flIsNeroCapable(conn))) print("flIsCommCapable(): {}".format(fl.flIsCommCapable(conn, CONDUIT))) fl.progOpen(conn, PROG_CONFIG) print("progGetPort(): {") (port, bit) = fl.progGetPort(conn, fl.LP_MISO) print(" MISO: {:c}{}".format(ord('A')+port, bit)) (port, bit) = fl.progGetPort(conn, fl.LP_MOSI) print(" MOSI: {:c}{}".format(ord('A')+port, bit)) (port, bit) = fl.progGetPort(conn, fl.LP_SS) print(" SS: {:c}{}".format(ord('A')+port, bit)) (port, bit) = fl.progGetPort(conn, fl.LP_SCK) print(" SCK: {:c}{}".format(ord('A')+port, bit)) print("}") fl.jtagClockFSM(conn, 0x0000005F, 9) fl.jtagShiftInOnly(conn, 32, BYTE_ARRAY) bs = fl.jtagShiftInOut(conn, 128, fl.SHIFT_ONES) print("jtagShiftInOut() got {} bytes: {{\n {}\n}}".format( len(bs), " ".join(["{:02X}".format(b) for b in bs]))) fl.jtagClockFSM(conn, 0x0000005F, 9) fl.spiSend(conn, BYTE_ARRAY, fl.SPI_LSBFIRST) bs = fl.spiRecv(conn, 8, fl.SPI_LSBFIRST) print("spiRecv() got {} bytes: {{\n {}\n}}".format( len(bs), " ".join(["{:02X}".format(b) for b in bs]))) fl.progClose(conn) print("jtagScanChain(): {")
required=True, metavar="<jtagPorts>", help="query the JTAG chain") argList = parser.parse_args() vp = argList.v[0] jtagPorts = argList.q[0] handle = fl.FLHandle() try: fl.flInitialise(0) handle = fl.flOpen(vp) fl.progOpen(handle, jtagPorts) # Try special-purpose enum: fl.jtagClockFSM(handle, 0x0000005F, 9) bs = fl.jtagShiftInOut(handle, 64, fl.SHIFT_ZEROS) print("TDO data, given 64 zeros:\n {}".format(" ".join( ["{:02X}".format(b) for b in bs]))) # Try explicit bytes: fl.jtagClockFSM(handle, 0x0000005F, 9) bs = fl.jtagShiftInOut( handle, 128, b"\xFF\xFF\xFF\xFF\x00\x00\x00\x00\xCA\xFE\xBA\xBE\xDE\xAD\xBE\xEF") print("TDO data, given 128 explicit bits:\n {}".format(" ".join( ["{:02X}".format(b) for b in bs]))) fl.progClose(handle) except fl.FLException as ex: