Page 1 of 1

/dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 4:14 pm
by nandor65
Hi,

I am unable to enable /dev/ttyS0 on Strech using raspi-config. Exact steps are as follows:
$ sudo raspi-config
Interfacing options -> Serial -> No -> Yes ... Finish -> reboot

after reboot

$ ls -l /dev/ttS0 /dev/ttyAMA0
answers this:
ls: cannot access '/dev/ttyS0': No such file or directory
crw-rw---- 1 root dialout 204, 64 Nov 16 16:56 /dev/ttyAMA0

Also checked /boot/config.txt and it has the line
enable_uart=1
as the last line.

please advise. thank you.
Nandor

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 4:28 pm
by PhilE
You have a typo in your message ("ttS0" should be "ttyS0") but I'm going to assume that you typed it correctly at the command prompt. You could run

Code: Select all

ls /dev/tty*
to confirm.

Which model of Pi are you running on? And what is the software history of your image (what did you install, did you upgrade, etc.)?

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 4:47 pm
by PhilE
My guess is that you aren't running on a Pi 3B or a Pi Zero W, in which case ttyS0 (uart1) has to be enabled specially. In fact, unless you are on a Compute Module there isn't much point in enabling ttyS0 because there is only one position it can appear on the 40-way header (GPIOs 14 and 15) - ttyAMA0 has the same restriction and it is a better UART.

1. In config.txt add the following line:

Code: Select all

dtoverlay=uart1,txd1_pin=<x>,rxd1_pin=<y>
where <x> and <y> are 14/15, 32/33 or 40/41 (or you can mix and match if you really want to). Don't use 14 and 15 if ttyAMA0 is also enabled there.

