diff --git a/litex/build/openocd.py b/litex/build/openocd.py index 5f392d31c..f287f6365 100644 --- a/litex/build/openocd.py +++ b/litex/build/openocd.py @@ -96,7 +96,7 @@ proc jtagstream_drain {tap tx chunk_rx max_rx} { proc jtagstream_rxtx {tap client is_poll} { if {![$client eof]} { if {!$is_poll} { - set tx [$client read -nonewline 1] + set tx [$client read 1] } else { set tx "" } diff --git a/litex/tools/litex_server.py b/litex/tools/litex_server.py index 56e222885..c336014a6 100755 --- a/litex/tools/litex_server.py +++ b/litex/tools/litex_server.py @@ -212,7 +212,7 @@ def main(): elif args.jtag: from litex.tools.litex_term import JTAGUART from litex.tools.remote.comm_uart import CommUART - bridge = JTAGUART(config=args.jtag_config) + bridge = JTAGUART(config=args.jtag_config, binary_mode=True) bridge.open() print("[CommUART] port: JTAG / ", end="") comm = CommUART(os.ttyname(bridge.name), debug=args.debug) diff --git a/litex/tools/litex_term.py b/litex/tools/litex_term.py index 3a6567e35..700b89c80 100755 --- a/litex/tools/litex_term.py +++ b/litex/tools/litex_term.py @@ -126,9 +126,10 @@ class CrossoverUART: from litex.build.openocd import OpenOCD class JTAGUART: - def __init__(self, config="openocd_xc7_ft2232.cfg", port=20000): # FIXME: add command line arguments - self.config = config - self.port = port + def __init__(self, config="openocd_xc7_ft2232.cfg", port=20000, binary_mode=False): # FIXME: add command line arguments + self.config = config + self.port = port + self.binary_mode = binary_mode def open(self): self.file, self.name = pty.openpty() @@ -155,9 +156,10 @@ class JTAGUART: while True: r = os.read(self.file, 1) self.tcp.send(r) - if r == bytes("\n".encode("utf-8")): - self.tcp.send("\r".encode("utf-8")) - self.tcp.send("\n".encode("utf-8")) + if not self.binary_mode: + if r == bytes("\n".encode("utf-8")): + self.tcp.send("\r".encode("utf-8")) + self.tcp.send("\n".encode("utf-8")) def tcp2pty(self): while True: