Problems with RPi2 camera and Yocto

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problems with RPi2 camera and Yocto

3,892 Views
evankahn
Contributor II


Hi all -

I am trying to get video4linux working with the Raspberry Pi 2 camera (board v.1.3, sensor model OV5647), which is plugged into the MIPI/CSI port on my i.mx6 developer board (QWKS-SCMIMX6). Thus far it is recognized as an i2c device but does not show up under /dev/video0.

I am new to working with the Linux kernel and I can retrace the steps taken to get here -- please let me know if I have any misunderstandings that are leading to this not working.

I did a relatively clean build of yocto, starting from the meta-fsl-arm layer, and applied board-specific patch files for the SCM-IMX6.

After an initial build where I confirmed that yocto worked and booted, I spent a while grepping through the device tree files. Eventually I found the following code in the build folder, in the device tree file /arch/arm/boot/dts/imx6q.dtsi:

aips-bus@02100000 { /* AIPS2 */

                        mipi_dsi: mipi@021e0000 {

                                compatible = "fsl,imx6q-mipi-dsi";

                                reg = <0x021e0000 0x4000>;

                                interrupts = <0 102 0x04>;

                                gpr = <&gpr>;

                                clocks = <&clks IMX6QDL_CLK_HSI_TX>, <&clks IMX6QDL_CLK_VIDEO_27M>;

                                clock-names = "mipi_pllref_clk", "mipi_cfg_clk";

                                status = "disabled";

                        };

                };

So I pushed a patch that changed status = "disabled" to status="enabled". I do not know if this was the right thing to do, but it seemed to make sense. The patch worked and yocto compiled without any issues.

After flashing to an SD card and booting the device, I then made sure that the proper kernel modules were present. Using this page as a rough guide and looking through modules.dep, I found that the kernel modules I wanted to get the camera to work were at least present: ov5647_camera_mipi.ko, and mxc_v4l2_capture. I also double-checked with "bitbake -c configure virtual/kernel" that all of the kernel drivers required to run the ov5647 were configured to be installed in the recipe. (By the way, HDMI output works properly, and I can confirm that v4l can output test patterns, just not read input from a camera. I have also tested the Pi camera with a Raspberry Pi and it worked fine.)

I used modprobe to enable ov5647_camera_mipi, v4l2_int_device, and mxc_v4l2_capture. The latter module also turned on several dependencies. At that point lsmod returned a list of dependencies equal to the one on the previously linked Tinyrex webpage, the only difference being that v4l2_int_device did not rely on ov5647_camera_mipi. Using i2cdetect I could see that the camera was showing up at i2c1, address 0x36; exactly what I expected. However, when I use i2cdump on that address I get all zeroes with maybe 2 bytes of data; and nothing shows up as /dev/video0.

I also tried using modules-load.d to load the three modules at boot. None of it made a difference. I grepped through dmesg to try and find any mention of a camera or an i2c device that looked familiar; still nothing under /dev/video0.

Most recently I rolled back the change that I made with the kernel patch above and repeated all these steps again to no avail.

If anyone could shed a little bit of light on why this isn't working it would be very much appreciated. I'm happy to provide any information that might be needed to troubleshoot this problem. Thanks very much!

0 Kudos
6 Replies

2,087 Views
igorpadykov
NXP Employee
NXP Employee

Hi evan

for OV5647 bringup steps please look at

i.MX6 OV5647 Bayer sensor driver (ERROR: v4l2 c... | NXP Community

Best regards

igor

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos

2,087 Views
evankahn
Contributor II

Hi--

Thanks for the suggestion; I'm still trying to work through the bringup process -- I can't even get the system to recognize the camera device under /dev/video0. If there's a better first stage of checking whether or not the camera hardware is being recognized, let me know.

I'm still unsure how (if at all) the .dtsi files need to be modified in order to register the camera device. I have been sifting through V4L2 documentation​ and it seems like there are several levels of device drivers that join forces to drive the camera at a kernel level. However, since I can't even get anything to show up at /dev/video0, I can only assume I am missing something relatively basic.

As I understand it, the kernel module mxc_mipi_csi.ko is the module that implements the v4l2 standard, as well as the one that should handle MIPI camera input devices at a high level (including registering the deviceusing the subdevice module ov5647_camera_mipi.ko for sensor-specific functionality). However, grepping through dynamic debug messages suggests that the driver is not seeing the camera. I am not sure what configuration steps I have to take - pre-compile or post-boot - that I must take to ultimately get the camera to work. Do I need to make modifications to the device tree file similar to this​ in order to convince the drivers to register the CSI device, adding a ov5647-specific entry to my dtsi file? Or should everything work out of the box and there's just a broken pipe somewhere between two layers of the camera driver stack? Or -- is the OV5647 only partially supported (on either the mx6 itself or the particular single-chip developer board I'm using), meaning that I will have to make changes to the driver source myself?

I've been staring this in the face for over a week; I realize that my understanding of the process is probably fundamentally flawed or incomplete at some point along the line, and I'd love if someone could let me know if anything I've said thus far is based on a misunderstanding. I'm trying to go through this process as methodically as possible but I'm really struggling even to find a thread that I know how to start unraveling.

Thanks!

2,087 Views
aliismail
Contributor IV

Hi Evan,

Did you manage to complete this?

Ali

0 Kudos

2,087 Views
evankahn
Contributor II

In a way. Since writing this post I've delved pretty deep into device tree stuff and gotten a better sense of what I was actually doing. It turns out that the iMX6 IPU is not compatible with the raw RGB data being sent by the ov5647, despite the fact that the carrier board I was using had a pinout compatible only with the Pi camera. The OV5647 driver provided in the Yocto package is actually for the i.MX7. So in order to receive image data from the Pi camera on the iMX6, you need to use some version of the community driver by Viion Systems, which is limited to a terrible frame rate since it does colorspace conversion in software rather than on the IPU. For more information, check this and this. I found this to be not worth it and ended up buying a Boundary Devices SabreSD and associated MIPI camera assembly, which was more expensive but worked out of the box.

2,087 Views
aliismail
Contributor IV

That sounds pretty frustrating. I can't even plug the camera in without some failure in the i2c bus. In that nxp thread that you linked, would you say that the modifications are spot on with the SCM board?

0 Kudos

2,087 Views
evankahn
Contributor II

No, he was building for the Wandboard. His driver has been iterated on and adapted for different platforms - that thread is its earliest incarnation; you can figure out if an ov5647 driver is based on his code by searching for "Viion Systems" in the code. A better bet (the first thing I tried) was to start messing with the driver for the Hummingboard platform (whose development is detailed in the second thread I linked). It is based on Dave McMordie's code, but is designed to support the Raspberry Pi Camera 1.3 rather than a bare ov5647. This repository contains it (in drivers/media/mxc/capture) as well as information on how to set up the device tree to incorporate it (in the hummingboard dtsi file, ctrl-F "mipi"). I took a few days trying to adapt this code to work on the SCM and I ultimately couldn't get it working due to differences further up in the v4l2 stack (there's no reason that the hardware wouldn't be compatible), but I am pretty new to this and you might have an easier time of it. You will need to make different changes to the device tree file to toggle the LED/reset GPIO pins, due to the fact that the SCM and the Hummingboard map different GPIO to the camera serial connector.

I never had an i2c bus failure while plugging in the camera. Even without any device tree support or drivers loaded the camera still showed up under i2c address 0x36. Use "i2cdetect -y 1" to check whether that's the case for you.