What is minimum serial baud rate on (bullseye) Raspberry Pi OS (using python) and Raspberry Pi 4B?

Question:

In my setup I need to read from a serial port that transmits at 600 baud.
I can’t change the transmitter speed.
Using my Raspberry Pi 3B+ with a years old un-updated image (version 10 buster) it works fine.
When using my Raspberry Pi 4B with the newest (bullseye) and fully updated (8th Feb. 2023) Raspberry Pi OS it doesn’t work.

For test purposes I have setup my own transmitter and it works fine if I transmit and receive at 1200 to 115200 baud. But at 600 baud I just receive gibberish.
I am working on an alternative driver (using python) that reads the GPIO pin using bit-banging which should be possible at this slow speed but it seems very unstable.
I am using /dev/serial0 (pin15 as RX) and because of other connected hardware this serial port / GPIO is my only option.

Python test transmitter code:

import time
import serial
serialport2 = serial.Serial("/dev/ttyUSB1", 600, timeout=1, bytesize=8)
while True:
    sendDataStr = "YX"
    serialport2.write(sendDataStr.encode())
    time.sleep(0.1)
serialport2.close()

Python receiver code:

import serial
serialport = serial.Serial("/dev/serial0", 600, timeout=1, bytesize=8)
while True:
    try:
        print(serialport.read())        
    except KeyboardInterrupt:
        serialport.close()
        break

Is the slow serial speed hit by a kernel timeout or something along those lines?
Does anyone know what the minimum speed that Raspberry Pi 4B and Raspberry Pi OS has been testet at?
Any ideas for a workaround? Using a C-driver for bit-banging or a completely different serial driver or?
Python version on (old) buster: 3.7.3
Python version on (new) bullseye: 3.9.2

Asked By: SteadyAsARock

||

Answers:

It seems the minimum baud rate is 1200 using standard configuration.
However, this is using the ‘mini UART’ which has limited capabilities.
So if the Bluetooth is not needed it is possible to swap the mini UART for the
PL011 UART which is a proper hardware implemented UART.
Add the following line to config.txt:

    # If using RPi3
    dtoverlay=pi3-miniuart-bt

    # If using RPi4
    dtoverlay=miniuart-bt

The "/dev/serial0" will now run at 600 baud without issues.

Answered By: SteadyAsARock