Enabling the Raspberry Pi camera on HASSOS installations is unfortunately not as simple as connecting the camera and configuring Home Assistant as described at https://www.home-assistant.io/integrations/rpi_camera.
For the camera to work at all, an alternate firmware needs to be loaded when the Raspberry Pi boots. On Raspberry Pi OS (and many others), the alternate firmware is included with the OS installation image, and switching to the alternate firmware is accomplished by running raspi-config and selecting "Enable Camera" from the menu. HASSOS does not include either the alternate firmware or the raspi-config program, so all of the steps need to be done manually.
The steps below attempt to describe the steps that need to be performed. They have worked for me on a Raspberry Pi 3B+ running HASSOS 4.11 through 4.15. If you have a different setup your mileage may vary (but hopefully you'll get enough hints from the below to get it working).
As of HASSOS 6.0, as mentioned in the closing notes of home-assistant/operating-system#947 on June 17th 2021, the alternate firmware files are automatically included in the builds. Therefore much of this guide is obsolete - only the last two sections need to be followed (enable the camera in config.txt and reboot).
Shortly after HASSOS 6.0 was released, some code change between Home Assistant Core 2021.7.4 and Home Assistant Core 2021.8.1 broke the camera support on HASSOS platforms. A fix was applied and core versions 2021.11.3 and later work once again, so avoid core versions 2021.8.0 through 2021.11.2 to retain a working rpi_camera.
The high-level overview of what needs to be done is:
- Find the alternate firmware files compatible with the version of HASSOS that you are running or are going to be running after the next reboot.
- Place the firmware files on a machine that your HASSOS box has scp/sftp access to.
- Copy the firmware files to the HASSOS addon_core_ssh container.
- Copy the firmware files to the HASSOS /mnt/boot partition.
- Edit the HASSOS /mnt/boot/config.txt file to enable the alternate firmware and make other camera related changes.
- Reboot HASSOS, then configure the camera as documented elsewhere.
(skip this step on HASSOS 6.0 and later)
Find your HASSOS version if you don't already know it. There are many ways to do this, like looking at the host system information information in the Home Assistant client you use. Another way is to run the following from an SSH connection to Home Assistant:
ha info | grep hassos:
E.g. 4.13
(NOTE: replace HASSOS-VERSION with your version of HASSOS, e.g. https://github.com/home-assistant/operating-system/blob/4.13/buildroot/package/rpi-firmware/rpi-firmware.mk)
The firmware hash is the value of the make variable RPI_FIRMWARE_VERSION
In this example, the firmware hash is: 7caead9416f64b2d33361c703fb243b8e157eba4
Go to https://github.com/raspberrypi/firmware/commit/FIRMWARE-HASH
E.g. https://github.com/raspberrypi/firmware/commit/7caead9416f64b2d33361c703fb243b8e157eba4
And download the start_x.elf and fixup_x.dat files from there. If start_x.elf and fixup_x.dat are NOT in that commit, click on "Browse Files (at this point in history)", navigate to boot/, and download the firmware files from there.
Save both firmware files on a system that your HASSOS box will be able to access with scp or sftp.
(skip this step on HASSOS 6.0 and later)
This is a two-step process, since the HASSOS host does not have any support for copying remote files directly to the host. Therefore the concept is to copy the firmware files to a container that does have support for remote file transfer, then copy those files to the host using the docker cp command.
- Install and configure the ssh add-on (https://github.com/home-assistant/hassio-addons/blob/master/ssh/DOCS.md)
- Establish an ssh connection to Home Assistant via the ssh add-on
- Copy the firmware files from the machine you saved them to, to /tmp, using scp or sftp. The SSH add-on also has curl installed, so that could potentially be used to transfer the firmware files instead of scp or sftp.
- Connect to the HASSOS host on port 22222 (instructions at https://developers.home-assistant.io/docs/operating-system/debugging/#ssh-access-to-the-host)
- cd /mnt/boot
- docker cp addon_core_ssh:/tmp/start_x.elf .
- docker cp addon_core_ssh:/tmp/fixup_x.dat .
Connect to the HASSOS host on port 22222, and edit (with "vi") the /mnt/boot/config.txt file as follows.
The camera needs more GPU memory than the default setting provides. Increase the GPU memory to 128 MB where possible by adding the following lines. See https://www.raspberrypi.org/documentation/raspbian/applications/camera.md and https://www.raspberrypi.org/documentation/configuration/config-txt/memory.md for reference.
gpu_mem=128
gpu_mem_256=64
gpu_mem_512=128
gpu_mem_1024=128
Enable the alternate firmware:
# Setting start_x to 1 does exactly the same
# thing as the following 2 lines that are commented
# out, but with reduced risk for errors due to typos
start_x=1
#start_file=start_x.elf
#fixup_file=fixup_x.dat
# The next line is optional, if you don't want the
# red LED on the camera to light while the camera
# is active
disable_camera_led=1
After all of the steps above have been completed, reboot the HASSOS host and continue configuring the camera as documented in https://www.home-assistant.io/integrations/rpi_camera.
so I'm pretty sure you do not have partitionmmcblk0p1
edit: running HAOS from TF card is really not recommended (as TF / SD cards have a short lifespan), so I thought it is CM4 (there are versions with eMMC onboard).
When you edit config.txt its autogenerated part should stay untouched.
Working config.txt for RPi4
BTW Do you remember about motionEye Addon?
Native rpi_camera platform have NOT been working for years using HAOS (it only works in Debian/Raspbian Container (Docker) installations)
I'm not able to show motionEye configuration, butyou shouldn't edit a file, try to configure camera from motionEye GUI.In comments above there are lots of unnecessary steps, only 3 steps are really required
rpi_camera
does not work)It could depend on camera chipset but for me (OV5647) it was third position from the end of list
"Normal" ssh connection in HAOS is without root privileges to host (it is only "fake-root" - it is just inside container), so if you need ssh connection to the host with real root, you have to prepare separate ssh configuration
https://developers.home-assistant.io/docs/operating-system/debugging/#ssh-access-to-the-host
There is also alternate way to do something on the host as real root - using local console (keyboard + monitor) and CLI where you can login as root - in CLI just type
login
(without user nor pass).