wiki:Exercises/13_4/IntroToSDK

Introduction to the Xilinx Software Development Kit (SDK)

(compatible with WARP v3)

In this exercise, users will be introduced to a tool that is used heavily in WARP development: the Xilinx Software Development Kit (SDK). Users will use these tools to construct a simple "Hello World" software project that prints messages via UART to a terminal running on the user's PC and controls the User I/O on the board to run on and off LEDs and display numbers on the hexadecimal displays.

The SDK will look very familiar to users who are comfortable with the Eclipse IDE. Basically, the SDK allows users to write custom C or C++ code to execute on the MicroBlaze processor. Furthermore, it natively supports step-by-step debugging of code as well as code profiling.

Prerequisites

  • You have a WARP v3 board
  • ESD protection for the WARP board (wrist strap, etc)
  • External USB JTAG cable and a micro USB cable for UART
  • Complete installation of ISE System Edition 13.4
  • Set up a terminal on your computer using PuTTY or an alternative. Instructions to do this are available instructions here.

Instructions

  1. Download the WARP v3 Template Project. Note: any template for your version of the hardware will work fine for this exercise as only the SDK is necessary. In general, when FPGA hardware designs must be generated, the "lite" template will build the quickest, but it lacks peripherals like Ethernet that may be necessary for designs other than this simple Introduction to the SDK exercise.
  2. Extract the archive into a folder on your hard drive. Note: this folder must not contain any spaces in the path (this includes folders such as "My Documents" in Windows; Please note that in Windows 7, the Desktop folder can be used, "C:\Users\<username>\Desktop", whereas in previous versions of Windows the Desktop folder was under the "Documents and Settings" directory and could not be used).
  3. Launch the Xilinx SDK from the Start Menu. It will ask you to select a workspace. Click "Browse ..." and navigate to the "SDK_workspace" folder in the archive you just extracted. Do not check the box for "Use this as the default and do not ask again." We recommend the convention of using a single workspace per hardware project; checking this box will make this difficult. More useful tips for using the SDK are available here. Click OK.
  4. Rather strangely, the Xilinx SDK does not automatically know about software drivers to custom peripherals in your XPS project. You have to explicitly tell the SDK where to find your hardware project. This is a step you have to do with every new SDK workspace. In this exercise, we do not have any custom peripherals, but it is still a good habit to get into. Click on the "Xilinx Tools" menu item and select "Repositories." Here, you want to ensure two things:
    • In Local Repositories, you want to point the SDK to the folder that contains the XPS project system.xmp file. Click on "New..." and navigate to and select this folder.
    • In Global Repositories, you want the SDK to point to the edk_user_repository folder on your hard drive. Unlike the local repositories, the SDK does remember this setting across workspaces. You'll only need to manually add the edk_user_repository the first time you run the SDK.
  5. In the template project you downloaded, we have provided a template software project. We now need to add it to the workspace. Click on File→Import...
  6. Click the + next to "General" and select "Existing Projects into Workspace." Then click "Next."
  7. In the "Select root directory:" click "Browse..." Then, navigate to the "SDK_workspace" folder in the extracted archive and click "OK"
  8. Three projects have now been populated in the "Projects" area of the import window. Make sure all of these are checked. Do not check "Copy projects into workspace" because these projects are already in the SDK_workspace folder. Click "Finish."
  9. The three projects now appear in the "Project Explorer" on the left of the screen:
    • The "*_hw_platform" contains all of the necessary hardware-specific information for the project. This includes any custom FPGA cores that the project may have. This comes from the Xilinx Platform Studio (XPS) tool. Instructions for using this tool to generate hardware platform information for the SDK is available in the Introduction to XPS exercise.
    • The "*_bsp" is a "Board Support Package" and it contains the software drivers for the peripherals contained in the hardware platform.
    • The "*_example" project is the top-level software project that you will modify to add a print of "Hello World" to the UART.
  10. Click the + button next to the "*_example" project. Then open the "src" folder by clicking the + button next to it. Finally, double click the "*_example.c" file to open it in the editor. At this point, you can look through this source code and see that it will print some messages to the terminal and will count upwards, displaying the current count on the hexadecimal displays on the WARP board and the LEDs.
  11. Right click on the "*_example" software project in the Project Explorer and click "Generate Linker Script." Here, we will assign instruction and data pieces of our code to various pieces of memory in our XPS hardware project. Assign the following:
    • The code sections to "ilmb_cntrl_dlmb_cntlr"
    • The data sections to "xps_bram_if_cntlr_0"
    • The heap and stack to "xps_bram_if_cntlr_1"
  12. Click "Generate" and then "Yes" to the message that says you are going to overwrite an existing linker script. The console will print messages and end with "Finished building: *_example.elf.elfcheck"
  13. Make sure your WARP hardware is powered on (fan should be running). Also make sure the WARP hardware is connected via JTAG (for programming) and connected via micro USB (for terminal communication) to your computer.
  14. Click the "Xilinx Tools" menu item and then "Program FPGA." Then click Program. This will load the hardware design onto the board. It will not load the software project.
  15. Open up a terminal emulator on your computer and configure it to accept your COM port with speed 57600 baud.
  16. The SDK is somewhat sensitive on what project has "focus" when you tell it to do something like load a design onto the board. Make sure the "*_example" project is highlighted. If it is not, click on it so that it will be.
  17. Click the menu item "Run" and then click "Run." A window will pop up asking you to select a way to run your "*_example" program. Click "Launch on Hardware" and then okay.
  18. The project is now running! You should see the LEDs and hexadecimal displays on the board incrementing twice a second. Furthermore, your terminal should be printing.
  19. Try to modify any of the prints in the code with your own custom strings. Click save. The SDK will automatically recompile the project. Download it again through the "run" menu.
  20. Also, find the usleep(250000) line inside the userio_example() function. This line is telling the processor to wait for half a second before incrementing the displays upwards. Replace this with usleep(500000) and you should see the board count half as fast.

Discussion

The purpose of this exercise was to take you through the whole process of writing software for an existing hardware project. In the System Generator Peripheral Export exercise, you will develop a custom FPGA peripheral core and control it via custom software.

Additional Questions and Feedback

If you have any additional questions about this exercise or other feedback, please post to the WARP Forums.

Last modified 11 years ago Last modified on Apr 23, 2013, 3:59:50 PM