jtagbone/openocd: add binary mode on JTAGUART to fix "\n" to "\r" remapping that is not wanted in binary mode.

This commit is contained in:
Florent Kermarrec 2021-02-04 11:41:36 +01:00
parent b589959084
commit 4d1deffbb0
3 changed files with 10 additions and 8 deletions

View File

@ -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 ""
}

View File

@ -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)

View File

@ -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: