meta-digi-dey: Add auto-serial-console recipe.

This support comes from meta-linaro @9f899282caa9 and adds the ability
to configure getty dynamically from the console argument in the kernel
command line.

This will make it possible to enable/disable the console dynamically as
signalled by U-Boot.

Signed-off-by: Alex Gonzalez <alex.gonzalez@digi.com>
This commit is contained in:
Alex Gonzalez 2016-05-10 14:45:59 +02:00
parent b4c0c0af9a
commit f15d7c3e31
4 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,24 @@
#!/bin/sh
set -e
[ -f "/etc/default/autogetty" ] && . /etc/default/autogetty
[ "${ENABLED}" != "1" ] && exit
for arg in $(cat /proc/cmdline); do
case "${arg}" in
console=*)
eval ${arg}
TTY="${console%,*}"
SPEED="${console#*,}"
# If no speed is given default to 115200 and fall-back
[ "${SPEED}" = "${TTY}" ] && SPEED="115200,57600,38400,19200,9600"
if [ -n "${TTY}" ] && grep -qs "${TTY}" /etc/securetty; then
/sbin/getty -L "${SPEED}" "${TTY}" &
fi
;;
esac
done

View File

@ -0,0 +1,29 @@
#!/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/auto-getty
NAME="auto-getty"
case "$1" in
start)
echo -n "Starting auto-serial-console: "
start-stop-daemon -S -b -n $NAME --exec $DAEMON
echo "done"
;;
stop)
echo -n "Stopping auto-serial-console: "
start-stop-daemon -K -n $NAME
echo "done"
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: auto-serial-console { start | stop | restart }" >&2
exit 1
;;
esac
exit 0

View File

@ -0,0 +1 @@
ENABLED=##ENABLED##

View File

@ -0,0 +1,34 @@
SUMMARY = "Auto Serial Console script"
DESCRIPTION = "Scripts to call the console tty from the kernel cmd line"
SECTION = "base"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "\
file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \
file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420 \
"
SRC_URI = "\
file://autogetty \
file://auto-getty \
file://auto-serial-console \
"
S = "${WORKDIR}"
inherit update-rc.d
INITSCRIPT_NAME = "auto-serial-console"
INITSCRIPT_PARAMS = "start 99 5 ."
do_install () {
install -m 0755 -d ${D}${sysconfdir}/default
AUTOGETTY_ENABLE='${@base_conditional( "TRUSTFENCE_CONSOLE_DISABLE", "1", "1", "0", d )}'
install -m 0644 ${WORKDIR}/autogetty ${D}${sysconfdir}/default/autogetty
sed -i -e "s/##ENABLED##/${AUTOGETTY_ENABLE}/g" ${D}${sysconfdir}/default/autogetty
install -m 0755 -d ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/auto-serial-console ${D}${sysconfdir}/init.d/auto-serial-console
install -m 0755 -d ${D}${bindir}
install -m 0755 ${WORKDIR}/auto-getty ${D}${bindir}/auto-getty
}