19

On my embedded system I usually use /dev/ttyS0 as a main console. This is achieved by passing kernel parameter console=/dev/ttyS0 and when init takes its part, getty is fired on the same device as specified in inittab by eg. ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100.

Is there any possibility to change these settings without restart and switch the console to another terminal like ttyS1, ttyUSBx or even some pseudo tty?

Chris Stratton
  • 39,853
  • 6
  • 84
  • 117
Honza
  • 1,734
  • 3
  • 16
  • 22
  • The main reason why I'm asking is my need to use ttyS0 for an occasional binary transfer to another device. The rest of the time it should behave like standard console. – Honza May 30 '13 at 07:13
  • 1
    In order to refine the scope of your question: after the boot process (output to ttyS0), you want to change the console output to another *tty*, without the use of a change of runtime level, ie without using the command *init* to another level? – Déjà vu May 30 '13 at 07:31
  • Yes, maybe used term runtime is confusing, I have updated the question. – Honza May 30 '13 at 08:49
  • 1
    Maybe [chvt](http://linuxandfriends.com/chvt-switch-between-virtual-terminals-linux-command/) can help? – Déjà vu May 30 '13 at 09:12
  • @Honza How about passing more than one parameter to grub: `console=/dev/ttyS0,/dev/ttyS1` – Vilhelm Gray May 30 '13 at 12:52
  • This is very much a development question - especially as if one of the existing hooks such as the /proc node I mention below isn't sufficient, it may be necessary to *modify the kernel source* to introduce a controllable switch in the console driver. – Chris Stratton May 31 '13 at 15:19

1 Answers1

7

It seems that perhaps you don't actually want the console log messages on another device, but are only proposing to redirect them there to stop them from interfering with binary transfers on the primary serial device.

If that is the case, you may be able to solve your problem by dynamically adjusting the console log level.

http://tuxthink.blogspot.com/2012/07/printk-and-console-log-level.html

Suggests that you can do this by writing to a proc node:

echo "6" > /proc/sys/kernel/printk

Would set it to 6 in their example. I suspect setting it to 0 or 1 would work for your purposes - if something goes that wrong, your binary transfer is probably failed anyway.

Log entries should still be retrievable by dmesg regardless of this setting.

Chris Stratton
  • 39,853
  • 6
  • 84
  • 117