Hi,
We are trying to interface OV5640 camera using the MIPI interface on to a iMX6 processor.
We find that the camera is getting correctly detected in i2C with the correct I2C id (as 0x3c). We found this out by running the i2c detect command and it reports the 3C device on the i2C bus it has been connected.
However, when booting the image (We are using the standard OV5640 device driver that is coming with Linux kernel 3.x), we get the following error message:
ov5640_read_reg: write reg error:reg=300a
ov5640_probe: cannot find camera
On inspecting the code, we find that this error message is coming because of the fact either the i2c read was not successful or the value in the register address 300a was not 0x56. Since we are able to detect this device successfully in i2c detect, can we safely assume that there is no problem in reading on i2c bus?
If this is a correct assumption, what could be the issue for this failure? Any inputs on this will be much appreciated.
Thanks in advance
dear all :
I have a problem on the ov5640 camera and show the same image into four parts.Look at the following picture:
hello,vasan,
I checked OV5640 datasheet, The value of 0x300A and 0x300B is High byte and Low byte of OV5640 CHIP ID. In order to valiate if camera can normally work, you can comment those code related with CHIP ID, and let camera driver continue to run, not return.
Try it ,please !
Regards,
weidong
Hello Weidong,
Thanks for your quick response! I very much appreciate it.
If I comment this section out for checking the High Byte and Low Byte, it goes further below and gives the error in the next i2C command as follows:
ov5640_write_reg: write reg error reg=3635, val=13
Finally, we have the error reported as "v4l2 capture: slave not found" - which I think is happening because once an i2C command write/read fails, the subsequent initialization of that device does not happen. Because of this device registration/init getting failed, the device is reported as not found.
Please let us know if you have any further clues to get this problem resolved for us.
Regards
Vasan
Hello Weldong,
Another related point to this is that on the same i2c Bus (i2c bus 1, which is the second bus), we have some other devices also provisioned to be using the same i2C bus in our schematics. These other devices are: OV5642 (for dual camera support) and HDMI interface.
Will this cause any issue on iMX6? Just thinking out aloud here....
Regards
Vasan
Hello,Vasan,
If devices on i2c1 bus have different i2c address, it is no problem. I checked OV5640 datasheet, there is no 0x3635 register, Could you confirm it again ?
Regards,
Weidong
Hello Wiedong,
Both OV5640 and OV5642 share the same I2C ID but at any point in time we are connecting ONLY one device now. In our subsequent revision of schematics, we are going to put them on two different I2C buses.
I checked and found out that the error message was as I had mentioned on 0x3635 register.
Here is the code snippet (This is the code version that is existing in Linux kernel 3.x version):
static struct reg_value ov5640_init_setting_30fps_VGA[] = {
{0x3103, 0x11, 0, 0}, {0x3008, 0x82, 0, 5}, {0x3008, 0x42, 0, 0},
{0x3103, 0x03, 0, 0}, {0x3017, 0x00, 0, 0}, {0x3018, 0x00, 0, 0},
{0x3034, 0x18, 0, 0}, {0x3035, 0x14, 0, 0}, {0x3036, 0x38, 0, 0},
{0x3037, 0x13, 0, 0}, {0x3108, 0x01, 0, 0}, {0x3630, 0x36, 0, 0},
{0x3631, 0x0e, 0, 0}, {0x3632, 0xe2, 0, 0}, {0x3633, 0x12, 0, 0},
{0x3621, 0xe0, 0, 0}, {0x3704, 0xa0, 0, 0}, {0x3703, 0x5a, 0, 0},
{0x3715, 0x78, 0, 0}, {0x3717, 0x01, 0, 0}, {0x370b, 0x60, 0, 0},
{0x3705, 0x1a, 0, 0}, {0x3905, 0x02, 0, 0}, {0x3906, 0x10, 0, 0},
{0x3901, 0x0a, 0, 0}, {0x3731, 0x12, 0, 0}, {0x3600, 0x08, 0, 0},
{0x3601, 0x33, 0, 0}, {0x302d, 0x60, 0, 0}, {0x3620, 0x52, 0, 0},
{0x371b, 0x20, 0, 0}, {0x471c, 0x50, 0, 0}, {0x3a13, 0x43, 0, 0},
{0x3a18, 0x00, 0, 0}, {0x3a19, 0xf8, 0, 0}, {0x3635, 0x13, 0, 0},
.....
static int ov5640_init_mode(enum ov5640_frame_rate frame_rate,
enum ov5640_mode mode)
{
......
if (mode == ov5640_mode_INIT) {
pModeSetting = ov5640_init_setting_30fps_VGA;
iModeSettingArySize = ARRAY_SIZE(ov5640_init_setting_30fps_VGA);
ov5640_data.pix.width = 640;
ov5640_data.pix.height = 480;
for (i = 0; i < iModeSettingArySize; ++i, ++pModeSetting) {
Delay_ms = pModeSetting->u32Delay_ms;
RegAddr = pModeSetting->u16RegAddr;
Val = pModeSetting->u8Val;
Mask = pModeSetting->u8Mask;
if (Mask) {
retval = ov5640_read_reg(RegAddr, &RegVal);
if (retval < 0)
goto err;
RegVal &= ~(u8)Mask;
Val &= Mask;
Val |= RegVal;
}
retval = ov5640_write_reg(RegAddr, Val);
if (retval < 0)
goto err;
if (Delay_ms)
msleep(Delay_ms);
......
}
Regards
Vasan
Hi Vasan,
Register 0x3635 is available with OV5640 sensor. Check whether you have configured your I2C bus with proper speed, mode and time out. Default I2C speed used is 100KHz or 400KHz. Also, make sure your I2C driver is loaded before loading camera driver.
Regards,
Sathya Kumar P