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: 

Customizing a ZynqMP Platform Using PetaLinux

Moderator
Moderator
6 0 428

Author’s Note: This content is a guest blog originally written by Masaharu Takizawa from PALTEK Corporation, Japan.

This blog entry covers the basics of configuring the device tree to add the details of external peripherals and third-party applications to a PetaLinux project.

In some cases, the device tree does not generate all of the required information needed for the peripheral of interest (for example, Ethernet PHY information).

In these cases, you will need to add this board level and board-specific information manually to the device tree file (system-user.dtsi).

Top-level overview of the PetaLinux tool flow:picture1.PNG

 

Basic steps to create and configure the PetaLinux project for ZynqMP platforms:

  1. The Petalinux installer and BSP files are available on Xilinx.com at the link below:

https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-design-tools.html

  1. source the PetaLinux settings using this command:

        source <petalinux_installation_path>/settings.sh

  1. Create the PetaLinux ZynqMP project:

    1. BSP Flow:
      petalinux-create -t project -s xilinx-zcu102-v2019.1-final.bsp
      (This example is for a ZCU102 board)
      Note: the BSP files need to be downloaded from Xilinx.com

    2. Template Flow:
      petalinux-create --type project --template zynqMP --name custom-project

  2. Importing the HDF
    1. petalinux-config --get-hw-description=<JUST_PATH_OF_HDF/XSA_LOCATION>
    2. Change the MACHINE_NAME value to the one you want in DTG SETTINGS.
      The possible values for the machine names are: ac701-full, ac701-lite, kc705-full, kcu105, zc1275-revb, zcu1285- reva, zc1751-dc1, zc1751-dc2, zc702, zc706, avnet-ultra96-rev1, zcu100-revc, zcu102- rev1.0, zcu104-revc, zcu106-reva, zcu111-reva, zedboard, vcu118- rev2.0, sp701-rev1.0

      pic2.PNG
  3. Save and Exit the project config
  4. Run this command to build the entire project:
    petalinux-build

Overview of PetaLinux Build Flow:

pic3.PNG

Upon building the project successfully, PetaLinux auto-generates the various device tree files and the build images targeted for the evaluation or the custom platform.

Below is the tree structure of various components created when you build the PetaLinux project:

Paltek-1.PNG

Steps to Edit the device tree file to add the Ethernet PHY information

It is recommended to use the system-user.dtsi file for adding, modifying and deleting nodes or values.

System user DTSIs are added at the end, which means that the values they contain are at a higher priority.

You can overwrite any existing value in other DTSIs by defining them in system user DTSIs.

Here is an example of adding PHY information to the PS ethernet node:

/dts-v1/;

/include/ "system-conf.dtsi"

/ {

};

Describe outside this "};".

&gem0 {

  phy-handle = <&phy0>;

  ps7_ethernet_0_mdio: mdio {

   phy0: phy@7 {

    compatible = "marvell,88e1116r";

    device_type = "ethernet-phy";

    reg = <7>;

   };

  };

};

※ Definitions that do not exist in template

/include/ "system-conf.dtsi"

/ {

 << Fill in here >>

};

 

Define gem0 in zynqmp.dtsi:

gem0: ethernet@ff0b0000 {

 compatible = "cdns,zynqmp-gem";

 status = "disabled";

 interrupt-parent = <&gic>;

 interrupts = <0 57 4>, <0 57 4>;

 reg = <0x0 0xff0b0000 0x0 0x1000>;

 clock-names = "pclk", "hclk", "tx_clk";

 #address-cells = <1>;

 #size-cells = <0>;

 #stream-id-cells = <1>;

 iommus = <&smmu 0x874>;

 power-domains = <&pd_eth0>;

};

 

 

