david_1234
Posts: 332
Joined: Mon Jan 01, 2018 2:14 pm

UART problem

Thu Jan 02, 2020 9:38 am

Hello ,
Using PI4 Buster OS
I need to have 2 serial ports
I'm using serial0 without any problem
my problem is the 2nd serial ....
When I use UART2 which is PIN28 I can read the data from the sensor - everything is working great
in the python code I'm opening /dev/serial1.
But when I reboot the PI - the PI won't boot up (freeze , I don't see nothing on connected screen) why is it? how to overcame this?
this is the /boot/config.txt file

Code: Select all

hdmi_force_hotplug=1
hdmi_group=2
hdmi_mode=85

dtparam=i2c_arm=on
dtoverlay=i2c3
#dtoverlay=i2c4
#dtoverlay=i2c5
#dtoverlay=i2c6
#dtparam=i2s=on
dtparam=spi=on
#dtoverlay=spi1-2cs
dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=12
#dtoverlay=mcp2515-can1,oscillator=8000000,interrupt=16
dtoverlay=spi-bcm2835-overlay
# Enable audio (loads snd_bcm2835)
dtparam=audio=on

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d

disable_splash=1
enable_uart=1
dtoverlay=uart2


so I thought to use another UART , UART5 (PIN 33)
but when I change in the config.txt to

Code: Select all

dtoverlay=i2c5
enable_uart=1
dtoverlay=uart5
is doesn't work I get no data using
/dev/serial1-4


also I only see this

Code: Select all

ls /dev/ttyAMA*
/dev/ttyAMA0  /dev/ttyAMA1
what is wrong?

Thanks ,

User avatar
bensimmo
Posts: 4636
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: UART problem

Thu Jan 02, 2020 11:48 am

/dev/serial# is a redirected link to /dev/ttyAMA# (ttyS0)

It was/is for convenience when the Pi3 needed to switch between miniUART and Full fat UART or the code be used on other Pi's

If you don't plan on moving devices, you can use ttyAMA0 and ttyAMA1 directly.

Unfortunately most the information is in the forum with respect to the Pi4 at the moment and it port settings (https://www.raspberrypi.org/documentati ... on/uart.md has not been updated yet).

But I'm not sure if the /serial# links where fully setup? I remember they were not implement some time ago.
so serial0 & serial1 direct to ttyAMA0 or ttySO depending on settings and the rest you talk to ttyAMA1 etc.
Also check the pins don't clash with i2c you are setting etc.

P.S. Also I would move the setting after the [Pi4] heading and before the [all] as they are Pi4 specific commands.
That is just incase you out the SD card in a zero, pi2/3 etc..

david_1234
Posts: 332
Joined: Mon Jan 01, 2018 2:14 pm

Re: UART problem

Thu Jan 02, 2020 12:57 pm

This setting will be only for PI4 - if I will create a copy it will be to another PI4

I still can't understand what you are saying , and what is the reason I have this problem ,
pi won't boot when PIN28 is connected to serial tx sensor?

now it's working when I'm using /dev/serial1

Code: Select all

dtoverlay=i2c3
dtoverlay=i2c4
dtoverlay=i2c5
dtoverlay=i2c6

enable_uart=1
dtoverlay=uart5
this is all the PI do (right now) just read data from PIN33

trejan
Posts: 2179
Joined: Tue Jul 02, 2019 2:28 pm

Re: UART problem

Thu Jan 02, 2020 1:03 pm

david_1234 wrote:
Thu Jan 02, 2020 12:57 pm
pi won't boot when PIN28 is connected to serial tx sensor?
Pin 27 and 28 are special as the firmware configures them to be an I2C interface to probe for a HAT autoconfiguration EEPROM. It is best to use a different UART on another set of pins but if you must use it then you can disable the probing by adding force_eeprom_read=0 to /boot/config.txt

david_1234
Posts: 332
Joined: Mon Jan 01, 2018 2:14 pm

Re: UART problem

Thu Jan 02, 2020 1:32 pm

this is a good and important information ! - Thanks!

so If I only use SPI,UART protocols is this all I have to config in /boot/config.txt?

Code: Select all

dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=12
dtoverlay=spi-bcm2835-overlay

disable_splash=1
enable_uart=1
dtoverlay=uart5


[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

# uncomment if hdmi display is not detected and composite is being output
hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
hdmi_group=2
hdmi_mode=85
in this configuration I will be able to read the canbus device on spi0
and separated serial devices on pin 33 and pin 10 ?

will not have any hardware issues?

Thanks ,

User avatar
bensimmo
Posts: 4636
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: UART problem

Thu Jan 02, 2020 1:36 pm

Also looking at that
I2C #5 has been enabled (aka scl5) it is also clashing with your uart5 setting.
Set one or the other, not both.


Image

david_1234
Posts: 332
Joined: Mon Jan 01, 2018 2:14 pm

Re: UART problem

Thu Jan 02, 2020 1:44 pm

No no
something is not good , and I don't know what happand
this is the config file

Code: Select all

dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=8000000,interrupt=12
dtoverlay=spi-bcm2835-overlay

dtparam=audio=on

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d

disable_splash=1
enable_uart=1
dtoverlay=uart5
with this config - I can't read the data from the serial
it stop reading data ..

when I add this lines

Code: Select all

dtparam=i2c_arm=on
dtoverlay=i2c5
reboot
it start working


WHY?
How could it be???

User avatar
bensimmo
Posts: 4636
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: UART problem

Thu Jan 02, 2020 9:03 pm

I don't know :
What sensor is it?

david_1234
Posts: 332
Joined: Mon Jan 01, 2018 2:14 pm

Re: UART problem

Sun Jan 05, 2020 11:05 am

The data is from Arduino ,
what does it matter?
it something in the pi config , no?

Return to “Beginners”