Linux Serial Console Setup
- Serial Console Ubuntu
- Linux Serial Console Setup For Pc
- Linux Usb Serial Console Setup
- Arch Linux Setup Serial Console
- Azure Serial Console Linux
You can configure the system to allow logins from a terminal over a serial port by seting up a getty(1) session on the serial port - getty is the tool for setting up a terminal and allowing logins onto it. The Serial Console in the Azure portal provides access to a text-based console for Linux virtual machines (VMs) and virtual machine scale set instances. This serial connection connects to the ttys0 serial port of the VM or virtual machine scale set instance, providing access to it independent of the network or operating system state. An Arch Linux machine can be configured for connections via the serial console port, which enables administration of a machine even if it has no keyboard, mouse, monitor, or network attached to it. Installation of Arch Linux is possible via the serial console as well. A basic environment for this.
Back to RPi Advanced Setup.
The serial port is a low-level way to send data between the Raspberry Pi and another computer system. There are two main ways in which it can be used:
- Connecting to a PC to allow access to the Linux console. This can help to fix problems during boot, or to log in to the Raspberry Pi if the video and network are not available.
- Connecting to a microcontroller or other peripheral which has a serial interface. This can be useful if you want the Raspberry Pi to control another device.
- 2Connection to a PC
- 3Connection to a microcontroller or other peripheral
- 3.2S/W: Preventing Linux from using the serial port
Connections and signal levels
The Raspberry Pi serial port consists of two signals (a 'transmit' signal, TxD and a 'receive' signal RxD) made available on the GPIO header. To connect to another serial device, you connect the 'transmit' of one to the 'receive' of the other, and vice versa. You will also need to connect the Ground pins of the two devices together.
The Broadcom chip at the heart of the Raspberry Pi has low power serial ports with limitations of voltage and protocol compatibility. The ports use 0V and 3.3 V logic levels, not 0 & +5V TTL levels or the +/-12 V used by RS-232 serial ports found on some older PCs. If you wish to connect one of these, you need a board or adapter to convert the signal levels. See this tutorial for one example on how to build a 3.3 V to RS-232 level converter with a breadboard, a MAX3232CPE IC and five 0.1 µF capacitors. If your Raspberry Pi has bluetooth/wireless capability, then the on-chip UART connected to the header pins is the less capable mini-UART with no break detection, no framing errors detection, no parity bit, no receive timeout interrupt and no DCD, DSR, DTR or RI signals (See RPi UART info for more details.)
If you wish to connect your Raspberry Pi to a PC with a USB port, the simplest option is to use a USB-to-serial cable which uses 3.3 V logic levels (e.g. the Adafruit 954 cable, the FTDI TTL-232R-RPI cable, or the Debug Buddy ultimate serial port). These can be simply plugged in directly to the GPIO header (see illustration).
- For using the Adafruit 954 cable on Windows, see Adafruit 954 USB serial cable.
If you wish to connect to a peripheral which has 0/5 V signals, you should ideally have a circuit to convert between the voltage levels. See this tutorial for an example using a ready-made level shifter module. Other circuits for level shifting are shown at RPi_GPIO_Interface_Circuits#Level_Shifters. The Debug Buddy ultimate serial port can also be configured for 0/5 V signals.
NOTE FOR RASPBERRY PI 3: The Raspberry pi 3 has changed things a bit and you might need to add the option enable_uart=1
at the end of /boot/config.txt
(see this post by a Pi Engineer)
Connection to a PC
You can connect the Raspberry Pi to a PC using a USB-serial cable, or (if it has an RS-232 port) a level-converter circuit - see above for details. Grace period for expired license in texas. When this is done, you will need to set up a terminal emulator program on your PC as described below.
Console serial parameters
The following parameters are needed to connect to the Raspberry Pi console, and apply on both Linux and Windows.
- Speed (baud rate): 115200
- Bits: 8
- Parity: None
- Stop Bits: 1
- Flow Control: None

