Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pcam not generating frames #27

Open
fpgadeveloper opened this issue Nov 17, 2022 · 10 comments
Open

Pcam not generating frames #27

fpgadeveloper opened this issue Nov 17, 2022 · 10 comments

Comments

@fpgadeveloper
Copy link

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:

  • I have never been able to get an image into the notebook - VDMA just waits forever, at this line frame = mipi.readframe().
  • When probing the MIPI pins with an oscilloscope, I see that there is nothing coming out of the image sensor, even after the line mipi.start().
  • When I use the same Pcam on PYNQ-ZU board, the same notebook works fine (ie. I get an image in the notebook and when I probe the MIPI pins, I can see data coming out of the image sensor).
  • When I use Adam Taylor's Kria Pcam example on the same Kria board with the same Pcam, it works fine and I get video on the monitor.
  • When I use some custom code to manually configure the Pcam in PYNQ, I can get data to come out of the MIPI pins of the image sensor.

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
Copy link
Collaborator

Hi @fpgadeveloper,

We are investigating. We'll get back to you

Mario

@mariodruiz
Copy link
Collaborator

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
Copy link
Author

fpgadeveloper commented Nov 17, 2022

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
Copy link
Author

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
Copy link
Collaborator

mariodruiz commented Nov 17, 2022

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
Copy link

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

@fpgadeveloper
Copy link
Author

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
Copy link

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
Copy link

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

@mariodruiz
Copy link
Collaborator

Hi @meanarchist,

There's a long thread here with a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants