My Pi3 serial console produces rubbish and fails to respond to the keyboard.

up vote 56 down vote accepted

This answer is still correct, and explains in more detail the nature of the changes, but most users of current Raspbian should just run sudo raspi-config Select Interfacing Options / Serial then specify if you want a Serial console (probably no) then if you want the Serial Port hardware enabled (probably yes). Then use /dev/serial0 in any code which accesses the Serial Port.

The BCM2837 on the Raspberry Pi3 , Pi3B+, PiZeroW has 2 UARTs (as did its predecessors), however to support the Bluetooth functionality the fully featured PL011 UART was moved from the header pins to the Bluetooth chip and the mini UART made available on header pins 8 & 10.

This has a number of consequences for users of the serial interface.

The /dev/ttyAMA0 previously used to access the UART now connects to Bluetooth.
The miniUART is now available on /dev/ttyS0.
In the latest operating system software there is a /dev/serial0 which selects the appropriate device so you can replace /dev/ttyAMA0 with /dev/serial0 and use the same software on the Pi3 and earlier models.

Unfortunately there are a number of other consequences:-

The mini UART is a secondary low throughput UART  
  intended to be used as a console.
The mini Uart has the following features:
• 7 or 8 bit operation.
• 1 start and 1 stop bit.
• No parities.
• Break generation.
• 8 symbols deep FIFOs for receive and transmit.
• SW controlled RTS, SW readable CTS.
• Auto flow control with programmable FIFO level.
• 16550 like registers.
• Baudrate derived from system clock.

There is no support for parity and the throughput is limited, but the latter should not affect most uses.

There is one killer feature "Baudrate derived from system clock" which makes the miniUART useless as the this clock can change dynamically e.g. if the system goes into reduced power or in low power mode.

Modifying the /boot/config.txt removes this dependency by adding the following line at the end:-

core_freq=250

This fixes the problem and appears to have little impact. The SPI clock frequency and ARM Timer are also dependent on the system clock.

For some bizarre reason the default for Pi3 using the latest 4.4.9 kernel is to DISABLE UART. To enable it you need to change enable_uart=1 in /boot/config.txt. (This also fixes the core_freq so this is no longer necessary.)

Finally if you don't use Bluetooth (or have undemanding uses) it is possible to swap the ports back in Device Tree. There is a pi3-miniuart-bt and pi3-disable-bt module which are described in /boot/overlays/README.

  • Thank you @Milliways for the great explanation. What I haven't go though... I have a Radio-Module that connects to my raspberry using UART and it prefers a baud-rate of 9600. So that should work if I set core_freq=250 and then configure my baud rate in ma python script? Also, would be great if you could have a look at: raspberrypi.stackexchange.com/questions/47379/… Thank you! – Georg May 15 '16 at 18:30
  • I have tried /dev/serial0, and enable_uart=1 in /boot/config.txt, with a wiringPi code that used to work with raspberry pi 2, yet it still fails to initiate serial communication (return condition is -1). I also tried /dev/S0 to no avail. What might I be missing? (also freed serial port from raspi-config). (everything including raspbian is up to date) – Özgen Eren May 25 '16 at 7:32
  • 1
    @OE1 If you have a question ask it in a new question, not in Comments. – Milliways May 25 '16 at 7:53
  • I am little confused. How do you mean it doesn't support parity? I have a device my pi3 talks to and it has to have EVEN parity or my system won't talk to it. After following your answer and naseer answer, I was able to get my pi3 running my program talk SUCCESSFULLY to this device which is set for EVEN parity. – ThN Sep 16 '16 at 13:51
  • @ThN The Broadcom datasheet states "No parities". If you send serial with parity the Pi will ignore the parity. The Pi will send with no parity - what your device will do with the 50% of characters with wrong parity depends on the device. If you have questions you should ask as a question, not in comments. – Milliways Sep 17 '16 at 1:10

finally this got work for my pi3 (os: debian jessie)

please follow these 6 steps carefully.

Step 1 - Install Raspbian Jessie onto a SD card and boot the Pi when connected to a network Login via terminal or desktop and shell Configure the system with:

sudo raspi-config

Expand filesystem and enable serial on advanced page, exit and reboot.

Step 2 -this won't necessary if you have jessie new release Update the system with:

sudo apt-get update

sudo apt-get upgrade

Step 3 - Device Tree settings as below:

Add device tree to /boot/config.txt to disable the Raspberry Pi 3 bluetooth.

sudo nano /boot/config.txt

Add at the end of the file

*if you want to change the blutooth to miniuart port(bad)

dtoverlay=pi3-miniuart-bt

*if you want to disable the blutooth(good)

dtoverlay=pi3-disable-bt

Exit the editor saving your changes.

Step 4 - reboot the pi

sudo reboot

step 5 -

a)to disable the Serial Console edit the file using

sudo nano /boot/cmdline.txt

remove the word phase "console=serial0,115200" or "console=ttyAMA0,115200"

Exit and save your changes

b)to Enable the Serial Console edit the file using

sudo nano /boot/cmdline.txt

Change the file to the following:

dwc_otg.lpm_enable=0 console=tty1 console=serial0(or ttyAMA0),115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

Exit and save your changes

Step 6 - reboot the pi

sudo reboot

-----------------that's all,have fun-------------------------------

  • On rpi2 this works and I have it connected to a bluetooth relay board and send it messages via AT commands. But can I receive data from an arduino this way? – marciokoko Jun 16 '17 at 0:23

Naseer's answer is correct but a bit elaborate if you just flashed the latest rasbian. All I needed to do, is just to add the following line to my config.txt (from e.g. windows where you plug in the SD card on the fat32 partition):

dtoverlay=pi3-disable-bt

Then plug it in, and the pi will directly print stuff on the console pins.

  • How can this work? Bluetooth UART is not even connected to GPIO pins! – Dmitry Grigoryev Nov 15 '16 at 15:09
  • 3
    @DmitryGrigoryev It works for me on my PI 3. – ThN Nov 29 '16 at 15:23
  • 1
    This worked for me as well, I found that this thread helped to clarify a few small issues: raspberrypi.org/forums/… – Chris Oct 21 '17 at 7:31

protected by Community Nov 6 '16 at 15:04

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.