UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor abuchowicz
Visitor
201 Views
Registered: ‎05-16-2018

How to patch axi-vcu.tcl in Petalinux?

I have a design in Vivado/Petalinux 2017.4.Porting to the newer version is currently impossible.

Unfortunately DTG generates incorrect register addresses for VCU as described here: https://forums.xilinx.com/t5/Embedded-Linux/vcu-problem/td-p/897664

One of users mentions patching the axi_vcu.tcl file. However, I can't find it neither in my project nor in Petalinux. How can I patch this file, so that the correct DTS will be generated?

TIA & Regards,
Andrzej

0 Kudos
4 Replies
Scholar wzab
Scholar
177 Views
Registered: ‎08-24-2011

Re: How to patch axi-vcu.tcl in Petalinux?

The answer record: https://www.xilinx.com/support/answers/70296.html decribes the procedure to patch the device tree generator.

It is worth to look into the patches:
https://www.xilinx.com/Attachment/0001-Update-the-ddr4-driver-if-it-has-more-memory-ranges.patch
https://www.xilinx.com/Attachment/0001-Update-the-logic-to-fix-the-main-memory-node.patch

Probably the patch shown in  https://forums.xilinx.com/t5/Embedded-Linux/vcu-problem/m-p/907222/highlight/true#M30078 may be applied in a similar manner (see the "Solution" section in https://www.xilinx.com/support/answers/70296.html . It describes how and where modify the device-tree-generation_%.bbappend file.).

It is also possible to generate the patch, changing the 2017.4 version of axi_vcu.tcl into the 2018.3 version:

git clone https://github.com/Xilinx/device-tree-xlnx.git
cd device-tree-xlnx
git diff xilinx-v2017.4 xilinx-v2018.3 -- axi_vcu/data/axi_vcu.tcl > ../0001-axi-vcu-2017.4-2018.3.patch

So generated patch, however, contains additional sections, not included in the patch published in the referenced post (I attach the generated patch below).

diff --git a/axi_vcu/data/axi_vcu.tcl b/axi_vcu/data/axi_vcu.tcl
index b9f0e66..a2aef94 100644
--- a/axi_vcu/data/axi_vcu.tcl
+++ b/axi_vcu/data/axi_vcu.tcl
@@ -24,10 +24,19 @@ proc generate {drv_handle} {
     }
     # Generate properties required for vcu node
     set node [gen_peripheral_nodes $drv_handle]
+    if {$node == 0} {
+           return
+    }
     hsi::utils::add_new_dts_param "${node}" "#address-cells" 2 int
     hsi::utils::add_new_dts_param "${node}" "#size-cells" 2 int
-    set tab "\n\t\t\t\t"
-    set reg "0x0 0xa0040000 0x0 0x1000>,$tab<0x0 0xa0041000 0x0 0x1000"
+    hsi::utils::add_new_dts_param "${node}" "#clock-cells" 1 int
+    set vcu_ip [get_cells -hier $drv_handle]
+    set baseaddr [get_baseaddr $vcu_ip no_prefix]
+    set slcr_offset 0x40000
+    set logicore_offset 0x41000
+    set vcu_slcr_reg [format %08x [expr 0x$baseaddr + $slcr_offset]]
+    set logicore_reg [format %08x [expr 0x$baseaddr + $logicore_offset]]
+    set reg "0x0 0x$vcu_slcr_reg 0x0 0x1000>, <0x0 0x$logicore_reg 0x0 0x1000"
     set_drv_prop $drv_handle reg $reg int
     set intr_val [get_property CONFIG.interrupts $drv_handle]
     set intr_parent [get_property CONFIG.interrupt-parent $drv_handle]
