linuxconsolekernelttycmdline-args

Linux console changed, print OK, read NOK


I'm working on a small embedded linux platform at the office where I have to change the default console from ttyS0 to another ttySx. The ttyS0 is enabled and is the default console. I enabled the other ttyS, successfully probed it, I've given it the ID=4, which means now I can see it properly as /dev/ttyS4.

So I modified the cmdline from:

CMDLINE=...console=ttyS0,921600n8 console=tty0...

to

CMDLINE=...console=ttyS4,921600n8 console=tty0...

The uarts are connected to FTDI chips. With console=ttyS0 I can successfully read/write on this shell. With console=ttyS4 I can see what the kernel prints, but whatever I write is ignored by linux.

So I checked the TX/RX of the new ttyS4. I have opened a putty session on this com port. Logging in over ssh to have access to linux file system i did few tests:

echo 1234 > /dev/ttyS4        
echo 1234 > /dev/console

Both above commands successfully print "1234" on the putty window corresponding to the ttyS4.

Then:

cat /dev/console             
cat /dev/ttyS4

Both above cat commands display successfully what I type & ENTER on my putty window. That means the electrical connections as well as the driver for ttyS4 are working well. However, if I try to access the file system in this putty window, I can't. Typing enter will just print a new empty line, nothing else. It's like the new console=ttyS4 doesn't forward the data I write to the linux.

I can see the new console=ttyS4,921600n8 console=tty0 when I type cat /proc/cmdline

Any help appreciated.


Solution

  • Consoles are just input and output devices. If you want to use them for shell logins, start a getty on them.

    With SysVinit, you can do this by editing /etc/inittab and copying or uncommenting a line there:

    4:2345:respawn:/sbin/getty 38400 tty4
    

    With systemd, you can run

    systemctl enable console-getty.service getty@tty4.service