News:

Attention: For security reasons,please choose a user name *different* from your login name.
Also make sure to choose a secure password and change it regularly.

Main Menu

zynqberry demo project 1 iic initalization of the csi camera

Started by lyding, August 27, 2018, 12:09:03 PM

Previous topic - Next topic

lyding

Hello,
a few days ago I asked about how to setup the csi to hdmi camera stream
of the zynqberry demo1 project in a bare metal application.
I was told I could use the code of the fsbl as the initialization of the in and out vdma
as well as the initialization of the video timing controller happens there.
That all works fine, I can draw primitives onto the screen by writing directly into the framebuffer.
Sadly the code of my old project to initialize the camera doesnt seem to work. Is there a code
example for this as well?

I hope you can help me,
lyding

Oleksandr Kiyenko

Hello.

You can find camera initialization code at te0726_m_demo1\os\petalinux\project-spec\meta-user\recipes-apps\rpicam\rpicam
For a bare-metal application, you just need to replace Linux functions in i2c_reg_read and i2c_reg_write to Xilinx I2C functions for bare-metal apps.


Best regards
Oleksandr Kiyenko

lyding


Eric

Hello,

I have the same problem as Lyding and so I try to replace the Linux functions in i2c_reg_read and i2c_reg_write to Xilinx I2C functions for bare-metal apps but I have not succeeded at the moment and I am a little blocked...
Lyding, have you managed to adapt these functions with the Xilinx I2C functions and make the application work?
If one of you has a piece of code, I'm interested.
Thanks a lot for your help.

Best regards
Eric

Eric

Hello,

I am always blocked with the adaptation of i2c_reg_read and i2c_reg_write to bare-metal apps.
To bypass these methods I'm trying to communicate using XiicPs functions.
I arrive to select the I2C Mux channel but after I cannot read the register CS_CMMN_CHIP_ID_H for example.

Source extract:
   /*
    * Receiving Register Data
    */
   u8 MsgPointRd = 0;
   Status = XIicPs_MasterRecvPolled(&IicInstance, 0x300A, 2, IIC_SLAVE_ADDR_RD);
   if (Status != XST_SUCCESS) {
      return XST_FAILURE;
   }
with IIC_SLAVE_ADDR_RD = 0x6D

Am I missing a step to initalize the camera properly?

I have seen that 2 GPIOs are connected in CSI2 bus? Are they needed in the power up sequence?

Thanks
Eric

Oleksandr Kiyenko

Hello,

functions should be like

int i2c_reg_write(XIicPs *InstancePtr, u8 chip_addr, u16 reg_addr, u8 reg_val){
    u8 WriteBuffer[3];
int Status;

WriteBuffer[0] = reg_addr >> 8;
WriteBuffer[1] = reg_addr & 0xFF;
WriteBuffer[2] = reg_val;
    Status = XIicPs_MasterSendPolled(&InstancePtr, WriteBuffer, 3, chip_addr);
    if (Status != I2C_SUCCESS) {
return Status;
    }

    /* Wait until bus is idle to start another transfer */
    while (XIicPs_BusIsBusy(&I2cInstancePtr));

return I2C_SUCCESS;
}

u8 i2c_reg_read(XIicPs *InstancePtr, u8 chip_addr, u16 reg_addr)
{
u8 wr_data[2];
u8 rd_data;

wr_data[0] = reg_addr >> 8;
wr_data[1] = reg_addr & 0xFF;
XIicPs_MasterSendPolled(InstancePtr, wr_data, 2, chip_addr);
XIicPs_MasterRecvPolled(InstancePtr, &rd_data, 1, chip_addr);
while (XIicPs_BusIsBusy(InstancePtr));
return rd_data;
}



Best regards
Oleksandr Kiyenko

Eric

Hey,

Thanks Oleksandr for your reply.

I'm now able to read the chip ID :) but I'm still not seeing anything from the camera.

I took a look into the configuration sequence (Enable/Disable, Reset...)
When I activate the reset and read the value of register 0x0103 I receive 0x00 and not 0x01 as set
        i2c_reg_write(&IicInstance, IIC_SLAVE_ADDR, 0x0103, 0x01);                 // Reset
        xil_printf("Registre 0x0103 : 0x%02x\n", i2c_reg_read(&IicInstance, IIC_SLAVE_ADDR, 0x0103));

The reading of the registers set in ov5647_sensor_common_10bit and ov5647_sensor_1296_968_30 seems OK.

Is it normal?

Regards,
Eric

JH

Hi,
did you check:

       
  • te0726_m_demo1\os\petalinux\project-spec\meta-user\recipes-apps\rpicam\rpicam
  • --> rpicam.c
  • --> sensor_config.h
