When we left the hardware build we had just exported the HDF and bit file to SDK, initially this will have exported the required information to a directory local to the Vivado project.
With the project exported we can close down Vivado and open SDK, if this is the first time you have opened SDK you will be asked for the workspace you wish to use. The workspace is the area where your projects and associated software projects like Board Support Packages (BSP) and copies of the hardware definition will be stored.
Within SDK to get this up and running we need to do the following
- Create a hardware definition project
- Create a Board Support Package for the hardware definition
- Create our application – in this case a simple hello world
- Build the application – this is the simple part
- Define the debug environment such that we can run the application on the Arty board over the JTAG link.
The first step is to import the hardware definition we just exported from Vivado to do this select file->new-> other from the SDK menu this will open a dialog box, beneath the Xilinx folder as shown below select new Hardware Platform Specification
On the next dialog box enter your project name, I always prefer to call it project_HW to be clear what it is and browse to the directory within your Vivado project which contains the HDF file. Note this is within the .sdk folder under your Vivado project.
This will create the hardware specification which, will appear under the project explorer on the left side of SDK, as shown below (this does show all three of the elements we need to create a project)
We are now in a position that we can create a BSP for the hardware platform, this contains the drivers necessary for the hardware. We can create the BSP by selecting file->new->board support package this will open a dialog box like below
Enter a project name, notice how it has picked up the hardware platform we just created, for this example we will use the standalone operating system.
This will a settings pop up for the BSP there are no changes we need to make here but this is where we can add in additional options if needed e.g. light weight IP stack etc
We can also on the standalone page select the stdin and stdout for the compiler make sure this is set to uart lite as below.
With this verified you can close the BSP settings and you will see a progress box appear while the software generates the BSP files for your system.
At this point we can then create our application, for this example I am going to use the simple hello world template. We can create the application project by selecting file->new->application project this will open a dialog box where we can select the BSP we previously created the hardware definition and the processor we are targeting (in this case there is only one)
This will create a simple application which will output hello world over the USB-UART, selecting build all will then enable us to build the BSP and the application project such that we get an ELF file which can be downloaded and run on the hardware. The project is built using the project->build all settings and you will see the ELF file appear under your application project as below
The next stage is to run it on the Arty board, this requires that we remove the jumper on J1 on the arty board such that we do not load the design example already loaded within the QSPI flash.
To run the example we need to do the following
- Programme the FPGA
- Download the ELF
Before we can download the ELF we need to create a debug environment such that when we click on it we can download the elf. To do this right click on your application project and select Debug As -> Debug Configurations as below
This will open a dialog box where we can create a new debug environment, we wish to create a new GBD debug application
One you have selected new you will see the dialog box below, you should only need to change the information on page one (most should be auto populated)
Provide a name and If not selected select the Rest Processor from the drop down menu close to the bottom, we also need to click on the Debugger applications tab and uncheck the option ”stop at main() when debugging” this ensures the application will run automatically on download finally then click on apply not debug and then close.
With this completed it is time to connect the arty board to the USB of your PC, this will auto detect and install any software required when it is completed we can progress and test our application. Note it should only ever need to install once.
The first thing to do is programme the FPGA we do this under the Xilinx Tools -> Programme FPGA which will open the following dialog box (you should not need to change anything)
Click on program and you will see the FPGA is programmed, you can confirm this on your Arty board as the done LED will illuminate green.
We are now ready to download our ELF file, click on the bug icon on the top menu and this will use the debug configuration we just created to download the application
Once downloaded you will notice the software runs and the message “hello world” will appear in your chosen terminal programme.
You can find part one here