summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--meta/classes/qemuboot.bbclass2
-rw-r--r--meta/conf/machine/qemuarm.conf2
-rw-r--r--meta/conf/machine/qemuarm64.conf2
-rw-r--r--meta/conf/machine/qemuarmv5.conf2
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py2
-rwxr-xr-xscripts/runqemu61
6 files changed, 31 insertions, 40 deletions
diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
index 8798ad80e6..1f8012edc1 100644
--- a/meta/classes/qemuboot.bbclass
+++ b/meta/classes/qemuboot.bbclass
@@ -103,7 +103,7 @@ def qemuboot_vars(d):
103 build_vars = ['MACHINE', 'TUNE_ARCH', 'DEPLOY_DIR_IMAGE', 103 build_vars = ['MACHINE', 'TUNE_ARCH', 'DEPLOY_DIR_IMAGE',
104 'KERNEL_IMAGETYPE', 'IMAGE_NAME', 'IMAGE_LINK_NAME', 104 'KERNEL_IMAGETYPE', 'IMAGE_NAME', 'IMAGE_LINK_NAME',
105 'STAGING_DIR_NATIVE', 'STAGING_BINDIR_NATIVE', 105 'STAGING_DIR_NATIVE', 'STAGING_BINDIR_NATIVE',
106 'STAGING_DIR_HOST'] 106 'STAGING_DIR_HOST', 'SERIAL_CONSOLES']
107 return build_vars + [k for k in d.keys() if k.startswith('QB_')] 107 return build_vars + [k for k in d.keys() if k.startswith('QB_')]
108 108
109do_write_qemuboot_conf[vardeps] += "${@' '.join(qemuboot_vars(d))}" 109do_write_qemuboot_conf[vardeps] += "${@' '.join(qemuboot_vars(d))}"
diff --git a/meta/conf/machine/qemuarm.conf b/meta/conf/machine/qemuarm.conf
index 37dae8c863..e5ec4cc065 100644
--- a/meta/conf/machine/qemuarm.conf
+++ b/meta/conf/machine/qemuarm.conf
@@ -17,7 +17,7 @@ QB_SYSTEM_NAME = "qemu-system-arm"
17QB_MACHINE = "-machine virt,highmem=off" 17QB_MACHINE = "-machine virt,highmem=off"
18QB_CPU = "-cpu cortex-a15" 18QB_CPU = "-cpu cortex-a15"
19# Standard Serial console 19# Standard Serial console
20QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0 vmalloc=256" 20QB_KERNEL_CMDLINE_APPEND = "vmalloc=256"
21# For graphics to work we need to define the VGA device as well as the necessary USB devices 21# For graphics to work we need to define the VGA device as well as the necessary USB devices
22QB_GRAPHICS = "-device VGA,edid=on" 22QB_GRAPHICS = "-device VGA,edid=on"
23QB_OPT_APPEND = "-device qemu-xhci -device usb-tablet -device usb-kbd" 23QB_OPT_APPEND = "-device qemu-xhci -device usb-tablet -device usb-kbd"
diff --git a/meta/conf/machine/qemuarm64.conf b/meta/conf/machine/qemuarm64.conf
index 05fd1f749b..51f7ecdcfd 100644
--- a/meta/conf/machine/qemuarm64.conf
+++ b/meta/conf/machine/qemuarm64.conf
@@ -17,8 +17,6 @@ QB_SYSTEM_NAME = "qemu-system-aarch64"
17QB_MACHINE = "-machine virt" 17QB_MACHINE = "-machine virt"
18QB_CPU = "-cpu cortex-a57" 18QB_CPU = "-cpu cortex-a57"
19QB_CPU_KVM = "-cpu host -machine gic-version=3" 19QB_CPU_KVM = "-cpu host -machine gic-version=3"
20# Standard Serial console
21QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0"
22# For graphics to work we need to define the VGA device as well as the necessary USB devices 20# For graphics to work we need to define the VGA device as well as the necessary USB devices
23QB_GRAPHICS = "-device VGA,edid=on" 21QB_GRAPHICS = "-device VGA,edid=on"
24QB_OPT_APPEND = "-device qemu-xhci -device usb-tablet -device usb-kbd" 22QB_OPT_APPEND = "-device qemu-xhci -device usb-tablet -device usb-kbd"
diff --git a/meta/conf/machine/qemuarmv5.conf b/meta/conf/machine/qemuarmv5.conf
index dfe2a89573..7050bae088 100644
--- a/meta/conf/machine/qemuarmv5.conf
+++ b/meta/conf/machine/qemuarmv5.conf
@@ -12,7 +12,7 @@ SERIAL_CONSOLES ?= "115200;ttyAMA0 115200;ttyAMA1"
12# For runqemu 12# For runqemu
13QB_SYSTEM_NAME = "qemu-system-arm" 13QB_SYSTEM_NAME = "qemu-system-arm"
14QB_MACHINE = "-machine versatilepb" 14QB_MACHINE = "-machine versatilepb"
15QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0,115200 console=tty vmalloc=256" 15QB_KERNEL_CMDLINE_APPEND = "vmalloc=256"
16QB_OPT_APPEND = "-usb -device usb-tablet" 16QB_OPT_APPEND = "-usb -device usb-tablet"
17PREFERRED_VERSION_linux-yocto ??= "5.10%" 17PREFERRED_VERSION_linux-yocto ??= "5.10%"
18QB_DTB = "${@oe.utils.version_less_or_equal('PREFERRED_VERSION_linux-yocto', '4.7', '', 'zImage-versatile-pb.dtb', d)}" 18QB_DTB = "${@oe.utils.version_less_or_equal('PREFERRED_VERSION_linux-yocto', '4.7', '', 'zImage-versatile-pb.dtb', d)}"
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 77ec939ad7..eb23dbceb8 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -176,7 +176,7 @@ class QemuRunner:
176 self.logger.error("Failed to create listening socket: %s" % msg[1]) 176 self.logger.error("Failed to create listening socket: %s" % msg[1])
177 return False 177 return False
178 178
179 bootparams = 'console=tty1 console=ttyS0,115200n8 printk.time=1' 179 bootparams = ' printk.time=1'
180 if extra_bootparams: 180 if extra_bootparams:
181 bootparams = bootparams + ' ' + extra_bootparams 181 bootparams = bootparams + ' ' + extra_bootparams
182 182
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