@@ -16,25 +16,24 @@ REQUIRED_DISTRO_FEATURES += "usrmerge"
do_install() {
if [ ! -z "${SERIAL_CONSOLES}" ] ; then
- default_baudrate=`echo "${SERIAL_CONSOLES}" | sed 's/\;.*//'`
install -d ${D}${sysconfdir}/systemd/system/getty.target.wants/
tmp="${SERIAL_CONSOLES}"
for entry in $tmp ; do
baudrate=`echo $entry | sed 's/\;.*//'`
ttydev=`echo $entry | sed -e 's/^[0-9]*\;//' -e 's/\;.*//'`
- if [ "$baudrate" = "$default_baudrate" ] ; then
- # enable the service
- ln -sf ${systemd_system_unitdir}/serial-getty@.service \
- ${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty@$ttydev.service
- else
- # install custom service file for the non-default baudrate
- install -m 0644 ${S}/serial-getty@.service ${D}${systemd_system_unitdir}/serial-getty$baudrate@.service
- sed -i -e "s/\@BAUDRATE\@/$baudrate/g" ${D}${systemd_system_unitdir}/serial-getty$baudrate@.service
- # enable the service
- ln -sf ${systemd_system_unitdir}/serial-getty$baudrate@.service \
- ${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty$baudrate@$ttydev.service
- fi
+ ln -sf ${systemd_system_unitdir}/serial-getty@.service \
+ ${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty@$ttydev.service
+ # agetty runs with --keep-baud, so set the rate it keeps
+ case "$baudrate" in
+ ''|*[!0-9]*)
+ ;;
+ *)
+ install -d ${D}${sysconfdir}/systemd/system/serial-getty@$ttydev.service.d
+ printf '[Service]\nExecStartPre=-${base_bindir}/stty -F /dev/%%I %s\n' $baudrate \
+ > ${D}${sysconfdir}/systemd/system/serial-getty@$ttydev.service.d/baudrate.conf
+ ;;
+ esac
done
fi
}
Since commit b6a7617145c3 ("systemd-serialgetty: use existing unit files in systemd") removed the recipe's own serial-getty@.service, the baud rates in SERIAL_CONSOLES are no longer applied, and any entry whose rate differs from the first one fails do_install, as the unit template it copies no longer exists: install: cannot stat '.../serial-getty@.service': No such file or directory Enable systemd's serial-getty@.service for every console, and give each one with a numeric rate a drop-in that sets it with stty before agetty starts. That unit runs agetty with --keep-baud, so agetty keeps the rate, while the unit itself stays as systemd ships it. stty comes from busybox or coreutils; without it, the getty still starts, at the rate the line already has. With nothing answering on the line, systemd's terminal setup for stty adds about a second before the login prompt, on top of a similar wait for agetty itself. Tested on master with qemux86-64 core-image-minimal and "115200;ttyS0 38400;ttyS1", also reversed: both consoles get a getty at their configured rate, whether or not the kernel command line sets one. Fixes: b6a7617145c3 ("systemd-serialgetty: use existing unit files in systemd") AI-Generated: Uses Claude Code (Claude Opus 5.5) Signed-off-by: Niko Mauno <niko.mauno@vaisala.com> --- v2: - Apply the SERIAL_CONSOLES baud rates with a per-tty stty drop-in instead of documenting them as ignored. v1 was "systemd-serialgetty: Fix do_install for mixed baud rates". - After a BREAK, agetty switches to the first rate in systemd's 115200,57600,38400,9600 list until the getty restarts; the old unit ran agetty at one fixed rate. - Applies to wrynose as-is. - The code was generated with Claude Code (see the AI-Generated: tag). --- .../systemd/systemd-serialgetty.bb | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-)