mirror of
https://github.com/AsahiLinux/m1n1
synced 2025-02-16 21:58:27 +00:00
linux.py: Allow specifying a separate TTY device
This allows e.g. opening a TTY on the UART serial device after booting the kernel via USB. Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
7dfe24ee2c
commit
f6297437c0
2 changed files with 17 additions and 7 deletions
|
@ -8,6 +8,7 @@ parser.add_argument('dtb', type=pathlib.Path)
|
|||
parser.add_argument('initramfs', nargs='?', type=pathlib.Path)
|
||||
parser.add_argument('--compression', choices=['auto', 'none', 'gz', 'xz'], default='auto')
|
||||
parser.add_argument('-b', '--bootargs', type=str, metavar='"boot arguments"')
|
||||
parser.add_argument('-t', '--tty', type=str)
|
||||
args = parser.parse_args()
|
||||
|
||||
from setup import *
|
||||
|
@ -98,5 +99,11 @@ daif = 0xc0
|
|||
u.msr(DAIF, daif)
|
||||
print("DAIF: %x" % daif)
|
||||
|
||||
tty_dev = None
|
||||
if args.tty is not None:
|
||||
tty_dev = serial.Serial(args.tty)
|
||||
tty_dev.reset_input_buffer()
|
||||
|
||||
p.kboot_boot(kernel_base)
|
||||
iface.ttymode()
|
||||
|
||||
iface.ttymode(tty_dev)
|
||||
|
|
|
@ -134,12 +134,15 @@ class UartInterface:
|
|||
sys.stdout.write(chr(c))
|
||||
sys.stdout.flush()
|
||||
|
||||
def ttymode(self):
|
||||
tout = self.dev.timeout
|
||||
self.tty_enable = True
|
||||
self.dev.timeout = None
|
||||
def ttymode(self, dev=None):
|
||||
if dev is None:
|
||||
dev = self.dev
|
||||
|
||||
term = Miniterm(self.dev, eol='cr')
|
||||
tout = dev.timeout
|
||||
self.tty_enable = True
|
||||
dev.timeout = None
|
||||
|
||||
term = Miniterm(dev, eol='cr')
|
||||
term.exit_character = chr(0x1d) # GS/CTRL+]
|
||||
term.menu_character = chr(0x14) # Menu: CTRL+T
|
||||
term.raw = True
|
||||
|
@ -157,7 +160,7 @@ class UartInterface:
|
|||
term.join()
|
||||
term.close()
|
||||
|
||||
self.dev.timeout = tout
|
||||
dev.timeout = tout
|
||||
self.tty_enable = False
|
||||
|
||||
def reply(self, cmd):
|
||||
|
|
Loading…
Add table
Reference in a new issue