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:
Basic steps to create and configure the PetaLinux project for ZynqMP platforms:
source <petalinux_installation_path>/settings.sh
Overview of PetaLinux Build Flow:
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:
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:
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 = <ðernet_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";
};
};
&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.
&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>;
};
};
};
&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>;
};
};
};
&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
};
&gem0 {
/delete-property/ pinctrl-names;
/delete-property/ pinctrl-0;
/delete-property/ phy-reset-gpio;
/delete-property/ phy-reset-active-low;
};
&gem0 {
/delete-node/ ethernet-phy@7; // Delete Node
};
&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
IMAGE_INSTALL_append = " peekpoke"
IMAGE_INSTALL_append = " gpio-demo"
IMAGE_INSTALL_append = “ iperf3 ” <<= add this linePetalinux-config -c rootfs -> User Packages -> [*] iperf3
References:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.