Raspberry Pi: Enable the Serial Port

By default the serial port is configured to start up a console input/output. To be able to use the serial port to connect and talk to other devices , the serial port console login needs to be disabled. This used to be a procedure more or less straight forward. With the introduction of the Raspberry Pi 3 this has become somewhat confusing however.

A good tutorial how to set up the serial port on a Raspberry Pi 3 with Raspbian Jessie can be found here. And here is a translation into German.

On older models,  including the Raspberry Pi Zero, There are two files that need to be edited. The following procedure is appropriate for Raspbian Wheezy OS.

The first one is /etc/inittab

This file has the command to enable the login prompt and this needs to be disabled. Edit the file and move to the end of the file. You will see a line similar to

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Disable it by adding a # character to the beginning (marked red below0. Save the file.

#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

The second file to be edited is  /boot/cmdline.txt
The contents of the file look like this

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Remove all references to ttyAMA0 (marked in red above). The file will now look like this

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

Save the file and reboot,

 sudo shutdown -r now

done.

Using Raspbian Jessie, the Uart needs to be activated. Edit this file:

/boot/config.txt

at the end of the file, add the following line:

enable_uart=1

disable the console login on /dev/ttyAMA0:

sudo systemctl stop serial-getty@ttyAMA0.service
sudo systemctl disable serial-getty@ttyAMA0.service

Reboot, done. Again, the Pi 3 is more complicated,  see here.

Continue to next step

Advertisements