Modem Manager keeps filtering my port

Hi!

I have added UDEV rules but Modem Manager always filters away my desired port ttyS0 (used for LTE module) on Raspberry Pi 3 using balenaOS 2.47.0+rev1 in production mode.

I see this in the log of Modem Manager:

ModemManager[14504]: <debug> [1588779337.826235] (tty/ttyS0): adding device at sysfs path: /sys/devices/platform/soc/3f215040.serial/tty/ttyS0
ModemManager[14504]: <debug> [1588779337.827084] [filter] (tty/ttyS0): port filtered: tty platform driver 

UDEV rules in hostOs (/etc/udev/rules.d/98.rules):

ACTION=="add|change|move", KERNEL=="soc", ENV{ID_MM_DEVICE_PROCESS}="1"
ACTION=="add|change|move", KERNEL=="soc", ENV{ID_MM_PLATFORM_DRIVER_PROBE}="1"
ACTION!="add|change|move|bind", GOTO="mm_whitelist_end", DEVPATH=="/devices/platform/soc/3f215040.serial/tty/ttyS0", ENV{ID_MM_DEVICE_PROCESS}="1", LABEL="mm_whitelist_end" 
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0195", NAME="LTE"

udevadm info:

root@85305ec:~# udevadm info -p /sys/devices/platform/soc/3f215040.serial/tty/ttyS0
P: /devices/platform/soc/3f215040.serial/tty/ttyS0
N: ttyS0
L: 0
S: serial0
E: DEVPATH=/devices/platform/soc/3f215040.serial/tty/ttyS0
E: DEVNAME=/dev/ttyS0
E: MAJOR=4
E: MINOR=64
E: SUBSYSTEM=tty
E: USEC_INITIALIZED=8318192
E: ID_MM_CANDIDATE=1
E: DEVLINKS=/dev/serial0
E: TAGS=:systemd:

How do I un-filter the ttyS0 from modem manager in BalenaOS?

Thanks in advance!

It looks like there is a problem with your UDEV rule. The actual rule is simpler:

ACTION!="add|change|move|bind", GOTO="mm_whitelist_end"
DEVPATH=="/devices/platform/soc/3f215040.serial/tty/ttyS0" ENV{ID_MM_DEVICE_PROCESS}="1"
LABEL="mm_whitelist_end"

You need to see ID_MM_DEVICE_PROCESS tagged with udevadm afterwards.

Hi @majorz!

I added the rule to /mnt/boot/config.json file:

	"os": {
		"udevRules": {
			"98": "ACTION!=\"add|change|move|bind\", GOTO=\"mm_whitelist_end\", DEVPATH == \"/devices/platform/soc/3f215040.serial/tty/ttyS0\", ENV{ID_MM_DEVICE_PROCESS}=\"1\",LABEL = \"mm_whitelist_end\"\n"
		}
	}

But Modem Manager is still filtering the port away. Am I adding the rule in the wrong way or syntax error?
Log:

(tty/ttyS0): adding device at sysfs path: /sys/devices/platform/soc/3f215040.serial/tty/ttyS0
May 08 08:24:49 85305ec ModemManager[2904]: [filter] (tty/ttyS0): port filtered: tty platform driver
root@85305ec:/usr/src/app/rak_common_for_gateway# udevadm info -p /sys/devices/platform/soc/3f215040.serial/tty/ttyS0
P: /devices/platform/soc/3f215040.serial/tty/ttyS0
N: ttyS0
L: 0
E: DEVPATH=/devices/platform/soc/3f215040.serial/tty/ttyS0
E: DEVNAME=/dev/ttyS0
E: MAJOR=4
E: MINOR=64
E: SUBSYSTEM=tty
E: USEC_INITIALIZED=32262070976
E: ID_MM_CANDIDATE=1
E: TAGS=:systemd:

Thanks again

Hi @tibhel,

It looks like you have not escaped properly the rule. Please note that it is a multi-line statement so you need to add it accordingly.

Here is a short documentation on how you may escape those rules: https://github.com/balena-os/meta-balena#udevrules

Thanks,
Zahari