balena-io-experimental / libcamera-apps

Example repo to showcase Raspberry Pi's new libcamera stack on balenaOS
6 stars 5 forks source link

Camera not detected #1

Open AndreMaz opened 2 years ago

AndreMaz commented 2 years ago

Thanks for the repo @rahul-thakoor However, in my case the camera is still not being detected. Do you have any idea what might be the issue? I'm using RPi 4 with balenaOS 2.94.4|supervisor 12.11.36

Here's the result for the libcamera-hello --list-cameras -n -v on balena and RPI OS Balena

[0:52:12.100730882] [80]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3424-e68e0f1e
No cameras available!
Closing Libcamera application(frames displayed 0, dropped 0)
Camera stopped!
Tearing down requests, buffers and configuration
Camera closed

RPI OS

[0:01:53.677768678] [3402]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3406-e96d0201
[0:01:53.721401441] [3403]  WARN CameraSensorProperties camera_sensor_properties.cpp:141 No static properties available for 'imx477'
[0:01:53.721722998] [3403]  WARN CameraSensorProperties camera_sensor_properties.cpp:143 Please consider updating the camera sensor properties database
[0:01:53.721859776] [3403] ERROR CameraSensor camera_sensor.cpp:551 'imx477 10-001a': Camera sensor does not support test pattern modes.
[0:01:53.740133946] [3403]  INFO RPI raspberrypi.cpp:1326 Registered camera /base/soc/i2c0mux/i2c@1/imx477@1a to Unicam device /dev/media0 and ISP device /dev/media1
Available cameras
-----------------
0 : imx477 [4056x3040] (/base/soc/i2c0mux/i2c@1/imx477@1a)
    Modes: 'SRGGB10_CSI2P' : 1332x990 
           'SRGGB12_CSI2P' : 2028x1080 2028x1520 4056x3040 
Closing Libcamera application(frames displayed 0, dropped 0)
Camera stopped!
Tearing down requests, buffers and configuration
Camera closed
AndreMaz commented 2 years ago

Issue solved.

After adding dtoverlay=imx477 (HQ camera (IMX477)) the camera is detected.

image

Here's the log:

 libcamera  [0:00:43.117945822] [77]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3424-e68e0f1e
 libcamera  [0:00:43.167621674] [79]  WARN CameraSensorProperties camera_sensor_properties.cpp:141 No static properties available for 'imx477'
 libcamera  [0:00:43.167705562] [79]  WARN CameraSensorProperties camera_sensor_properties.cpp:143 Please consider updating the camera sensor properties database
 libcamera  [0:00:43.167750951] [79] ERROR CameraSensor camera_sensor.cpp:551 'imx477 10-001a': Camera sensor does not support test pattern modes.
 libcamera  [0:00:43.254275970] [79]  INFO RPI raspberrypi.cpp:1317 Registered camera /base/soc/i2c0mux/i2c@1/imx477@1a to Unicam device /dev/media3 and ISP device /dev/media0
 libcamera  Available cameras
 libcamera  -----------------
 libcamera  0 : imx477 [4056x3040] (/base/soc/i2c0mux/i2c@1/imx477@1a)
 libcamera      Modes: 'SRGGB10_CSI2P' : 1332x990 
 libcamera             'SRGGB12_CSI2P' : 2028x1080 2028x1520 4056x3040 
 libcamera  Closing Libcamera application(frames displayed 0, dropped 0)
 libcamera  Camera stopped!
 libcamera  Tearing down requests, buffers and configuration
 libcamera  Camera closed
AndreMaz commented 2 years ago

I'm reopening this because I noticed that

data:
  applicationConfigVariables:
    - BALENA_HOST_CONFIG_gpu_mem: 128
    - BALENA_HOST_CONFIG_dtoverlay: "vc4-kms-v3d"
    - BALENA_HOST_CONFIG_camera_auto_detect: 1
    - BALENA_HOST_CONFIG_max_framebuffers: 2

does not seem to have effect. Yesterday, to get things working, I've manually set the configs in the Dashboard.

rahul-thakoor commented 2 years ago

hey @AndreMaz thanks for reporting this.

Can you please confirm how you deployed the application? Did you

  1. Use balenaCLI to push the app to balenaCloud or
  2. Use the Deploy with balena button in the README.md?
