Better section name
[ikiwiki.git] / docs / docs / newhandbook / serial_communications / index.mdwn
index ecb6ae1..1504102 100644 (file)
@@ -1,8 +1,9 @@
 ## Chapter 18 Serial Communications 
 [[!toc  levels=3]]
 
-## Synopsis 
+***Reorganized, and parts rewritten by Ivailo Mladenov. ***
 
+## Synopsis 
 
 
 UNIX® has always had support for serial communications. In fact, the very first UNIX machines relied on serial lines for user input and output. Things have changed a lot from the days when the average ***terminal*** consisted of a 10-character-per-second serial printer and a keyboard. This chapter will cover some of the ways in which DragonFly uses serial communications.
@@ -213,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].
 
 
 
@@ -235,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&section4) 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).
 
 
@@ -251,38 +248,6 @@ Most devices in the kernel are accessed through ***device special files***, whic
 
 
 
-#### 18.1.4.1 Making Device Special Files 
-
-
-
-A shell script called `MAKEDEV` in the `/dev` directory manages the device special files. To use `MAKEDEV` to make dial-up device special files for `COM1` (port 0), `cd` to `/dev` and issue the command `MAKEDEV ttyd0`. Likewise, to make dial-up device special files for `COM2` (port 1), use `MAKEDEV ttyd1`.
-
-
-
-`MAKEDEV` not only creates the `/dev/ttyd`***N****** device special files, but also the `/dev/cuaa`***N******, `/dev/cuaia`***N******, `/dev/cuala`***N******, `/dev/ttyld`***N******, and `/dev/ttyid`***N****** nodes.
-
-
-
-After making new device special files, be sure to check the permissions on the files (especially the `/dev/cua*` files) to make sure that only users who should have access to those device special files can read and write on them -- you probably do not want to allow your average user to use your modems to dial-out. The default permissions on the `/dev/cua*` files should be sufficient:
-
-
-
-    
-
-    crw-rw----    1 uucp     dialer    28, 129 Feb 15 14:38 /dev/cuaa1
-
-    crw-rw----    1 uucp     dialer    28, 161 Feb 15 14:38 /dev/cuaia1
-
-    crw-rw----    1 uucp     dialer    28, 193 Feb 15 14:38 /dev/cuala1
-
-
-
-
-
-These permissions allow the user `uucp` and users in the group `dialer` to use the call-out devices.
-
-
-
 ### 18.1.5 Serial Port Configuration 
 
 
@@ -370,8 +335,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 
@@ -422,7 +385,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.
 
 
 
@@ -1102,7 +1065,6 @@ and the modem has not accepted a call yet, this means that `getty` has completed
 If you do not see any `getty` processes waiting to open the desired `ttyd`***N****** port, double-check your entries in `/etc/ttys` to see if there are any mistakes there. Also, check the log file `/var/log/messages` to see if there are any log messages from `init` or `getty` regarding any problems. If there are any messages, triple-check the configuration files `/etc/ttys` and `/etc/gettytab`, as well as the appropriate device special files `/dev/ttydN`, for any mistakes, missing entries, or missing device special files.
 
 
-
 #### 18.3.6.2 Try Dialing In 
 
 
@@ -1110,23 +1072,770 @@ If you do not see any `getty` processes waiting to open the desired `ttyd`***N**
 Try dialing into the system; be sure to use 8 bits, no parity, and 1 stop bit on the remote system. If you do not get a prompt right away, or get garbage, try pressing Enter about once per second. If you still do not see a login: prompt after a while, try sending a `BREAK`. If you are using a high-speed modem to do the dialing, try dialing again after locking the dialing modem's interface speed (via `AT&B1` on a U.S. Robotics Sportster modem, for example).
 
 