2. In cmdline.txt add the following somewhere in the line (don't split the line):

Code: Select all

8250.nr_uarts=1
After a reboot /dev/ttyS0 should exist. You can confirm the pin usage with "raspi-gpio get".

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 4:55 pm
by nandor65
hi PhilE,
thanks for your comments.
RPi3 RevB

[email protected]:~ $ ls /dev/tty*
/dev/tty /dev/tty19 /dev/tty3 /dev/tty40 /dev/tty51 /dev/tty62
/dev/tty0 /dev/tty2 /dev/tty30 /dev/tty41 /dev/tty52 /dev/tty63
/dev/tty1 /dev/tty20 /dev/tty31 /dev/tty42 /dev/tty53 /dev/tty7
/dev/tty10 /dev/tty21 /dev/tty32 /dev/tty43 /dev/tty54 /dev/tty8
/dev/tty11 /dev/tty22 /dev/tty33 /dev/tty44 /dev/tty55 /dev/tty9
/dev/tty12 /dev/tty23 /dev/tty34 /dev/tty45 /dev/tty56 /dev/ttyAMA0
/dev/tty13 /dev/tty24 /dev/tty35 /dev/tty46 /dev/tty57 /dev/ttyprintk
/dev/tty14 /dev/tty25 /dev/tty36 /dev/tty47 /dev/tty58
/dev/tty15 /dev/tty26 /dev/tty37 /dev/tty48 /dev/tty59
/dev/tty16 /dev/tty27 /dev/tty38 /dev/tty49 /dev/tty6
/dev/tty17 /dev/tty28 /dev/tty39 /dev/tty5 /dev/tty60
/dev/tty18 /dev/tty29 /dev/tty4 /dev/tty50 /dev/tty61

Stretch Lite was downoladed from repository on 13th Nov, SD was written using that image. then I did these steps:
$ sudo raspi-config
Boot Options -> Wait for network at boot
Localisation Options -> Change Timezone
Interfacing Options -> Camera -> Enable
Interfacing Options -> SSH -> Enable
reboot
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade
$ sudo apt-get clean
$ sudo apt-get install --no-install-recommends xserver-xorg
$ sudo apt-get install --no-install-recommends xinit
$ sudo apt-get install lxde-core lxappearance
$ sudo apt-get install lightdm
$ sudo raspi-config (consol only)
Boot Options -> Desktop/CLI ->B3 Desktop
Interfacing Options -> VNC -> Enable
reboot

Hope this helps.
Nandor

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 5:06 pm
by PhilE
Can you post the output of the following commands?:

Code: Select all

$ dmesg | grep 8250
$ cat /proc/device-tree/soc/[email protected]/status

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 5:11 pm
by nandor65
[email protected]:~ $ dmesg | grep 8250
[email protected]:~ $ cat /proc/device-tree/soc/[email protected]/status
[email protected]:~ $

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 5:21 pm
by PhilE
Thanks - we're slowly eliminating the impossibilities. On a Pi 3B UART1 is enabled automatically if enable_uart=1 appears in config.txt, except if either the pi3-disable-bt or pi3-miniuart-bt overlays are being used.

More typing:

Code: Select all

$ grep -E "^[^#]" /boot/config.txt
$ cat /boot/cmdline.txt

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 5:24 pm
by nandor65
[email protected]:~ $ grep -E "^[^#]" /boot/config.txt
framebuffer_width=1280
framebuffer_height=720
dtparam=audio=on
start_x=1
gpu_mem=128
enable_uart=1
[email protected]:~ $ cat /boot/cmdline.txt
dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=5ac82c05-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 5:26 pm
by nandor65
and I would like to add that I did not do those points you suggested in your comment of Thu Nov 16, 2017 5:47 pm since i was not sure if that is for RPi3B.

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 5:32 pm
by nandor65
and one more addition : I am using bcm2835-v4l2 module loaded.

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 5:39 pm
by PhilE
Please add "dtdebug=1" to config.txt, reboot, then run:

Code: Select all

$ sudo vcdbg log msg |& grep dt

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 5:44 pm
by nandor65
[email protected]:~ $ sudo vcdbg log msg |& grep dt
001773.554: brfs: File read: /mfs/sd/bcm2709-rpi-2-b.dtb
001773.578: Loading 'bcm2709-rpi-2-b.dtb' to 0x466130 size 0x4135
001785.313: dtdebug: delete_node(/__local_fixups__)
001793.556: dtdebug: /aliases:i2c_vc=i2c0
001799.356: dtdebug: /__symbols__:i2c_vc=i2c0
001804.103: dtdebug: /__overrides__:i2c_vc=i2c0
001816.125: dtdebug: /__overrides__:i2c_vc_baudrate=i2c0_baudrate
001821.000: dtdebug: /aliases:i2c=i2c1
001826.969: dtdebug: /__symbols__:i2c=i2c1
001831.805: dtdebug: /__overrides__:i2c=i2c1
001836.723: dtdebug: /aliases:i2c_arm=i2c1
001842.731: dtdebug: /__symbols__:i2c_arm=i2c1
001847.608: dtdebug: /__overrides__:i2c_arm=i2c1
001859.827: dtdebug: /__overrides__:i2c_baudrate=i2c1_baudrate
001872.039: dtdebug: /__overrides__:i2c_arm_baudrate=i2c1_baudrate
001872.060: dtparam: pwr_led_gpio=35
001875.455: dtdebug: Found override pwr_led_gpio
001875.500: dtdebug: override pwr_led_gpio: cell target gpios @ offset 4 (size 4)
001884.908: dtparam: uart0_clkrate=48000000
001888.411: dtdebug: /__overrides__ has no uart0_clkrate property
001888.424: Unknown dtparam 'uart0_clkrate' - ignored
001891.825: dtparam: audio=on
001895.241: dtdebug: Found override audio
001895.275: dtdebug: override audio: string target 'status'
001917.962: dtdebug: /aliases:serial0=uart0
001922.954: dtdebug: /aliases:serial1=uart1
002944.768: dtparam: arm_freq=900000000
002948.108: dtdebug: Found override arm_freq
002948.159: dtdebug: override arm_freq: cell target clock-frequency @ offset 0 (size 4)
002956.399: dtdebug: override arm_freq: cell target clock-frequency @ offset 0 (size 4)
002964.704: dtdebug: override arm_freq: cell target clock-frequency @ offset 0 (size 4)
002973.117: dtdebug: override arm_freq: cell target clock-frequency @ offset 0 (size 4)
002981.608: dtparam: core_freq=250000000
002985.159: dtdebug: /__overrides__ has no core_freq property
002985.174: Unknown dtparam 'core_freq' - ignored
002985.191: dtparam: cache_line_size=64
002988.495: dtdebug: Found override cache_line_size
002988.542: dtdebug: override cache_line_size: cell target cache-line-size @ offset 0 (size 4)
003005.379: dtdebug: delete_node(/hat)

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 5:51 pm
by PhilE

Code: Select all

001773.554: brfs: File read: /mfs/sd/bcm2709-rpi-2-b.dtb
001773.578: Loading 'bcm2709-rpi-2-b.dtb' to 0x466130 size 0x4135
Bingo. Are you sure this is a Pi3B?

Code: Select all

$ grep Revision /proc/cpuinfo
$ cat /proc/device-tree/model

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 5:56 pm
by PhilE
You should also consider why you want to use ttyS0 on a non-Compute Module Pi because of the GPIO-usage issue I mentioned earlier.

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 5:58 pm
by nandor65
[email protected]:~ $ grep Revision /proc/cpuinfo
Revision : a01041
[email protected]:~ $ cat /proc/device-tree/model
Raspberry Pi 2 Model B Rev 1.1

looks like this is a RPi2.

what is the solution for RPi2 then?

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 6:01 pm
by PhilE
See my second (unusually prescient) post. But why do you want to use ttyS0 at all when you have ttyAMA0 (which is more capable) and you can't use both at once?

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 6:02 pm
by nandor65
there is a custom built PCB attached to GPIO which controls an IR cut filter. I would like to control this PCB via dev/ttyS0.

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 6:07 pm
by nandor65
the engineer who built this PCB told me to control via asynchron TTL serial port with these params: 38400bps 8bit 1stop no-parity no-flowcontrol
and I thought i need to use ttyS0.

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 6:09 pm
by PhilE
See page 102 of the BCM2835 ARM Peripherals guide and you may understand the problem. UART1 uses TXD1 and RXD1, so look for those functions in the table.

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 6:10 pm
by PhilE
ttyAMA0 is the obvious choice unless you are using it for something else.

Re: /dev/ttyS0 issue on Stretch

Posted: Thu Nov 16, 2017 6:13 pm
by nandor65
PhilE,
many thanks, looks like I need to do some readings.
N