top of page

MicroZed Chronicles: Alveo Edition SW Development

Having learned in our previous blog about how the Base Address Registers work for transfers in the Alveo system, we are now able to start working on and developing software applications. As we saw in the last blog, we are provided with several applications that can be used to interact with the U55C we are working with.

 

These programs, included in the tools folder, enable developers to read or write registers within the design and facilitate Direct Memory Access (DMA) transfers in either direction between the host and the card.

 

As such, we can call these functions from our applications to perform the transfers we desire. However, while providing a nice basis we do of course need to be able to start developing our own applications, again we can use the provided source as a good template.

 

One of the key things we need to understand when developing software applications are the devices accessible to the user space. We can find these under the /dev directory in our Linux operating system.



Under this directory we will see several devices which enable user space access to the U55C:

 

  • Xdma0_user – This enables access to the AXI Lite network as we saw in the last blog.

  • Xdma0_control – This used to access the DMA subsystem PCIe Registers

  • Xdma0_events_* - These are used to recognise user interrupts.

  • Xdma0_c2h_* - These are used to transfer data from the card to the host

  • Xdma0_h2c_* - These are used to transfer data from the hast to the card

 

Of main interest to us, when we conduct high-bandwidth transfers, are the control, c2h, and h2c channels.

 

The process of creating a transfer is very straightforward, as demonstrated by the demo applications.


Of course as you would expect the transfer leverages elements of the user space application which defines the channels to be used and allocates the buffers of data and transfer size. Once this has been created the driver in the kernel space takes over and creates the necessary descriptors and then starts the transfer. Once the transfer is started the DMA takes over and reads the descriptor to determine which kind of transfer is being requested. With the descriptor processed the DMA then performs the transfer which moves the data in the correct direction either from or to the card. After the transfer is completed the kernel driver looks for interrupts and checks the status before returning these to the user side to checking.

 

This is one of the benefits of using the XDMA driver is the complexity is abstracted away, enabling the application developer to focus on the actually behaviour of the application.

 

Lets examine the sw in the file dma_from_device.c; this file transfers data from the card to the host. To use the function created by this source code the developer needs to provide the device name, the file to be transferred, the transfer size, axi address and number of transfer to perform.  For example:

 

dma_from_device -d <device> -f <file> -s <size> -a <address> -c <transfercount>

 

Inside the dma_from_device.c the file contains initial sanity checking on inputs and reporting of the configuration input. The functionality begins at line 171 where the function test_dma is defined.

 

At line 196, we can see the channel being opened, and at line 206, the file being created to write the data to.

The allocation of the buffers begins at line 218. Once the buffer is allocated, the next step is to perform the transfer.

Following the data transfer, the size of the transfer is checked to ensure it was completed.

Having understood more about how the software application works and how we can use the pre existing examples as a good starting point for our own custom applications. We can look in a our next article at applications for Alveo developed in Vivado.


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



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.



Sponsored by AMD

0 comments

Comments


bottom of page