Camera model
Rapsberry Pi Camera V2
What is the problem?
Trying to setup Raspberry Pi Camera v2 and the settings I put in octopi.txt are not being honored. The defaults are getting used.
I netboot my RPi4. Since octopi.txt lives on the boot partition which is mounted; I can only assume, after webcamd starts the settings aren't used. Once the system comes up and I restart the webcamd service the settings in octopi.txt are used.
- Modify octopi.txt to have desired camera settings
- Reboot octopi
- Custom camera settings not being used.
- Manually restart webcamd
sudo systemctl restart webcamd
and setting in file are used
What did you already try to solve it?
Logs (/var/log/webcamd.log
, syslog, dmesg, ... no logs, no support)
Attached are octopi.txt and webcamd.log. In the webcamd log file the first start of webcamd is on boot and the second is after I manually restarted it.
logfiles.zip (4.2 KB)
Additional information about your setup (OctoPrint version, OctoPi version, ...)
OctoPrint version : 1.7.3
OctoPi version : 0.18.0
It seems like it's loading the backup config because the config file was not found.
There are several things you could do. For example:
- you could automatically restart webcamd after each boot
- you could try to put the config file somewhere else (maybe the boot partition gets mounted too late)
- you could change the values of the backup config
for the last two points edit the /root/bin/webcamd
and change the relevant lines.
If you rather want to do the first point and need help tag me and we figure that one out.
Yes that is exactly what is happening. I did some analsys of when systemd was starting the webcamd service and found that it was happening before the mount of /boot
finished.
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.
webcamd.service +1.092s
└─basic.target @3.271s
└─sockets.target @3.270s
└─avahi-daemon.socket @3.270s
└─sysinit.target @3.251s
└─systemd-timesyncd.service @2.659s +589ms
└─systemd-tmpfiles-setup.service @2.074s +471ms
└─local-fs.target @2.031s
└─local-fs-pre.target @2.030s
└─keyboard-setup.service @1.460s +569ms
└─systemd-journald.socket @1.290s
└─system.slice @1.265s
└─-.slice @1.265s
pi@octopi:~ $ sudo systemd-analyze critical-chain boot.mount
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.
boot.mount +733ms
└─network-online.target @6.044s
└─network.target @6.007s
└─dhcpcd.service @3.328s +2.675s
└─basic.target @3.271s
└─sockets.target @3.270s
└─avahi-daemon.socket @3.270s
└─sysinit.target @3.251s
└─systemd-timesyncd.service @2.659s +589ms
└─systemd-tmpfiles-setup.service @2.074s +471ms
└─local-fs.target @2.031s
└─local-fs-pre.target @2.030s
└─keyboard-setup.service @1.460s +569ms
└─systemd-journald.socket @1.290s
└─system.slice @1.265s
└─-.slice @1.265s
I think this is an issue in OctoPi as the webcamd service is packaged with the OS. Instead of installing it to an SD card I netbooted. I took the octopi image file and then extracted it out onto my PXE server and configured the Pi to boot from that. If a service is going to depend on a config file it should make sure it is there before starting. Due to the parallel nature of systemd boot process that gets more complicated but it can be handled.
I added the following ExecStartPre=/usr/bin/test -f /boot/octopi.txt
to /etc/systemd/system/webcamd.service
under the [Service]
section and that has resolved my issue. Full edited unit file below.
[Unit]
Description=the OctoPi webcam daemon with the user specified config
ConditionPathExists=/etc/octopi_streamer/mjpeg
[Service]
WorkingDirectory=/root/bin
StandardOutput=append:/var/log/webcamd.log
StandardError=append:/var/log/webcamd.log
ExecStartPre=/usr/bin/test -f /boot/octopi.txt
ExecStart=/root/bin/webcamd
Restart=always
Type=forking
RestartSec=1
[Install]
WantedBy=multi-user.target