Bug#883202: systemd: only sets baud rate for first console= kernel parameter

Joshua Marshall joshua.marshall80 at yahoo.com
Thu Nov 30 16:23:12 GMT 2017


Package: systemd
Version: 232-25+deb9u1
Severity: normal

Dear Maintainer,

root at debian:/home/testing# uname -a                                                         
Linux debian 4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64 GNU/Linux

root at debian:/home/testing# systemctl --version
systemd 232
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN

root at debian:/home/testing# update-grub --version
grub-mkconfig (GRUB) 2.02~beta3-5


It seems only the first console= kernel parameter's baud rate is set once the
system starts. I'm not entirely sure this is a systemd issue but at the very
least grub passes the correct kernel parameters.

I have a device with one physical serial port but the system recognizes two
working ports. ttyS0 is the physical serial port that I can see output from.
ttyS1 seems to be a virtual port with no physical way to access. ttyS3 and
ttyS4 will throw errors if queried with stty.

If I change the order of the console= entries in the grub config only the first
serial entry has its baud rate automatically set as desired.

If grub conf has this:
GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS1,115200n8 console=ttyS0,38400n8"

ttyS0 won't work, but ttyS1 will be configured correctly. ttyS0 will have 9600
baud with 0 rows and 0 columns.

However grub conf has this:
GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0,38400n8 console=ttyS1,115200n8"

ttyS0 will work and have a baud rate of 38400. ttyS1 will have 9600 baud with 0
rows and 0 columns.

I was expecting them to both be configured as specified in the kernel
parameters.

This came about because I was trying to enable multiple different ttyS serial
consoles on boot for portability. I'd like to swap the same hard drive and have
console access regardless of the hardware it's in. But on different devices
the working port is assigned to a different ttyS* number.



More details below:

####### MORE INFO ############

###############################
### WHEN ttyS0 DOESN'T WORK ###
###############################
root at debian:/home/testing# cat /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS1,115200n8 console=ttyS0,38400n8"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=38400 --word=8 --parity=no --stop=1"
root at debian:/home/testing# update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.9.0-4-amd64
Found initrd image: /boot/initrd.img-4.9.0-4-amd64
grub-probe: error: cannot find a GRUB drive for /dev/sdb1.  Check your device.map.
done
root at debian:/home/testing# 


# reboot

Loading Linux 4.9.0-4-amd64 ...
Loading initial ramdisk ...


# console output on 38400 vanishes at this point. I can try 9600, 38400, and
# 115200 on ttyS0 and none of them show anything, but the system boots and I
# can login through ssh.

root at debian:/home/testing# stty --all -F /dev/ttyS0
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc
root at debian:/home/testing# stty --all -F /dev/ttyS1
speed 115200 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt
-echoctl -echoke -flusho -extproc
root at debian:/home/testing# 




########################
### WHEN ttyS0 WORKS ###
########################
root at debian:/home/testing# cat /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0,38400n8 console=ttyS1,115200n8"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=38400 --word=8 --parity=no --stop=1"
root at debian:/home/testing# update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.9.0-4-amd64
Found initrd image: /boot/initrd.img-4.9.0-4-amd64
grub-probe: error: cannot find a GRUB drive for /dev/sdb1.  Check your device.map.
done
root at debian:/home/testing# reboot


# in serial console


