tools/litex_server/litex_term: Add --jtag-chain argument.

This commit is contained in:
Florent Kermarrec 2021-05-06 15:41:25 +02:00
parent 24105f12d5
commit 34ed5672c3
2 changed files with 7 additions and 4 deletions

View File

@ -178,6 +178,7 @@ def main():
# JTAG arguments # JTAG arguments
parser.add_argument("--jtag", action="store_true", help="Select JTAG interface") parser.add_argument("--jtag", action="store_true", help="Select JTAG interface")
parser.add_argument("--jtag-config", default="openocd_xc7_ft232.cfg", help="OpenOCD JTAG configuration file") parser.add_argument("--jtag-config", default="openocd_xc7_ft232.cfg", help="OpenOCD JTAG configuration file")
parser.add_argument("--jtag-chain", default=1, help="JTAG chain")
# UDP arguments # UDP arguments
parser.add_argument("--udp", action="store_true", help="Select UDP interface") parser.add_argument("--udp", action="store_true", help="Select UDP interface")
@ -212,7 +213,7 @@ def main():
elif args.jtag: elif args.jtag:
from litex.tools.litex_term import JTAGUART from litex.tools.litex_term import JTAGUART
from litex.tools.remote.comm_uart import CommUART from litex.tools.remote.comm_uart import CommUART
bridge = JTAGUART(config=args.jtag_config) bridge = JTAGUART(config=args.jtag_config, chain=int(args.jtag_chain))
bridge.open() bridge.open()
print("[CommUART] port: JTAG / ", end="") print("[CommUART] port: JTAG / ", end="")
comm = CommUART(os.ttyname(bridge.name), debug=args.debug) comm = CommUART(os.ttyname(bridge.name), debug=args.debug)

View File

@ -133,9 +133,10 @@ class BridgeUART:
from litex.build.openocd import OpenOCD from litex.build.openocd import OpenOCD
class JTAGUART: class JTAGUART:
def __init__(self, config="openocd_xc7_ft2232.cfg", port=20000): def __init__(self, config="openocd_xc7_ft2232.cfg", port=20000, chain=1):
self.config = config self.config = config
self.port = port self.port = port
self.chain = chain
def open(self): def open(self):
self.file, self.name = pty.openpty() self.file, self.name = pty.openpty()
@ -156,7 +157,7 @@ class JTAGUART:
def jtag2tcp(self): def jtag2tcp(self):
prog = OpenOCD(self.config) prog = OpenOCD(self.config)
prog.stream(self.port) prog.stream(self.port, self.chain)
def pty2tcp(self): def pty2tcp(self):
while True: while True:
@ -540,6 +541,7 @@ def _get_args():
parser.add_argument("--jtag-name", default="jtag_uart", help="JTAG UART type: jtag_uart (default), jtag_atlantic") parser.add_argument("--jtag-name", default="jtag_uart", help="JTAG UART type: jtag_uart (default), jtag_atlantic")
parser.add_argument("--jtag-config", default="openocd_xc7_ft2232.cfg", help="OpenOCD JTAG configuration file for jtag_uart") parser.add_argument("--jtag-config", default="openocd_xc7_ft2232.cfg", help="OpenOCD JTAG configuration file for jtag_uart")
parser.add_argument("--jtag-chain", default=1, help="JTAG chain.")
return parser.parse_args() return parser.parse_args()
def main(): def main():
@ -560,7 +562,7 @@ def main():
term.payload_length = 128 term.payload_length = 128
term.delay = 1e-6 term.delay = 1e-6
elif args.jtag_name == "jtag_uart": elif args.jtag_name == "jtag_uart":
bridge = JTAGUART(config=args.jtag_config) bridge = JTAGUART(config=args.jtag_config, chain=int(args.jtag_chain))
bridge.open() bridge.open()
port = os.ttyname(bridge.name) port = os.ttyname(bridge.name)
else: else: