remove udev (#592)

* init permissions

* lil more

* lil less

* unroll

* no udev

* nicer

* fix build
This commit is contained in:
Adeeb Shihadeh
2026-05-05 19:21:56 -07:00
committed by GitHub
parent 1f19f25f27
commit ec6c469b8d
19 changed files with 106 additions and 81 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -e
set -eo pipefail
UBUNTU_BASE_URL="https://cdimage.ubuntu.com/ubuntu-base/releases/24.04/release/"
UBUNTU_FILE="ubuntu-base-24.04.3-base-arm64.tar.gz"
-1
View File
@@ -76,7 +76,6 @@ apt-fast install --no-install-recommends -yq \
ubuntu-minimal \
ubuntu-server \
ubuntu-standard \
udev \
udhcpc \
wget \
wireless-tools \
+3 -1
View File
@@ -13,7 +13,7 @@ apt-get install -y --no-install-recommends \
libdbus-1-dev \
libpolkit-gobject-1-dev \
libsystemd-dev \
udev
systemd-dev
cd ModemManager
meson setup build \
@@ -21,6 +21,8 @@ meson setup build \
--libdir=/usr/lib/aarch64-linux-gnu \
--sysconfdir=/etc \
--buildtype=release \
-Dudev=false \
-Dudevdir=/usr/lib/udev \
-Dqmi=true \
-Dmbim=false \
-Dqrtr=false \
+1 -1
View File
@@ -6,7 +6,7 @@ Requires=polkit.service
[Service]
Type=dbus
BusName=org.freedesktop.ModemManager1
ExecStart=/usr/sbin/ModemManager --filter-policy=strict --debug
ExecStart=/usr/sbin/ModemManager --filter-policy=strict --debug --no-auto-scan
StandardError=null
Restart=on-abort
CapabilityBoundingSet=CAP_SYS_ADMIN
@@ -7,7 +7,7 @@
Description=Path watching for qseecomd.service
DefaultDependencies=no
Conflicts=shutdown.target
Before=paths.target shutdown.target systemd-udev-trigger.service
Before=paths.target shutdown.target
[Path]
PathModified=/dev/qseecom
@@ -1,5 +0,0 @@
KERNEL=="binder", MODE="0666"
KERNEL=="log_main", SUBSYSTEM=="misc", NAME="log/main", MODE="0644"
KERNEL=="log_radio", SUBSYSTEM=="misc", NAME="log/radio", MODE="0644"
KERNEL=="log_system", SUBSYSTEM=="misc", NAME="log/system", MODE="0644"
KERNEL=="log_events", SUBSYSTEM=="misc", NAME="log/events", MODE="0644"
@@ -1,24 +0,0 @@
# EG25
# Interface 0 - GNSS
# Interface 2 - AT
# Interface 3 - AT
SUBSYSTEM=="tty",ATTRS{idVendor}=="2c7c",ATTRS{idProduct}=="0125",ENV{ID_USB_INTERFACE_NUM}=="00",ENV{ID_MM_DEVICE_IGNORE}="1"
SUBSYSTEM=="tty",ATTRS{idVendor}=="2c7c",ATTRS{idProduct}=="0125",ENV{ID_USB_INTERFACE_NUM}=="02",SYMLINK+="modem_at0",ENV{ID_MM_PORT_IGNORE}="1"
SUBSYSTEM=="tty",ATTRS{idVendor}=="2c7c",ATTRS{idProduct}=="0125",ENV{ID_USB_INTERFACE_NUM}=="03",SYMLINK+="modem_at1",ENV{ID_MM_PORT_IGNORE}="1"
# EG91
# Interface 0 - debug
# Interface 1 - GPS
# Interface 2 - AT
# Interface 3 - AT
SUBSYSTEM=="tty",ATTRS{idVendor}=="2c7c",ATTRS{idProduct}=="6007",ENV{ID_USB_INTERFACE_NUM}=="00",ENV{ID_MM_DEVICE_IGNORE}="1"
SUBSYSTEM=="tty",ATTRS{idVendor}=="2c7c",ATTRS{idProduct}=="6007",ENV{ID_USB_INTERFACE_NUM}=="01",ENV{ID_MM_DEVICE_IGNORE}="1"
SUBSYSTEM=="tty",ATTRS{idVendor}=="2c7c",ATTRS{idProduct}=="6007",ENV{ID_USB_INTERFACE_NUM}=="02",SYMLINK+="modem_at0",ENV{ID_MM_PORT_IGNORE}="1"
SUBSYSTEM=="tty",ATTRS{idVendor}=="2c7c",ATTRS{idProduct}=="6007",ENV{ID_USB_INTERFACE_NUM}=="03",SYMLINK+="modem_at1",ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
ACTION=="add",SUBSYSTEM=="usb",ATTR{idVendor}=="2c7c",ATTR{idProduct}=="6007",RUN+="/bin/sh -c 'echo -n $kernel:1.4 > /sys/bus/usb/drivers/cdc_ether/unbind'"
# C16
KERNEL=="ttyACM1",ENV{ID_MM_DEVICE_IGNORE}="1"
KERNEL=="ttyACM0",ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
KERNEL=="ttyACM2",ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="05c6", ATTRS{idProduct}=="9330", NAME="usb%n"
@@ -1,2 +0,0 @@
ACTION=="add|change", KERNEL=="event[0-9]*", ENV{ID_SEAT}="seat0"
SUBSYSTEM=="input", MODE="666"
@@ -1,10 +0,0 @@
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="panel0-backlight", RUN+="/bin/chgrp video /sys/class/backlight/%k/brightness"
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="panel0-backlight", RUN+="/bin/chmod g+w /sys/class/backlight/%k/brightness"
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="panel0-backlight", RUN+="/bin/chgrp video /sys/class/backlight/%k/bl_power"
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="panel0-backlight", RUN+="/bin/chmod g+w /sys/class/backlight/%k/bl_power"
ACTION=="add", SUBSYSTEM=="platform", KERNEL=="soc:qcom,dsi-display@0", RUN+="/bin/chgrp video /sys/devices/platform/soc/%k/max_brightness_percent"
ACTION=="add", SUBSYSTEM=="platform", KERNEL=="soc:qcom,dsi-display@0", RUN+="/bin/chmod g+w /sys/devices/platform/soc/%k/max_brightness_percent"
ACTION=="add", SUBSYSTEM=="leds", KERNEL=="led:torch_2", RUN+="/bin/chgrp video /sys/class/leds/%k/brightness"
ACTION=="add", SUBSYSTEM=="leds", KERNEL=="led:torch_2", RUN+="/bin/chmod g+w /sys/class/leds/%k/brightness"
ACTION=="add", SUBSYSTEM=="leds", KERNEL=="led:switch_2", RUN+="/bin/chgrp video /sys/class/leds/%k/brightness"
ACTION=="add", SUBSYSTEM=="leds", KERNEL=="led:switch_2", RUN+="/bin/chmod g+w /sys/class/leds/%k/brightness"
@@ -1,3 +0,0 @@
KERNEL=="kgsl-3d0", GROUP="gpu", MODE="0660"
KERNEL=="ion", GROUP="gpu", MODE="0660"
SUBSYSTEM=="drm", GROUP="gpu", MODE="0660"
@@ -1 +0,0 @@
KERNEL=="i2c-[0-9]*", GROUP="gpio", MODE="0660"
@@ -1,4 +0,0 @@
SUBSYSTEM=="usb", ATTRS{idVendor}=="bbaa", ATTRS{idProduct}=="ddee", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="bbaa", ATTRS{idProduct}=="ddcc", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE="0666"
SUBSYSTEM=="spidev", MODE="0666"
@@ -1,2 +0,0 @@
SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c 'find -L /sys/class/gpio/ -maxdepth 2 -exec chown root:gpio {} \; -exec chmod 770 {} \; || true'"
SUBSYSTEM=="gpio", KERNEL=="gpiochip[0]", GROUP="gpio", MODE="660"
@@ -1,3 +0,0 @@
# Create Android-style boot partition links for vendor services.
KERNEL=="mmcblk[0-9]*p[0-9]*", SUBSYSTEM=="block", ACTION=="add", RUN+="/etc/udev/scripts/bootdevice-by-name.sh %k"
KERNEL=="[hs]d[a-z][0-9]*", SUBSYSTEM=="block", ACTION=="add", RUN+="/etc/udev/scripts/bootdevice-by-name.sh %k"
@@ -1,22 +0,0 @@
#!/bin/sh
set -e
dev="$1"
uevent="/sys/class/block/$dev/uevent"
[ -e "$uevent" ] || exit 0
boot_dev="$(sed -n 's/.*androidboot.bootdevice=\([^ ]*\).*/\1/p' /proc/cmdline | awk '{print $NF}')"
[ -n "$boot_dev" ] || exit 0
real_sysfs_path="$(realpath "/sys/class/block/$dev")"
case "$real_sysfs_path" in
*"$boot_dev"*) ;;
*) exit 0 ;;
esac
partition_name="$(sed -n 's/^PARTNAME=//p' "$uevent")"
[ -n "$partition_name" ] || exit 0
mkdir -p /dev/block/bootdevice/by-name
ln -sf "/dev/$dev" "/dev/block/bootdevice/by-name/$partition_name"
+45
View File
@@ -32,6 +32,41 @@ function run_init {
return $ret
}
function init_permissions {
local path
local video_paths=(
/sys/class/backlight/panel0-backlight/brightness
/sys/class/backlight/panel0-backlight/bl_power
/sys/devices/platform/soc/soc:qcom,dsi-display@0/max_brightness_percent
/sys/class/leds/led:torch_2/brightness
/sys/class/leds/led:switch_2/brightness
)
find /dev -maxdepth 1 \( -name binder -o -name 'spidev*' \) -type c -exec chmod 0666 {} +
[[ -d /dev/input ]] && find /dev/input -maxdepth 1 -type c -exec chmod 0666 {} +
for path in "${video_paths[@]}"; do
chgrp video "$path"
chmod g+w "$path"
done
for path in /dev/kgsl-3d0 /dev/ion /dev/dri/card* /dev/dri/controlD* /dev/dri/renderD*; do
[[ -c "$path" ]] || continue
chgrp gpu "$path"
chmod 0660 "$path"
done
for path in /dev/i2c-* /dev/gpiochip0; do
[[ -c "$path" ]] || continue
chgrp gpio "$path"
chmod 0660 "$path"
done
[[ -d /sys/class/gpio ]] && find -L /sys/class/gpio/ -maxdepth 2 \
-exec chown root:gpio {} + \
-exec chmod 770 {} +
}
function init_filesystems {
local failed=0
local pids=()
@@ -92,6 +127,13 @@ function init_filesystems {
wait "$pid" || failed=1
done
# rmt_storage is the only thing that relies on /dev/block/bootdevice/by-name.
mkdir -p /dev/block/bootdevice/by-name
ln -sf /dev/sdf2 /dev/block/bootdevice/by-name/modemst1
ln -sf /dev/sdf3 /dev/block/bootdevice/by-name/modemst2
ln -sf /dev/sdf4 /dev/block/bootdevice/by-name/fsg
ln -sf /dev/sdf5 /dev/block/bootdevice/by-name/fsc
# *** setup RW areas ***
systemd-tmpfiles --create /usr/comma/tmpfiles.conf
@@ -196,6 +238,8 @@ function init_gpio {
sleep .05
done
done
init_permissions
}
function init_sound {
@@ -253,6 +297,7 @@ function init_debug {
sudo -u comma /usr/comma/debug.py
}
run_init init_permissions &
run_init init_filesystems &
run_init init_qcom &
run_init init_gpio &
+33
View File
@@ -17,6 +17,38 @@ function is_modem_up {
fi
}
function is_modem_sysfs {
local path="$1"
local parent vendor product
parent="$(realpath "$path")"
while [[ -n "$parent" && "$parent" != "/" ]]; do
if [[ -r "$parent/idVendor" && -r "$parent/idProduct" ]]; then
read -r vendor < "$parent/idVendor"
read -r product < "$parent/idProduct"
[[ "$vendor" == "2c7c" || "$vendor:$product" == "05c6:9330" ]]
return
fi
parent="${parent%/*}"
done
return 1
}
function report_modem_kernel_events {
local path name subsystem
for path in /sys/class/tty/ttyUSB* /sys/class/tty/ttyACM* /sys/class/usbmisc/cdc-wdm* /sys/class/net/*; do
[[ -e "$path" ]] || continue
is_modem_sysfs "$path" || continue
name="${path##*/}"
subsystem="${path%/*}"
subsystem="${subsystem##*/}"
mmcli --report-kernel-event="action=add,subsystem=$subsystem,name=$name"
done
}
function reset {
echo " Resetting..."
gpio $LTE_RST_N 1
@@ -76,6 +108,7 @@ case "$1" in
reset
power_button
done
report_modem_kernel_events
;;
stop)
@@ -0,0 +1,17 @@
# Rules parsed by ModemManager itself when built without udev support.
# EG25
SUBSYSTEM=="tty", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", ENV{ID_USB_INTERFACE_NUM}=="00", ENV{ID_MM_DEVICE_IGNORE}="1"
SUBSYSTEM=="tty", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", ENV{ID_USB_INTERFACE_NUM}=="02", ENV{ID_MM_PORT_IGNORE}="1"
SUBSYSTEM=="tty", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", ENV{ID_USB_INTERFACE_NUM}=="03", ENV{ID_MM_PORT_IGNORE}="1"
# EG91
SUBSYSTEM=="tty", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="6007", ENV{ID_USB_INTERFACE_NUM}=="00", ENV{ID_MM_DEVICE_IGNORE}="1"
SUBSYSTEM=="tty", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="6007", ENV{ID_USB_INTERFACE_NUM}=="01", ENV{ID_MM_DEVICE_IGNORE}="1"
SUBSYSTEM=="tty", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="6007", ENV{ID_USB_INTERFACE_NUM}=="02", ENV{ID_MM_PORT_IGNORE}="1"
SUBSYSTEM=="tty", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="6007", ENV{ID_USB_INTERFACE_NUM}=="03", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
# C16
KERNEL=="ttyACM1", ENV{ID_MM_DEVICE_IGNORE}="1"
KERNEL=="ttyACM0", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
KERNEL=="ttyACM2", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
+5
View File
@@ -38,6 +38,11 @@ systemctl disable multipathd.service
systemctl disable multipathd.socket
systemctl disable lvm2-monitor.service
systemctl mask systemd-backlight@.service
systemctl mask systemd-udevd.service
systemctl mask systemd-udevd-control.socket
systemctl mask systemd-udevd-kernel.socket
systemctl mask systemd-udev-trigger.service
systemctl mask systemd-udev-settle.service
systemctl disable dpkg-db-backup.timer
systemctl disable ua-reboot-cmds.service
systemctl disable ubuntu-advantage.service