AndreMaz commented 2 years ago

@rahul-thakoor I've deployed with CLI balena push <FLEET-NAME> --source .

rahul-thakoor commented 2 years ago

Yes @AndreMaz that's expected since as of today the balena push workflow does not interpret variables from the balena.yml file. we are working to resolve this inconsitency

AndreMaz commented 2 years ago

Thank you for the explanation.

we are working to resolve this inconsistency

Is there any GH issue where I can track the progress on this?

meawoppl commented 2 years ago

As a short term workaround:

You can set the flag in the config.txt BEFORE THE FIRST BOOT. Or use the balena dashboard to set it on the device. Navigate the menus: Device Configuration >> Custom Configuration >> Add Custom Configuration Name: BALENA_HOST_CONFIG_camera_auto_detect Value: 1

Or set it fleetwide in a menu above that with a similar flow.

This is annoying and took me some time to figure out!!!

meawoppl commented 2 years ago

@rahul-thakoor I would also be interested in tracking the progress on this. I like most configuraton to live in the repo, and without this, you have to do some hand config to get an app rolling in the standard workflows.

edorgeville commented 2 years ago

Just spent two hours fiddling with all those options, turns out the version of balenaOS I was using (raspberrypi4-64-2.85.2+rev3) was too old. Upgrading to raspberrypi4-64-2.99.27 fixes the issue on my side.

meawoppl commented 2 years ago

This is a non-issue for current versions. The easiest fix at this point is a version upgrade IMHO

reinhrst commented 2 years ago

I'm trying and getting this error on a raspberry pi 3 B+. Is there any reason it shouldn't work on the RPi3? Are there people that have got it to work on RPi3?

Getting the error both with the balena push and the Deploy with Balena button.

Running balenaOS 2.101.7+rev2 (for rpi3, 64bit).

reinhrst commented 2 years ago

And just as I wrote it, I realised that in the supportedDeviceTypes it has raspberrypi3, but not raspberrypi3-64. It works on 32bit OS! Would still be interesting to get it to work on RPi3-64, but good enough for now. Thanks!

reinhrst commented 2 years ago

I couldn't let it rest, and dove back in. Interestingly it works on the PI3 B+ 64 bit on balenaOS 2.94.4, however the exact same image doesn't work anymore on balenaOS 2.101.7+rev2 or balenaOS 2.105.1+rev1.

In cannot access intermediate balena OS images, so I can't see where it broke. I will try to get a hold of an RPi4 today and see how it works on there.

reinhrst commented 2 years ago

Continuing the deep dive: it seems that initialisation of the camera (both the ov5647 and the official pi cam 2.1 imx219) breaks on this line in dmesg: [ 12.618169] ov5647 10-0036: Failed to get power regulators and [ 12.956096] imx219 10-0010: failed to get regulators (to be clear: I tried both cams, one at a time). They fail on Rpi3 64 bit for any of the currently available OSes > 2.94.4 (balenaOS 2.94.4 does not have this message, and, indeed, I can access the cam).

I also tried on RPi4, and both cams work, there is no line in dmesg abouth power regulators.

The error message about power regulators led to https://forums.raspberrypi.com/viewtopic.php?t=323308&start=25, and the suggestion is to use CONFIG_REGULATOR_FIXED_VOLTAGE during kernel compile. The kernel is part of balenaOS and cannot be updated/recompiled by users. I don't know how to check if this flag was present during kernel compile, but at least the story makes sense to me now: somewhere between version 2.94.4 and 2.101.7+rev2 the flag was removed from the kernel config (or maybe the 2.94.4 kernel had this on by default).

For now it's ok to work on balenaOS 2.94.4, which allows me to both have a 64-bit OS and a camera (meaning I can take pictures and feed them to YOLOv5).

If somewhere knows where I can report this as an issue to balena, I'd be happy to do so (feels good to think that my 2 days of research were not for nothing :)); It would be good if newer balena OS versions would work again!

KhanMechAI commented 2 years ago

I have been banging my head against this one, thanks for the tips. Will downgrade to 2.94.4 and see how I go. To confirm I'm using balenaOS 2.106.2 and still facing this issue.

reinhrst commented 2 years ago

