From d4ab23bfe2f6c49b512e2a5ce2c8993c6b952547 Mon Sep 17 00:00:00 2001 From: Ivailo Date: Mon, 10 Jan 2011 03:24:33 -0800 Subject: [PATCH] --- .../serial_communications/index.mdwn | 455 +++++++++++++++++- 1 file changed, 447 insertions(+), 8 deletions(-) diff --git a/docs/docs/newhandbook/serial_communications/index.mdwn b/docs/docs/newhandbook/serial_communications/index.mdwn index 29ef982f..d8b09753 100644 --- a/docs/docs/newhandbook/serial_communications/index.mdwn +++ b/docs/docs/newhandbook/serial_communications/index.mdwn @@ -214,7 +214,7 @@ For example, on a system with four serial ports, these are the serial-port speci -If your kernel does not recognize all of your serial ports, you will probably need to configure a custom DragonFly kernel for your system. For detailed information on configuring your kernel, please see [kernelconfig.html Chapter 10]. +If your kernel does not recognize all of your serial ports, you will probably need to configure a custom DragonFly kernel for your system. For detailed information on configuring your kernel, please see [kernelconfig.html Chapter 12]. @@ -236,10 +236,6 @@ The relevant device lines for your kernel configuration file would look like thi -You can comment-out or completely remove lines for devices you do not have. Please refer to the [sio(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#sio§ion4) manual page for more information on serial ports and multiport boards configuration. - - - **Note:** `port IO_COM1` is a substitution for `port 0x3f8`, `IO_COM2` is `0x2f8`, `IO_COM3` is `0x3e8`, and `IO_COM4` is `0x2e8`, which are fairly common port addresses for their respective serial ports; interrupts 4, 3, 5, and 9 are fairly common interrupt request lines. Also note that regular serial ports ***cannot*** share interrupts on ISA-bus PCs (multiport boards have on-board electronics that allow all the 16550A's on the board to share one or two interrupt request lines). @@ -371,8 +367,6 @@ For DragonFly, there are three kinds of terminals: * [ X terminals](term.html#TERM-X) -The remaining subsections describe each kind. - #### 18.2.1.1 Dumb Terminals @@ -423,7 +417,7 @@ This section describes what you need to configure on your DragonFly system to en -Recall from [boot.html Chapter 7] that the `init` process is responsible for all process control and initialization at system startup. One of the tasks performed by `init` is to read the `/etc/ttys` file and start a `getty` process on the available terminals. The `getty` process is responsible for reading a login name and starting the `login` program. +Recall from [boot.html Chapter 10] that the `init` process is responsible for all process control and initialization at system startup. One of the tasks performed by `init` is to read the `/etc/ttys` file and start a `getty` process on the available terminals. The `getty` process is responsible for reading a login name and starting the `login` program. @@ -1450,3 +1444,448 @@ To send files, start the receiving program on the remote end. Then, type `~C sz *** +## 18.5 Setting Up the Serial Console + + +### 18.5.1 Introduction + + + +DragonFly has the ability to boot on a system with only a dumb terminal on a serial port as a console. Such a configuration should be useful for two classes of people: system administrators who wish to install DragonFly on machines that have no keyboard or monitor attached, and developers who want to debug the kernel or device drivers. + + + +As described in [boot.html Chapter 10], DragonFly employs a three stage bootstrap. The first two stages are in the boot block code which is stored at the beginning of the DragonFly slice on the boot disk. The boot block will then load and run the boot loader (`/boot/loader`) as the third stage code. + + + +In order to set up the serial console you must configure the boot block code, the boot loader code and the kernel. + + + +### 18.5.2 Serial Console Configuration, Terse Version + + + +This section assumes that you are using the default setup, know how to connect serial ports and just want a fast overview of a serial console. If you encounter difficulty with these steps, please see the more extensive explaination of all the options and advanced settings in [serialconsole-setup.html#SERIALCONSOLE-HOWTO Section 18.5.3]. + + + + 1. Connect the serial port. The serial console will be on COM1. + + 1. `echo -h > /boot.config` to enable the serial console for the boot loader and kernel. + + 1. Edit `/etc/ttys` and change `off` to `on` for the `ttyd0` entry. This enables a login prompt on the serial console, which mirrors how video consoles are typically setup. + + 1. `shutdown -r now` will reboot the system with the serial console. + + + +### 18.5.3 Serial Console Configuration + + + + 1. Prepare a serial cable. + + You will need either a null-modem cable or a standard serial cable and a null-modem adapter. See [ Section 18.1.2](serial.html#SERIAL-CABLES-PORTS) for a discussion on serial cables. + + 1. Unplug your keyboard. + + Most PC systems probe for the keyboard during the Power-On Self-Test (POST) and will generate an error if the keyboard is not detected. Some machines complain loudly about the lack of a keyboard and will not continue to boot until it is plugged in. + + If your computer complains about the error, but boots anyway, then you do not have to do anything special. (Some machines with Phoenix BIOS installed merely say ***`Keyboard failed`*** and continue to boot normally.) + + If your computer refuses to boot without a keyboard attached then you will have to configure the BIOS so that it ignores this error (if it can). Consult your motherboard's manual for details on how to do this. + + **Tip:** Setting the keyboard to ***Not installed*** in the BIOS setup does ***not*** mean that you will not be able to use your keyboard. All this does is tell the BIOS not to probe for a keyboard at power-on, so it will not complain if the keyboard is not plugged in. You can leave the keyboard plugged in even with this flag set to ***Not installed*** and the keyboard will still work. + + **Note:** If your system has a PS/2® mouse, chances are very good that you may have to unplug your mouse as well as your keyboard. This is because PS/2 mice share some hardware with the keyboard and leaving the mouse plugged in can fool the keyboard probe into thinking the keyboard is still there. In general, this is not a problem since the mouse is not much good without the keyboard anyway. + + 1. Plug a dumb terminal into `COM1` (`sio0`). + + If you do not have a dumb terminal, you can use an old PC/XT with a modem program, or the serial port on another UNIX® box. If you do not have a `COM1` (`sio0`), get one. At this time, there is no way to select a port other than `COM1` for the boot blocks without recompiling the boot blocks. If you are already using `COM1` for another device, you will have to temporarily remove that device and install a new boot block and kernel once you get DragonFly up and running. (It is assumed that `COM1` will be available on a file/compute/terminal server anyway; if you really need `COM1` for something else (and you cannot switch that something else to `COM2` (`sio1`)), then you probably should not even be bothering with all this in the first place.) + + 1. Make sure the configuration file of your kernel has appropriate flags set for `COM1` (`sio0`). + + Relevant flags are: + + `0x10`:: Enables console support for this unit. The other console flags are ignored unless this is set. Currently, at most one unit can have console support; the first one (in config file order) with this flag set is preferred. This option alone will not make the serial port the console. Set the following flag or use the `-h` option described below, together with this flag.`0x20`:: Forces this unit to be the console (unless there is another higher priority console), regardless of the `-h` option discussed below. This flag replaces the `COMCONSOLE` option in DragonFly versions 2.`***X***`. The flag `0x20` must be used together with the `0x10` flag.`0x40`:: Reserves this unit (in conjunction with `0x10`) and makes the unit unavailable for normal access. You should not set this flag to the serial port unit which you want to use as the serial console. This reserves this port for "low-level IO", i.e. kernel debugging.`0x80`:: This port will be used for remote kernel debugging. + + Example: + + + + device sio0 at isa? port IO_COM1 flags 0x10 irq 4 + + + + See the [sio(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#sio§ion4) manual page for more details. + + If the flags were not set, you need to run UserConfig (on a different console) or recompile the kernel. + + 1. Create `boot.config` in the root directory of the `a` partition on the boot drive. + + This file will instruct the boot block code how you would like to boot the system. In order to activate the serial console, you need one or more of the following options--if you want multiple options, include them all on the same line: + + `-h`:: Toggles internal and serial consoles. You can use this to switch console devices. For instance, if you boot from the internal (video) console, you can use `-h` to direct the boot loader and the kernel to use the serial port as its console device. Alternatively, if you boot from the serial port, you can use the `-h` to tell the boot loader and the kernel to use the video display as the console instead.`-D`:: Toggles single and dual console configurations. In the single configuration the console will be either the internal console (video display) or the serial port, depending on the state of the `-h` option above. In the dual console configuration, both the video display and the serial port will become the console at the same time, regardless of the state of the `-h` option. However, note that the dual console configuration takes effect only during the boot block is running. Once the boot loader gets control, the console specified by the `-h` option becomes the only console.`-P`:: Makes the boot block probe the keyboard. If no keyboard is found, the `-D` and `-h` options are automatically set. + + **Note:** Due to space constraints in the current version of the boot blocks, the `-P` option is capable of detecting extended keyboards only. Keyboards with less than 101 keys (and without F11 and F12 keys) may not be detected. Keyboards on some laptop computers may not be properly found because of this limitation. If this is the case with your system, you have to abandon using the `-P` option. Unfortunately there is no workaround for this problem. + + Use either the `-P` option to select the console automatically, or the `-h` option to activate the serial console. + + You may include other options described in [boot(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#boot§ion8) as well. + + The options, except for `-P`, will be passed to the boot loader (`/boot/loader`). The boot loader will determine which of the internal video or the serial port should become the console by examining the state of the `-h` option alone. This means that if you specify the `-D` option but not the `-h` option in `/boot.config`, you can use the serial port as the console only during the boot block; the boot loader will use the internal video display as the console. + + 1. Boot the machine. + + When you start your DragonFly box, the boot blocks will echo the contents of `/boot.config` to the console. For example: + + + + /boot.config: -P + + Keyboard: no + + + + The second line appears only if you put `-P` in `/boot.config` and indicates presence/absence of the keyboard. These messages go to either serial or internal console, or both, depending on the option in `/boot.config`. + + || Options || Message goes to || + + || none || internal console || + + || `-h` || serial console || + + || `-D` || serial and internal consoles || + + || `-Dh` || serial and internal consoles || + + || `-P`, keyboard present || internal console || + + || `-P`, keyboard absent || serial console || + + After the above messages, there will be a small pause before the boot blocks continue loading the boot loader and before any further messages printed to the console. Under normal circumstances, you do not need to interrupt the boot blocks, but you may want to do so in order to make sure things are set up correctly. + + Hit any key, other than Enter, at the console to interrupt the boot process. The boot blocks will then prompt you for further action. You should now see something like: + + + + >> DragonFly/i386 BOOT + + Default: 0:ad(0,a)/boot/loader + + boot: + + + + Verify the above message appears on either the serial or internal console or both, according to the options you put in `/boot.config`. If the message appears in the correct console, hit Enter to continue the boot process. + + If you want the serial console but you do not see the prompt on the serial terminal, something is wrong with your settings. In the meantime, you enter `-h` and hit Enter/Return (if possible) to tell the boot block (and then the boot loader and the kernel) to choose the serial port for the console. Once the system is up, go back and check what went wrong. + + + +After the boot loader is loaded and you are in the third stage of the boot process you can still switch between the internal console and the serial console by setting appropriate environment variables in the boot loader. See [serialconsole-setup.html#SERIALCONSOLE-LOADER Section 18.5.6]. + + + +### 18.5.4 Summary + + + +Here is the summary of various settings discussed in this section and the console eventually selected. + + + +#### 18.5.4.1 Case 1: You Set the Flags to 0x10 for `sio0` + + + + + + device sio0 at isa? port IO_COM1 flags 0x10 irq 4 + + + + + +[[!table data=""" +| Options in /boot.config | Console during boot blocks | Console during boot loader | Console in kernel + nothing | internal | internal | internal + `-h` | serial | serial | serial + `-D` | serial and internal | internal | internal + `-Dh` | serial and internal | serial | serial + `-P`, keyboard present | internal | internal | internal + `-P`, keyboard absent | serial and internal | serial | serial | + +"""]] + +#### 18.5.4.2 Case 2: You Set the Flags to 0x30 for sio0 + + + + + + device sio0 at isa? port IO_COM1 flags 0x30 irq 4 + + + + + +[[!table data=""" +| Options in /boot.config | Console during boot blocks | Console during boot loader | Console in kernel + nothing | internal | internal | serial + `-h` | serial | serial | serial + `-D` | serial and internal | internal | serial + `-Dh` | serial and internal | serial | serial + `-P`, keyboard present | internal | internal | serial + `-P`, keyboard absent | serial and internal | serial | serial | + +"""]] + +### 18.5.5 Tips for the Serial Console + + + +#### 18.5.5.1 Setting a Faster Serial Port Speed + + + +By default, the serial port settings are: 9600 baud, 8 bits, no parity, and 1 stop bit. If you wish to change the speed, you need to recompile at least the boot blocks. Add the following line to `/etc/make.conf` and compile new boot blocks: + + + + + + BOOT_COMCONSOLE_SPEED=19200 + + + + + +If the serial console is configured in some other way than by booting with `-h`, or if the serial console used by the kernel is different from the one used by the boot blocks, then you must also add the following option to the kernel configuration file and compile a new kernel: + + + + + + options CONSPEED=19200 + + + + + +#### 18.5.5.2 Using Serial Port Other Than `sio0` for the Console + + + +Using a port other than `sio0` as the console requires some recompiling. If you want to use another serial port for whatever reasons, recompile the boot blocks, the boot loader and the kernel as follows. + + + + 1. Get the kernel source. + + 1. Edit `/etc/make.conf` and set `BOOT_COMCONSOLE_PORT` to the address of the port you want to use (0x3F8, 0x2F8, 0x3E8 or 0x2E8). Only `sio0` through `sio3` (`COM1` through `COM4`) can be used; multiport serial cards will not work. No interrupt setting is needed. + + 1. Create a custom kernel configuration file and add appropriate flags for the serial port you want to use. For example, if you want to make `sio1` (`COM2`) the console: + + + + device sio1 at isa? port IO_COM2 flags 0x10 irq 3 + + + + or + + + + device sio1 at isa? port IO_COM2 flags 0x30 irq 3 + + + + The console flags for the other serial ports should not be set. + + 1. Recompile and install the boot blocks and the boot loader: + + + + # cd /sys/boot + + # make + + # make install + + + + 1. Rebuild and install the kernel. + + 1. Write the boot blocks to the boot disk with [disklabel(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#disklabel§ion8) and boot from the new kernel. + + + +#### 18.5.5.3 Entering the DDB Debugger from the Serial Line + + + +If you wish to drop into the kernel debugger from the serial console (useful for remote diagnostics, but also dangerous if you generate a spurious BREAK on the serial port!) then you should compile your kernel with the following options: + + + + + + options BREAK_TO_DEBUGGER + + options DDB + + + + + +#### 18.5.5.4 Getting a Login Prompt on the Serial Console + + + +While this is not required, you may wish to get a ***login*** prompt over the serial line, now that you can see boot messages and can enter the kernel debugging session through the serial console. Here is how to do it. + + + +Open the file `/etc/ttys` with an editor and locate the lines: + + + + + + ttyd0 "/usr/libexec/getty std.9600" unknown off secure + + ttyd1 "/usr/libexec/getty std.9600" unknown off secure + + ttyd2 "/usr/libexec/getty std.9600" unknown off secure + + ttyd3 "/usr/libexec/getty std.9600" unknown off secure + + + + + +`ttyd0` through `ttyd3` corresponds to `COM1` through `COM4`. Change `off` to `on` for the desired port. If you have changed the speed of the serial port, you need to change `std.9600` to match the current setting, e.g. `std.19200`. + + + +You may also want to change the terminal type from `unknown` to the actual type of your serial terminal. + + + +After editing the file, you must `kill -HUP 1` to make this change take effect. + + + +### 18.5.6 Changing Console from the Boot Loader + + + +Previous sections described how to set up the serial console by tweaking the boot block. This section shows that you can specify the console by entering some commands and environment variables in the boot loader. As the boot loader is invoked at the third stage of the boot process, after the boot block, the settings in the boot loader will override the settings in the boot block. + + + +#### 18.5.6.1 Setting Up the Serial Console + + + +You can easily specify the boot loader and the kernel to use the serial console by writing just one line in `/boot/loader.rc`: + + + + + + set console=comconsole + + + + + +This will take effect regardless of the settings in the boot block discussed in the previous section. + + + +You had better put the above line as the first line of `/boot/loader.rc` so as to see boot messages on the serial console as early as possible. + + + +Likewise, you can specify the internal console as: + + + + + + set console=vidconsole + + + + + +If you do not set the boot loader environment variable `console`, the boot loader, and subsequently the kernel, will use whichever console indicated by the `-h` option in the boot block. + + + +In versions 3.2 or later, you may specify the console in `/boot/loader.conf.local` or `/boot/loader.conf`, rather than in `/boot/loader.rc`. In this method your `/boot/loader.rc` should look like: + + + + + + include /boot/loader.4th + + start + + + + + +Then, create `/boot/loader.conf.local` and put the following line there. + + + + + + console=comconsole + + + + + +or + + + + + + console=vidconsole + + + + + + + **Note:** At the moment, the boot loader has no option equivalent to the `-P` option in the boot block, and there is no provision to automatically select the internal console and the serial console based on the presence of the keyboard. + + + +#### 18.5.6.2 Using a Serial Port Other Than `sio0` for the Console + + + +You need to recompile the boot loader to use a serial port other than `sio0` for the serial console. Follow the procedure described in [serialconsole-setup.html#SERIALCONSOLE-COM2 Section 18.5.5.2]. + + + +### 18.5.7 Caveats + + + +The idea here is to allow people to set up dedicated servers that require no graphics hardware or attached keyboards. Unfortunately, while most systems will let you boot without a keyboard, there are quite a few that will not let you boot without a graphics adapter. Machines with AMI BIOSes can be configured to boot with no graphics adapter installed simply by changing the ***graphics adapter*** setting in the CMOS configuration to ***Not installed.*** + + + +However, many machines do not support this option and will refuse to boot if you have no display hardware in the system. With these machines, you will have to leave some kind of graphics card plugged in, (even if it is just a junky mono board) although you will not have to attach a monitor. You might also try installing an AMI BIOS. + +*** -- 2.41.0