Trying to get Pi V1 Camera working on rpi3a+

Hello!

I’m trying to get a Raspberry Pi Camera Module v1 (OV5647 sensor) working on a Raspberry Pi 3A+ using Elixir Nerves with libcamera.

Current Issue

  • libcamera-hello --list-cameras returns “No cameras available!”

  • Same hardware works perfectly on Raspberry Pi OS

  • Tried custom systems with various config changes of nerves_system_rpi3a and nerves_system_rpi0_2

What I’ve Tried

  • Added camera modules to /etc/modules

  • Tried both camera_auto_detect=1 and dtoverlay=ov5647 in config.txt

  • Added CONFIG_USER_NS=y to kernel config

  • Modules load but no /dev/video* devices created

Questions

  1. Has anyone gotten v1 Pi cameras working on RPi3A+ with Nerves recently?

  2. Are there any working examples or configs I should be looking at?

I’m way out of my element with embedded systems and have been spinning my llm token wheels trying to get this working. The hardware definitely works out of the box on Raspberry OS.

If anyone can point me in a direction that would be awesome. I know there was a similar thread here that might have gotten things working for the rpi5. That’s where most of my cargo culting inspirations have come from.

Thanks for any help!

Ugh. Yes,the Raspberry Pi 5 required quite a few updates to get working with Nerves and the error you’re getting looks very similar. I know that it can’t be the same issue, but there’s not really much to go on and it used to work.

Let me reach out to the Pi camera users I know to see if they have any wisdom to share.

Thanks for posting about this. There’s an issue with the Pi 5 that I’m hearing about that may require me to investigate and if I do, it will be really convenient for me to try a RPi Zero 2 at the same time.

1 Like

I took a look, but will need to look more next week. Linux detects and loads the kernel modules for me, but “libcamera-hello –list-cameras” still returns no cameras after a timeout. The timeout seems promising since when I first started, detection failed immediately. At least now, I get a nice message in the dmesg when the camera sensor loads.

I’ve started sending PRs to the nerves_system_rpi3a and nerves_system_rpi0_2 systems. If I follow your post right, then I bet that you only need to add CONFIG_I2C_MUX_PINCTRL=m to your kernel config to get to where I’m at right now. However, it still won’t work. When I get time again, my next steps will be to see if enabling libcamera debug prints or running strace will give a clue.

Thanks super much for taking a look @fhunleth!

I’ll get caught up with those PRs, try this latest config, and continue tinkering. Thanks again!

One more fix for you at Include vc4 overlays to enable the vc4 for cameras and display · nerves-project/nerves_system_rpi3a@ebf63d0 · GitHub .

I would like to do a little more before making a release, but I’m able to capture video now with libcamera-vid. I think that you should be able to with that fix.

For anyone stumbling on this thread, here’s how I debugged this issue:

  1. sftp into the nerves device
  2. Get /sys/firmware/fdt
  3. Run dtc -O dts fdt > rpi3.dts
  4. Look through the dts for camera-related entries. For each one, look at the compatible string and then recursively grep through the Linux kernel source code to find the .c file with that string. If there’s not a .o file, then it wasn’t built and a Linux kernel config option needs to be turned on.
  5. Look through the dts file for status = “disabled” entries. These tend to exist when the RPi bootloader can’t find the overlay file for that piece of hardware. Edit the fwup.conf to add those device tree overlay files.

At the beginning I did a quick check of dmesg and I strace’d libcamera-vid since I’m not that familiar with the camera and was hoping for an obvious error message. I didn’t get any. I know that there’s some way of turning on more debug messages too. Nothing stood out and then I saw that the kernel wasn’t loading modules, checked the device tree, and got lucky with greping compatible strings.

3 Likes

Hi again Frank, really appreciate your time and attention here. I’ve applied your latest changes on main of nerves_system_rpi3a (ebf63d0) but still no cameras are detected for me.

Troubleshooting alongside an llm agent, here’s where I’m at. (I confess I’m coming from the web and I’m hanging on by a thread for these lower level concepts.)

Here are the specific commands I ran on the device and their results:

  1. Checking libcamera

When I run libcamera-hello --list-cameras, it reports no cameras, as expected.

*System.cmd("libcamera-hello", \["--list-cameras"\])*

{"No cameras available!\\\\n", 0}
  1. Checking Kernel Messages (dmesg)

The kernel does seem to detect the camera sensor on the I2C bus. Grepping dmesg for ov5647 shows the device is recognized.

*System.cmd("dmesg", \[\]) |> elem(0) |> String.contains?("ov5647")*

