summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJon Mason <jdmason@kudzu.us>2021-03-10 18:05:32 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-03-11 14:00:36 +0000
commit16d1669ff9f28013db829593c018b418304abad3 (patch)
tree660cb131b65ffadf1992b874a51910da80130d58 /scripts
parentbd0ada8994ce3c1cb3a2d67dc9e8fae5c348118e (diff)
downloadpoky-16d1669ff9f28013db829593c018b418304abad3.tar.gz
runqemu: correct forcing of ttyS0
Some platforms do not use ttyS* for their serial consoles (e.g., qemuarm and qemuarm64). The hardcoding of this can cause issues. Modify runqemu to use the serial consoles defined in SERIAL_CONSOLES instead of hardcoding. (From OE-Core rev: 9dea4cd2f9f46ab3a75562639a22d8f56b4d26af) Signed-off-by: Jon Mason <jon.mason@arm.com> Change-Id: I746d56de5669c955c5e29d3ded70c0a4d3171f17 Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/runqemu61
1 files changed, 27 insertions, 34 deletions
diff --git a/scripts/runqemu b/scripts/runqemu
index 4c8358e9de..842509eb14 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -139,6 +139,7 @@ class BaseConfig(object):
139 'OE_TMPDIR', 139 'OE_TMPDIR',
140 'OECORE_NATIVE_SYSROOT', 140 'OECORE_NATIVE_SYSROOT',
141 'MULTICONFIG', 141 'MULTICONFIG',
142 'SERIAL_CONSOLES',
142 ) 143 )
143 144
144 self.qemu_opt = '' 145 self.qemu_opt = ''
@@ -464,7 +465,6 @@ class BaseConfig(object):
464 if ('gtk' in sys.argv): 465 if ('gtk' in sys.argv):
465 raise RunQemuError('Option nographic makes no sense alongside the gtk option.' % (arg)) 466 raise RunQemuError('Option nographic makes no sense alongside the gtk option.' % (arg))
466 self.qemu_opt_script += ' -nographic' 467 self.qemu_opt_script += ' -nographic'
467 self.kernel_cmdline_script += ' console=ttyS0'
468 elif arg == 'sdl': 468 elif arg == 'sdl':
469 if 'gl' in sys.argv[1:]: 469 if 'gl' in sys.argv[1:]:
470 self.set_dri_path() 470 self.set_dri_path()
@@ -493,10 +493,8 @@ class BaseConfig(object):
493 elif arg == 'novga': 493 elif arg == 'novga':
494 self.qemu_opt_script += ' -vga none' 494 self.qemu_opt_script += ' -vga none'
495 elif arg == 'serial': 495 elif arg == 'serial':
496 self.kernel_cmdline_script += ' console=ttyS0'
497 self.serialconsole = True 496 self.serialconsole = True
498 elif arg == "serialstdio": 497 elif arg == "serialstdio":
499 self.kernel_cmdline_script += ' console=ttyS0'
500 self.serialstdio = True 498 self.serialstdio = True
501 elif arg == 'audio': 499 elif arg == 'audio':
502 logger.info("Enabling audio in qemu") 500 logger.info("Enabling audio in qemu")
@@ -1321,6 +1319,31 @@ class BaseConfig(object):
1321 raise RunQemuError("Failed to boot, QB_SYSTEM_NAME is NULL!") 1319 raise RunQemuError("Failed to boot, QB_SYSTEM_NAME is NULL!")
1322 self.qemu_system = qemu_system 1320 self.qemu_system = qemu_system
1323 1321
1322 def setup_serial(self):
1323 # Setup correct kernel command line for serial
1324 if self.serialstdio == True or self.serialconsole == True or re.search("-nographic", self.qemu_opt) or self.tcpserial_portnum:
1325 for entry in self.get('SERIAL_CONSOLES').split(' '):
1326 self.kernel_cmdline_script += ' console=%s' %entry.split(';')[1]
1327
1328 if self.serialstdio == True or re.search("-nographic", self.qemu_opt):
1329 self.qemu_opt += " -serial mon:stdio"
1330 else:
1331 self.qemu_opt += " -serial mon:vc"
1332 if self.serialconsole:
1333 if sys.stdin.isatty():
1334 subprocess.check_call(("stty", "intr", "^]"))
1335 logger.info("Interrupt character is '^]'")
1336
1337 self.qemu_opt += " %s" % self.get("QB_SERIAL_OPT")
1338
1339 # We always wants ttyS0 and ttyS1 in qemu machines (see SERIAL_CONSOLES).
1340 # If no serial or serialtcp options were specified, only ttyS0 is created
1341 # and sysvinit shows an error trying to enable ttyS1:
1342 # INIT: Id "S1" respawning too fast: disabled for 5 minutes
1343 serial_num = len(re.findall("-serial", self.qemu_opt))
1344 if serial_num < 2:
1345 self.qemu_opt += " -serial null"
1346
1324 def setup_final(self): 1347 def setup_final(self):
1325 qemu_bin = os.path.join(self.bindir_native, self.qemu_system) 1348 qemu_bin = os.path.join(self.bindir_native, self.qemu_system)
1326 1349
@@ -1365,37 +1388,7 @@ class BaseConfig(object):
1365 if self.snapshot: 1388 if self.snapshot:
1366 self.qemu_opt += " -snapshot" 1389 self.qemu_opt += " -snapshot"
1367 1390
1368 if self.serialconsole: 1391 self.setup_serial()
1369 if sys.stdin.isatty():
1370 subprocess.check_call(("stty", "intr", "^]"))
1371 logger.info("Interrupt character is '^]'")
1372
1373 first_serial = ""
1374 if not re.search("-nographic", self.qemu_opt):
1375 first_serial = "-serial mon:vc"
1376 # We always want a ttyS1. Since qemu by default adds a serial
1377 # port when nodefaults is not specified, it seems that all that
1378 # would be needed is to make sure a "-serial" is there. However,
1379 # it appears that when "-serial" is specified, it ignores the
1380 # default serial port that is normally added. So here we make
1381 # sure to add two -serial if there are none. And only one if
1382 # there is one -serial already.
1383 serial_num = len(re.findall("-serial", self.qemu_opt))
1384 if serial_num == 0:
1385 self.qemu_opt += " %s %s" % (first_serial, self.get("QB_SERIAL_OPT"))
1386 elif serial_num == 1:
1387 self.qemu_opt += " %s" % self.get("QB_SERIAL_OPT")
1388
1389 # We always wants ttyS0 and ttyS1 in qemu machines (see SERIAL_CONSOLES),
1390 # if not serial or serialtcp options was specified only ttyS0 is created
1391 # and sysvinit shows an error trying to enable ttyS1:
1392 # INIT: Id "S1" respawning too fast: disabled for 5 minutes
1393 serial_num = len(re.findall("-serial", self.qemu_opt))
1394 if serial_num == 0:
1395 if re.search("-nographic", self.qemu_opt) or self.serialstdio:
1396 self.qemu_opt += " -serial mon:stdio -serial null"
1397 else:
1398 self.qemu_opt += " -serial mon:vc -serial null"
1399 1392
1400 def start_qemu(self): 1393 def start_qemu(self):
1401 import shlex 1394 import shlex