The peripherals we communicate with in embedded systems use a wide range of interfaces from I2C, UART, SPI to Gigabit ethernet and PCIe. Ensuring we know how to configure and work with these interfaces using embedded Linux is critical. Having previously looked at how to work with SPI, GPIO and IIC in this blog we will be examining how we can work with interfaces which use UART for communication.
To do this we are going to be using the ZU Board and leverage its Micro Click interface as that breaks out a serial port which is accessible.
Our Vivado design is going to be straight forward, we will create a project targeting the ZU Board.
With the project open we will create a new block diagram and add in the following components.
Zynq MPSoC block – run the block automation to configure for the ZU Board, configure the block to enable the PL-PS Interrupts.
AXI Lite UART – Configured for 115200 baud rate no parity
Concat block – connected between the AXI UART Lite Interrupt and the Zynq MPSoC Interrupt input.
To connect the connection automation to create the AXI Network which connects the Zynq MPSoC AXI with the AXI UART Lite.
Validate the design and build the bitstream, once the bitstream is completed the next step is to export the XSA and using PetaLinux 2024.1 we need to create a project.
Creating the project is straight forward and unlike for other examples we have seen e.g. SPI we do not need to make adjustments to the device tree or add in drivers into the kernel. Everything we need is already included when the XSA is used to configure the newly created PetaLinux project.
We can use the following commands to create the project
petalinux-create -t project -n axi_uart --template zynqMP
Running the command, will parse the XSA and configure the project in accordance with hardware design.
petalinux-config --get-hw-description=<xsa location>
Examining the PetaLinux configuration which opens after the configuration is completed, we can see the AXI UART Lite has been detected correctly as it is an option for the u-boot / Linux terminal.
We can build the project by running the command
petalinux-build
Once built we can examine the device tree for the PL this will show the driver which is bound along with the interrupt controller, interrupt allocation and baud rate etc.
Package the project files to create a boot.bin and copy the boot.bin, boot.scr and image.ub onto the SD card and power on the ZU Board.
I connected the TX and RX pins on the micro click port along with ground to a CD232HD cable which has a inbuilt FTDI chip.
We can see the how the AXI UART Lite enumerates under /dev in this instance it enumerates as ttyUL1.
Using the terminal once logged in we need to create a new group called dialout to use the AXI UART Lite. Once the new group is created we need to add the account we are using to the newly created group.
newgrp dialout
sudo usermod -a petalinux -G dialout
groups $petalinux
To send commands over the AXI UART Lite we can echo out over the serial port using the command
echo 123 > /dev/ttyUL1
Opening a second serial terminal which is connected to the CD232HD cable we can see commands appear as they are sent from the ZUBoard to the terminal.
Now we are able to start development of applications which might want to use RS232 based Micro Clicks or other sensors and systems.
Workshops and Webinars
If you enjoyed the blog why not take a look at the free webinars, workshops and training courses we have created over the years. Highlights include
Professional PYNQ Learn how to use PYNQ in your developments
Introduction to Vivado learn how to use AMD Vivado
Ultra96, MiniZed & ZU1 three day course looking at HW, SW and PetaLinux
Arty Z7-20 Class looking at HW, SW and PetaLinux
Mastering MicroBlaze learn how to create MicroBlaze solutions
HLS Hero Workshop learn how to create High Level Synthesis based solutions
Perfecting Petalinux learn how to create and work with PetaLinux OS
Boards
Get an Adiuvo development board
Adiuvo Spartan 7 / RPi 2040 Embedded System Development Board
Embedded System Book
Do you want to know more about designing embedded systems from scratch? Check out our book on creating embedded systems. This book will walk you through all the stages of requirements, architecture, component selection, schematics, layout, and FPGA / software design. We designed and manufactured the board at the heart of the book! The schematics and layout are available in Altium here Learn more about the board (see previous blogs on Bring up, DDR validation, USB, Sensors) and view the schematics here.
Comments