Author Topic: zynqberry demo project 1 iic initalization of the csi camera  (Read 2520 times)

lyding

  • Active Member
  • *
  • Posts: 5
zynqberry demo project 1 iic initalization of the csi camera
« on: August 27, 2018, 12:09:03 PM »
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

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 397
Re: zynqberry demo project 1 iic initalization of the csi camera
« Reply #1 on: August 28, 2018, 12:43:52 PM »
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

  • Active Member
  • *
  • Posts: 5
Re: zynqberry demo project 1 iic initalization of the csi camera
« Reply #2 on: August 28, 2018, 03:29:32 PM »
Thank you very much,
again :D

lyding

Eric

  • Active Member
  • *
  • Posts: 7
Re: zynqberry demo project 1 iic initalization of the csi camera
« Reply #3 on: September 07, 2018, 05:16:00 PM »
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

  • Active Member
  • *
  • Posts: 7
Re: zynqberry demo project 1 iic initalization of the csi camera
« Reply #4 on: September 11, 2018, 05:27:02 PM »
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

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 397
Re: zynqberry demo project 1 iic initalization of the csi camera
« Reply #5 on: September 12, 2018, 02:56:10 PM »
Hello,

functions should be like
Code: [Select]
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

  • Active Member
  • *
  • Posts: 7
Re: zynqberry demo project 1 iic initalization of the csi camera
« Reply #6 on: September 12, 2018, 05:33:15 PM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1605
Re: zynqberry demo project 1 iic initalization of the csi camera
« Reply #7 on: September 13, 2018, 12:00:42 PM »
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

  • Active Member
  • *
  • Posts: 7
Re: zynqberry demo project 1 iic initalization of the csi camera
« Reply #8 on: September 19, 2018, 12:21:49 PM »

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

  • Active Member
  • *
  • Posts: 7
Re: zynqberry demo project 1 iic initalization of the csi camera
« Reply #9 on: September 20, 2018, 06:46:46 PM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1605
Re: zynqberry demo project 1 iic initalization of the csi camera
« Reply #10 on: September 24, 2018, 08:24:19 AM »
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

  • Active Member
  • *
  • Posts: 7
Re: zynqberry demo project 1 iic initalization of the csi camera
« Reply #11 on: September 25, 2018, 05:34:28 PM »

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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1605
Re: zynqberry demo project 1 iic initalization of the csi camera
« Reply #12 on: September 26, 2018, 10:47:18 AM »
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

  • Active Member
  • *
  • Posts: 7
Re: zynqberry demo project 1 iic initalization of the csi camera
« Reply #13 on: September 26, 2018, 06:06:23 PM »

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

Thank you all

Gloria

  • Active Member
  • *
  • Posts: 18
Re: zynqberry demo project 1 iic initalization of the csi camera
« Reply #14 on: April 06, 2021, 01:17:31 PM »
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

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 397
Re: zynqberry demo project 1 iic initalization of the csi camera
« Reply #15 on: April 07, 2021, 09:10:57 AM »
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

  • Active Member
  • *
  • Posts: 18
Re: zynqberry demo project 1 iic initalization of the csi camera
« Reply #16 on: April 07, 2021, 09:39:33 AM »
Hi, what should I do to switch  I2C mux to the right bus ?