-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_control1_camera.sh
More file actions
executable file
·104 lines (89 loc) · 3.53 KB
/
Copy pathsetup_control1_camera.sh
File metadata and controls
executable file
·104 lines (89 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
# ============================================================================
# GERTIE Control1 Camera Setup Script
# ============================================================================
# This script configures control1 (rep8 local camera) to prevent PipeWire
# from auto-claiming the camera hardware, which blocks local_camera_node.
#
# Run this ONCE on control1 after initial setup or OS reinstall.
# Requires sudo privileges and a reboot to take effect.
#
# Usage: sudo ./setup_control1_camera.sh
# ============================================================================
set -e
echo "============================================"
echo "GERTIE Control1 Camera Setup"
echo "============================================"
echo ""
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "ERROR: This script must be run with sudo"
echo "Usage: sudo ./setup_control1_camera.sh"
exit 1
fi
# Check if this is control1 (has local camera)
if [ ! -e /dev/video0 ]; then
echo "WARNING: /dev/video0 not found"
echo "This script is intended for control1 with the HQ camera attached."
read -p "Continue anyway? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
echo "Step 1: Disabling PipeWire V4L2 camera module..."
echo "------------------------------------------------"
# Create PipeWire config directory if it doesn't exist
mkdir -p /etc/pipewire/pipewire.conf.d
# Create config to disable V4L2 module (prevents PipeWire from grabbing cameras)
cat > /etc/pipewire/pipewire.conf.d/disable-v4l2.conf << 'EOF'
# GERTIE: Disable PipeWire camera access so local_camera_node can use it
context.modules = [
{ name = "libpipewire-module-v4l2" args = { } flags = [ "disabled" ] }
]
EOF
echo "✓ Created /etc/pipewire/pipewire.conf.d/disable-v4l2.conf"
echo ""
echo "Step 2: Adding udev rule for IMX477 HQ camera..."
echo "-------------------------------------------------"
# Create udev rule as backup (tells PipeWire not to manage this specific camera)
cat > /etc/udev/rules.d/99-gertie-camera.rules << 'EOF'
# GERTIE: Prevent PipeWire from managing the HQ camera (IMX477)
SUBSYSTEM=="video4linux", ATTR{name}=="*imx477*", ENV{PIPEWIRE_DONT_MANAGE}="1"
SUBSYSTEM=="video4linux", ATTR{name}=="*imx477*", ENV{LIBCAMERA_DONT_MANAGE}="1"
EOF
echo "✓ Created /etc/udev/rules.d/99-gertie-camera.rules"
# Reload udev rules
udevadm control --reload-rules
echo "✓ Reloaded udev rules"
echo ""
echo "Step 3: Enabling local_camera_node service..."
echo "-----------------------------------------------"
# Enable the service to start on boot
if [ -f /etc/systemd/system/local_camera_node.service ]; then
systemctl enable local_camera_node.service
echo "✓ Enabled local_camera_node.service"
else
echo "⚠ local_camera_node.service not installed yet"
echo " Run sync_to_nodes.sh first, then:"
echo " sudo cp local_camera_node.service /etc/systemd/system/"
echo " sudo systemctl enable local_camera_node.service"
fi
echo ""
echo "============================================"
echo "Setup Complete!"
echo "============================================"
echo ""
echo "IMPORTANT: You must REBOOT for changes to take effect:"
echo ""
echo " sudo reboot"
echo ""
echo "After reboot:"
echo " - PipeWire will no longer grab the camera"
echo " - local_camera_node.service will start automatically"
echo " - Run ./run_qt_with_logging.sh to test"
echo ""
echo "To verify camera is free after reboot:"
echo " sudo lsof /dev/video0"
echo " (should show only local_camera_node or nothing)"
echo ""