commit 82635955fef4815e9a383db76ed9aad24e16ddbe
parent ff895276c8c8aa367aa948c9037a26abb317c270
Author: Daniel Barlow <dan@telent.net>
Date: Fri, 19 Jul 2024 23:41:52 +0100
add modemmanager service and udev rules to tag the modem parts
a surprisngly large number of the udev rules do turn out to
be actually needed. Ignore the pasted comments about rpmsgexport,
even those ones are important
Diffstat:
| M | configuration.nix | | | 92 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- |
1 file changed, 82 insertions(+), 10 deletions(-)
diff --git a/configuration.nix b/configuration.nix
@@ -75,7 +75,89 @@ in {
fileSystems."/" = lib.mkDefault {
autoResize = lib.mkForce false;
};
+ services.udev.extraRules = ''
+ACTION!="add|change|move|bind", GOTO="mm_qcom_soc_end"
+
+# Process only known wwan, net and rpmsg ports
+SUBSYSTEM=="net", DRIVERS=="bam-dmux", GOTO="mm_qcom_soc_process"
+# SUBSYSTEM=="platform", DRIVERS=="bam-dmux", GOTO="mm_qcom_soc_process"
+SUBSYSTEM=="net", DRIVERS=="ipa", GOTO="mm_qcom_soc_process"
+SUBSYSTEM=="wwan", DRIVERS=="qcom-q6v5-mss", GOTO="mm_qcom_soc_process"
+SUBSYSTEM=="rpmsg", DRIVERS=="qcom-q6v5-mss", GOTO="mm_qcom_soc_process"
+GOTO="mm_qcom_soc_end"
+
+LABEL="mm_qcom_soc_process"
+
+# Flag the port as being part of the SoC
+ENV{ID_MM_QCOM_SOC}="1"
+
+# #
+# # Add a common physdev UID to all ports in the Qualcomm SoC, so that they
+# # are all bound together to the same modem object.
+# #
+# # The MSM8916, MSM8974, .... Qualcomm SoCs use the combination of RPMSG/WWAN
+# # based control ports plus BAM-DMUX based network ports.
+# #
+ENV{ID_MM_PHYSDEV_UID}="qcom-soc"
+
+# port type hints for the rpmsgexport-ed ports
+SUBSYSTEM=="rpmsg", ATTR{name}=="DATA*", ATTR{name}=="*_CNTL", ENV{ID_MM_PORT_TYPE_QMI}="1"
+SUBSYSTEM=="rpmsg", ATTR{name}=="DATA*", ATTR{name}!="*_CNTL", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
+
+# ignore every other port without explicit hints
+SUBSYSTEM=="rpmsg", ENV{ID_MM_PORT_TYPE_QMI}!="1", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}!="1", ENV{ID_MM_PORT_IGNORE}="1"
+
+# explicitly ignore ports intended for USB tethering (DATA40, DATA40_CNTL)
+SUBSYSTEM=="rpmsg", ATTR{name}=="DATA40*", ENV{ID_MM_PORT_IGNORE}="1"
+KERNEL=="rmnet_usb*", ENV{ID_MM_PORT_IGNORE}="1"
+
+# flag all rpmsg ports under this plugin as candidate
+# KERNEL=="rpmsg*", SUBSYSTEM=="rpmsg", ENV{ID_MM_CANDIDATE}="1"
+KERNEL=="rpmsg*", SUBSYSTEM=="rpmsg", ENV{ID_MM_CANDIDATE}="1"
+
+LABEL="mm_qcom_soc_end"
+
+
+
+ACTION!="add|change|move|bind", GOTO="mm_candidate_end"
+# # Opening bound but disconnected Bluetooth RFCOMM ttys would initiate the
+# # connection. Don't do that.
+
+KERNEL=="rfcomm*", DEVPATH=="*/virtual/*", GOTO="mm_candidate_end" # */
+
+SUBSYSTEM=="net", ENV{ID_MM_CANDIDATE}="1"
+
+# WWAN subsystem port handling
+# - All USB devices ignored for now, only PCI devices expected
+# - Only "wwan_port" device types processed (single ports); we fully ignore
+# the "wwan_dev" device type (full device, not just one port)
+
+SUBSYSTEMS=="usb", GOTO="mm_candidate_end"
+SUBSYSTEM=="wwan", ENV{DEVTYPE}=="wwan_dev", GOTO="mm_candidate_end"
+SUBSYSTEM=="wwan", ENV{ID_MM_CANDIDATE}="1"
+
+LABEL="mm_candidate_end"
+
+
+ '';
+ systemd.services.ModemManager = {
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig =
+ let script = pkgs.writeScript "start-modem-manager" ''
+ #!${pkgs.bash}/bin/bash
+ source ${config.system.build.setEnvironment}
+ ${modemmanager_}/bin/ModemManager
+ '';
+ in {
+ StandardInput = "journal";
+ StandardError = "journal";
+ StandardOutput = "journal";
+ SyslogIdentifier = "ModemManager";
+ ExecStart = script;
+ Restart = "always";
+ };
+ };
networking = {
useDHCP = true;
hostName = "biscuit";
@@ -112,16 +194,6 @@ in {
services.openssh.enable = true;
- services.udev.extraRules = ''
- SUBSYSTEM!="rpmsg", GOTO="qcom_rpmsg_end"
- # symlink rpmsg endpoints under useful names
- ATTR{name}=="DATA5_CNTL", SYMLINK+="modem"
- # open SMD channels when the remoteproc comes up
- KERNEL!="rpmsg_ctrl[0-9]*", GOTO="qcom_rpmsg_end"
- ATTRS{rpmsg_name}!="modem|hexagon", GOTO="qcom_rpmsg_end"
- ACTION=="add", RUN+="${rpmsgexport}/bin/rpmsgexport /dev/$name DATA5_CNTL"
- LABEL="qcom_rpmsg_end"
- '';
environment.systemPackages = with pkgs; [ drm-framebuffer];
users.users.dan = {