of the reference design?
This is only an example for Raspberry Pi Camera Rev 1.3 or Camera Rev 2.1. For other configuration of this sensor chip, you must search by yourself.

brJohn


Eric


Thank you for your replies.
But I have downloaded demo1 (2017.1) but there is no difference between directories demo3 and demo1 (rpicam.c, sensor_config.h...).
I read the register 0x302A SC_CMMN_SUB_ID, does it correspond to the camera version (bits 0-2) ?
If it is, it appears I'm working with version 1 (I read B1.)
And so I won't need the second part of the configuration (starting with printf("Camera V2.X configuration\n");)

Still having issues with register 0x0103, I cannot read 0x01 after writing into it.
Any clues on that?

Thanks
Eric

Eric

Really sorry to bother you again with my problem.

I ave tested the camera initialization with the sources "rpi-camera.c" and "sensor_config.h" from the directory : "te0726_m_demo1\os\petalinux\components\apps\rpi-camera"
(from the link TE0726/Reference_Design/2016.2/te0726_m_demo1), it does not work any better.
I have the same behavior as with the sources "rpicam.c" and "sensor_config.h" from the directory : "zynqberrydemo3\os\petalinux\project-spec\meta-user\recipes-apps\rpicam\files"
(from the link TE0726/Reference_Design/2017.1/zynqberrydemo3).

The rpicam sources of zynqberrydemo3 have additional configurations but concerning the CAMERA_V1_3 part, the configuration is identical:
  - ov5647_sensor_common_10bit = sensor_common_10bit
  - ov5647_sensor_1296_968_30  = sensor_1296_968_30.

I do not see what does not work for this camera initialization?
Surely there is one thing to do that I forget?

On my previous posts, I have indicated read the value 0xB1 for the register SC_CMMN_SUB_ID (0x302A), is that it?
The registers 0x0100 and 0x0103 are not readable?
The SCCB registers must have the default values ? This is the case for me except the SRB CTRL register where I read 0xF5 instead of 0xF9?

For my project, I started with the file: "te0726-zynqberrydemo3_noprebuilt-vivado_2017.1-build_03_20170705132834.zip", I just changed the version of Vivado in 2017.2 and launched the various steps...

Many thanks in advance for your help

Best Regards,
Eric

JH

Dear Eric,

does the prebuilt files from your 2017.1 demo works with your hw setup? Which camera did you use?

PS Demo 1,2,3 are the same HW/SW-project only only changes on FSBL DMA controller initialisation and OS configuration was done.

There was also a different on the video stream between RPI camera v1.3 and v2.1. this selection was done with linux script, see (17.1 design):
TE0726\zynqberrydemo1\misc\sd_script\init.sh

br
John

Eric


Thank you for your help JH.
Indeed, by activating bit 0 register 0x43c10040 at '1', an image capture is successful  :)

On the other hand, to have the video streaming, there is something to configure, to activate?
At the end of my main.c file, I must just make vdma_out_init, vdma_in_init and "while(1)"?
Thanks in advance for your new help

Eric

JH

Hi,
no 43c10040 enables the frame buffer and set correct stream setup for 1.3 or 2.1 (I think there was only some different in colour).
If frame buffer is enabled, that the frames will continuously write into the memory area. What you do with this is you decision.
In Demo 1  frame buffer address area from camera was the same as frame buffer as from the hdmi output, so you see the video stream on the monitor. On the other 2 demos it was different area, so Debian deskto or Video player output was seen on the monitor.

br
John

Eric


Now I have streaming video !!
I putted VDMAInCfg.EnableFrameCounter = 0 in vdma_in_init and it worked  :)

Thank you all

Gloria

Hi,
I also want to use the sensor_config.h and rpicam.c in vitis, and I replace the iic_write/read_reg.
However, the project does not work.
I have a few questions.
Do I need add and constrain the CSI GPIO0 and GPIO1?
My camera is IMX219 and the address in the demo is 0x36 and 0x10?
The address seems to be wrong...
The IIC MUX address is 0x70, how should I get the address of IIC of CSI?
Thank you very much!
Looking forward to your reply!

Oleksandr Kiyenko

Hi Gloria.

> Do I need add and constrain the CSI GPIO0 and GPIO1?
Don't think that you really need it.

>My camera is IMX219 and the address in the demo is 0x36 and 0x10?
>The address seems to be wrong...
>The IIC MUX address is 0x70, how should I get the address of IIC of CSI?
Please at first run the Linux demo project. With this project, you can check if all your hardware is connected correctly and working.
Then using "i2cdetect" command you can scan I2C buses and find your camera. As I remember it should be on bus 5.
Then if you want to implement baremetal app, you will need to switch I2C mux to the right bus and configure camera.


Best regards
Oleksandr Kiyenko

Gloria

Hi, what should I do to switch  I2C mux to the right bus ?