The device tree file system-user.dtsi can be used to do the following:

    1. Add a Node - An unregistered Node or Sub Node can be added to the Device Tree for the Evaluation Board and Device Tree for the PCW.
      • In the example below we can add information to system-user.dtsi so that GEM0 which was previously using MIO (RGMII) is changed to EMIO (GMII) and connected to another PHY chip via a GMII to RGMII IP:

        zynq-7000.dtsi

        gem0: ethernet@e000b000 {

          compatible = "cdns,zynq-gem", "cdns,gem";

          reg = <0xe000b000 0x1000>;

          status = "disabled";

          interrupts = <0 22 4>;

          clocks = <&clkc 30>, <&clkc 30>, <&clkc 13>;

          clock-names = "pclk", "hclk", "tx_clk";

          #address-cells = <1>;

          #size-cells = <0>;

        };


        zc702.dtsi:

        &gem0 {

          phy-handle = <&ethernet_phy>;

          pinctrl-names = "default";

          pinctrl-0 = <&pinctrl_gem0_default>;

          phy-reset-gpio = <&gpio0 11 0>;

          phy-reset-active-low;

          ethernet_phy: ethernet-phy@7 {

            reg = <7>;

            device_type = "ethernet-phy";

          };

        };


        pcw.dtsi:


        &gem0 {

          phy-handle = <&phy0>;

          phy-mode = "gmii";

          status = "okay";

          xlnx,ptp-enet-clock = <0x69f6bcb>;

          ps7_ethernet_0_mdio: mdio {

            #address-cells = <1>;

            #size-cells = <0>;

            gmii_to_rgmii_0: gmii_to_rgmii_0@8 {

              compatible = "xlnx,gmii-to-rgmii-1.0";

              phy-handle = <&phy0>;

              reg = <8>;

            };

          };

        };


        Add the external PHY definition here.

        Note: the definition of the gmii_to_rgmii IP has already been described.

        system-user.dtsi:

        &gem0 {

          ps7_ethernet_0_mdio: mdio {

            #address-cells = <1>;

            #size-cells = <0>;

            phy0: phy@1 {  // Add this node

              reg = <1>;

              microchip,led-modes = <1>;

            };

            gmii_to_rgmii_0: gmii_to_rgmii_0@8 {

              compatible = "xlnx,gmii-to-rgmii-1.0";

              phy-handle = <&phy0>;

              reg = <8>;

            };

          };

        };



    2. Add Node contents
      • Node contents (parameters) can be added that are not registered in the Device Tree for the Evaluation Board and Device Tree for the PCW.

        See the Parameters highlighted in the below example:

        system-user.dtsi:

        &gem0 {

          local-mac-address = [00 0a 35 00 1e 53];

          gmii2rgmii-phy-handle = <&gmii_to_rgmii_0>;

          xlnx,has-mido = <0x1>; // Add these

          ps7_ethernet_0_mdio: mdio {

            #address-cells = <1>;

            #size-cells = <0>;

            phy0: phy@1 { 

              reg = <1>;

              microchip,led-modes = <1>;

            };

            gmii_to_rgmii_0: gmii_to_rgmii_0@8 {

              compatible = "xlnx,gmii-to-rgmii-1.0";

              phy-handle = <&phy0>;

              reg = <8>;

            };

          };

        };

 

  1. Change the contents of a Node
    • You can change the parameter values registered in the Device Tree for the Evaluation Board and Device Tree for the PCW:

      system-user.dtsi:

      &gem0 {

        local-mac-address = [00 0a 35 00 1e 53];

        gmii2rgmii-phy-handle = <&gmii_to_rgmii_0>;

        xlnx,has-mido = <0x1>; 

        phy-handle = <&phy0>; // Change the Value

        };

       

  2. Delete parameter definition in a Node
    • Unnecessary parameter lines registered in the Device Tree for the evaluation board can be deleted using /delete-property/ <parameter>

      &gem0 {

        /delete-property/ pinctrl-names;

        /delete-property/ pinctrl-0;

        /delete-property/ phy-reset-gpio;

        /delete-property/ phy-reset-active-low;

        };



  3. Delete Node
      • You can delete unnecessary nodes and sub nodes registered in the evaluation board Device Tree using /delete-node/  <node_name>

        &gem0 {

          /delete-node/  ethernet-phy@7; // Delete Node

        };


    • Please note that if a node is referenced somewhere, it must be deleted after deleting or changing its value.
      Here is how to do that:delete-node.PNG
  4. Invalidating the entire driver definition
    • You can disable the driver definition enabled in the evaluation board Device Tree and the PCW Device Tree.
    • The driver definition is activated in pcw.dtsi with status = “okay”;
    • To disable this, write the following in system-user.dtsi:

      &gem0 {

        status = “disabled";

      };

Building Third party Linux Applications in PetaLinux

We can add any existing utility (For example: iperf3) to a PetaLinux project after making the below modifications

  1. Edit <project>/project-spec/meta-user/recipes-core/images/petalinux-image.bbappend
  2. Add the utility name (For example, iperf3) which its Yocto recipe understands.
    For example:

    IMAGE_INSTALL_append = " peekpoke"

    IMAGE_INSTALL_append = " gpio-demo"

    IMAGE_INSTALL_append = “ iperf3 ”    <<= add this line
  3. Add this application as a user package to rootfs using the following:

    Petalinux-config -c rootfs -> User Packages -> [*] iperf3

  1. After it is built this application appears in /usr/bin/

References: