Xilinx / Kria-PYNQ

PYNQ support and examples for Kria SOMs
Other
90 stars 40 forks source link

Pcam not generating frames #27

Open fpgadeveloper opened 1 year ago

fpgadeveloper commented 1 year ago

I am currently using Ubuntu 22.04, however I have tested this on the Ubuntu 20.04.3 image and I get the same result.

In the mipi_to_displayport.ipynb notebook, I am unable to get an image out of the Pcam and into the notebook.

These are my observations:

From those tests, I think we can be confident that both my Kria and my Pcam are fine and that they can work together. I think that we can also suspect that the problem is related to the configuration of the Pcam. Perhaps it is not pausing enough between I2C read/writes, perhaps the traces are longer on the Kria vs PYNQ-ZU which creates extra latency that is not accounted for by the driver. I notice that the decoupling cap on the Kria is 1uF whereas it is 10uF + 100nF on the PYNQ-ZU. I notice that the Pcam enable line on the Kria is driven by an open drain with a 10K pullup vs the PYNQ-Z1 which uses a push-pull output driver. Perhaps my flex cable is not so great (it came with the Pcam). These differences might mean that longer delays are necessary, but I'm just guessing at this point. It is already operating at a low frequency (100kHz) so perhaps it's more about the delays between reads/writes. I'll keep debugging this and let you know if I figure it out.

mariodruiz commented 1 year ago

Hi @fpgadeveloper,

We are investigating. We'll get back to you

Mario

mariodruiz commented 1 year ago

Hi @fpgadeveloper,

Are the i2c devices available after the BaseOverlay object is created?

This command below should return 7 i2c devices

i2cdetect -l

If you get 7 devices with the command above, what is the output of this other command?

i2cdetect -y 6

Mario

fpgadeveloper commented 1 year ago

Hi @mariodruiz ,

Yes, after I load the base overlay, I can see the I2C devices:

root@kria:/# i2cdetect -l
i2c-1   i2c             Cadence I2C at ff030000                 I2C adapter
i2c-2   i2c             ZynqMP DP AUX                           I2C adapter
i2c-3   i2c             xiic-i2c 800b0000.i2c                   I2C adapter
i2c-4   i2c             i2c-3-mux (chan_id 0)                   I2C adapter
i2c-5   i2c             i2c-3-mux (chan_id 1)                   I2C adapter
i2c-6   i2c             i2c-3-mux (chan_id 2)                   I2C adapter
i2c-7   i2c             i2c-3-mux (chan_id 3)                   I2C adapter

This is the output from i2cdetect -y 6:

root@kria:/# i2cdetect -y 6
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- UU -- -- --   

After running the next line mipi = base.mipi (this is needed to raise the enable signal of the camera), I can now see the camera responding:

root@kria:/# i2cdetect -y 6
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- UU -- -- --      

However, like before, there is nothing coming out of the image sensor.

Jeff

fpgadeveloper commented 1 year ago

Hey @mariodruiz ,

You gave me an idea. The default value for the Pcam enable signal should probably be 1, just like it is in the PYNQ-ZU base design. In the Kria KV260 base design, the default value is not set:

Kria:

  set gpio_ip_reset [ create_bd_cell -type ip -vlnv xilinx.com:ip:axi_gpio:2.0 gpio_ip_reset ]
  set_property -dict [ list \
   CONFIG.C_ALL_OUTPUTS {1} \
   CONFIG.C_ALL_OUTPUTS_2 {1} \
   CONFIG.C_GPIO2_WIDTH {1} \
   CONFIG.C_GPIO_WIDTH {1} \
   CONFIG.C_IS_DUAL {1} \
 ] $gpio_ip_reset

PYNQ-ZU:

  set gpio_ip_reset [ create_bd_cell -type ip -vlnv xilinx.com:ip:axi_gpio:2.0 gpio_ip_reset ]
  set_property -dict [ list \
   CONFIG.C_ALL_OUTPUTS {1} \
   CONFIG.C_ALL_OUTPUTS_2 {1} \
   CONFIG.C_GPIO2_WIDTH {1} \
   CONFIG.C_GPIO_WIDTH {1} \
   CONFIG.C_IS_DUAL {1} \
   CONFIG.C_DOUT_DEFAULT_2 {0x00000001} \
 ] $gpio_ip_reset

On my board, it seems to be defaulting to 0, which I have confirmed by probing with the oscilloscope, but we can also see that because it doesn't respond to I2C reads until we run mipi = base.mipi. When you run i2cdetect -y 6 after only loading the base overlay, do you get a response from the camera?

mariodruiz commented 1 year ago

do you get a response from the camera?

No, I don't. Only, UU in the address 0x74. But, then the driver initializes properly and I can transfer images.

ihsanalhafiz commented 1 year ago

hi guys, do you have any solution for this? i got similar problem.

fpgadeveloper commented 1 year ago

I've been able to test my Pcam (and others) on another platform, using my own baremetal driver and I haven't seen these issues occur. So my current thought is that the PYNQ PCam driver is not quite right yet, it needs to be tested with more Pcams. I'd dig deeper but I had to move onto other priorities.

ihsanalhafiz commented 1 year ago

For my case, sometime it works fine, but sometime does not work. but mostly does not. i got this error zocl-drm axi:zyxclmm_drm: IRQ index 0 not found

do you think it is because the interrupt error?

meanarchist commented 5 months ago

Guys I still have this issue were anyone able to resolve it? @mariodruiz any updates on how to resolve this?

mariodruiz commented 5 months ago

Hi @meanarchist,

There's a long thread here with a workaround.