]> code.ossystems Code Review - openembedded-core.git/commitdiff
runqemu: correct forcing of ttyS0
authorJon Mason <jdmason@kudzu.us>
Wed, 10 Mar 2021 23:05:32 +0000 (18:05 -0500)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 11 Mar 2021 13:59:35 +0000 (13:59 +0000)
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.

Signed-off-by: Jon Mason <jon.mason@arm.com>
Change-Id: I746d56de5669c955c5e29d3ded70c0a4d3171f17
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/qemuboot.bbclass
meta/conf/machine/qemuarm.conf
meta/conf/machine/qemuarm64.conf
meta/conf/machine/qemuarmv5.conf
meta/lib/oeqa/utils/qemurunner.py
scripts/runqemu

index 8798ad80e68b7bf1c1264f35879fd1468a127497..1f8012edc1d7b2b88d24a3aeef779f414f180d93 100644 (file)
@@ -103,7 +103,7 @@ def qemuboot_vars(d):
     build_vars = ['MACHINE', 'TUNE_ARCH', 'DEPLOY_DIR_IMAGE',
                 'KERNEL_IMAGETYPE', 'IMAGE_NAME', 'IMAGE_LINK_NAME',
                 'STAGING_DIR_NATIVE', 'STAGING_BINDIR_NATIVE',
-                'STAGING_DIR_HOST']
+                'STAGING_DIR_HOST', 'SERIAL_CONSOLES']
     return build_vars + [k for k in d.keys() if k.startswith('QB_')]
 
 do_write_qemuboot_conf[vardeps] += "${@' '.join(qemuboot_vars(d))}"
index 37dae8c86353432b85996161225638cd75886731..e5ec4cc065f02b2f5d790a7726aee8468de97bd9 100644 (file)
@@ -17,7 +17,7 @@ QB_SYSTEM_NAME = "qemu-system-arm"
 QB_MACHINE = "-machine virt,highmem=off"
 QB_CPU = "-cpu cortex-a15"
 # Standard Serial console
-QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0 vmalloc=256"
+QB_KERNEL_CMDLINE_APPEND = "vmalloc=256"
 # For graphics to work we need to define the VGA device as well as the necessary USB devices
 QB_GRAPHICS = "-device VGA,edid=on"
 QB_OPT_APPEND = "-device qemu-xhci -device usb-tablet -device usb-kbd"
index 05fd1f749b0f0a8d1598c8cb7a0e43dc7f1fefcb..51f7ecdcfda5dea6915f3d00ab7581eadda29510 100644 (file)
@@ -17,8 +17,6 @@ QB_SYSTEM_NAME = "qemu-system-aarch64"
 QB_MACHINE = "-machine virt"
 QB_CPU = "-cpu cortex-a57"
 QB_CPU_KVM = "-cpu host -machine gic-version=3"
-# Standard Serial console
-QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0"
 # For graphics to work we need to define the VGA device as well as the necessary USB devices
 QB_GRAPHICS = "-device VGA,edid=on"
 QB_OPT_APPEND = "-device qemu-xhci -device usb-tablet -device usb-kbd"
index dfe2a89573b227dfa5e6486c2504bb72c2a20678..7050bae088504b0799b43b032735c4cbc549a7f6 100644 (file)
@@ -12,7 +12,7 @@ SERIAL_CONSOLES ?= "115200;ttyAMA0 115200;ttyAMA1"
 # For runqemu
 QB_SYSTEM_NAME = "qemu-system-arm"
 QB_MACHINE = "-machine versatilepb"
-QB_KERNEL_CMDLINE_APPEND = "console=ttyAMA0,115200 console=tty vmalloc=256"
+QB_KERNEL_CMDLINE_APPEND = "vmalloc=256"
 QB_OPT_APPEND = "-usb -device usb-tablet"
 PREFERRED_VERSION_linux-yocto ??= "5.10%"
 QB_DTB = "${@oe.utils.version_less_or_equal('PREFERRED_VERSION_linux-yocto', '4.7', '', 'zImage-versatile-pb.dtb', d)}"
index 77ec939ad7253cb6d4bf0bbf539a88b8af91dc45..eb23dbceb854a9fac6f89b6d593643c1af3fc3a0 100644 (file)
@@ -176,7 +176,7 @@ class QemuRunner:
             self.logger.error("Failed to create listening socket: %s" % msg[1])
             return False
 
-        bootparams = 'console=tty1 console=ttyS0,115200n8 printk.time=1'
+        bootparams = ' printk.time=1'
         if extra_bootparams:
             bootparams = bootparams + ' ' + extra_bootparams
 
