Package: grub-installer
Tags: patch

I was surprised by grub not showing up on the serial
console after an installation over serial with kernel
option console=ttyS0,11520n8r

The grub menu.lst contained

serial --unit=1 --speed=115200 --word=r --parity=no --stop=1

But 'r' is an invalid value for word (it takes 5-8).

It turns out the parsing in grub_serial_console() doesn't
handle options strings correctly that specify a word size != 8
or a flow control parameter (or both).

grub_serial_console() interprets the third character after
the baud rate as value for 'word'. serial-console.txt in
linux-2.6/Documentation, OTOH, says:

options: depend on the driver. For the serial port this
defines the baudrate/parity/bits/flow control of
the port, in the format BBBBPNF, where BBBB is the
speed, P is parity (n/o/e), N is number of bits,
and F is flow control ('r' for RTS). Default is
9600n8. The maximum baudrate is 115200.

So it should actually take the second character as value
for word and ignore any third character, because grub doesn't
seem to offer any option for setting flow control.

The attached patch makes it work for me and fixes both word
and flow control handling. I've checked the results against
Alex' test script [1], and the results look good to me.

[1] http://bugs.debian.org/cgi-bin/bugre...?bug=416310#25

Max


grub_serial_console console=ttyS0
serial --unit=0 --speed=9600 --stop=1
grub_serial_console console=ttyS1
serial --unit=1 --speed=9600 --stop=1
grub_serial_console console=ttyS0,9600
serial --unit=0 --speed=9600 --stop=1
grub_serial_console console=ttyS0,115200
serial --unit=0 --speed=115200 --stop=1
grub_serial_console console=ttyS1,9600
serial --unit=1 --speed=9600 --stop=1
grub_serial_console console=ttyS1,115200
serial --unit=1 --speed=115200 --stop=1
grub_serial_console console=ttyS1,9600n
serial --unit=1 --speed=9600 --parity=no --stop=1
grub_serial_console console=ttyS1,115200n
serial --unit=1 --speed=115200 --parity=no --stop=1
grub_serial_console console=ttyS1,9600e
serial --unit=1 --speed=9600 --parity=even --stop=1
grub_serial_console console=ttyS1,115200e
serial --unit=1 --speed=115200 --parity=even --stop=1
grub_serial_console console=ttyS1,9600o
serial --unit=1 --speed=9600 --parity=odd --stop=1
grub_serial_console console=ttyS1,115200o
serial --unit=1 --speed=115200 --parity=odd --stop=1
grub_serial_console console=ttyS1,9600n8
serial --unit=1 --speed=9600 --parity=no --stop=1
grub_serial_console console=ttyS1,115200n8
serial --unit=1 --speed=115200 --parity=no --stop=1
grub_serial_console console=ttyS1,9600n7
serial --unit=1 --speed=9600 --parity=no --stop=1
grub_serial_console console=ttyS1,115200n7
serial --unit=1 --speed=115200 --parity=no --stop=1
grub_serial_console console=ttyS1,9600n8r
serial --unit=1 --speed=9600 --word=r --parity=no --stop=1
grub_serial_console console=ttyS1,115200n8r
serial --unit=1 --speed=115200 --word=r --parity=no --stop=1
grub_serial_console console=ttyS1,9600n7r
serial --unit=1 --speed=9600 --word=r --parity=no --stop=1
grub_serial_console console=ttyS1,115200n7r
serial --unit=1 --speed=115200 --word=r --parity=no --stop=1
grub_serial_console console=ttyS1,9600o8
serial --unit=1 --speed=9600 --parity=odd --stop=1
grub_serial_console console=ttyS1,115200o8
serial --unit=1 --speed=115200 --parity=odd --stop=1
grub_serial_console console=ttyS1,9600o7
serial --unit=1 --speed=9600 --parity=odd --stop=1
grub_serial_console console=ttyS1,115200o7
serial --unit=1 --speed=115200 --parity=odd --stop=1
grub_serial_console console=ttyS1,9600o8r
serial --unit=1 --speed=9600 --word=r --parity=odd --stop=1
grub_serial_console console=ttyS1,115200o8r
serial --unit=1 --speed=115200 --word=r --parity=odd --stop=1
grub_serial_console console=ttyS1,9600o7r
serial --unit=1 --speed=9600 --word=r --parity=odd --stop=1
grub_serial_console console=ttyS1,115200o7r
serial --unit=1 --speed=115200 --word=r --parity=odd --stop=1
grub_serial_console console=ttyS1,9600e8
serial --unit=1 --speed=9600 --parity=even --stop=1
grub_serial_console console=ttyS1,115200e8
serial --unit=1 --speed=115200 --parity=even --stop=1
grub_serial_console console=ttyS1,9600e7
serial --unit=1 --speed=9600 --parity=even --stop=1
grub_serial_console console=ttyS1,115200e7
serial --unit=1 --speed=115200 --parity=even --stop=1
grub_serial_console console=ttyS1,9600e8r
serial --unit=1 --speed=9600 --word=r --parity=even --stop=1
grub_serial_console console=ttyS1,115200e8r
serial --unit=1 --speed=115200 --word=r --parity=even --stop=1
grub_serial_console console=ttyS1,9600e7r
serial --unit=1 --speed=9600 --word=r --parity=even --stop=1
grub_serial_console console=ttyS1,115200e7r
serial --unit=1 --speed=115200 --word=r --parity=even --stop=1
================================
The following are invalid inputs but are still handeled
grub_serial_console console=ttyS1,9600X
serial --unit=1 --speed=9600 --stop=1
grub_serial_console console=ttyS1,115200X
serial --unit=1 --speed=115200 --stop=1
grub_serial_console console=ttyS1,9600X8
serial --unit=1 --speed=9600 --stop=1
grub_serial_console console=ttyS1,115200X7
serial --unit=1 --speed=115200 --stop=1
grub_serial_console console=ttyS1,9600X7r
serial --unit=1 --speed=9600 --word=r --stop=1
grub_serial_console console=ttyS1,115200X8r
serial --unit=1 --speed=115200 --word=r --stop=1

