Skip to contentSkip to conversation

qemuriscv: check serial consoles w.r.t. /proc/consoles

PATCH Superseded Khem Raj 1 participant 2 messages Dec 11, 2020 RISC-V

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/2 qemuriscv: check serial consoles w.r.t. /proc/consoles

qemuriscv enables hvc0 along with ttyS0, however its not enabled in /proc/consoles, getty tries to enable it in inittab and erroring out

Fixes below message with sysvinit

INIT: Id "hvc0" respawning too fast: disabled for 5 minutes

---
 meta/conf/machine/include/riscv/qemuriscv.inc | 1 +
 1 file changed, 1 insertion(+)
meta/conf/machine/include/riscv/qemuriscv.inc +1 -0
index 0e88c91aa6..47d7e9b174 100644
@@ -10,6 +10,7 @@ KERNEL_IMAGETYPES += "uImage"
 KEEPUIMAGE = "no"
 
 SERIAL_CONSOLES ?= "115200;ttyS0 115200;hvc0"
+SERIAL_CONSOLES_CHECK = "${SERIAL_CONSOLES}"
 
 IMAGE_FSTYPES += "ext4 wic.qcow2"
 
Signature · 1 line
2.29.2
author
#1 lore raw

PATCH 2/2 busybox-inittab: Implement SYSVINIT_ENABLED_GETTYS and USE_VT

This ensures that busybox init can generate matching tty's in inittab as system defines, secondly resepcts USE_VT for creating virtual ttys

---
 .../busybox/busybox-inittab_1.32.0.bb         | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)
meta/recipes-core/busybox/busybox-inittab_1.32.0.bb +50 -0
index 61fb8cbad1..8d0f419f4d 100644
@@ -23,6 +23,53 @@ do_install() {
 		id=`echo ${i} | sed -e 's/^.*;//' -e 's/;.*//'`
 		echo "$id::respawn:${base_sbindir}/getty ${j}" >> ${D}${sysconfdir}/inittab
 	done
+	if [ "${USE_VT}" = "1" ]; then
+		cat <<EOF >>${D}${sysconfdir}/inittab
+# ${base_sbindir}/getty invocations for the runlevels.
+#
+# The "id" field MUST be the same as the last
+# characters of the device (after "tty").
+#
+# Format:
+#  <id>:<runlevels>:<action>:<process>
+#
+
+EOF
+
+		for n in ${SYSVINIT_ENABLED_GETTYS}
+		do
+			echo "tty$n:12345:respawn:${base_sbindir}/getty 38400 tty$n" >> ${D}${sysconfdir}/inittab
+		done
+		echo "" >> ${D}${sysconfdir}/inittab
+	fi
+
+}
+
+pkg_postinst_${PN} () {
+# run this on host and on target
+if [ "${SERIAL_CONSOLES_CHECK}" = "" ]; then
+       exit 0
+fi
+}
+
+pkg_postinst_ontarget_${PN} () {
+# run this on the target
+if [ -e /proc/consoles ]; then
+        tmp="${SERIAL_CONSOLES_CHECK}"
+        for i in $tmp
+        do
+                j=`echo ${i} | sed -e s/^.*\;//g -e s/\:.*//g`
+                k=`echo ${i} | sed s/^.*\://g`
+                if [ -z "`grep ${j} /proc/consoles`" ]; then
+                        if [ -z "${k}" ] || [ -z "`grep ${k} /proc/consoles`" ] || [ ! -e /dev/${j} ]; then
+                                sed -i -e /^.*${j}\ /d -e /^.*${j}$/d /etc/inittab
+                        fi
+                fi
+        done
+        kill -HUP 1
+else
+        exit 1
+fi
 }
 
 # SERIAL_CONSOLES is generally defined by the MACHINE .conf.
@@ -33,3 +80,6 @@ FILES_${PN} = "${sysconfdir}/inittab"
 CONFFILES_${PN} = "${sysconfdir}/inittab"
 
 RCONFLICTS_${PN} = "sysvinit-inittab"
+
+USE_VT ?= "1"
+SYSVINIT_ENABLED_GETTYS ?= "1"
Signature · 1 line
2.29.2