BalenaOS ModemManager

Hi all,

I run a container that provides 4g connectivity. I would like to update this container with its new features. But I believe that my container is tainted by ModemManager or NetworkManager during the update causes it to lose connection. I should be able to update devices from remote.

Any ideas about how to do this update smoothly? Maybe disabling modem manager completely? Can I somehow disable modemManager to mess around with my modem?

Hello @berkayg could you please share any logs?

What device type are you using? What OS version?

I use photon-nano CTI board with a Sierra Wireless, Incorporated EM7421 modem. BalenaOS version is 4.0.9

I tried add following UDEV rules in config.json on /mnt/boot.

SUBSYSTEMS=="usb", ATTRS{idVendor}=="1199", GOTO="mm_sierra_generic"
SUBSYSTEMS=="usb", ATTRS{bInterfaceNumber}=="?*", ENV{.MM_USBIFNUM}="$attr{bInterfaceNumber}"
ATTRS{idVendor}=="1199", ATTRS{idProduct}=="9091", ENV{.MM_USBIFNUM}=="00", SUBSYSTEM=="tty", ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idVendor}=="1199", ATTRS{idProduct}=="9091", ENV{.MM_USBIFNUM}=="00", SUBSYSTEM=="tty", ENV{ID_MM_PORT_IGNORE}="1"
ATTRS{idVendor}=="1199", ATTRS{idProduct}=="9091", ENV{.MM_USBIFNUM}=="00", SUBSYSTEM=="tty", ENV{ID_MM_TTY_MANUAL_SCAN_ONLY}="1"
ATTRS{idVendor}=="1199", ATTRS{idProduct}=="9091", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idVendor}=="1199", ATTRS{idProduct}=="9091", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_PORT_IGNORE}="1"
ATTRS{idVendor}=="1199", ATTRS{idProduct}=="9091", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_TTY_MANUAL_SCAN_ONLY}="1"
ATTRS{idVendor}=="1199", ATTRS{idProduct}=="9091", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idVendor}=="1199", ATTRS{idProduct}=="9091", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_PORT_IGNORE}="1"
ATTRS{idVendor}=="1199", ATTRS{idProduct}=="9091", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_TTY_MANUAL_SCAN_ONLY}="1"

