mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-22 06:33:03 +00:00
proxyclient: handle baud rate switching properly for non-Glasgow UARTs
Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
96d133e854
commit
053f2edbc3
2 changed files with 19 additions and 8 deletions
|
@ -190,8 +190,10 @@ class UartInterface:
|
||||||
self.cmd(self.REQ_NOP)
|
self.cmd(self.REQ_NOP)
|
||||||
self.reply(self.REQ_NOP)
|
self.reply(self.REQ_NOP)
|
||||||
|
|
||||||
def proxyreq(self, req, reboot=False, no_reply=False):
|
def proxyreq(self, req, reboot=False, no_reply=False, pre_reply=None):
|
||||||
self.cmd(self.REQ_PROXY, req)
|
self.cmd(self.REQ_PROXY, req)
|
||||||
|
if pre_reply:
|
||||||
|
pre_reply()
|
||||||
if no_reply:
|
if no_reply:
|
||||||
return
|
return
|
||||||
elif reboot:
|
elif reboot:
|
||||||
|
@ -329,14 +331,14 @@ class M1N1Proxy:
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
self.iface = iface
|
self.iface = iface
|
||||||
|
|
||||||
def request(self, opcode, *args, reboot=False, signed=False, no_reply=False):
|
def request(self, opcode, *args, reboot=False, signed=False, no_reply=False, pre_reply=None):
|
||||||
if len(args) > 6:
|
if len(args) > 6:
|
||||||
raise ValueError("Too many arguments")
|
raise ValueError("Too many arguments")
|
||||||
args = list(args) + [0] * (6 - len(args))
|
args = list(args) + [0] * (6 - len(args))
|
||||||
req = struct.pack("<7Q", opcode, *args)
|
req = struct.pack("<7Q", opcode, *args)
|
||||||
if self.debug:
|
if self.debug:
|
||||||
print("<<<< %08x: %08x %08x %08x %08x %08x %08x"%tuple([opcode] + args))
|
print("<<<< %08x: %08x %08x %08x %08x %08x %08x"%tuple([opcode] + args))
|
||||||
reply = self.iface.proxyreq(req, reboot=reboot, no_reply=no_reply)
|
reply = self.iface.proxyreq(req, reboot=reboot, no_reply=no_reply, pre_reply=None)
|
||||||
if no_reply:
|
if no_reply:
|
||||||
return
|
return
|
||||||
ret_fmt = "q" if signed else "Q"
|
ret_fmt = "q" if signed else "Q"
|
||||||
|
@ -376,8 +378,10 @@ class M1N1Proxy:
|
||||||
return self.request(self.P_GET_BASE)
|
return self.request(self.P_GET_BASE)
|
||||||
def set_baud(self, baudrate):
|
def set_baud(self, baudrate):
|
||||||
self.iface.tty_enable = False
|
self.iface.tty_enable = False
|
||||||
|
def change():
|
||||||
|
self.iface.dev.baudrate = baudrate
|
||||||
try:
|
try:
|
||||||
self.request(self.P_SET_BAUD, baudrate, 16, 0x005aa5f0)
|
self.request(self.P_SET_BAUD, baudrate, 16, 0x005aa5f0, pre_reply=change)
|
||||||
finally:
|
finally:
|
||||||
self.iface.tty_enable = True
|
self.iface.tty_enable = True
|
||||||
def udelay(self, usec):
|
def udelay(self, usec):
|
||||||
|
|
|
@ -4,15 +4,22 @@ from tgtypes import *
|
||||||
from utils import *
|
from utils import *
|
||||||
|
|
||||||
uartdev = os.environ.get("M1N1DEVICE", "/dev/ttyUSB0")
|
uartdev = os.environ.get("M1N1DEVICE", "/dev/ttyUSB0")
|
||||||
usbuart = serial.Serial(uartdev, 115200)
|
uart = serial.Serial(uartdev, 115200)
|
||||||
|
|
||||||
iface = UartInterface(usbuart, debug=False)
|
iface = UartInterface(uart, debug=False)
|
||||||
p = M1N1Proxy(iface, debug=False)
|
p = M1N1Proxy(iface, debug=False)
|
||||||
|
|
||||||
|
try:
|
||||||
|
uart.timeout = 0.15
|
||||||
|
iface.nop()
|
||||||
|
p.set_baud(1500000)
|
||||||
|
except UartTimeout:
|
||||||
|
uart.baudrate = 1500000
|
||||||
|
iface.nop()
|
||||||
|
|
||||||
u = ProxyUtils(p)
|
u = ProxyUtils(p)
|
||||||
mon = RegMonitor(u)
|
mon = RegMonitor(u)
|
||||||
|
|
||||||
p.set_baud(1500000)
|
|
||||||
|
|
||||||
iface.nop()
|
iface.nop()
|
||||||
|
|
||||||
fb = u.ba.video.base
|
fb = u.ba.video.base
|
||||||
|
|
Loading…
Reference in a new issue