-If you still cannot get a login: prompt, check `/etc/gettytab` again and double-check that
+If you dial but the modem on the DragonFly system will not answer, make sure that the modem is configured to answer the phone when DTR is asserted. If the modem seems to be configured correctly, verify that the DTR line is asserted by checking the modem's indicator lights (if it has any).
+
 
 
+If you have gone over everything several times and it still does not work, take a break and come back to it later. If it still does not work, perhaps you can send an electronic mail message to the [DragonFly User related mailing list](http://leaf.dragonflybsd.org/mailarchive/) describing your modem and your problem, and the good folks on the list will try to help.
 
-* The initial capability name specified in `/etc/ttys` for the line matches a name of a capability in `/etc/gettytab`
+***
+## 18.4 Dial-out Service 
 
 
-* Each `nx=` entry matches another `gettytab` capability name
 
+The following are tips for getting your host to be able to connect over the modem to another computer. This is appropriate for establishing a terminal session with a remote host.
 
-* Each `tc=` entry matches another `gettytab` capability name
 
 
-If you dial but the modem on the DragonFly system will not answer, make sure that the modem is configured to answer the phone when DTR is asserted. If the modem seems to be configured correctly, verify that the DTR line is asserted by checking the modem's indicator lights (if it has any).
+This is useful to log onto a BBS.
 
 
 
-If you have gone over everything several times and it still does not work, take a break and come back to it later. If it still does not work, perhaps you can send an electronic mail message to the [DragonFly User related mailing list](http://leaf.dragonflybsd.org/mailarchive/) describing your modem and your problem, and the good folks on the list will try to help.
+This kind of connection can be extremely helpful to get a file on the Internet if you have problems with PPP. If you need to FTP something and PPP is broken, use the terminal session to FTP it. Then use zmodem to transfer it to your machine.
+
+
+
+### 18.4.1 My Stock Hayes Modem Is Not Supported, What Can I Do? 
+
+
+
+Actually, the manual page for `tip` is out of date. There is a generic Hayes dialer already built in. Just use `at=hayes` in your `/etc/remote` file.
+
+
+
+The Hayes driver is not smart enough to recognize some of the advanced features of newer modems--messages like `BUSY`, `NO DIALTONE`, or `CONNECT 115200` will just confuse it. You should turn those messages off when you use `tip` (using `ATX0&W`).
+
+
+
+Also, the dial timeout for `tip` is 60 seconds. Your modem should use something less, or else tip will think there is a communication problem. Try `ATS7=45&W`.
+
+
+
+ **Note:** As shipped, `tip` does not yet support Hayes modems fully. The solution is to edit the file `tipconf.h` in the directory `/usr/src/usr.bin/tip/tip`. Obviously you need the source distribution to do this.
+
+
+
+Edit the line `#define HAYES 0` to `#define HAYES 1`. Then `make` and `make install`. Everything works nicely after that.
+
+
+
+### 18.4.2 How Am I Expected to Enter These AT Commands? 
+
+
+
+Make what is called a ***direct*** entry in your `/etc/remote` file. For example, if your modem is hooked up to the first serial port, `/dev/cuaa0`, then put in the following line:
+
+
+
+    
+
+    cuaa0:dv#/dev/cuaa0:br#19200:panone
+
+
+
+
+
+Use the highest bps rate your modem supports in the br capability. Then, type `tip cuaa0` and you will be connected to your modem.
+
+
+
+Or use `cu` as `root` with the following command:
+
+
+
+    
+
+    # cu -l`***line***` -s`***speed***`
+
+
+
+
+
+`***line***` is the serial port (e.g.`/dev/cuaa0`) and `***speed***` is the speed (e.g.`57600`). When you are done entering the AT commands hit  **~.**  to exit.
+
+
+
+### 18.4.3 The `@` Sign for the pn Capability Does Not Work! 
+
+
+
+The `@` sign in the phone number capability tells tip to look in `/etc/phones` for a phone number. But the `@` sign is also a special character in capability files like `/etc/remote`. Escape it with a backslash:
+
+
+
+    
+
+    pn=\@
+
+
+
+
+
+### 18.4.4 How Can I Dial a Phone Number on the Command Line? 
+
+
+
+Put what is called a ***generic*** entry in your `/etc/remote` file. For example:
+
+
+
+    
+
+    tip115200|Dial any phone number at 115200 bps:\
+
+            :dv#/dev/cuaa0:br#115200:athayes:pa=none:du:
+
+    tip57600|Dial any phone number at 57600 bps:\
+
+            :dv#/dev/cuaa0:br#57600:athayes:pa=none:du:
+
+
+
+
+
+Then you can do things like:
+
+
+
+    
+
+    # tip -115200 5551234
+
+
+
+
+
+If you prefer `cu` over `tip`, use a generic `cu` entry:
+
+
+
+    
+
+    cu115200|Use cu to dial any number at 115200bps:\
+
+            :dv#/dev/cuaa1:br#57600:athayes:pa=none:du:
+
+
+
+
+
+and type:
+
+
+
+    
+
+    # cu 5551234 -s 115200
+
+
+
+
+
+### 18.4.5 Do I Have to Type in the bps Rate Every Time I Do That? 
+
+
+
+Put in an entry for `tip1200` or `cu1200`, but go ahead and use whatever bps rate is appropriate with the br capability. `tip` thinks a good default is 1200 bps which is why it looks for a `tip1200` entry. You do not have to use 1200 bps, though.
+
+
+
+### 18.4.6 I Access a Number of Hosts Through a Terminal Server 
+
+
+
+Rather than waiting until you are connected and typing `CONNECT <host>` each time, use tip's `cm` capability. For example, these entries in `/etc/remote`:
+
+
+
+    
+
+    pain|pain.deep13.com|Forrester's machine:\
+
+            :cm#CONNECT pain\n:tcdeep13:
+
+    muffin|muffin.deep13.com|Frank's machine:\
+
+            :cm#CONNECT muffin\n:tcdeep13:
+
+    deep13:Gizmonics Institute terminal server:\
+
+            :dv#/dev/cuaa2:br#38400:athayes:du:pa=none:pn=5551234:
+
+
+
+
+
+will let you type `tip pain` or `tip muffin` to connect to the hosts pain or muffin, and `tip deep13` to get to the terminal server.
+
+
+
+### 18.4.7 Can Tip Try More Than One Line for Each Site? 
+
+
+
+This is often a problem where a university has several modem lines and several thousand students trying to use them.
+
+
+
+Make an entry for your university in `/etc/remote` and use `@` for the `pn` capability:
+
+
+
+    
+
+    big-university:\
+
+            :pn#\@:tcdialout
+
+    dialout:\
+
+            :dv#/dev/cuaa3:br#9600:atcourier:du:pa=none:
+
+
+
+
+
+Then, list the phone numbers for the university in `/etc/phones`:
+
+
+
+    
+
+    big-university 5551111
+
+    big-university 5551112
+
+    big-university 5551113
+
+    big-university 5551114
+
+
+
+
+
+`tip` will try each one in the listed order, then give up. If you want to keep retrying, run `tip` in a while loop.
+
+
+
+### 18.4.8 Why Do I Have to Hit  **Ctrl** + **P**  Twice to Send  **Ctrl** + **P**  Once? 
+
+
+
+ **Ctrl** + **P**  is the default ***force*** character, used to tell `tip` that the next character is literal data. You can set the force character to any other character with the `~s` escape, which means ***set a variable.***
+
+
+
+Type `~sforce=`***single-char****** followed by a newline. `***single-char***` is any single character. If you leave out `***single-char***`, then the force character is the nul character, which you can get by typing  **Ctrl** + **2**  or  **Ctrl** + **Space** . A pretty good value for `***single-char***` is  **Shift** + **Ctrl** + **6** , which is only used on some terminal servers.
+
+
+
+You can have the force character be whatever you want by specifying the following in your `$HOME/.tiprc` file:
+
+
+
+    
+
+    force=<single-char>
+
+
+
+
+
+### 18.4.9 Suddenly Everything I Type Is in Upper Case?? 
+
+
+
+You must have pressed  **Ctrl** + **A** , `tip`'s ***raise character,*** specially designed for people with broken caps-lock keys. Use `~s` as above and set the variable `raisechar` to something reasonable. In fact, you can set it to the same as the force character, if you never expect to use either of these features.
+
+
+
+Here is a sample .tiprc file perfect for  **Emacs**  users who need to type  **Ctrl** + **2**  and  **Ctrl** + **A**  a lot:
+
+
+
+    
+
+    force=^^
+
+    raisechar=^^
+
+
+
+
+
+The ^^ is  **Shift** + **Ctrl** + **6** .
+
+
+
+### 18.4.10 How Can I Do File Transfers with `tip`? 
+
+
+If you are talking to another UNIX® system, you can send and receive files with `~p` (put) and `~t` (take). These commands run `cat` and `echo` on the remote system to accept and send files. The syntax is:
+
+
+
+`~p` local-file [remote-file]
+
+
+
+`~t` remote-file [local-file]
+
+
+
+There is no error checking, so you probably should use another protocol, like zmodem.
+
+
+
+### 18.4.11 How Can I Run zmodem with `tip`? 
+
+
+
+To receive files, start the sending program on the remote end. Then, type `~C rz` to begin receiving them locally.
+
+
+
+To send files, start the receiving program on the remote end. Then, type `~C sz `***files****** to send them to the remote system.
+
+***
+
+## 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&section4) 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&section8) 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&section8) 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.***
+
 
-***