Skip to contentSkip to conversation

add support for virtual terminal

PATCH Superseded Yegor Yefremov 3 participants 6 messages Nov 7, 2011 – Nov 8, 2011

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 add support for virtual terminal

introduces new option "Enable virtual console on tty1" to enable virtual terminal on tty1

---
Changes:
v2: corrected the patch according to Baruch's comments

 fs/skeleton/etc/inittab    |    3 +++
 target/generic/Config.in   |    3 +++
 target/generic/Makefile.in |   16 ++++++++++++++++
 3 files changed, 22 insertions(+)
fs/skeleton/etc/inittab +3 -0
Index: b/fs/skeleton/etc/inittab
===================================================================
@@ -23,6 +23,9 @@
 # now run any rc scripts
 ::sysinit:/etc/init.d/rcS
 
+# Put a getty on a virtual terminal
+#tty1::respawn:/sbin/getty tty1 38400 # GENERIC_VT
+
 # Put a getty on the serial port
 #ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 # GENERIC_SERIAL
 
target/generic/Config.in +3 -0
Index: b/target/generic/Config.in
===================================================================
@@ -116,6 +116,9 @@
 	default "57600"		if BR2_TARGET_GENERIC_GETTY_BAUDRATE_57600
 	default "115200"	if BR2_TARGET_GENERIC_GETTY_BAUDRATE_115200
 
+config BR2_TARGET_GENERIC_TTY_PORT
+	bool "Enable virtual console on tty1"
+
 config BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
 	bool "remount root filesystem read-write during boot"
 	default y
target/generic/Makefile.in +16 -0
Index: b/target/generic/Makefile.in
===================================================================
@@ -23,6 +23,16 @@
 	$(SED) '/# GENERIC_SERIAL$$/s~^.*#~$(shell echo $(TARGET_GENERIC_GETTY) | tail -c+4)::respawn:/sbin/getty -L $(TARGET_GENERIC_GETTY) $(TARGET_GENERIC_GETTY_BAUDRATE) vt100 #~' \
 		$(TARGET_DIR)/etc/inittab
 
+# Put a getty on virtual terminal
+target-generic-do-getty-tty1:
+	#$(SED) 's/#tty1/tty1/' $(TARGET_DIR)/etc/inittab
+	$(SED) '/^#.*# GENERIC_VT$$/s~^#\+~~' $(TARGET_DIR)/etc/inittab
+
+# Don't put a getty on virtual terminal
+target-generic-dont-getty-tty1:
+	#$(SED) 's/tty1/#tty1/' $(TARGET_DIR)/etc/inittab
+	$(SED) '/^[^#].*# GENERIC_VT$$/s~^~#~' $(TARGET_DIR)/etc/inittab
+
 # Find commented line, if any, and remove leading '#'s
 target-generic-do-remount-rw:
 	$(SED) '/^#.*# REMOUNT_ROOTFS_RW$$/s~^#\+~~' $(TARGET_DIR)/etc/inittab
@@ -39,6 +49,12 @@
 TARGETS += target-generic-issue
 endif
 
+ifeq ($(BR2_TARGET_GENERIC_TTY_PORT),y)
+TARGETS += target-generic-do-getty-tty1
+else
+TARGETS += target-generic-dont-getty-tty1
+endif
+
 ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y)
 ifeq ($(BR2_PACKAGE_SYSVINIT),y)
 TARGETS += target-generic-getty-sysvinit
#1 lore raw

PATCH v2 1/1 add support for virtual terminal

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yegor" == Yegor Yefremov <[email protected]> writes:

Yegor> introduces new option "Enable virtual console on tty1" Yegor> to enable virtual terminal on tty1

I'm not sure I like another option for this - Can't you just use the existing GENERIC_SERIAL and/or the post-build script for this?

Signature · 1 line
Bye, Peter Korsgaard
#2 lore raw

PATCH v2 1/1 add support for virtual terminal

Am 07.11.2011 23:39, schrieb Peter Korsgaard:

Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yegor" == Yegor Yefremov <[email protected]> writes:

Yegor> introduces new option "Enable virtual console on tty1" Yegor> to enable virtual terminal on tty1