Linux terminal set up
If your PC is running Linux, you will need to know the port name of its serial port:
- Built-in (standard) Serial Port: the Linux standard is /dev/ttyS0, /dev/ttyS1, and so on
- USB Serial Port Adapter: /dev/ttyUSB0, /dev/ttyUSB1, and so on.
- Some types of USB serial adapter may appear as /dev/ttyACM0 ..
You will need to be a member of the dialout group to access this port (for later releases the required group is tty). You can check which is needed with:
and you will see something like 'crw-rw----T 1 root dialout ..', c means character device, and root can 'read,write' and the group dialout can 'read,write' to the port and everyone else cannot access it.
To find out if you, the current user, is in the group dialout, use the command:
If you do not see dialout listed, add yourself with the command
You then have a choice of terminal emulation programs:
- Super Easy Way Using GNU Screen
Enter the command below into a terminal window
To exit GNU screen, type Control-A k.
- Super Easy Way Using Minicom
Run Minicom with the following parameters:
You can exit Minicom with Control-A x
Note: If you haven't configured minicom before (i.e: first use after installation), or if you find that your keyboard key presses are not sent to the RPi, you should make sure Hardware Flow Control is disabled. See Tedious Old-Fashioned Way Using Minicom to configure minicom.
- Tedious Old-Fashioned Way Using Minicom
Another method to setup minicom is described in the Tincantools Minicom Tutorial
- GUI method with GtkTerm
Start GtkTerm, select Configuration->Port and enter the values above in the labeled fields.
Network connection with the point-to-point protocol (ppp)
The easiest way to set up a network connection between your Raspberry Pi and another computer is with an Ethernet cable. If this is not possible, as is the case for the Raspberry Pi Model A, you can set up a connection over the serial cable. This uses the Point-to-point Protocol (PPP). A network connection running over a serial cable can be very useful for copying files onto the Raspberry Pi.
Step 1: Log in to the Raspberry Pi over the serial cable and run the Point-to-Point Protocol Daemon:
Some garbage will start appearing in the terminal. This is the cue to quit your terminal program and proceed to step two.
Step 2: On your local computer, start the Point-to-Point protocol. On a Linux or Mac computer you can do this by typing:
replacing /dev/tty.usbserial-FTGCC2MV with the name of your serial port. In the above line, 115200 is the baud rate of the connection, 10.0.0.1 is the local internet protocol (IP) address, the address you want your computer to have. 10.0.0.2 is the remote IP address, it is the address that the Raspberry Pi will have.
Test the connection:
Virtual connection to the LAN
Instead of 10.0.0.0/8 you could as well use normal 192.168.0.0/16 addresses;the first address must be the real address of the local (serving) system.You can chose the second address; it must not yet be assigned on the LAN (and be outside the DHCP range).The advantage is that the system connected to the serial line will appear as if it is directly connected to the LAN (arp protocol).
You must enable routing on the system directly connected to the LAN for other systems to access the system connected to the serial line:
On the guest system connected via the serial cable you must set the default route pointing to the serving system, e.g.
You should also configure /etc/resolv.conf if you want to use DNS.
Windows terminal set-up
Users of Windows Vista or later will need to download a terminal program, for instance PuTTY, or TeraTerm. Users of Windows XP and below can choose between using PuTTY and the built-in Hyperterminal.
PuTTY users simply need to choose 'serial', select the correct COM port and set the speed, as shown in the dialog below.
If you are unsure of the COM port, run [Device Manager] and look under 'Ports'. USB-attached serial adapters should have the name of the adapter shown (the Adafruit cable comes up as 'Prolific USB-to_Serial Comm Port'.
Boot messages
If your connection is set up correctly, when the Raspberry Pi is booted you should see many messages as the system comes up:
and so on. Eventually, you should see a login prompt:
You can then log in as you would with a keyboard and screen.
Unwanted serial garbage input
Note that on older software by accident the internal pullups of the RxD GPIO pins were not enabled, this could lead to lots of serial garbage being picked up if the GPIO pin was touched, or even if a finger was nearby. In extreme case this could lead to kernel warnings and other problems.
Connection to a microcontroller or other peripheral
H/W considerations
If your microcontroller or peripheral works with 5V logic levels, level conversion is necessary - see 'Connecting to a PC' for details.
If your microcontroller or peripheral works with 3.3V logic levels then you can connect its TxD, RxD signals directly to the RxD and TxD pins of the Raspberry. However it's probably a good idea to connect the signals with a 2.2 kΩ resistors in series. This will prevent damage if two outputs are accidentally connected together (e.g. if you connect TxD with TxD or if a GPIO input pin is accidentally programmed as output).
S/W: Preventing Linux from using the serial port
By default Linux will grab the serial port and use it as a terminal. If you want to use it for other purposes you must prevent this. Here are the methods you can use:
Method 1, raspi-config (easiest, try this first)
Run sudo raspi-config
and check if it has the option advanced options
-> serial
. If it has, set it to disabled and you're done.
Method 2, using an existing script (easy)
There's a nice little script to automate the steps bellow.
Method 3, manual configuration (complex)
If neither raspi-config nor the script works for you then follow the hard way.
NOTE FOR RASPBERRY PI 3: The Raspberry pi 3 has changed things around a bit: ttyAMA0 now refers to the serial port that is connected to the bluetooth. The old serial port is now called ttyS0. So if you have an RPI3, everywhere you see 'ttyAMA0' below, you should read 'ttyS0'.
The Broadcom UART appears as /dev/ttyAMA0
under Linux. There are several minor things in the way if you want to have dedicated control of the serial port on a Raspberry Pi.
- Firstly, the kernel will use the port as controlled by kernel command line contained in
/boot/cmdline.txt
. The file will look something like this:
The console keyword outputs messages during boot, and the kgdboc keyword enables kernel debugging. You will need to remove all references to ttyAMA0. So, for the example above /boot/cmdline.txt
, should contain:
You must be root to edit this (e.g. use sudo nano /boot/cmdline.txt
). Be careful doing this, as a faulty command line can prevent the system booting.
- Secondly, after booting, a login prompt appears on the serial port. This is controlled by the following lines in
/etc/inittab
:
You will need to edit this file to comment out the second line, i.e.
Finally you will need to reboot the Raspberry Pi for the new settings to take effect. Once this is done, you can use /dev/ttyAMA0
like any normal Linux serial port, and you won't get any unwanted traffic confusing the attached devices.
The above instructions have been verified on Raspbian 'Wheezy'; other distributions may be set up differently. To double-check, use
to show the current kernel command line, and
to search for getty
processes using the serial port.
A tutorial on accessing the Raspberry Pi's serial port from Python is available at Serial_port_programming.
Handshaking lines
You can have the RTS0 signal on GPIO 17 (P1-11) or GPIO 31 (P5-06) if you set them to ALT function 3. Likewise, the CTS0 is available on GPIO 30 (P5-05), if it is set to ALT function 3. You can control the settings of I/O pins with gpio_setfunc.
Glitch when opening serial port
When the serial port is opened the voltage on TXD pulses negative for approximately 32 µs (regardless of the baud rate). This pulse may be interpreted as a transmission by a device connected to the TXD pin, which could have unintended effects. An error tolerant communication protocol should be used to avoid problems this glitch could cause. Another method for avoiding problems is to use a GPIO pin to implement the RTS signal, and to have the connected device ignore all data on TXD until RTS is asserted. If the connected device is susceptible to the glitch and cannot be modified, it is sometimes possible to obtain correct operation by opening the serial port in advance of initiating transmission. This can be done in the shell with the sleep program:
In a shell script, the following commands may be used to kill the sleep process once serial transmission is complete.
Serial Console Ubuntu
|
Linux Serial Console Setup For Pc
FreeBSD has the ability to boot a system with a dumb terminal on a serial port as a console. This configuration is useful for system administrators who wish to install FreeBSD on machines that have no keyboard or monitor attached, and developers who want to debug the kernel or device drivers.
As described in Chapter 12, The FreeBSD Booting Process, FreeBSD employs a three stage bootstrap. The first two stages are in the boot block code which is stored at the beginning of the FreeBSD slice on the boot disk. The boot block then loads and runs the boot loader as the third stage code.
Windows xp pro sp2 cd key. In order to set up booting from a serial console, the boot block code, the boot loader code, and the kernel need to be configured.
This section provides a fast overview of setting up the serial console. This procedure can be used when the dumb terminal is connected to COM1
.
COM1
Linux Usb Serial Console Setup

Connect the serial cable to
COM1
and the controlling terminal.To configure boot messages to display on the serial console, issue the following command as the superuser:
Edit
/etc/ttys
and changeoff
toon
anddialup
tovt100
for thettyu0
entry. Otherwise, a password will not be required to connect via the serial console, resulting in a potential security hole.Reboot the system to see if the changes took effect.
If a different configuration is required, see the next section for a more in-depth configuration explanation.
This section provides a more detailed explanation of the steps needed to setup a serial console in FreeBSD.
Prepare a serial cable.
Use either a null-modem cable or a standard serial cable and a null-modem adapter. See Section 26.2.1, “Serial Cables and Ports” for a discussion on serial cables.
Unplug the keyboard.
Many 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 will refuse to boot until the keyboard is plugged in.
If the computer complains about the error, but boots anyway, no further configuration is needed.
If the computer refuses to boot without a keyboard attached, configure the BIOS so that it ignores this error. Consult the motherboard's manual for details on how to do this.
Tip:
Try setting the keyboard to “Not installed” in the BIOS. This setting tells the BIOS not to probe for a keyboard at power-on so it should not complain if the keyboard is absent. If that option is not present in the BIOS, look for an “Halt on Error” option instead. Setting this to “All but Keyboard” or to “No Errors” will have the same effect.
If the system has a PS/2® mouse, unplug it as well. 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.
Note:
While most systems will boot without a keyboard, quite a few will not boot without a graphics adapter. Some systems can be configured to boot with no graphics adapter by changing the “graphics adapter” setting in the BIOS configuration to “Not installed”. Other systems do not support this option and will refuse to boot if there is no display hardware in the system. With these machines, leave some kind of graphics card plugged in, even if it is just a junky mono board. A monitor does not need to be attached.
Plug a dumb terminal, an old computer with a modem program, or the serial port on another UNIX® box into the serial port.
Add the appropriate
hint.sio.*
entries to/boot/device.hints
for the serial port. Some multi-port cards also require kernel configuration options. Refer to sio(4) for the required options and device hints for each supported serial port.Create
boot.config
in the root directory of thea
partition on the boot drive.This file instructs the boot block code how to boot the system. In order to activate the serial console, one or more of the following options are needed. When using multiple options, include them all on the same line:
-h
Toggles between the internal and serial consoles. Use this to switch console devices. For instance, to boot from the internal (video) console, use
-h
to direct the boot loader and the kernel to use the serial port as its console device. Alternatively, to boot from the serial port, use-h
to tell the boot loader and the kernel to use the video display as the console instead.-D
Toggles between the 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
-h
. 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-h
. However, the dual console configuration takes effect only while the boot block is running. Once the boot loader gets control, the console specified by-h
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,
-P
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 laptops may not be properly found because of this limitation. If this is the case, do not use-P
.
Use either
-P
to select the console automatically or-h
to activate the serial console. Refer to boot(8) and boot.config(5) for more details.The options, except for
-P
, are passed to the boot loader. The boot loader will determine whether the internal video or the serial port should become the console by examining the state of-h
. This means that if-D
is specified but-h
is not specified in/boot.config
, the serial port can be used as the console only during the boot block as the boot loader will use the internal video display as the console.Boot the machine.
When FreeBSD starts, the boot blocks echo the contents of
/boot.config
to the console. For example:The second line appears only if
-P
is in/boot.config
and indicates the presence or absence of the keyboard. These messages go to either the 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 presentinternal console -P
, keyboard absentserial console After the message, there will be a small pause before the boot blocks continue loading the boot loader and before any further messages are printed to the console. Under normal circumstances, there is no need to interrupt the boot blocks, but one can do so in order to make sure things are set up correctly.
Press any key, other than Enter, at the console to interrupt the boot process. The boot blocks will then prompt for further action:
Verify that the above message appears on either the serial or internal console, or both, according to the options in
/boot.config
. If the message appears in the correct console, press Enter to continue the boot process.If there is no prompt on the serial terminal, something is wrong with the settings. Enter
-h
then Enter or Return 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.
During the third stage of the boot process, one can still switch between the internal console and the serial console by setting appropriate environment variables in the boot loader. See loader(8) for more information.
Note:
This line in /boot/loader.conf
or /boot/loader.conf.local
configures the boot loader and the kernel to send their boot messages to the serial console, regardless of the options in /boot.config
:
That line should be the first line of /boot/loader.conf
so that boot messages are displayed on the serial console as early as possible.
Arch Linux Setup Serial Console
If that line does not exist, or if it is set to console='vidconsole'
, the boot loader and the kernel will use whichever console is indicated by -h
in the boot block. See loader.conf(5) for more information.
At the moment, the boot loader has no option equivalent to -P
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.
Tip:
While it is not required, it is possible to provide a login
prompt over the serial line. To configure this, edit the entry for the serial port in /etc/ttys
using the instructions in Section 26.3.1, “Terminal Configuration”. If the speed of the serial port has been changed, change std.9600
to match the new setting.
By default, the serial port settings are 9600 baud, 8 bits, no parity, and 1 stop bit. To change the default console speed, use one of the following options:
Edit
/etc/make.conf
and setBOOT_COMCONSOLE_SPEED
to the new console speed. Then, recompile and install the boot blocks and the boot loader: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, add the following option, with the desired speed, to a custom kernel configuration file and compile a new kernel:Add the
-S
boot option to19200
/boot.config
, replacing19200
with the speed to use.Add the following options to
/boot/loader.conf
. Replace115200
with the speed to use.
26.6.4. Entering the DDB Debugger from the Serial Line
Azure Serial Console Linux
To configure the ability to drop into the kernel debugger from the serial console, add the following options to a custom kernel configuration file and compile the kernel using the instructions in Chapter 8, Configuring the FreeBSD Kernel. Note that while this is useful for remote diagnostics, it is also dangerous if a spurious BREAK is generated on the serial port. Refer to ddb(4) and ddb(8) for more information about the kernel debugger.