index 4c8358e9de7982683390088efaeaf00fee2aba72..842509eb145fa62f5c71e3b8a1010b055d07637d 100755 (executable)
@@ -139,6 +139,7 @@ class BaseConfig(object):
                         'OE_TMPDIR',
                         'OECORE_NATIVE_SYSROOT',
                         'MULTICONFIG',
+                        'SERIAL_CONSOLES',
                         )
 
         self.qemu_opt = ''
@@ -464,7 +465,6 @@ class BaseConfig(object):
                 if ('gtk' in sys.argv):
                     raise RunQemuError('Option nographic makes no sense alongside the gtk option.' % (arg))
                 self.qemu_opt_script += ' -nographic'
-                self.kernel_cmdline_script += ' console=ttyS0'
             elif arg == 'sdl':
                 if 'gl' in sys.argv[1:]:
                     self.set_dri_path()
@@ -493,10 +493,8 @@ class BaseConfig(object):
             elif arg == 'novga':
                 self.qemu_opt_script += ' -vga none'
             elif arg == 'serial':
-                self.kernel_cmdline_script += ' console=ttyS0'
                 self.serialconsole = True
             elif arg == "serialstdio":
-                self.kernel_cmdline_script += ' console=ttyS0'
                 self.serialstdio = True
             elif arg == 'audio':
                 logger.info("Enabling audio in qemu")
@@ -1321,6 +1319,31 @@ class BaseConfig(object):
             raise RunQemuError("Failed to boot, QB_SYSTEM_NAME is NULL!")
         self.qemu_system = qemu_system
 
+    def setup_serial(self):
+        # Setup correct kernel command line for serial
+        if self.serialstdio == True or self.serialconsole == True or re.search("-nographic", self.qemu_opt) or self.tcpserial_portnum:
+            for entry in self.get('SERIAL_CONSOLES').split(' '):
+                self.kernel_cmdline_script += ' console=%s' %entry.split(';')[1]
+
+        if self.serialstdio == True or re.search("-nographic", self.qemu_opt):
+            self.qemu_opt += " -serial mon:stdio"
+        else:
+            self.qemu_opt += " -serial mon:vc"
+            if self.serialconsole:
+                if sys.stdin.isatty():
+                    subprocess.check_call(("stty", "intr", "^]"))
+                    logger.info("Interrupt character is '^]'")
+
+                self.qemu_opt += " %s" % self.get("QB_SERIAL_OPT")
+
+        # We always wants ttyS0 and ttyS1 in qemu machines (see SERIAL_CONSOLES).
+        # If no serial or serialtcp options were specified, only ttyS0 is created
+        # and sysvinit shows an error trying to enable ttyS1:
+        #     INIT: Id "S1" respawning too fast: disabled for 5 minutes
+        serial_num = len(re.findall("-serial", self.qemu_opt))
+        if serial_num < 2:
+            self.qemu_opt += " -serial null"
+
     def setup_final(self):
         qemu_bin = os.path.join(self.bindir_native, self.qemu_system)
 
@@ -1365,37 +1388,7 @@ class BaseConfig(object):
         if self.snapshot:
             self.qemu_opt += " -snapshot"
 
-        if self.serialconsole:
-            if sys.stdin.isatty():
-                subprocess.check_call(("stty", "intr", "^]"))
-                logger.info("Interrupt character is '^]'")
-
-            first_serial = ""
-            if not re.search("-nographic", self.qemu_opt):
-                first_serial = "-serial mon:vc"
-            # We always want a ttyS1. Since qemu by default adds a serial
-            # port when nodefaults is not specified, it seems that all that
-            # would be needed is to make sure a "-serial" is there. However,
-            # it appears that when "-serial" is specified, it ignores the
-            # default serial port that is normally added.  So here we make
-            # sure to add two -serial if there are none. And only one if
-            # there is one -serial already.
-            serial_num = len(re.findall("-serial", self.qemu_opt))
-            if serial_num == 0:
-                self.qemu_opt += " %s %s" % (first_serial, self.get("QB_SERIAL_OPT"))
-            elif serial_num == 1:
-                self.qemu_opt += " %s" % self.get("QB_SERIAL_OPT")
-
-        # We always wants ttyS0 and ttyS1 in qemu machines (see SERIAL_CONSOLES),
-        # if not serial or serialtcp options was specified only ttyS0 is created
-        # and sysvinit shows an error trying to enable ttyS1:
-        #     INIT: Id "S1" respawning too fast: disabled for 5 minutes
-        serial_num = len(re.findall("-serial", self.qemu_opt))
-        if serial_num == 0:
-            if re.search("-nographic", self.qemu_opt) or self.serialstdio:
-                self.qemu_opt += " -serial mon:stdio -serial null"
-            else:
-                self.qemu_opt += " -serial mon:vc -serial null"
+        self.setup_serial()
 
     def start_qemu(self):
         import shlex