Xilinx / kria-vitis-platforms

Kria Vitis platforms and overlays
Apache License 2.0
87 stars 42 forks source link

Generated device tree file doesn't load MIPI driver #14

Open ioindustries opened 2 years ago

ioindustries commented 2 years ago

I have built the kv260_ispMipiRx_vcu_DP platform provided in this repository for use with the smartcam application on a KV260 starter kit.

My goal is to add VCU, MIPI, and DP support to my custom carrier card design and run the same smartcam application with the use of the PetaLinux drivers which I believe are at /dev/allegroIP (for VCU) and /dev/media0 (for MIPI). I want to be able to create and boot a PetaLinux project with those drivers loaded for this platform before I attempt to do it on my custom one.

So I created a Petalinux project from the kv260_ispMipiRx_vcu_DP.xsa file using --get-hw-description and the OS boots up properly but doesn't load the VCU or MIPI drivers. The default app that's loaded with xmutil is kv260-dp which doesn't load those drivers. When I load the kv260-smartcam app, all the drivers load properly. So I'm assuming the drivers are only loaded through accelerated apps using xmutil?

I generated a device tree overlay file from the kv260_ispMipiRx_vcu_DP.xsa by using the instructions here: Generate Device Tree Overlay

xsct

hsi open_hw_design <path to kv260_ispMipiRx_vcu_DP.xsa>
hsi set_repo_path <path to device-tree-xlnx repository>
hsi create_sw_design device-tree -os device_tree -proc psu_cortexa53_0
hsi set_property CONFIG.dt_overlay true [hsi::get_os]
hsi set_property CONFIG.dt_zocl true [hsi::get_os]
hsi generate_target -dir <desired_dts_filename>
hsi close_hw_design [hsi current_hw_design]

dtc -@ -O dtb -o pl.dtbo pl.dtsi

Then, I built an example vector add accelerated application using the KV260 Platform Tutorial and moved it to the accelerated app directory (/lib/firmware/xilinx) along with the DTBO device tree overlay file generated above. When I load it with xmutil, it loads the VCU drivers correctly to /dev/allegroIP but it doesn't load the MIPI drivers which I believe should be at /dev/media0.

Interestingly, I tried generating a DTBO file from the DTSI file found here and it loads all the drivers properly. This leads me to believe that there's something wrong with the DTSI file I generated myself. Can somebody help me figure out why my generated device tree file doesn't load the MIPI driver properly the way the kv260-smartcam.dtsi does? Thanks!

Here's my generated DTSI file can be found here.

marcobergamin-videam commented 1 year ago

I think I have a similar problem. Following the Petalinux workflow, the builtin smartcam app works, but when I try to load my app (built following this tutorial) the /dev/media0 device is not loaded. Following the Ubuntu workflow, the app created works perfectly and I can see the /dev/media0.

chkohn commented 1 year ago

The device tree generator (dtg) tool that generates a dts(i) from an xsa does not always produce a complete or correct device tree. it can be used as a starting point but the user may need to further tweak the dtsi for correct functionality.

Having a golden reference like the smartcam dts file allows to compare individual dt nodes for missing or incorrect properties. It is also useful to refer to the device tree bindings doc of each driver in the kernel tree and cross check the generated results against the bindings doc.

Specifically for video pipelines, the device tree nodes are connected as a graph where nodes represent the v4l subdevices and ports represent how they are linked. dtg may not be able to generate this correctly. dtg is also not aware of board-level components.

Hope this helps troubleshoot your dtsi.

marcobergamin-videam commented 1 year ago

Hello @chkohn, thanks for your answer. Turns out my dtsi was fine, the problem was that the Petalinux kernel does not include this driver which, I guess, is builtin in the Ubuntu Kernel. Took me a lot of time to understand this problem because I was focused on the device tree and the Vivado design. Best regards, Marco

chkohn commented 1 year ago

@marcobergamin-videam glad you figured it out and thanks for posting the solution to your problem. hopefully it will help others that run into the same problem.