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.
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.
Recent Comments