Free Your Raspberry Pi Serial Port

By default Raspbian configures the Raspberry Pi serial port (GPIO14-GPIO15) to provide boot-up information. It also allows you to login via a connected device. If you need to use the Pi’s serial port for something else (i.e. a specific add-on board) you will need to disable this default functionality.

It’s something I needed to do when I played with the Ciseco Pi-Lite and luckily isn’t too difficult as the instructions below will hopefully show.

Disable Login Via Serial Port

To disable the login feature we can run the following command to edit the inittab system file :

sudo nano /etc/inittab

Use the cursor keys to find the line :

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

and add a # character at the beginning of the line to give :

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

Press “CTRL-X”, “Y” and finally “Enter” or “Return” to save the file.

Disable Boot Messages

When the Pi is booting all the debug messages are sent to the serial port. This can be useful for some purposes but we need to turn this off to free the port for our own use.

To stop the messages being sent to the port we need to edit another system file. Run the following command to edit the cmdline.txt file :

sudo nano /boot/cmdline.txt

Use the cursor keys to find the line :

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

and remove the block of console parameters in the middle to give you :

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

Press “CTRL-X”, “Y” and finally “Enter” or “Return” to save. You should be returned to the command prompt.

Restart Pi

Now the changes have been made the Pi must be restarted for them to take effect.

Reboot using :

sudo reboot

Test Using Minicom (optional)

If you have a suitable device (e.g. a PC) to connect to your Pi via a serial interface you can use the “Minicom” utility to send data to it via the Pi’s serial port. This is a quick way to test the configuration changes have been successful.

You can install Minicom using the following command :

sudo apt-get install minicom

Press “Y” when prompted.

You can then use Minicom to send and receive data over the serial port :

minicom -b 9600 -o -D /dev/ttyAMA0

Pressing keys on your keyboard should result in them appearing on your connected device.

To exit Minicom press “CTRL-A”, then “X” and finally press “Return” to select “Yes” from the prompt.

Your serial port is now ready for whatever plans you have for it.

This entry was posted in Hardware, Tutorials & Help and tagged , . Bookmark the permalink.

6 Responses to Free Your Raspberry Pi Serial Port

  1. piguy says:

    Ok I have tried this and it’s not working at all nor can I edit /boot/cmdline.txt because it is completely blank. I am using the current version raspbian.

    • Brian Wallace says:

      Is it raspberian OS? It’s there by default even now, but of course doesn’t exist in XMBC or other OS. It’s software so depends on the OS at startup ;)

  2. Aak says:

    This instruction works perfectly fine. I am not sure why it didn’t work for you piguy?
    Thanks Matt.

  3. Fred H says:

    Is it possible to retain the debug output and at the end of the boot cycle, disconnect it and reconnect as an available port? And at every boot?

    I would like to retain the debug portion since it makes sense to be able to see the data in the event of an error. Then, afterwards use another application (e.g., PuTTY ) and make use of the port.

    I actually want to connect a serial GPS to the port for use with GPSd.

    As a Linux/RPi noob I may not have the wording correct but I hope it is understandable.


  4. SuvwI says:

    Hi I have tried testing Minicom from 1pi (AMA0) to 2pi(USB0) and the connection is ok and communication exists however when I Type in one the other just displays Strange characters. why?

    If I try USB0 to AMA0 nothing appears at all.


  5. guna says:

    I tried to communicate RPI B+ and my PC thru minicom. I can only receive datas on PC from RPi, but couldnt RPI from PC. If i type any characters on minicom, the minicom will get hang, nothing happen on both sides (in PC as well as in RPI). Am using CP2102 serial bridge. Pl reply asap

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>