{true, 0}

The specific log lines are:

\[    0.021274\] /soc/csi@7e801000: Fixed dependency cycle(s) with /soc/i2c0mux/i2c@1/ov5647@36

\[    0.021303\] /soc/i2c0mux/i2c@1/ov5647@36: Fixed dependency cycle(s) with /soc/csi@7e801000
  1. Checking Loaded Modules (lsmod)

This seems to be the core of the problem: the ov5647 kernel module is not being loaded. Grepping the output of lsmod for ov5647 returns nothing.

System.cmd("lsmod", \[\]) |> elem(0) |> String.contains?("ov5647")

{false, 0}

I’ve double-checked that this exact camera and Pi work correctly with the standard Raspberry Pi OS.

I’ll continue down the road of debugging and see what I can come up with. Thanks again.

Thanks for hanging in there to debug this.

I’m double checking all of the Nerves systems now. Synchronize camera config with Raspberry Pi 3 by fhunleth · Pull Request #262 · nerves-project/nerves_system_rpi3a · GitHub might help.

If it doesn’t, could you sftp over to your device and get /sys/firmware/fdt? And then either post it or run dtc -O dts fdt > rpi3.dts and post rpi3.dts. I don’t have that camera handy. I have to believe that we’re really close.

Frank

libcamera-hello is finding a camera! super exciting thanks for getting to the bottom of this.

The libcamera-jpeg command seems to have trouble at the end with trying to open the file :thinking:. I can try to chip away at this in a few hours and try other commands.

This is great progress! Thanks so much!

iex(7)> cmd “libcamera-hello --list-cameras”Available cameras

0 : ov5647 [2592x1944 10-bit GBRG] (/base/soc/i2c0mux/i2c@1/ov5647@36)Modes: ‘SGBRG10_CSI2P’ : 640x480 [58.92 fps - (16, 0)/2560x1920 crop]1296x972 [46.34 fps - (0, 0)/2592x1944 crop]1920x1080 [32.81 fps - (348, 434)/1928x1080 crop]2592x1944 [15.63 fps - (0, 0)/2592x1944 crop]

iex(8)> cmd “libcamera-jpeg -o yay.jpeg”[0:04:39.514440455] [237]  INFO Camera camera_manager.cpp:326 libcamera v0.5.0[0:04:39.573094585] [238]  INFO RPI vc4.cpp:447 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media3 and ISP device /dev/media1[0:04:39.573195000] [238]  INFO RPI pipeline_base.cpp:1121 Using configuration file ‘/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml’Preview window unavailableMode selection for 1296:972:12:PSGBRG10_CSI2P,640x480/0 - Score: 3296SGBRG10_CSI2P,1296x972/0 - Score: 1000SGBRG10_CSI2P,1920x1080/0 - Score: 1349.67SGBRG10_CSI2P,2592x1944/0 - Score: 1567Stream configuration adjusted[0:04:39.575190346] [237]  INFO Camera camera.cpp:1205 configuring streams: (0) 1296x972-YUV420 (1) 1296x972-SGBRG10_CSI2P[0:04:39.576002317] [238]  INFO RPI vc4.cpp:622 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 1296x972-SGBRG10_1X10 - Selected unicam format: 1296x972-pGAA#0 (0.00 fps) exp 33239.00 ag 8.00 dg 1.00#1 (30.00 fps) exp 33239.00 ag 8.00 dg 1.00… … … #141 (30.01 fps) exp 33239.00 ag 8.00 dg 1.00Mode selection for 2592:1944:12:PSGBRG10_CSI2P,640x480/0 - Score: 7832SGBRG10_CSI2P,1296x972/0 - Score: 5536SGBRG10_CSI2P,1920x1080/0 - Score: 4238.67SGBRG10_CSI2P,2592x1944/0 - Score: 1000Stream configuration adjusted[0:04:44.747732262] [237]  INFO Camera camera.cpp:1205 configuring streams: (0) 2592x1944-YUV420 (1) 2592x1944-SGBRG10_CSI2P[0:04:44.755350578] [238]  INFO RPI vc4.cpp:622 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 2592x1944-SGBRG10_1X10 - Selected unicam format: 2592x1944-pGAAStill capture image receivedERROR: *** failed to open file yay.jpeg ***255


Ah that seems to be a write permission to the filesystem. writing a jpeg to /tmp has it working!

I plan to test things a bit more soon. I’ll let you know if anything pops up.

Thanks for the fix!!

Great! Try writing to /data or /root.

I’ll aim to get releases out this week so this will all work better out-of-the-box.

2 Likes