Giter Club home page Giter Club logo

Comments (6)

XECDesign avatar XECDesign commented on May 29, 2024

@pelwell, is this something that has been or will be fixed with newer firmware/kernel or just expected behaviour?

from raspberrypi-sys-mods.

pelwell avatar pelwell commented on May 29, 2024

It's definitely not expected behaviour, and it may have been fixed with the latest firmware (coming to an apt upgrade soon) - knowing which Pi it was would help.

from raspberrypi-sys-mods.

pelwell avatar pelwell commented on May 29, 2024

Reproduced on a Pi 400.

from raspberrypi-sys-mods.

metachip avatar metachip commented on May 29, 2024

Serial Device Alias Fault Diagnosis

The problem is the line:

readlink /sys/class/tty/ttyS[0-9]*/device/of_node | sed 's/base/:/' | cut -d: -f2

in

/etc/udev/rules.d/99-com.rules

On Pi5 it works.

On Pi4 it does not.

The problem is the format of the descriptor for ttyS0 is different.

On Pi5:

$ echo cat /proc/device-tree/model
Raspberry Pi 5 Model B Rev 1.0
$ tail -2 /boot/firmware/config.txt
enable_uart=1
dtoverlay=disable-bt
$ readlink /sys/class/tty/ttyS0/device/of_node
../../../../firmware/devicetree/base/soc/serial@7d50c000

On Pi4:

$ echo cat /proc/device-tree/model
Raspberry Pi 4 Model B Rev 1.4
$ tail -2 /boot/firmware/config.txt
enable_uart=1
dtoverlay=disable-bt
$ readlink /sys/class/tty/ttyS0/device/of_node
$ ls /sys/class/tty/ttyS0/device/
driver driver_override modalias power subsystem tty uevent

Bottom line:

/etc/udev/rules.d/99-com.rules

requires modification to work on models other than Pi5. The test on of_node fails on Pi4 because it does not exist.

from raspberrypi-sys-mods.

pelwell avatar pelwell commented on May 29, 2024

The real problem is that the use of the bluetooth alias to determine which UART is which should be conditional on the existence of the console alias, not vice-versa:

diff --git a/etc.armhf/udev/rules.d/99-com.rules b/etc.armhf/udev/rules.d/99-com.rules
index 1931d3d..7ad5f38 100644
--- a/etc.armhf/udev/rules.d/99-com.rules
+++ b/etc.armhf/udev/rules.d/99-com.rules
@@ -17,11 +17,11 @@ SUBSYSTEM=="pwm", ACTION!="remove", PROGRAM="/bin/sh -c 'chgrp -R gpio /sys%p &&
 KERNEL=="ttyAMA[0-9]*|ttyS[0-9]*", PROGRAM="/bin/sh -c '\
         ALIASES=/proc/device-tree/aliases; \
         TTYNODE=$$(readlink /sys/class/tty/%k/device/of_node | sed 's/base/:/' | cut -d: -f2); \
-        if [ -e $$ALIASES/bluetooth ] && [ $$TTYNODE/bluetooth = $$(strings $$ALIASES/bluetooth) ]; then \
-            echo 1; \
-        elif [ -e $$ALIASES/console ]; then \
+        if [ -e $$ALIASES/console ]; then \
             if [ $$TTYNODE = $$(strings $$ALIASES/console) ]; then \
-                echo 0;\
+                echo 0; \
+            elif [ -e $$ALIASES/bluetooth ] && [ $$TTYNODE/bluetooth = $$(strings $$ALIASES/bluetooth) ]; then \
+                echo 1; \
             else \
                 exit 1; \
             fi \

Doing so with dtoverlay=disable-bt results in:

/dev/serial0 -> ttyAMA0

which is arguably more correct than:

/dev/serial0 -> ttyAMA0
/dev/serial1 -> ttyS0

since /dev/ttyS0 doesn't actually work (try it - the device node is disabled, and yet somehow the driver is creating a /dev/ entry for it, perhaps because of 8250.nr_uarts=1 on the command line).

from raspberrypi-sys-mods.

pelwell avatar pelwell commented on May 29, 2024

There's now a PR with this change: #85

from raspberrypi-sys-mods.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.