In the previous tutorial titled Creating a project using Base System Builder, we used Xilinx Platform Studio (EDK) to create a hardware design (bitstream) for the Zynq SoC. In this tutorial, we will complete the design by writing a software application to run on the ARM processor which is embedded in the Zynq SoC. Using the Xilinx SDK, we’ll create a simple application that will send the words “hello world” out of the serial port and into your PC serial console. In the next tutorials, we’ll write some applications that will interact with the peripherals we defined in the EDK project.
To perform this tutorial, you will need:
- Xilinx ISE Design Suite 14.7
- ZC706 evaluation board
- Some kind of serial console program such as Putty or Miniterm
If you didn’t do the previous tutorial about creating an EDK hardware project, you’ll at least need to download the project files and build the project in EDK. The files are available on Github at the link below:
Export the EDK project to SDK
- Open EDK by selecting “Xilinx Design Tools->ISE Design Suite 14.7->EDK->Xilinx Platform Studio”.
- Open the zc706-bsb project.
- Click “Export Design”.
- Click “Export and Launch SDK”.
- If you didn’t generate the bitstream earlier, EDK will generate the bitstream before exporting the design to SDK.
Software Development Kit
- The SDK should automatically open after the design is exported.
- The Xilinx SDK is built on the Eclipse SDK so it also uses the concept of workspaces. When the SDK starts up, it will ask you which workspace to open.
What are SDK Workspaces?
An SDK workspace is a folder where you can manage multiple software application(s) for one or more EDK hardware designs. People have different ways of managing their software projects, but I generally like to have one SDK workspace for each EDK project. You can place the workspace anywhere on your machine, but I personally like to organize my projects in a folder structure as follows:
- zc706-bsb: The high-level folder that uses the name of my project.
- EDK: The sub-folder with my EDK project files.
- SDK: The sub-folder with my SDK project files.
In the example above, my project name is “zc706-bsb”. So if you want to follow my way of doing things, create a folder named “SDK” within the “zc706-bsb” project folder (if you downloaded the project files from Github, the SDK folder should already be there). This folder will be your SDK workspace for this tutorial.
- Select the SDK sub-folder for your SDK workspace and click OK. As I generally have multiple projects and thus multiple SDK workspaces, I don’t tick the option “Use this as the default and do not ask again” because I want SDK to ask me which workspace to open every time.
- SDK opens up with a welcome screen that should look like the following image.
- Select “File->New->Application project”.
- In the dialog box that appears, type the name of the project as
hello_worldand click “Next”.
- We’re now asked if we would like to use a template for the application. Select the “hello world” template and click “Finish”.
- The SDK will now build the hello_world application and the hello_world BSP (board support package). When it is finished, your Project Explorer should look like the image below.
At this point, I suggest you have a poke around in the files that the SDK has created for you. For starters, open the
helloworld.c file and have a look at the code we’ll be running. Have a look at the linker script file
lscript.ld to see where your code, stack and heap memory will be placed. You can also checkout the files in the
hello_world_bsp board support package which is basically a collection of libraries that you can use in your application to take advantage of various peripherals and features of the Zynq. Some of the libraries include USB, watchdog timer, I2C, GPIO, Ethernet MAC and XADC.
You’re now ready to run the application on the ZC706 evaluation board.
Load the FPGA with the bitstream
- Turn on your hardware platform (ZC706 or whatever you are using).
- Connect a USB cable from your board’s UART port (J21 on the ZC706) to your computer’s USB port.
- Open your terminal program (eg. Putty or Miniterm) and connect to the COM port that corresponds to your UART over USB device. Make sure the port settings are 115200 baud, 8-bits, no parity, 1 stop bit.
- From the SDK menu, select “Xilinx Tools->Program FPGA”.
- In the “Program FPGA” dialog box, the defaults should already specify the correct bitstream for the hardware project. Make sure they correspond to the image below and click Program.
The Zynq will then be programmed with the bitstream and the console window should give you the message:
FPGA configured successfully with bitstream
Run the Software Application
- First make sure that the hello world application is selected in the Project Explorer, then select “Run->Run” or click the icon with the green play symbol in the toolbar.
- In the “Run As” dialog box, select “Launch on Hardware” and click OK.
- SDK will then program the Zynq with the hello world application and run it. You should see the words “Hello World” written in your terminal window.
Now you can try experimenting by modifying the code to do other things. Even though we didn’t place many peripherals in our EDK project, the Zynq is packed with a lot of fixed peripherals that the Base System Builder setup for us. If you want to try out some of these peripherals on your own, just checkout some of the example applications that Xilinx provides in the install folder.
In this folder you’ll find more examples than you’ll ever have time to try. Good luck!