In the last blog, we looked at how we could start to create a MicroZed project in Vivado 2020.1 just like we did when we started the blog nearly seven years ago. In that blog, we had just created the hardware build in Vivado. In this blog however, 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, enabling Vitis to create software applications. Within an XSA file you will find information on the address map along with the IP included and of course the bit file. The bit file however is not necessary to get started with the software development.
Within Vivado we create an XSA by selecting File --> Export --> 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, this is the first choice we will see when the dialog box appears when we want to export the hardware. We are going to create a fixed platform for this application.
Since we have implemented the design and have a bitstream available, we are now 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, 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 organized, I always keep the workspace within the project directory.
Select Create Platform Project from the Vitis welcome screen. 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 to platform creation, we need to first name the project. I follow a naming convention which labels it as the project I am working on (e.g., mz_354) followed by _platform.
On 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 opened dialog box, 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 include the board support package containing drivers for the IP in the design, along with the first stage boot loader which is required to create a bootable image.
To be able to use the platform, we need to first compile it. This builds all of the BSP and FSBL elements. To do this, click on the build icon which looks like a 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 by 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 processors available in the Zynq-7000 SoC and Zynq UltraScale+ MPSoC.
Select the standalone domain for the application. This should be the only domain created 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 the Hello World application. I opened the source file and made a few changes to the messages output.
Finally, because 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 in order for the boot file to be created.
Double check the boot creation dialog box. 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. This was the path for me:
mz_chron_354\workspace\mz_354_app_system\_ide\bootimage
The messages entered in your application should appear by inserting the SD card into the MicroZed and booting it up when connected to a terminal program.
The following showed for me:
Now we know how to create a simple application in both Vivado and Vitis 2020.1 targeting the MicroZed and this can of course be used for other Zynq-based boards.
As you can see, there have been several changes to the flow from when we started in Vivado 2013 all those years ago!
See My FPGA / SoC Projects: Adam Taylor on Hackster.io
Get the Code: ATaylorCEngFIET (Adam Taylor)
Commentaires