systemd: enable getty for framebuffer console (tty0)

Scenario: Use an HDMI/DVI monitor and USB keyboard (instead of RS232 connection) to control the starterkit.
Tested with: STKa6x Rev.02xx + BSP Rev.0109
May also work on: STKLS102xA, STKa7x, STKa6ULx

Use systemctl to temporarily enable the getty on a running system.
This actually creates a symlink
/etc/systemd/system/getty.target.wants/getty@tty0.service → /lib/systemd/system/getty@.service

mount -o remount,rw /
systemctl enable getty@tty0.service
mount -o remount,ro /
systemctl start getty@tty0.service

To permanently enable the getty you need to create a new PTXdist package, which takes care of creating a proper symbolic link (see above) in the root filesystem.

Simply put an .in and .make file in the rules/ directory of the BSP.
For instance

rules/systemd_getty.in
## SECTION=initmethod
 
if INITMETHOD_SYSTEMD
 
config INITMETHOD_SYSTEMD_GETTY
	bool
	prompt "start getty on tty0"
	help
	  Enable this to start a getty on tty0 during system boot
 
endif
rules/systemd_getty.make
# -*-makefile-*-
#
# Copyright (C) 2012 by Daniel Gericke <daniel.gericke@tqs.de>
#
# See CREDITS for details about who has contributed to this project.
#
# For further information about the PTXdist project and license conditions
# see the README file.
#
 
#
# We provide this package
#
PACKAGES-$(PTXCONF_INITMETHOD_SYSTEMD_GETTY) += initmethod-systemd-getty
 
INITMETHOD_SYSTEMD_GETTY_VERSION	:= 1
 
# ----------------------------------------------------------------------------
# Target-Install
# ----------------------------------------------------------------------------
 
$(STATEDIR)/initmethod-systemd-getty.targetinstall:
	@$(call targetinfo)
 
	@$(call install_init, initmethod-systemd-getty)
	@$(call install_fixup,initmethod-systemd-getty,PRIORITY,optional)
	@$(call install_fixup,initmethod-systemd-getty,SECTION,base)
	@$(call install_fixup,initmethod-systemd-getty,AUTHOR,"TQ Embedded <support@tq-group.com>")
	@$(call install_fixup,initmethod-systemd-getty,DESCRIPTION,missing)
 
ifdef PTXCONF_INITMETHOD_SYSTEMD
	@$(call install_link, initmethod-systemd-getty, ../../../lib/systemd/system/getty@service, \
		/etc/systemd/system/getty.target.wants/getty@tty0.service)
 
	@$(call install_finish,initmethod-systemd-getty)
 
	@$(call touch)
 
endif
# vim: syntax=make

Call

./p menuconfig

and select the new package, in the example above at
Root Filesystem —> init —> start getty on tty0 (NEW)

Now rebuild the BSP to have the new package included in the build results (i.e. RootFS & SD card images)

./p images
  • Last modified: 2022/08/04 15:02