@KhanMechAI What board are you on? I think 2.106.2 is not available for RPi3-64 bit, right? The newest/suggested balena OS version worked for me on RPi4-64 and RPi3-32. However please share your results (which board and if the downgrade made it work)!

KhanMechAI commented 2 years ago

@reinhrst I'm on an RPi4-64 too, but still struggling with it. Installing opencv from source prior to it and I'm wondering if thats messing with things. That or cooking it with my balena configs. Doesnt seem like the downgrade has worked, so must be my setup

reinhrst commented 2 years ago

@KhanMechAI Can you do something like dmesg | grep "10-0036" (or maybe another number; there should be a line about your camera, probably in red) in the host OS.

I just ran into another problem; everything was working fine as expected, until I added a PoE hat (the official RPi one). As far as I can tell now (but very preliminary research, so conclusions may be wrong), there likely is a collision between i2c stuff for controlling the little fan on the PoE hat and camera...

New error message: ov5647 10-0036: write sensor_oe_enable_regs erro.

@rahul-thakoor I understand you work at Balena. Is there a place to report these issues (since they seem to be in the balena OS)? What kind of additional research would be helpful?

rahul-thakoor commented 2 years ago

hey @reinhrst I would suggest creating a topic on our forums. Hopefully other community members would be able to help too.

Just to rule out any balenaOS related issue, I would suggest trying the camera and PoE hat on the same device but with Raspberry Pi OS.

KhanMechAI commented 2 years ago

Hey @reinhrst, I managed to get the camera detected and it was in fact due to my balena config. The overlay params are a bit tricky to the novice. Also a slight bit of confusion on my part, have a camera with the HQ camera, but was testing the deployment with the V2.1 camera 🫠

Thanks for being engaged on this though, really appreciate the support!

I should also say I havent quite managed to get the full application to run, but as for this issue, it does seem like i can at least query the camera

reinhrst commented 2 years ago

@rahul-thakoor Yes, of course, I should have mentioned that everything works as it should on Raspbian! There are reports of about a year ago about it not working in Raspbian (and seems that some kernel drivers were updated to fix this). Will give it a try on the forums -- next week when I'm back after a trip (and have access to the hardware again)!

@KhanMechAI good to hear that everything is working for you!

Jessseee commented 1 year ago

I am currently trying to get this working on a Raspberry Pi 4B 64bit with the new camera module v3. However, I cannot get it to detect the camera. I am on balenaOS 2.108.27. I tried running with local mode on and off and I also tried to set BALENA_HOST_CONFIG_dtoverlay: "vc4-kms-v3d", "imx708" for the new sensor type. The setup worked fine without Balena on RaspbianOS Bullseye 64bit.

UPDATE: Well, I think I found the problem... The imx708 overlay is not yet included in the kernel used by BalenaOS 2.108.27. I could have guessed as much. The current kernel version is 5.15.34-v8 and if I am right the imx708 overlay should be included in kernel version 5.15.84. So, I guess I'll be waiting for an OS update.

ScottGibb commented 9 months ago

@Jessseee Did this ever get added to the Balena OS. I am currently trying to do the same thing and am getting issues using the new PiCamera V3 to work with Balena.

Jessseee commented 9 months ago

@ScottGibb Not unless BelanaOS has upgraded their version of meta-raspberry. Unfortunately, the backward compatability layer I wrote for the imx708 device layer has not been merged yet. https://github.com/agherzan/meta-raspberrypi/pull/1197

reinhrst commented 9 months ago

In case anyone is interested (sorry for the late feedback), recent Balena OS's work for me on the RPi-64bit. I'm running this repo, on a Raspberry PI 3 with the official POE hat.

image

I changed some other settings on the device:

image

(the clipped value is: "poe_fan_temp0=10000,poe_fan_temp1_hyst=1000","poe_fan_temp0=60000,poe_fan_temp2_hyst=5000","poe_fan_temp2=65000,poe_fan_temp3_hyst=5000","poe_fan_temp3=70000,poe_fan_temp3_hyst=5000" to make sure the poe fan doesn't all the time run at 100%).

Not entirely sure which values are needed for what, but I remember that initially I had problems getting both PoE and camera to run at the same time.

Just wanted to share these values in case it helps anyone

image