MicroZed Chronicles: Industrial Input Output & Petalinux

October 8, 2021 

This content is republished from the MicroZed Chronicles, with permission from the author.


One of the many advantages to using an embedded Linux solution is the lower-level drivers are often part of the kernel. This saves us from having to write drivers of our own for simple devices this can save a little time for complex devices this can save considerable time.

One of the main aspects of our embedded Linux developments is reading and writing data from the real world which is often analogue in nature. This means our applications need to be able to interact with Analogue to Digital and Digital to Analogue Convertors or other specialist sensors. When we are working with PetaLinux we are often able to leverage the Industrial Input Output device drivers to be able to configure, control and sample the device.

Typically, these devices interface with the FPGA using a I2C or SPI interface though high sampling rate convertors may use different interfaces especially in programmable logic. Using the IIO sub system we can interface with ADC, DAC, Gryo, IMU, Accelerometers, Pressure sensors, Light sensors, Temperature sensors and Proximity sensors to mention a few.

In this blog we are going to walk through the creation of a IIO system on the Minimized which uses the AD7991, incidentally this also happens to be the ADC fitted on the PmodAD2. 

We will be doing this in Vivado and Petalinux 2021.1

To get started we need to create a new Vivado project.


On the next page of the project creation tab, enter the project name and the location to save the project. 

The next step is to declare the new project as an RTL project and that we will add in the RTL at a later stage.

Finally select the MiniZed board and finish the project creation process. 

Once the project has been created the next step is to create a simple block diagram and add in a Zynq processing system.


Run the block automation to configure the Zynq Processing System for the MiniZed, then double click on the Zynq PS to re-customise and ensure I2C0 is set to EMIO. 


On the block diagram make I2C external and create a wrapper for the block design.


In either the synthesis view or XDC set the pins as follow SCL L14, SDA M14, set both to LVCMOS3V3 and enable pullups on the IO. 


Build the bitstream when available export the XSA such that we can build the PetaLinux OS.

Create a PetaLinux project using the command

Petalinux-create -t project -n iio_mz413 –template zynq 


Change directory into the newly create project and configure it for the hardware just created using the command 

Petalinux-config - - get-hardware-description=/<XSA directory> 


Save the resulting configuration and enter the command below to configure the IIO device driver for the AD799x.

Petalinux-config -c kernel 


Now the device driver is enabled we need to do the mapping in the device tree, remember in petalinux the device tree we can change is under the meta-user layer.

To this device tree we need to add the following: 


This defines two voltage reference nodes and then connects the I2C 0 node which was enabled in Vivado to a new node for the ad7991 which is at I2C address 0x24. We state the driver to be associated with the node and define its supply and reference voltages.

The final entry deletes the CPU1 from the device tree as on the Minized it is single core.

We can then build the application and download to our MiniZed using the commands


petalinux-boot - - jtag - - fpga

petalinux-boot - - jtag - - kernel

This might take a few minutes to download the kernel and file system to the Minized. Once it is downloaded we can log in via a terminal window and check the Linux system. Done correctly we should see two IIO drivers in the system (one our AD7991 and the other XADC). 


Using the cat name command in the sys/bus/iio/devices directory we can see the first IIO device is the ad7991 and the second the XADC.

If we want to see what measurements channels can be observed, you can see the four inputs. 


Now how would we use this in a application is something we will look at in another blog.