I'm not sure I like another option for this - Can't you just use the existing GENERIC_SERIAL and/or the post-build script for this?

I'd like to have both serial console and virtual one (on tty I experiment with my program and vie serial console I can do other administrative tasks. One could use ssh, but this implies having network connection). Every time I execute make clean or clone BR I loose my inittab. Earlier versions of inittab had some ttys predefined, but they were deleted, so I thought, it would be useful to add this as an option. This way everyone should be satisfied.

Yegor

#3 lore raw

PATCH v2 1/1 add support for virtual terminal

Le Tue, 08 Nov 2011 08:49:10 +0100,
Yegor Yefremov <[email protected]> a ?crit :

Quoted 7 lines

I'd like to have both serial console and virtual one (on tty I experiment with my program and vie serial console I can do other administrative tasks. One could use ssh, but this implies having network connection). Every time I execute make clean or clone BR I loose my inittab. Earlier versions of inittab had some ttys predefined, but they were deleted, so I thought, it would be useful to add this as an option. This way everyone should be satisfied.

Just use a post-build script to customize your inittab. Something like:

BR2_ROOTFS_POST_BUILD_SCRIPT="board/yegor_company/yegor_project/post-build.sh"

with board/yegor_company/yegor_project/post-build.sh containing:

---------------8<------------------
#!/bin/sh

TARGET_DIR=$1

grep -q "^tty1::respawn:" $TARGET_DIR/etc/inittab || \
	echo "tty1::respawn:/sbin/getty tty1 38400" >> $TARGET_DIR/etc/inittab

---------------8<------------------

And there you are. If you don't like that, you can also just copy the fs/skeleton/etc/inittab into board/yegor_company/yegor_project/ and have the post-build.sh script do something like:

---------------8<------------------
#!/bin/sh

TARGET_DIR=$1
BOARD_DIR=board/yegor_company/yegor_project/

cp $BOARD_DIR/inittab $TARGET_DIR/etc/inittab
---------------8<------------------

And there you are.

Regards,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#4 lore raw

PATCH v2 1/1 add support for virtual terminal

In reply to Yegor Yefremov
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yegor" == Yegor Yefremov <[email protected]> writes:

Hi,

Quoted 2 lines
Quoted 2 lines

I'm not sure I like another option for this - Can't you just use the existing GENERIC_SERIAL and/or the post-build script for this?

Yegor> I'd like to have both serial console and virtual one (on tty I Yegor> experiment with my program and vie serial console I can do other Yegor> administrative tasks. One could use ssh, but this implies having Yegor> network connection). Every time I execute make clean or clone BR Yegor> I loose my inittab. Earlier versions of inittab had some ttys Yegor> predefined, but they were deleted, so I thought, it would be Yegor> useful to add this as an option. This way everyone should be Yegor> satisfied.

.. until someone wants a getty on tty2 or tty3 or so on. We need to keep serial config, as different boards have differnt serial port names, but I would like to keep the configuration options to a minimum, and just let people use custom inittab / skeleton or add it with the post-build script for special stuff.

Signature · 1 line
Bye, Peter Korsgaard
#5 lore raw

PATCH v2 1/1 add support for virtual terminal

Quoted 14 lines

Hi,

Quoted 2 lines
Quoted 2 lines

I'm not sure I like another option for this - Can't you just use the existing GENERIC_SERIAL and/or the post-build script for this?

Yegor> I'd like to have both serial console and virtual one (on tty I Yegor> experiment with my program and vie serial console I can do other Yegor> administrative tasks. One could use ssh, but this implies having Yegor> network connection). Every time I execute make clean or clone BR Yegor> I loose my inittab. Earlier versions of inittab had some ttys Yegor> predefined, but they were deleted, so I thought, it would be Yegor> useful to add this as an option. This way everyone should be Yegor> satisfied.

Quoted 5 lines

.. until someone wants a getty on tty2 or tty3 or so on. We need to keep serial config, as different boards have differnt serial port names, but I would like to keep the configuration options to a minimum, and just let people use custom inittab / skeleton or add it with the post-build script for special stuff.

O.K. I see your point and will follow Thomas's advice adding tty1 to my custom script.

Yegor