@@ -48,24 +57,51 @@ proc generate {drv_handle} {
 
     # Generate child encoder
     set ver [get_ipdetails $drv_handle "ver"]
-    set encoder_node [add_or_get_dt_node -l "encoder" -n "al5e@a0000000" -p $node]
+    set encoder_node [add_or_get_dt_node -l "encoder" -n "al5e@$baseaddr" -p $node]
     set encoder_comp "al,al5e-${ver}"
     set encoder_comp [append encoder_comp " al,al5e"]
     hsi::utils::add_new_dts_param "${encoder_node}" "compatible" $encoder_comp stringlist
-    set encoder_reg "0x0 0xa0000000 0x0 0x10000"
+    set encoder_reg "0x0 0x$baseaddr 0x0 0x10000"
     hsi::utils::add_new_dts_param "${encoder_node}" "reg" $encoder_reg int
     hsi::utils::add_new_dts_param "${encoder_node}" "interrupts" $intr_val int
     hsi::utils::add_new_dts_param "${encoder_node}" "interrupt-parent" $intr_parent reference
     # Fenerate child decoder
-    set decoder_node [add_or_get_dt_node -l "decoder" -n "al5d@a0020000" -p $node]
+    set decoder_offset 0x20000
+    set decoder_reg [format %08x [expr 0x$baseaddr + $decoder_offset]]
+    set decoder_node [add_or_get_dt_node -l "decoder" -n "al5d@$decoder_reg" -p $node]
     set decoder_comp "al,al5d-${ver}"
     set decoder_comp [append decoder_comp " al,al5d"]
     hsi::utils::add_new_dts_param "${decoder_node}" "compatible" $decoder_comp stringlist
-    set decoder_reg "0x0 0xa0020000 0x0 0x10000"
+    set decoder_reg "0x0 0x$decoder_reg 0x0 0x10000"
     hsi::utils::add_new_dts_param "${decoder_node}" "reg" $decoder_reg int
     hsi::utils::add_new_dts_param "${decoder_node}" "interrupts" $intr_val int
     hsi::utils::add_new_dts_param "${decoder_node}" "interrupt-parent" $intr_parent reference
-  
+    set clknames "pll_ref aclk vcu_core_enc vcu_core_dec vcu_mcu_enc vcu_mcu_dec"
+    overwrite_clknames $clknames $drv_handle
+    set ip [get_cells -hier $drv_handle]
+    set pins [get_pins -of_objects [get_nets -of_objects [get_pins -of_objects $ip "vcu_resetn"]]]
+           foreach pin $pins {
+                set sink_periph [::hsi::get_cells -of_objects $pin]
+                set sink_ip [get_property IP_NAME $sink_periph]
+                if {[string match -nocase $sink_ip "xlslice"]} {
+                        set gpio [get_property CONFIG.DIN_FROM $sink_periph]
+                        set pins [get_pins -of_objects [get_nets -of_objects [get_pins -of_objects $sink_periph "Din"]]]
+                        foreach pin $pins {
+                                set periph [::hsi::get_cells -of_objects $pin]
+                                set ip [get_property IP_NAME $periph]
+                                set proc_type [get_sw_proc_prop IP_NAME]
+                                if {[string match -nocase $proc_type "psu_cortexa53"] } {
+                                        if {[string match -nocase $ip "zynq_ultra_ps_e"]} {
+                                                set gpio [expr $gpio + 78]
+                                                hsi::utils::add_new_dts_param "$node" "reset-gpios" "gpio $gpio 0" reference
+                                        }
+                                }
+                                if {[string match -nocase $ip "axi_gpio"]} {
+                                         hsi::utils::add_new_dts_param "$node" "reset-gpios" "$periph $gpio 0 1" reference
+                                }
+                        }
+                }
+           }
 }
 
 proc get_ipdetails {drv_handle arg} {

I don't know if so generated DT will be compatible with the 2017.4 version of the IP core.

Regards,
Wojtek

 

0 Kudos
Visitor abuchowicz
Visitor
154 Views
Registered: ‎05-16-2018

Re: How to patch axi-vcu.tcl in Petalinux?

Dear Wojtek,

I have applied the patch to the device tree generator created as you described in your latest post. However the following error occured during the compilation

| invalid command name "overwrite_clknames"
| ERROR: [Hsi 55-1545] Problem running tcl command ::sw_axi_vcu::generate : invalid command name "overwrite_clknames"
|     while executing
| "overwrite_clknames $clknames $drv_handle"
|     (procedure "::sw_axi_vcu::generate" line 66)
|     invoked from within
| "::sw_axi_vcu::generate U_PROC_vcu_system_vcu_0"

I've modified the patch by replacing the line containing the command 'overwrite_clknames' with an empty line. The modified patch is listed below

diff --git a/axi_vcu/data/axi_vcu.tcl b/axi_vcu/data/axi_vcu.tcl
index b9f0e66..a2aef94 100644
--- a/axi_vcu/data/axi_vcu.tcl
+++ b/axi_vcu/data/axi_vcu.tcl
@@ -24,10 +24,19 @@ proc generate {drv_handle} {
     }
     # Generate properties required for vcu node
     set node [gen_peripheral_nodes $drv_handle]
+    if {$node == 0} {
+           return
+    }
     hsi::utils::add_new_dts_param "${node}" "#address-cells" 2 int
     hsi::utils::add_new_dts_param "${node}" "#size-cells" 2 int
-    set tab "\n\t\t\t\t"
-    set reg "0x0 0xa0040000 0x0 0x1000>,$tab<0x0 0xa0041000 0x0 0x1000"
+    hsi::utils::add_new_dts_param "${node}" "#clock-cells" 1 int
+    set vcu_ip [get_cells -hier $drv_handle]
+    set baseaddr [get_baseaddr $vcu_ip no_prefix]
+    set slcr_offset 0x40000
+    set logicore_offset 0x41000
+    set vcu_slcr_reg [format %08x [expr 0x$baseaddr + $slcr_offset]]
+    set logicore_reg [format %08x [expr 0x$baseaddr + $logicore_offset]]
+    set reg "0x0 0x$vcu_slcr_reg 0x0 0x1000>, <0x0 0x$logicore_reg 0x0 0x1000"
     set_drv_prop $drv_handle reg $reg int
     set intr_val [get_property CONFIG.interrupts $drv_handle]
     set intr_parent [get_property CONFIG.interrupt-parent $drv_handle]
@@ -48,24 +57,51 @@ proc generate {drv_handle} {
 
     # Generate child encoder
     set ver [get_ipdetails $drv_handle "ver"]
-    set encoder_node [add_or_get_dt_node -l "encoder" -n "al5e@a0000000" -p $node]
+    set encoder_node [add_or_get_dt_node -l "encoder" -n "al5e@$baseaddr" -p $node]
     set encoder_comp "al,al5e-${ver}"
     set encoder_comp [append encoder_comp " al,al5e"]
     hsi::utils::add_new_dts_param "${encoder_node}" "compatible" $encoder_comp stringlist
-    set encoder_reg "0x0 0xa0000000 0x0 0x10000"
+    set encoder_reg "0x0 0x$baseaddr 0x0 0x10000"
     hsi::utils::add_new_dts_param "${encoder_node}" "reg" $encoder_reg int
     hsi::utils::add_new_dts_param "${encoder_node}" "interrupts" $intr_val int
     hsi::utils::add_new_dts_param "${encoder_node}" "interrupt-parent" $intr_parent reference
     # Fenerate child decoder
-    set decoder_node [add_or_get_dt_node -l "decoder" -n "al5d@a0020000" -p $node]
+    set decoder_offset 0x20000
+    set decoder_reg [format %08x [expr 0x$baseaddr + $decoder_offset]]
+    set decoder_node [add_or_get_dt_node -l "decoder" -n "al5d@$decoder_reg" -p $node]
     set decoder_comp "al,al5d-${ver}"
     set decoder_comp [append decoder_comp " al,al5d"]
     hsi::utils::add_new_dts_param "${decoder_node}" "compatible" $decoder_comp stringlist
-    set decoder_reg "0x0 0xa0020000 0x0 0x10000"
+    set decoder_reg "0x0 0x$decoder_reg 0x0 0x10000"
     hsi::utils::add_new_dts_param "${decoder_node}" "reg" $decoder_reg int
     hsi::utils::add_new_dts_param "${decoder_node}" "interrupts" $intr_val int
     hsi::utils::add_new_dts_param "${decoder_node}" "interrupt-parent" $intr_parent reference
-  
+    set clknames "pll_ref aclk vcu_core_enc vcu_core_dec vcu_mcu_enc vcu_mcu_dec"
+    
+    set ip [get_cells -hier $drv_handle]
+    set pins [get_pins -of_objects [get_nets -of_objects [get_pins -of_objects $ip "vcu_resetn"]]]
+           foreach pin $pins {
+                set sink_periph [::hsi::get_cells -of_objects $pin]
+                set sink_ip [get_property IP_NAME $sink_periph]
+                if {[string match -nocase $sink_ip "xlslice"]} {
+                        set gpio [get_property CONFIG.DIN_FROM $sink_periph]
+                        set pins [get_pins -of_objects [get_nets -of_objects [get_pins -of_objects $sink_periph "Din"]]]
+                        foreach pin $pins {
+                                set periph [::hsi::get_cells -of_objects $pin]
+                                set ip [get_property IP_NAME $periph]
+                                set proc_type [get_sw_proc_prop IP_NAME]
+                                if {[string match -nocase $proc_type "psu_cortexa53"] } {
+                                        if {[string match -nocase $ip "zynq_ultra_ps_e"]} {
+                                                set gpio [expr $gpio + 78]
+                                                hsi::utils::add_new_dts_param "$node" "reset-gpios" "gpio $gpio 0" reference
+                                        }
+                                }
+                                if {[string match -nocase $ip "axi_gpio"]} {
+                                         hsi::utils::add_new_dts_param "$node" "reset-gpios" "$periph $gpio 0 1" reference
+                                }
+                        }
+                }
+           }
 }
 
 proc get_ipdetails {drv_handle arg} {

The project, after applying the above patch, compiles with no errors.

I have successfully modprobe'd the xlnx_vcu driver, but the following error was reported:

[  127.860167] xilinx-vcu 80140000.vcu: failed to set logicoreIP refclk rate

The patch partially solved the problem: vcu register addresses have the correct values now, but vcu is still not properly initialized.

Regards,

Andrzej

 

0 Kudos
Scholar wzab
Scholar
145 Views
Registered: ‎08-24-2011

Re: How to patch axi-vcu.tcl in Petalinux?

The lacking "overwrite_clknames" procedure is very simple ( https://github.com/Xilinx/device-tree-xlnx/blob/b7466bbeeede15ec72143e3c3466e067589821a1/device_tree/data/common_proc.tcl#L1636 ):

proc overwrite_clknames {clknames drv_handle} {
        set_drv_prop $drv_handle "clock-names" $clknames stringlist
}

Maybe it is sufficient to add it?

I attach the patch that should do that.

Regards,
Wojtek

0 Kudos
Visitor abuchowicz
Visitor
126 Views
Registered: ‎05-16-2018

Re: How to patch axi-vcu.tcl in Petalinux?

The patch solved the 'invalid command name "overwrite_clknames"' problem but the 'xilinx-vcu 80140000.vcu: failed to set logicoreIP refclk rate' error message still is displayed.

I've tried to encode the YUV sequence using the 'AL_Encoder.exe' application (from petalinux-2017.4). Unfortunately the app hangs up the entire system after encoding first 15 frames of the input sequence.

Regards,

Andrzej

 

0 Kudos