In the last blog we where looking at how we could start create a MicroZed project in Vivado 2020.1 just like we did when we started the blog nearly 7 years ago. In the previous blog we had just created the hardware build in Vivado, in this blog we are going to create a simple hello world program using Vitis.
The first thing we need to do in Vivado is to export the XSA, this is a compressed file which contains several elements which enables Vitis to create software applications. Within an XSA file you will find information on the address map, the IP included and of course the bit file. Although the bit file is not necessary to get started with the software development.
Within Vivado we create a XSA by selecting on File->Export Hardware
Starting with Vivado 2020.1 there is increased support when exporting the design to support either an embedded or acceleration flow application. As such when we want to export the hardware this is the first choice, we will see I the dialog which pops up. For this application we are going to create a fixed platform.
As we have implemented the design and have a bitstream available we are going to export a platform which includes the bitstream.
Finally, our last option is to select the location of the XSA and the name of it, for this example I left the location and name as recommended by Vivado. This should place the XSA inside the Vivado project directory.
Once the XSA is exported if you want you can use an archive program such as 7Zip to open the archive and examine its contents.
Now we are ready to get started with Vitis, we can start Vitis from the Tools menu in Vivado.
The first thing it will ask is where do we want to define the workspace; this is the working directory where all the Vitis projects and setting information will be stored.
To keep my projects organised I always keep the workspace within the project directory.
From the Vitis welcome screen we want to select create platform project, in Vitis a Platform defines domains which contain hardware definition, board support package and Boot loaders. Platforms can be used by several applications.
In the journey of platform creation we need to first name the project, I have been following a convention of naming it the project I am working on followed by _platform.
One the next page we will be asked if we want to create the platform from an XSA or existing platform. We want to use the XSA created previously in Vivado.
In the dialog which opens, select the XSA from the location it was exported to in Vivado, leave the check box ticked which will create the boot components.
This will create a new platform in Vitis, which will contain the board support package containing drivers for the IP in the design, along with the First Stage Boot Loader required to create a bootable image.
To be able to use the Platform we need to compile it, this builds all of the BSP and FSBL elements to do this click on the build Icon (hammer on the tool bar).
Once the platform has been created we can create a simple hello world application, this can be created from the menu and selecting File->New -> Application Project
This will open the application creation wizard, which creates both an application and a system application.
Once we have defined the name of the project the next step is to select the platform on which the applications runs.
On the next tab, create a new system project – System projects allow us to easily work with several different applications on the multiple processor available in the Zynq and Zynq MPSoC.
Select the standalone domain for the application, this should be the only domain created with when the platform was created.
The final option is to select the Hello World template project.
This will create a new system application project which contains a the hello world application, I opened the source file and made a few changes to the messages output.
Finally as the MicroZed does not have on board JTAG we need to create a boot file for the SD card. Right click on the system application and select create boot image, this will pull together all of the files required for the boot file to be created.
Double check the boot creation dialog which appears, notice there should be a boot loader followed by the programmable logic image and then finally the application software.
You will find the boot.bin file created under the directory indicated in the output path, for me this was the path