Skip to content

Commit

Permalink
jtagbone/openocd: add binary mode on JTAGUART to fix "\n" to "\r" rem…
Browse files Browse the repository at this point in the history
…apping that is not wanted in binary mode.
  • Loading branch information
enjoy-digital committed Feb 4, 2021
1 parent b589959 commit 4d1deff
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion litex/build/openocd.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def stream(self, port=20000):
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 ""
}
Expand Down
2 changes: 1 addition & 1 deletion litex/tools/litex_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 8 additions & 6 deletions litex/tools/litex_term.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ def crossover2pty(self):
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()
Expand All @@ -155,9 +156,10 @@ def pty2tcp(self):
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:
Expand Down

0 comments on commit 4d1deff

Please sign in to comment.