Loading Linux 4.9.0-4-amd64 ...
Loading initial ramdisk ...
[    0.000000] Linux version 4.9.0-4-amd64 (debian-kernel at lists.debian.org) (gcc
 version 6.3.0 20170516 (Debian 6.3.0-18) ) #1 SMP Debian 4.9.51-1 (2017-09-28)
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.9.0-4-amd64 root=UUID=50
b98bc5-fd31-4207-86f5-85dbab4262fb ro console=tty1 console=ttyS0,38400n8 console
=ttyS1,115200n8
[    0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point regi
sters'
[    0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'

...
...

[    0.000000] Policy zone: Normal                                              
[    0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.9.0-4-amd64 root=
UUID=50b98bc5-fd31-4207-86f5-85dbab4262fb ro console=tty1 console=ttyS0,38400n8 
console=ttyS1,115200n8                                                          
[    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)             
[    0.000000] Memory: 8128984K/8359916K available (6196K kernel code, 1137K rwd
ata, 2856K rodata, 1396K init, 688K bss, 230932K reserved, 0K cma-reserved)     
[    0.000000] Hierarchical RCU implementation.                                 
[    0.000000]  Build-time adjustment of leaf fanout to 64.                     
[    0.000000]  RCU restricting CPUs from NR_CPUS=512 to nr_cpu_ids=4.          
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=64, nr_cpu_ids=4     
[    0.000000] NR_IRQS:33024 nr_irqs:456 16                                     
[    0.000000] Console: colour dummy device 80x25                               
[    0.000000] console [tty1] enabled                                           
[    0.000000] console [ttyS0] enabled                                          
[    0.000000] clocksource: hpet: mask: 0xffffffff max_cycles: 0xffffffff, max_i
dle_ns: 79635855245 ns                                                          

...
...

[    5.791632] pstore: Registered erst as persistent store backend              
[    5.809638] GHES: APEI firmware first mode is enabled by APEI bit and WHEA _O
SC.                                                                             
[    5.831881] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled          
[    5.871208] 00:04: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 1655
0A                                                                              
[    5.913687] 00:05: ttyS1 at I/O 0x2f8 (irq = 3, base_baud = 115200) is a 1655
0A                                                                              
[    5.936051] Linux agpgart interface v0.103                                   

...
...

[   14.749195] ip_tables: (C) 2000-2006 Netfilter Core Team                     
[   14.771821] systemd[1]: systemd 232 running in system mode. (+PAM +AUDIT +SEL
INUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +
XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN)                                   
[   14.825930] systemd[1]: Detected architecture x86-64.                        
[   14.843409] systemd[1]: Set hostname to <debian>.                            
[   14.904974] systemd[1]: Listening on Journal Socket.                         
[   14.920015] systemd[1]: Reached target Remote File Systems.                  
[   14.937061] systemd[1]: Set up automount Arbitrary Executable File Formats Fi
le System Automount Point.                                                      
[   14.965302] systemd[1]: Listening on Syslog Socket.                          
[   14.980013] systemd[1]: Listening on Journal Socket (/dev/log).              
[   14.997902] systemd[1]: Listening on Journal Audit Socket.                   
[   15.014463] systemd[1]: Started Dispatch Password Requests to Console Directo
ry Watch.                                                                       
[   15.063688] EXT4-fs (sda1): re-mounted. Opts: errors=remount-ro              
[   15.137280] systemd-journald[221]: Received request to flush runtime journal 
from PID 1                                                                      
[   15.175176] input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/inp
ut0                                                                             

...
...
                                                                                
Debian GNU/Linux 9 debian ttyS0                                                 
                                                                                
debian login: [   17.117398] igb 0000:02:00.0 enp2s0: igb: enp2s0 NIC Link is Up
 100 Mbps Full Duplex, Flow Control: RX                                         
[   17.145470] IPv6: ADDRCONF(NETDEV_CHANGE): enp2s0: link becomes ready        
[  137.469360] random: crng init done                                           
                                                                                
Debian GNU/Linux 9 debian ttyS0                                                 
                                                                                
debian login: root                                                              
Password:                                                                       
Last login: Wed Nov 29 12:01:07 EST 2017 on ttyS0                               
Linux debian 4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64           
                                                                                
The programs included with the Debian GNU/Linux system are free software;       
the exact distribution terms for each program are described in the              
individual files in /usr/share/doc/*/copyright.                                 
                                                                                
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent               
permitted by applicable law.                                                    


# logged in through ssh


root at debian:/home/testing# stty --all -F /dev/ttyS0
speed 38400 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = <undef>; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig -icanon -iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc
root at debian:/home/testing# stty --all -F /dev/ttyS1
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc
root at debian:/home/testing# 

########## END OF MORE INFO #########





I was led to believe systemd might be responsible based info from the
following sites:
https://www.freedesktop.org/software/systemd/man/systemd-getty-generator.html#
http://0pointer.de/blog/projects/serial-console.html

I don't know much about systemd but it seems it is mostly responsible for
configuring serial consoles based on the kernel parameters.


-- Package-specific info:

-- System Information:
Debian Release: 9.2
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.9.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages systemd depends on:
ii  adduser         3.115
ii  libacl1         2.2.52-3+b1
ii  libapparmor1    2.11.0-3
ii  libaudit1       1:2.6.7-2
ii  libblkid1       2.29.2-1
ii  libc6           2.24-11+deb9u1
ii  libcap2         1:2.25-1
ii  libcryptsetup4  2:1.7.3-4
ii  libgcrypt20     1.7.6-2+deb9u2
ii  libgpg-error0   1.26-2
ii  libidn11        1.33-1
ii  libip4tc0       1.6.0+snapshot20161117-6
ii  libkmod2        23-2
ii  liblz4-1        0.0~r131-2+b1
ii  liblzma5        5.2.2-1.2+b1
ii  libmount1       2.29.2-1
ii  libpam0g        1.1.8-3.6
ii  libseccomp2     2.3.1-2.1
ii  libselinux1     2.6-3+b3
ii  libsystemd0     232-25+deb9u1
ii  mount           2.29.2-1
ii  procps          2:3.3.12-3
ii  util-linux      2.29.2-1

Versions of packages systemd recommends:
ii  dbus            1.10.22-0+deb9u1
ii  libpam-systemd  232-25+deb9u1

Versions of packages systemd suggests:
pn  policykit-1        <none>
pn  systemd-container  <none>
pn  systemd-ui         <none>

Versions of packages systemd is related to:
pn  dracut           <none>
ii  initramfs-tools  0.130
ii  udev             232-25+deb9u1

-- no debconf information



More information about the Pkg-systemd-maintainers mailing list