Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syslinux: change serial bit rate to 115200 #58196

Merged
merged 1 commit into from Mar 28, 2019
Merged

syslinux: change serial bit rate to 115200 #58196

merged 1 commit into from Mar 28, 2019

Conversation

tomfitzhenry
Copy link
Contributor

@tomfitzhenry tomfitzhenry commented Mar 24, 2019

Prior to this commit an installation over serial via syslinux would
involve:

  1. setting bitrate to BIOS's bitrate (varies, the recent PC Engines and Netgates are 115200)
  2. setting bitrate to syslinux's bitrate (38400)
  3. setting bitrate to stty's bitrate (115200)

By changing syslinux's bitrate to 115200, an installation over serial
is a smoother experience, and consistent with the GRUB2 installation
which is also 115200 bps
.

[root@nixos:~]# stty
speed 115200 baud; line = 0;
-brkint ixoff iutf8
-iexten

In a future commit I will add default serial terminals to the syslinux
kernel lines.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Prior to this commit an installation over serial via syslinux would
involve:
1. setting bitrate to BIOS's bitrate (typically 115200)
2. setting bitrate to syslinux's bitrate (38400)
3. setting bitrate to stty's bitrate (115200)

By changing syslinux's bitrate to 115200, an installation over serial
is a smoother experience, and consistent with the GRUB2 installation
which is also 115200 bps.

    [root@nixos:~]# stty
    speed 115200 baud; line = 0;
    -brkint ixoff iutf8
    -iexten

In a future commit I will add default serial terminals to the syslinux
kernel lines.
@tomfitzhenry
Copy link
Contributor Author

I see I'm not the first person to want this: https://logs.nix.samueldr.com/nixos-on-your-router/2018-08-29#1521591;

@@ -88,7 +88,7 @@ let
# result in incorrect boot entries.

baseIsolinuxCfg = ''
SERIAL 0 38400
SERIAL 0 115200
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this has some goofy side effects, but +1 -- I've made this patch on my own before :)

@tomfitzhenry
Copy link
Contributor Author

Other OSs:
OpenBSD: differs by architecture
debian-installer: 115200 on ARM. Not set on other architectures?
pfSense: 115200, changed from 9600
Arch Linux: Not enabled? (no "SERIAL" directive)

@oxij
Copy link
Member

oxij commented Mar 24, 2019 via email

@tomfitzhenry
Copy link
Contributor Author

I tested this by:

  1. building an image:
    nix-build -A config.system.build.isoImage -I nixos-config=modules/installer/cd-dvd/installation-cd-minimal.nix default.nix
  2. copying it to a USB stick
  3. booting that USB stick on a machine
  4. observed that syslinux was available over serial at 115200n8

@infinisil
Copy link
Member

I'm not very familiar with this, what is the biggest worry with this change? Different hardware? If I wanted to test this on my own, what does "observed that syslinux was available over serial at 115200n8" mean and how do I check that?

@tomfitzhenry
Copy link
Contributor Author

tomfitzhenry commented Mar 28, 2019

I'm not very familiar with this, what is the biggest worry with this change? Different hardware?

Yes. In particular, there might be hardware which doesn't support 115200, and so upon attempting to install NixOS might result in either not being able to serial connect, or even failure. That said, other distros have chosen 115200, and pySerial reports 115200 as being well supported on all platforms:

The parameter baudrate can be one of the standard values: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200. These are well supported on all platforms.
-- https://pyserial.readthedocs.io/en/latest/pyserial_api.html

what does "observed that syslinux was available over serial at 115200n8" mean and how do I check that?

  1. You'll need two machines with serial ports (e.g. an RS232 port):
    1. one to plug the installer USB in, which I'll call the installer
    2. one to serial connect to the installer (to view the boot/installation happen over serial), which I'll call the viewer.
  2. Connect the installer and the viewer via a null serial cable.
  3. On the viewer, execute picocom -d 115200 /dev/ttyS0
  4. Plug the installer USB into the installer.
  5. Power on the installer.
  6. On the viewer's picocom, you should see the installer booting (the same thing you'd see if you'd plugged a monitor into the installer)

If this patch works, then when the installer gets to the bootloader, you should see the bootloader. Prior to this patch, you would not see the bootloader.

That's the entirety of the patch.

If you continue the installation boot, the systemd service starting won't appear on the viewer's picocom (that is another problem to be addressed in #58198 ), but after 1-2min you'll get the usual installation root shell, which should be displayed on the viewer's picocom.

@flokli
Copy link
Contributor

flokli commented Mar 28, 2019

I mostly saw 9600 (painfully slow) or 115200 baudrates in the wild.

As a lot of other distros already use 115200 or switched to it, we should probably, too.

So 👍 for me too :-)

@samueldr do you want to add this to the 19.03 installer, too?

Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds good to me too then :)

@infinisil infinisil merged commit 1660845 into NixOS:master Mar 28, 2019
@samueldr
Copy link
Member

@flokli yes, and now backported

[release-19.03 970b97f] syslinux: change serial bit rate to 115200
Date: Sun Mar 24 19:29:52 2019 +1100
1 file changed, 1 insertion(+), 1 deletion(-)

peterhoeg pushed a commit that referenced this pull request Dec 22, 2020
Prior to this commit, installation over serial console would requiring
manually having to modify the kernel modeline, as described in
#58198 .

This is unnecessarily fiddly, so this commit adds a syslinux boot
entry that has serial enabled.

GRUB already has a serial console entry:
https://github.com/NixOS/nixpkgs/blob/2c07a0800a76be01a3c255f39e21877a9a389f84/nixos/modules/installer/cd-dvd/iso-image.nix#L311-L317

Why 115200 bps? This is already used in other places, e.g. #58196

I tested this change by building the image, booting the image, and
observing the boot process over serial:

    $ cd nixos/
    $ nix-build -A config.system.build.isoImage -I nixos-config=modules/installer/cd-dvd/installation-cd-minimal.nix default.nix
    $ sudo cp /nix/store/arcl702c3z8xlndlvnfplq9yhixjvs9k-nixos-20.09pre-git-x86_64-linux.iso/iso/nixos-20.09pre-git-x86_64-linux.iso /dev/sdb

    $ picocom -b 115200 /dev/ttyUSB0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants