From d6f6f3abdfe44131c3884b63987ca1097f9db17d Mon Sep 17 00:00:00 2001 From: Wenwen Fu Date: Thu, 20 Aug 2026 16:10:20 +0800 Subject: [PATCH] quickboot-camera: trigger cam-server on cam-req-mgr instead of video0 The udev rule matched KERNEL=="video0" to start cam-server, and the service ordered itself with After=/Wants=dev-video0.device. The videoN numbering is assigned in probe order and is not stable across kernel/DTB/sensor changes, so "video0" is not guaranteed to be the camera node. Match on ATTR{name}=="cam-req-mgr" instead -- the CAMSS request-manager node whose name is fixed regardless of enumeration order. cam-server is idempotent, so extra SYSTEMD_WANTS triggers from multiple matching nodes are harmless. To keep an explicit ordering without the unstable videoN name, the rule also publishes SYSTEMD_ALIAS=/dev/cam_req_mgr, exposing the node as the stable device unit dev-cam_req_mgr.device; the service orders itself with After=/Wants=dev-cam_req_mgr.device. Verified on rb3gen2-core-kit: /dev/video0 ATTR{name} is cam-req-mgr, the alias device unit comes up active, and cam-server is pulled in on a clean cold boot (critical-chain: cam-server.service -> dev-cam_req_mgr.device). Co-Authored-By: Claude Opus 4.8 (1M context) Signed-off-by: Wenwen Fu --- quickboot-camera/files/02-cam-server.rules | 16 ++++++++++++++-- quickboot-camera/files/cam-server.service | 10 +++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/quickboot-camera/files/02-cam-server.rules b/quickboot-camera/files/02-cam-server.rules index 61b5091..aa1a6c9 100644 --- a/quickboot-camera/files/02-cam-server.rules +++ b/quickboot-camera/files/02-cam-server.rules @@ -1,6 +1,18 @@ # Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. # SPDX-License-Identifier: BSD-3-Clause-Clear # -# Trigger cam-server.service automatically as soon as the main video device (video0) is enumerated by the kernel. +# Trigger cam-server.service automatically as soon as the camera subsystem's +# core node is enumerated by the kernel. +# +# Match on the Camera Request Manager (ATTR{name}=="cam-req-mgr") rather than a +# fixed KERNEL=="video0". The videoN numbering is assigned in probe order and is +# not stable across kernel/DTB/sensor changes, so "video0" is not guaranteed to +# be the camera node. "cam-req-mgr" is the CAMSS request-manager node whose name +# is fixed regardless of enumeration order. cam-server is idempotent, so if +# multiple matching nodes appear the extra SYSTEMD_WANTS triggers are harmless. +# +# SYSTEMD_ALIAS exposes this node as a stable device unit "dev-cam_req_mgr.device" +# so cam-server.service can order itself against it (After=/Wants=) without +# hardcoding the unstable videoN name. -SUBSYSTEM=="video4linux", KERNEL=="video0", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="cam-server.service" +SUBSYSTEM=="video4linux", ACTION=="add", ATTR{name}=="cam-req-mgr", ENV{SYSTEMD_ALIAS}="/dev/cam_req_mgr", TAG+="systemd", ENV{SYSTEMD_WANTS}="cam-server.service" diff --git a/quickboot-camera/files/cam-server.service b/quickboot-camera/files/cam-server.service index e996f51..23e64da 100644 --- a/quickboot-camera/files/cam-server.service +++ b/quickboot-camera/files/cam-server.service @@ -40,9 +40,13 @@ SourcePath=/usr/bin/cam-server # Remove default dependenies (sysinit.target, basic.target) to enable early start DefaultDependencies=no -# Start as soon as camera devices appear -After=dev-video0.device -Wants=dev-video0.device +# Order against the camera request-manager node via the stable device-unit alias +# published by 02-cam-server.rules (SYSTEMD_ALIAS=/dev/cam_req_mgr). This gives an +# explicit After=/Wants= ordering without hardcoding the unstable videoN name -- +# dev-cam_req_mgr.device tracks the cam-req-mgr node regardless of its videoN +# enumeration. +Wants=dev-cam_req_mgr.device +After=dev-cam_req_mgr.device [Service] User=root