eng_moh
Posts: 13
Joined: Wed Feb 08, 2017 6:43 am

disable serial console for raspberry pi 2

Tue Mar 21, 2017 12:39 pm

i need to send and receive text data to/from my pi and pc
by default logging screen appear
i can not disable serial console
i have raspberry pi 2

pcmanbob
Posts: 13159
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: disable serial console for raspberry pi 2

Tue Mar 21, 2017 1:09 pm

Hi.

if you run sudo raspi-config
select 5 interfacing options > 6 serial to disable shell and kernel messages on serial connection.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

klricks
Posts: 8474
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA

Re: disable serial console for raspberry pi 2

Tue Mar 21, 2017 1:13 pm

With fully updated Raspbian Jessie Pixel:

Code: Select all

sudo raspi-config
[5 Interfacing Options] --> [P6 Serial]:
...Loggin shell.....? <NO>
...Serial Port Enable....? <YES>
Unless specified otherwise my response is based on the latest and fully updated RPi OS Bullseye w/ Desktop OS.

eng_moh
Posts: 13
Joined: Wed Feb 08, 2017 6:43 am

Re: disable serial console for raspberry pi 2

Wed Mar 22, 2017 5:55 am

i have
Distributor ID: Raspbian
Release: 8.0
Codename: jessie

my tested code


serial_read.py

#!/usr/bin/env python
import time
import serial
ser = serial.Serial(port='/dev/ttyAMA0',baudrate = 9600,parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE,bytesize=serial.EIGHTBITS,timeout=1)
counter=0

while 1:
x=ser.readline()
print x

seial_write.py

#!/usr/bin/env python
import time
import serial

ser = serial.Serial(port='/dev/ttyAMA0',
baudrate = 9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1)
counter=0

while 1:
ser.write('Write counter: %d \n'%(counter))
time.sleep(1)
counter += 1
print counter


i do this steps
[5 Interfacing Options] --> [P6 Serial]:
...Loggin shell.....? <NO>
...Serial Port Enable....? <YES>

and my programs does this error

root@raspberrypi:/home/pi/ras_pi# python serial_write.py
Traceback (most recent call last):
File "serial_write.py", line 12, in <module>
timeout=1)
File "/usr/lib/python2.7/dist-packages/serial/serialutil.py", line 261, in __init__
self.open()
File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 278, in open
raise SerialException("could not open port %s: %s" % (self._port, msg))
serial.serialutil.SerialException: could not open port /dev/ttyAMA0: [Errno 2] No such file or directory: '/dev/ttyAMA0'
root@raspberrypi:/home/pi/ras_pi# python serial_read.py
Traceback (most recent call last):
File "serial_read.py", line 8, in <module>
ser = serial.Serial(port='/dev/ttyAMA0',baudrate = 9600,parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE,bytesize=serial.EIGHTBITS,timeout=1)
File "/usr/lib/python2.7/dist-packages/serial/serialutil.py", line 261, in __init__
self.open()
File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 278, in open
raise SerialException("could not open port %s: %s" % (self._port, msg))
serial.serialutil.SerialException: could not open port /dev/ttyAMA0: [Errno 2] No such file or directory: '/dev/ttyAMA0'


but my serial_write.py file worked before disable serial port(uart)

pcmanbob
Posts: 13159
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: disable serial console for raspberry pi 2

Wed Mar 22, 2017 7:51 am

Hi.
it seems that disabling it via raspi-config also disables the serial port.

so undo what you did in raspi-config ie re-enable shell and kernel messages on serial connection. select option yes
then reboot your pi

now enter this in a terminal window or at the commend line in Jessie lite

Code: Select all

sudo nano /boot/cmdline.txt
now this is one long line so you need to scroll across till you find "console=serial0,115200" or "console=ttyAMA0,115200"
delete this but make sure you have only a single space between the remaining commands.
then save it and exit, then reboot pi and you are done.
I tested this and you don't get the error if you do it this way.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

eng_moh
Posts: 13
Joined: Wed Feb 08, 2017 6:43 am

Re: disable serial console for raspberry pi 2

Wed Mar 22, 2017 8:48 am

thank you very much for your help
everything is ok

eng_moh
Posts: 13
Joined: Wed Feb 08, 2017 6:43 am

Re: disable serial console for raspberry pi 2

Wed Mar 22, 2017 8:51 am

final content for /boot/cmdline.txt file

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

after enable uart

vijay.panchal
Posts: 4
Joined: Mon Feb 26, 2018 5:21 am

Re: disable serial console for raspberry pi 2

Thu May 10, 2018 12:15 pm

eng_moh wrote:
Wed Mar 22, 2017 8:51 am
final content for /boot/cmdline.txt file

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

after enable uart
I found same.

Return to “Beginners”