Microzed Chronicles: Device Trees: Search All Content Blog

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

MicroZed Chronicles: Device Trees - Community Forums https://forums.xilinx.com/t5/Adaptable-Advantage-Blog/MicroZed-Chro...

Sign In (/plugins/common/feature
/saml/doauth/post?referer=https%3A%2F
%2Fforums.xilinx.com%2Ft5%2FAdaptable-
Advantage-Blog%2FMicroZed-Chronicles-
Help (/t5/help/faqpage)
Device-Trees%2Fba-p%2F1113862)

Blog Search all content

Community Forums (/) Blogs (/t5/Blogs/ct-p/blogs)


Adaptable Advantage Blog (/t5/Adaptable-Advantage-Blog/bg-p/tech_blog)
MicroZed Chronicles: Device Trees

MicroZed Chronicles: Device Trees

(/t5/user/viewprofilepage/user-id/277322)

xtech-blogs (https://forums.xilinx.com/t5/user/viewprofilepage/user-id/277322)
06-05-2020 05:55 AM
Xilinx Employee

0 0 35

Editor’s Note: This content is republished from the MicroZed Chronicles


(http://www.microzedchronicles.com/), with permission from the author and Hackster.io
(https://www.hackster.io/).

One of the great things about Zynq and Zynq MPSoC devices and the MicroBlaze
microprocessor is that we can run (them?) on embedded Linux operating systems. This gives
us the ability to easily work with networking, communications and leverage high-level open
source frameworks.

Of course, the great thing about using the SoCs of FPGA-based processors is their highly
flexible nature that allows new peripherals to be added as needed. For embedded Linux
solutions, this flexibility can be an issue as the kernel needs to know the hardware it is running
on, its configuration, and also what peripherals are available.

In the embedded Linux world, this information is provided by the device tree. The device tree is
separate from the kernel and describes the Linux system in a tree structure. From the root
node, each element of the system is defined as a node including the processor, memory, and
peripherals.

1 de 7 05/06/2020 11:34 a. m.
MicroZed Chronicles: Device Trees - Community Forums https://forums.xilinx.com/t5/Adaptable-Advantage-Blog/MicroZed-Chro...

Each node will have properties associated with it including address range, device properties,
interrupt numbers etc. Each node needs a name and an optional unit-address. Names should
be generic and reflect the function of the node. The unit-address value is the address of the
node on the specific bus type. If there is no unit-address on that bus type, the node name acts
to distinguish different nodes of the same type connected to the same bus.

As you can hopefully see, using a device tree avoids the need for us to include hard-coded
values within the source code. These values must be changed when the hardware description
changes.

When working with device trees, there are three commonly used terms:

DTS – Device Tree Source – This is a text description of the device tree
DTC – The Device Tree Compiler converts the DTS to a compiled output
DTB – Device Tree Blob – The compiled device tree which is deployed

When working with PetaLinux for our Zynq, Zynq MPSoC and MicroBlaze solutions, the device
trees are generated and compiled as part of the configuration and build process. However, at
times we need to make updates to the device tree to include additional drivers for elements
within either the processing system or programmable logic. For example, including SPI-DEV or
support for VDMA.

Within the PetaLinux project, the generated device tree source can be found under the following
directory.

<Petalinux_project>/components/plnx_workspace/device-tree-generation

2 de 7 05/06/2020 11:34 a. m.
MicroZed Chronicles: Device Trees - Community Forums https://forums.xilinx.com/t5/Adaptable-Advantage-Blog/MicroZed-Chro...

Looking in this directory, you will notice two things. Along with the DTS, there are also several
DTSI files. DSTI files are device tree source-include files which can be called up from the DTS.
This allows for a modular approach to the DTS creation.

Upon opening one of these files, you will also observe that these files are automatically
generated by PetaLinux and as such, changes to the device tree will be lost.

system-top.dts

3 de 7 05/06/2020 11:34 a. m.
MicroZed Chronicles: Device Trees - Community Forums https://forums.xilinx.com/t5/Adaptable-Advantage-Blog/MicroZed-Chro...

zynq-7000.dtsi (zynqmp.dtsi for ultrascale)

Within the PetaLinux build system, we will find the following DTS and DTSI files:

System-top.dts – The top-level device tree file


pl.dtsi – This file includes the memory mapped IP in the programmable logic
pcw.dtsi – The configuration of the dynamic processing system
zynq7000.dsti or zynqmp.dsti – Defines the processors and PS peripheral information
So where do we make changes to the device tree if we need to make any changes? These
changes are made under the meta-user layer at the following path:

<petalinux-project>/project-spec/meta-user/recipes-bsp/device-tree/files

Under this location you will see the system-user.dtsi file which is called up by system-top.dts.
This allows us to include additional drivers and binding. Of course, if necessary, we can include
other dtsi files in to system-user.dtsi.

Additions to the system-user.dtsi may not just include additional bindings for elements within the
programmable logic, but will also include configuration of the larger board design. For example,
it is common practice to include a I2C multiplexer to select between several I2C channels.
Information about this I2C multiplexer needs to be included in the device tree to enable support
within the Linux environment.

Let’s take a look in more detail using the Ultra96-V2 board as an example. In the hardware
design, the I2C mux is connected to PS I2C1.

4 de 7 05/06/2020 11:34 a. m.
MicroZed Chronicles: Device Trees - Community Forums https://forums.xilinx.com/t5/Adaptable-Advantage-Blog/MicroZed-Chro...

can then define each of the mux output channels and assign a label if we desire.

When we rebuild the PetaLinux system this will be included in the embedded Linux solution.
Looking under the /dev directory you will see ten I2C ports.

5 de 7 05/06/2020 11:34 a. m.
MicroZed Chronicles: Device Trees - Community Forums https://forums.xilinx.com/t5/Adaptable-Advantage-Blog/MicroZed-Chro...

You can then use the command I2Cdetect -l to determine which of the 10 ports are connected
to which node.

If you want to know more about device trees, I recommend checking out devicetree.org.

See My FPGA / SoC Projects: Adam Taylor on Hackster.io (https://www.hackster.io/adam-


taylor)

Get the Code: ATaylorCEngFIET (Adam Taylor) (https://github.com/ATaylorCEngFIET)

0 Kudos
cles-Device-Trees%2Fba-p%2F1113862&title=MicroZed+Chronicles%3A+Device+Trees&username=PoweredByLithium)

You must be a registered user to add a comment. If you've already registered, sign in. Otherwise,
register and sign in.

Comment (/plugins/common/feature/saml/doauth/post?redirectreason=permissiondenied&
referer=https%3A%2F%2Fforums.xilinx.com%2Ft5%2FAdaptable-Advantage-Blog%2FMicroZed-
Chronicles-Device-Trees%2Fba-p%2F1113862%23comment-on-this)

6 de 7 05/06/2020 11:34 a. m.
MicroZed Chronicles: Device Trees - Community Forums https://forums.xilinx.com/t5/Adaptable-Advantage-Blog/MicroZed-Chro...

MicroZed Chronicles: Device Trees (/t5/Adaptable-Advantage-Blog/MicroZed-Chronicles-Device-Trees/ba-


p/1113862)

Partner: Tips for Migrating SDAccel Projects to Vi... (/t5/Adaptable-Advantage-Blog/Partner-Tips-for-


Migrating-SDAccel-Projects-to-Vitis-2019-2/ba-p/1112377)

MicroZed Chronicles: MicroZed PYNQ (/t5/Adaptable-Advantage-Blog/MicroZed-Chronicles-MicroZed-


PYNQ/ba-p/1111917)

Radiation Tolerant Kintex UltraScale FPGA: One Sma... (/t5/Adaptable-Advantage-Blog/Radiation-Tolerant-


Kintex-UltraScale-FPGA-One-Small-Step-for/ba-p/1109189)

MicroZed Chronicles: PYNQ Features (/t5/Adaptable-Advantage-Blog/MicroZed-Chronicles-PYNQ-Features


/ba-p/1108655)

7 de 7 05/06/2020 11:34 a. m.

You might also like