grub_serial_console console=ttyS0
serial --unit=0 --speed=9600 --stop=1
grub_serial_console console=ttyS1
serial --unit=1 --speed=9600 --stop=1
grub_serial_console console=ttyS0,9600
serial --unit=0 --speed=9600 --stop=1
grub_serial_console console=ttyS0,115200
serial --unit=0 --speed=115200 --stop=1
grub_serial_console console=ttyS1,9600
serial --unit=1 --speed=9600 --stop=1
grub_serial_console console=ttyS1,115200
serial --unit=1 --speed=115200 --stop=1
grub_serial_console console=ttyS1,9600n
serial --unit=1 --speed=9600 --parity=no --stop=1
grub_serial_console console=ttyS1,115200n
serial --unit=1 --speed=115200 --parity=no --stop=1
grub_serial_console console=ttyS1,9600e
serial --unit=1 --speed=9600 --parity=even --stop=1
grub_serial_console console=ttyS1,115200e
serial --unit=1 --speed=115200 --parity=even --stop=1
grub_serial_console console=ttyS1,9600o
serial --unit=1 --speed=9600 --parity=odd --stop=1
grub_serial_console console=ttyS1,115200o
serial --unit=1 --speed=115200 --parity=odd --stop=1
grub_serial_console console=ttyS1,9600n8
serial --unit=1 --speed=9600 --word=8 --parity=no --stop=1
grub_serial_console console=ttyS1,115200n8
serial --unit=1 --speed=115200 --word=8 --parity=no --stop=1
grub_serial_console console=ttyS1,9600n7
serial --unit=1 --speed=9600 --word=7 --parity=no --stop=1
grub_serial_console console=ttyS1,115200n7
serial --unit=1 --speed=115200 --word=7 --parity=no --stop=1
grub_serial_console console=ttyS1,9600n8r
serial --unit=1 --speed=9600 --word=8 --parity=no --stop=1
grub_serial_console console=ttyS1,115200n8r
serial --unit=1 --speed=115200 --word=8 --parity=no --stop=1
grub_serial_console console=ttyS1,9600n7r
serial --unit=1 --speed=9600 --word=7 --parity=no --stop=1
grub_serial_console console=ttyS1,115200n7r
serial --unit=1 --speed=115200 --word=7 --parity=no --stop=1
grub_serial_console console=ttyS1,9600o8
serial --unit=1 --speed=9600 --word=8 --parity=odd --stop=1
grub_serial_console console=ttyS1,115200o8
serial --unit=1 --speed=115200 --word=8 --parity=odd --stop=1
grub_serial_console console=ttyS1,9600o7
serial --unit=1 --speed=9600 --word=7 --parity=odd --stop=1
grub_serial_console console=ttyS1,115200o7
serial --unit=1 --speed=115200 --word=7 --parity=odd --stop=1
grub_serial_console console=ttyS1,9600o8r
serial --unit=1 --speed=9600 --word=8 --parity=odd --stop=1
grub_serial_console console=ttyS1,115200o8r
serial --unit=1 --speed=115200 --word=8 --parity=odd --stop=1
grub_serial_console console=ttyS1,9600o7r
serial --unit=1 --speed=9600 --word=7 --parity=odd --stop=1
grub_serial_console console=ttyS1,115200o7r
serial --unit=1 --speed=115200 --word=7 --parity=odd --stop=1
grub_serial_console console=ttyS1,9600e8
serial --unit=1 --speed=9600 --word=8 --parity=even --stop=1
grub_serial_console console=ttyS1,115200e8
serial --unit=1 --speed=115200 --word=8 --parity=even --stop=1
grub_serial_console console=ttyS1,9600e7
serial --unit=1 --speed=9600 --word=7 --parity=even --stop=1
grub_serial_console console=ttyS1,115200e7
serial --unit=1 --speed=115200 --word=7 --parity=even --stop=1
grub_serial_console console=ttyS1,9600e8r
serial --unit=1 --speed=9600 --word=8 --parity=even --stop=1
grub_serial_console console=ttyS1,115200e8r
serial --unit=1 --speed=115200 --word=8 --parity=even --stop=1
grub_serial_console console=ttyS1,9600e7r
serial --unit=1 --speed=9600 --word=7 --parity=even --stop=1
grub_serial_console console=ttyS1,115200e7r
serial --unit=1 --speed=115200 --word=7 --parity=even --stop=1
================================
The following are invalid inputs but are still handeled
grub_serial_console console=ttyS1,9600X
serial --unit=1 --speed=9600 --stop=1
grub_serial_console console=ttyS1,115200X
serial --unit=1 --speed=115200 --stop=1
grub_serial_console console=ttyS1,9600X8
serial --unit=1 --speed=9600 --word=8 --stop=1
grub_serial_console console=ttyS1,115200X7
serial --unit=1 --speed=115200 --word=7 --stop=1
grub_serial_console console=ttyS1,9600X7r
serial --unit=1 --speed=9600 --word=7 --stop=1
grub_serial_console console=ttyS1,115200X8r
serial --unit=1 --speed=115200 --word=8 --stop=1