Traducido del English por IA ·
Lo que dice Emily es parte del asunto. El resto es el lío de UART de la Pi 3, que atrapa a todo el mundo.La Pi 3/4/Zero W tiene dos UART. ttyAMA0 es la PL011, la buena, con su propio reloj. ttyS0 es la mini UART, cuya velocidad en baudios se deriva del reloj del núcleo VPU; cuando el reloj del núcleo cambia, la velocidad se desvía y obtienes exactamente tus errores CRC de uno de cada cinco. En esos modelos, la PL011 está conectada por defecto al Bluetooth integrado y el conector GPIO recibe la mini UART. /dev/serial0 es un alias que siempre apunta a la que está en GPIO14/15.Así que, según tu configuración, estabas hablando con el chip Bluetooth o con la mini UART. Devuelve la PL011 al conector:
# /boot/firmware/config.txt (Bookworm)
enable_uart=1
dtoverlay=disable-bt
sudo systemctl disable hciuart
# y elimina console=serial0,115200 de /boot/firmware/cmdline.txt
sudo reboot
Después, abre /dev/serial0 en tu script, para que siga funcionando si cambias a otro modelo. Pierdes el Bluetooth integrado, que en una caja de lectura de contadores no vas a echar de menos.Si necesitas Bluetooth, la otra opción es core_freq=250 para fijar el reloj de la mini UART, pero prefiero la PL011.
Emily’s bit is part of it. The rest is the Pi 3 UART shuffle, which catches everyone.
The Pi 3/4/Zero W have two UARTs. ttyAMA0 is the PL011, the good one with its own clock. ttyS0 is the mini UART, whose baud rate is derived from the VPU core clock, so when the core clock moves the baud drifts and you get exactly your one-in-five CRC errors. On those models the PL011 is wired to the onboard Bluetooth by default and the GPIO header gets the mini UART. /dev/serial0 is an alias that always points at whichever one is on GPIO14/15.
So depending on your config you were either talking to the Bluetooth chip or to the mini UART. Give the PL011 back to the header:
# /boot/firmware/config.txt (Bookworm)
enable_uart=1
dtoverlay=disable-bt
sudo systemctl disable hciuart
# and remove console=serial0,115200 from /boot/firmware/cmdline.txt
sudo reboot
Then open /dev/serial0 in your script, so it keeps working if you move to another model. You lose onboard Bluetooth, which on a meter-reading box you don’t miss.
If you need Bluetooth, the other option is core_freq=250 to pin the clock for the mini UART, but I’d rather have the PL011.