My final config.json was something like this. I used commands on here GitHub - balena-os/meta-balena: A collection of Yocto layers used to build balenaOS images

  "developmentMode": true,
  "deviceType": "photon-nano",
  "os": {
    "udevRules": {
      "70-mm-sierra": "SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"1199\", GOTO=\"mm_sierra_generic\"\nGOTO=\"mm_sierra_end\"\nLABEL=\"mm_sierra_generic\"\nSUBSYSTEMS==\"usb\", ATTRS{bInterfaceNumber}==\"?*\", ENV{.MM_USBIFNUM}=\"$attr{bInterfaceNumber}\"\nATTRS{idVendor}==\"1199\", ATTRS{idProduct}==\"9091\", ENV{.MM_USBIFNUM}==\"00\", SUBSYSTEM==\"tty\", ENV{ID_MM_DEVICE_IGNORE}=\"1\"\nATTRS{idVendor}==\"1199\", ATTRS{idProduct}==\"9091\", ENV{.MM_USBIFNUM}==\"00\", SUBSYSTEM==\"tty\", ENV{ID_MM_PORT_IGNORE}=\"1\"\nATTRS{idVendor}==\"1199\", ATTRS{idProduct}==\"9091\", ENV{.MM_USBIFNUM}==\"00\", SUBSYSTEM==\"tty\", ENV{ID_MM_TTY_MANUAL_SCAN_ONLY}=\"1\"\nATTRS{idVendor}==\"1199\", ATTRS{idProduct}==\"9091\", ENV{.MM_USBIFNUM}==\"01\", SUBSYSTEM==\"tty\", ENV{ID_MM_DEVICE_IGNORE}=\"1\"\nATTRS{idVendor}==\"1199\", ATTRS{idProduct}==\"9091\", ENV{.MM_USBIFNUM}==\"01\", SUBSYSTEM==\"tty\", ENV{ID_MM_PORT_IGNORE}=\"1\"\nATTRS{idVendor}==\"1199\", ATTRS{idProduct}==\"9091\", ENV{.MM_USBIFNUM}==\"01\", SUBSYSTEM==\"tty\", ENV{ID_MM_TTY_MANUAL_SCAN_ONLY}=\"1\"\nATTRS{idVendor}==\"1199\", ATTRS{idProduct}==\"9091\", ENV{.MM_USBIFNUM}==\"02\", SUBSYSTEM==\"tty\", ENV{ID_MM_DEVICE_IGNORE}=\"1\"\nATTRS{idVendor}==\"1199\", ATTRS{idProduct}==\"9091\", ENV{.MM_USBIFNUM}==\"02\", SUBSYSTEM==\"tty\", ENV{ID_MM_PORT_IGNORE}=\"1\"\nATTRS{idVendor}==\"1199\", ATTRS{idProduct}==\"9091\", ENV{.MM_USBIFNUM}==\"02\", SUBSYSTEM==\"tty\", ENV{ID_MM_TTY_MANUAL_SCAN_ONLY}=\"1\"\nGOTO=\"mm_sierra_end\"\nLABEL=\"mm_sierra_end\"\n"

This created a 77-mm-sierra.rules file under /etc/udev/rules.d . However, when I run mmcli -L on HostOS I still see modem as

mmcli -L
    /org/freedesktop/ModemManager1/Modem/0 [Sierra Wireless, Incorporated] EM7421

dmesg | grep usb log for modem:

[    1.768777] usb 1-2.2: new high-speed USB device number 4 using tegra-xusb
[    1.790427] usb 1-2.2: config 1 has an invalid interface number: 8 but max is 3
[    1.790438] usb 1-2.2: config 1 has no interface number 1
[    1.791496] usb 1-2.2: New USB device found, idVendor=1199, idProduct=9091
[    1.791506] usb 1-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    1.791513] usb 1-2.2: Product: Sierra Wireless EM7421 Qualcomm\xc2\xae Snapdragon\xe2\x84\xa2 X16 LTE-A
[    1.791520] usb 1-2.2: Manufacturer: Sierra Wireless, Incorporated
[    1.791527] usb 1-2.2: SerialNumber: 8G2324201704B128
[   16.664568] usbcore: registered new interface driver qcserial
[   16.664596] usbserial: USB Serial support registered for Qualcomm USB modem
[   16.664644] usbcore: registered new interface driver btusb
[   16.667802] usb 1-2.2: Qualcomm USB modem converter now attached to ttyUSB0
[   16.671877] rtk_btusb: Realtek Bluetooth USB driver ver 3.1
[   16.675728] usbcore: registered new interface driver rtk_btusb
[   16.681299] usbcore: registered new interface driver cdc_wdm
[   16.687477] usb 1-2.2: Qualcomm USB modem converter now attached to ttyUSB1
[   16.689063] usb 1-2.2: Qualcomm USB modem converter now attached to ttyUSB2

I also fixed the syntax error in my udev rule above. Checked with udevadm test /dev/ttyUSB0
cmd to test it. It reads the rule but still mmcli -L returns me the modem.

Any ideas how to make ModemManager to IGNORE this modem? @mpous

edit 2:

Running udevadm info /dev/ttyUSB[0-1-2] shows similar results as here:

udevadm info /dev/ttyUSB2
P: /devices/70090000.xusb/usb1/1-2/1-2.2/1-2.2:1.3/ttyUSB2/tty/ttyUSB2
N: ttyUSB2
L: 0
S: serial/by-path/platform-70090000.xusb-usb-0:2.2:1.3-port0
S: serial/by-id/usb-Sierra_Wireless__Incorporated_Sierra_Wireless_EM7421_Qualcomm®_Snapdragon™_X16_LTE-A_8G2324201704B128-if03-port0
E: DEVPATH=/devices/70090000.xusb/usb1/1-2/1-2.2/1-2.2:1.3/ttyUSB2/tty/ttyUSB2
E: DEVNAME=/dev/ttyUSB2
E: MAJOR=188
E: ID_VENDOR=Sierra_Wireless__Incorporated
E: ID_VENDOR_ENC=Sierra\x20Wireless\x2c\x20Incorporated
E: ID_MODEL=Sierra_Wireless_EM7421_Qualcomm®_Snapdragon™_X16_LTE-A
E: ID_MODEL_ENC=Sierra\x20Wireless\x20EM7421\x20Qualcomm®\x20Snapdragon™\x20X16\x20LTE-A
E: ID_SERIAL=Sierra_Wireless__Incorporated_Sierra_Wireless_EM7421_Qualcomm®_Snapdragon™_X16_LTE-A_8G2324201704B128
E: ID_SERIAL_SHORT=8G2324201704B128
E: ID_TYPE=generic
E: ID_BUS=usb
E: ID_USB_INTERFACES=:ffffff:ff0000:
E: ID_USB_DRIVER=qcserial
E: ID_PATH=platform-70090000.xusb-usb-0:2.2:1.3
E: ID_PATH_TAG=platform-70090000_xusb-usb-0_2_2_1_3
E: DEVLINKS=/dev/serial/by-path/platform-70090000.xusb-usb-0:2.2:1.3-port0 /dev/serial/by-id/usb-Sierra_Wireless__Incorporated_Sierra_Wireless_EM7421_Qualcomm®_Snapdragon™_X16_LTE-A_8G2324201704B128-if03-port0
E: TAGS=:systemd:
E: CURRENT_TAGS=:systemd:

I see that ID_MM_PORT_IGNORE=1 and ID_MM_DEVICE_IGNORE=1. But mmcli -L still returns modem list. Are these ports ignored by mm or not I am confused :open_mouth:

I am also okay with deleting the mmcli so that it doesn’t start on boot. But the mmcli binary seems to be in read-only partition. Anyways to remove it completely? I should be able to delete it for production images as well.

I am already trying to disable using d-bus inside a running container but that is not seem to be effective.


According to some posts, it’s possible that ModemManager ignores specific udev tags when its filter policy is set to strict, which should be the default.

According to the man pages, there should be commands mmcli --modem=0 --inhibit and mmcli --inhibit-device=[UID]; maybe you can try your luck with that?
Note that both of these are blocking commands, so you might want to run them in the background.

Something like

mmcli --modem=0 --inhibit &


kill $PID

If all else fails, you could always try a kill $(pidof ModemManager).