K7 Embedded TRD 2013.2
Table of Contents
- 1 1 Introduction
- 2 2 Prerequisites
- 3 3 Building the FPGA Hardware Bitstream and Exporting the Hardware Platform to SDK
- 4 4. Building Software Applications
- 4.1 4.1 Application development based on a stand-alone environment
- 4.2 4.2 Application development based on the Xilkernel OS environment
- 4.2.1 4.2.1 Import an existing BSP and software application into a workspace (board_test_app_Webserver)
- 4.2.2 4.2.2 Building Video Demonstration with xilkernel and lwip
- 4.2.2.1 Video Demonstration BSP
- 4.2.2.2 Video Demonstration Hardware Setup
- 4.2.2.3 Running the Video Demonstration
- 4.2.2.4 Interacting with the Video Demonstration
1 Introduction
This page provides instructions on how to build various components of the Kintex-7 Embedded Targeted Reference Design (TRD) and how to setup the hardware platform and run the design on the Kintex-7 FPGA Embedded Kit. The Kintex-7 FPGA Embedded kit is based on a XC7K325T-2FFG900C device. For additional information, refer to UG913.
1.1 About the Kintex-7 Embedded TRD
The Kintex-7 embedded TRD showcases various features of the KC705 evaluation board. The TRDs are built around a MicroBlaze soft processor with various peripherals to enable embedded applications. Two designs are provided as part of this TRD: the KC705 System (BIST system) and the Video Demonstration system. The BIST system provides a platform to jump-start embedded system development on the KC705 evaluation platform.
The video demonstration is the superset of the BIST system. It provides a MicroBlaze processor based embedded platform which can be used to develop complex video systems. Along with these designs, a stand-alone software application and webserver-based application are provided. For additional information, please refer to UG985.
Block Diagram of KC705 (BIST) System
Block Diagram of Video Demonstration System
1.2 Kintex-7 Embedded TRD Package Contents
The Kintex-7 Embedded TRD package is released with the source code, Xilinx Vivado and SDK projects. The package also contains a stand-alone software application and webserver-based application which enables the user to run both the designs. This wiki page assumes the user has already downloaded the Kintex-7 Embedded TRD package and extracted its contents to the K7 TRD home directory referred to as K7_TRD_HOME in this wiki page.
Note: Because the package has a deep hierarchy structure, unzip the package at a user location so that the overall path length is smaller.
2 Prerequisites
The KC705 Embedded Kit ships with the version 2013.x Device-locked for the XC7K325T-2FFG900C FPGA and all required licenses to build the TRD. For additional information, refer to UG973, Vivado Design Suite User Guide: Release Notes, Installation, and Licensing
KC705 embedded kit MicroBlaze processor subsystem
Proper hardware setup and software installation, as described in UG913, Getting Started with the Kintex-7 FPGA KC705 Embedded Kit
EDK, SDK User Guide documents
General knowledge of FPGAs, digital design concepts, and microprocessors
Basic familiarity with the Xilinx Design Tools
Basic VHDL/Verilog knowledge
3 Building the FPGA Hardware Bitstream and Exporting the Hardware Platform to SDK
This section explains how to generate the FPGA hardware bitsream using the Xilinx Vivado tool and how to export the hardware platform to Xilinx Software Development Kit (SDK) for software application development.
3.1 BIST System
A pre-compiled bitstream can be found at $K7_TRD_HOME/ready_to_test/k7_emb_bist_top.bit.
Steps for building the BIST System FPGA hardware bitstream and Exporting the Hardware Platform to SDK
On Windows 7 platform:
Open Vivado 2013.x Tcl Shell by clicking Start > All Programs > Xilinx Design Tools > Vivado 2013.x > Vivado 2013.x Tcl Shell
Navigate to $K7_TRD_HOME/hardware/vivado/runs/ in the Vivado 2013.x Tcl Shell window.
Type launch_run.bat bist in the Tcl Shell Window and press enter.
On Linux platform:
Set VIVADO tool version to 2013.2
Navigate to $K7_TRD_HOME/hardware/vivado/runs/
Type ./launch_run.sh bist at the command prompt and press enter.
In launch_run script an automated TCL script will be called which will launch VIVADO, creates k7_emb_bist project and constructs a block diagram.
In the Flow Navigator pane on the left-hand side under Program and Debug, click Generate Bitstream. The bitstream will be generated at $K7_TRD_HOME/hardware/vivado/runs/k7_emb_bist/project/project.runs/impl_1/k7_emb_bist_top.bit
In the flow navigator click on Open Implemented Design. Click on "OK" when prompted for no trace timing results were found.. message
From the menu bar, select File > Export > Export Hardware.
In the Export Hardware window press OK. The SDK hardware platform will be exported to $K7_TRD_HOME/hardware/vivado/runs/k7_emb_bist/project/project.sdk/SDK/SDK_Export
Note: If the Launch SDK option is checked in the Export Hardware window, SDK will be launched immediately after SDK export has completed. This is not recommended at this point.
3.2 Video Demonstration System
A pre-compiled bitstream can be found at $K7_TRD_HOME/ready_to_test/k7_emb_vdemo_top.bit
Steps for building the Video Demonstration System FPGA hardware bitstream and Exporting the Hardware Platform to SDK
Once you execute launch_run command, given below, it will take approximately 5 hours to complete this step.
On Windows 7 platform:
Open Vivado 2013.x Tcl Shell by clicking Start > All Programs > Xilinx Design Tools > Vivado 2013.x > Vivado 2013.x Tcl Shell
Browse to $K7_TRD_HOME/hardware/vivado/runs/ in the Vivado 2013.x Tcl Shell window.
Type launch_run.bat vdemo in the Tcl Shell Window and press enter.
On Linux platform:
Browse to $K7_TRD_HOME/hardware/vivado/runs/
Type ./launch_run.sh vdemo at the command prompt and press enter.
In launch_run script an automated TCL script will be called which will launch VIVADO, creates k7_emb_vdemo project and constructs a block diagram.
In the Flow Navigator pane on the left-hand side under Program and Debug, click Generate Bitstream. The bitstream will be generated at
$K7_TRD_HOME/hardware/vivado/runs/k7_emb_vdemo/project/project.runs/impl_1/k7_emb_vdemo_top.bit
In the flow navigator click on Open Implemented Design. Click on "OK" when prompted for no trace timing results were found.. message
From the menu bar, select File > Export > Export Hardware.
In the Export Hardware window press OK. The SDK hardware platform will be exported to
$K7_TRD_HOME/hardware/vivado/runs/k7_emb_vdemo/project/project.sdk/SDK/SDK_Export
Note: If the Launch SDK option is checked in the Export Hardware window, SDK will be launched immediately after SDK export has completed. This is not recommended at this point
4. Building Software Applications
The software applications described in this tutorial are:
Hello World application
Board Test Apps (Console mode) application
Board Test Apps (Webserver mode) application
Video Demonstration application
Steps involved in building a Software Application:
Create a workspace using SDK tool
Import a Hardware platform
Create / Import BSP (board support package); modify settings as needed
Create / Import software application; modify settings as needed
Build the application
Types of Board Support Packages:
Different software platforms can be used to cover a variety of different needs. These platforms include:
Stand-alone platforms for small dedicated systems that do not require an OS
The stand-alone software platform is a single-threaded environment used when an application accesses processor functions directly. Some functions that the stand-alone software platform provides are processor interrupt handling, exception handling, and cache handling. The stand-alone software platform also supports program profiling
Xilkernel (kernel for Xilinx embedded processors) for small systems that need to manage multiple tasks
Linux for systems that have large software content (not part of this TRD).
Based on the platform, software application development is divided into two primary categories:
• Application development based on a stand-alone environment.
• Application development based on the xilkernel OS environment.
Prebuilt applications and platforms are available in the Kintex-7 Embedded TRD package as a reference at $K7_TRD_HOME/software
4.1 Application development based on a stand-alone environment
Steps listed below are followed for stand-alone software development:
• Create a new workspace and import the hardware platform into the workspace
• Create a new board support package (BSP) and application
• Import an existing BSP and software application into a workspace
4.1.1 Create a new workspace and import the hardware platform into the workspace
To begin working with SDK, an SDK workspace must be created. An SDK workspace is a directory that contains information on the projects being worked on. The workspace holds software project files, SDK settings, and log files.
The hardware platform is the embedded hardware design that is exported in the form of an XML file. The hardware platform is populated to SDK when the XML file is imported. Multiple hardware platform projects can be created in SDK.
Note:
The hardware platform project used build standalone application is the hardware specification exported from the hardware system which is located at $K7_TRD_HOME/hardware/vivado/runs/k7_emb_bist/project/project.sdk/SDK/SDK_Export/hw
Alternately, the prebuilt xml file for BIST system is placed at location: $K7_TRD_HOME/software/standalone_app/board_test_app/hw_platform
The process of creating a new SDK workspace and importing a hardware platform into the workspace includes:
• Creating a New SDK Workspace for Software Development
• Adding a New Hardware Platform Project to an SDK Workspace
Creating a New SDK Workspace for Software Development
Launch SDK.
On Windows, select Start > All Programs > Xilinx Design Tools > Vivado 2013.x > SDK > Xilinx SDK 2013.x
On a Linux host, enter xsdk at a command prompt.
2. When the Workspace Launcher appears, specify the SDK workspace as $K7_TRD_HOME/software/standalone_app/board_test_app/SDK_Workspace. Click OK in the Workspace Launcher.
3. When SDK opens, a Welcome screen is displayed. Close the Welcome screen after browsing through the displayed information. When the Welcome screen is closed, the Project Explorer tab is displayed and is empty.
Adding a New Hardware Platform Project to an SDK Workspace
To develop applications with SDK, a hardware platform must be specified in the SDK workspace. To add a hardware platform project into the workspace, follow these steps:
1. Select File > New > Project... > Xilinx > Hardware Platform Specification in SDK.
2. Populate the new hardware platform project with these selections:
• Project Name: hw_platform
• Project Location: Ensure that the Use default location checkbox is selected.
• Target Hardware Specification: Click Browse and select hardware design export file (.xml) from one of the above paths.
3. Click Finish.
4. When the hardware platform is loaded, the Project Explorer tab includes the hardware platform. The system XML file in this view provides a short summary of the hardware platform when opened in SDK.
4.1.2. Create a new board support package (BSP) and application
After the SDK workspace is created and the hardware platform is imported, a new BSP can be created in the SDK. A BSP contains libraries and drivers that software applications can utilize when using the provided APIs. A software project is the software application source and settings.
This section uses a Hello World software application as an example of creating a new stand-alone software project. The Hello World software project is created from one of the example application templates provided in the SDK. The process of creating a Hello World software project with a new BSP using the stand-alone software platform includes:
• Creating the Hello World Software Project and BSP
• Running the Hello World Software Project
Creating the Hello World Software Project and BSP
Follow these steps to create the Hello World application project and a corresponding BSP. The BSP is built to use the stand-alone software platform. Although this BSP is created for use with a Hello World software application, it can be used for other software applications that require a basic stand-alone software platform.
1. Select File > New > Application Project in the SDK.
2. Enter the Project Name: as hello_world_0.
3. Keep Use default location selected.
4. Keep the default selections for Target Hardware.
5. Keep the OS Platform selection at Standalone, Language selection to C. For Board Support Package select Create New. This selection creates a new BSP for the Hello World software application project. The default name for BSP is populated with hello_world_0_bsp.
6. Click Next.
7. Select the template for Hello World.
8. Click Finish. The SDK starts to compile the hello_world_bsp_0 BSP and the hello_world_0 application.
Note: For Xilinx C projects, SDK automatically create makefiles which compile the sources into object files and link the object files into an executable file.
View / Modify BSP settings:
1. Right-click hello_world_0_bsp in the Project Explorer tab and select Board Support Package Settings. Settings for the BSP can be changed in these menus.
2. The BSP settings menu is popped up, and the Overview menu is the initial menu shown. This initial menu contains the OS type and version used, as well as a description of the selected OS type. This menu shows the target hardware specification file location and the target processor. This menu also allows the option to add libraries, such as the Xilinx Flash library and the lwip TCP/IP Stack library. No special settings are needed in this initial screen.
3. Select the stand-alone menu. This menu includes the configuration options for the stand-alone software platform.
4. In the Operating System configuration section of the stand-alone menu, ensure that stdin and stdout are set to rs232_uart_1 by clicking the text in the Value column.
5. Select the drivers menu. In this menu, the driver and driver version used for the hardware platform peripherals can be viewed. No special settings are needed in the drivers menu.
6. Select the cpu menu. This menu includes processor driver parameters that can be changed, including the compiler that is used for libraries and applications, and any extra compiler flags that are needed for compilation. No special settings are needed in the cpu menu.
7. Click OK. The BSP and application are recompiled.
After the hello_world_bsp_0 BSP and hello_world_0 applications are compiled, expand the microblaze_0 section of hello_world_bsp_0 in the Project Explorer tab. The code, include, lib, and libsrc folders contain the libraries for the hardware peripherals in the reference system. In this view, files can be opened by double-clicking them.
Now expand the src section of hello_world_0 in the Project Explorer tab. The source code of the Hello World application project is stored here.
Double-click the helloworld.c file. The file opens in the SDK Editor window. The file can be modified as needed.
Note the lscript.ld file in the helloworld project. This file is the linker script that was generated for the helloworld project. A linker script is required to specify where the software code is loaded in the hardware system memory.
Running the Hello World Software Project
After the Hello World application is created and built, it can be run on the KC705 board. Follow these steps to program the FPGA and run the Hello World application:
Note: Ensure that the Kintex-7 board is connected to Host PC, as detailed in the Getting Started Guide
1. The FPGA must be programmed with the hardware configuration bitstream before the software application can be run. Program the FPGA with these steps:
a. In the SDK, select Xilinx Tools > Program FPGA.
b. Ensure that the system.bit and system_bd.bmm files are selected from $K7_TRD_HOME/software/standalone_app/board_test_app/SDK_Workspace/hw_platform/. Leave the initialization ELF as bootloop. Bootloop keeps the processor in a known state while it waits for another program to be downloaded to run or to be debugged.
c. Click Program to program the FPGA. SDK confirms when the FPGA is successfully programmed with the bitstream.
2. SDK provides two build configurations: Debug and Release.
Each build configuration uses a different set of compiler settings, macros, and linker settings.
This application uses the Release configuration to run without debugging. Right-click the hello_world_0 application in the Project Explorer tab and select Build Configurations > Set Active > Release. The hello_world_0 application is rebuilt for the Release configuration.
3. In the Project Explorer tab, right-click hello_world_0 and select Run As > Run Configurations.
4. In the Run Configurations box, select Xilinx C/C++ ELF and click the New button to create a new Run configuration.
5. Populate the Main tab of the new run configuration with these selections:
• Name: hello_world_0 Release
• C/C++ Application: Release/hello_world_0.elf
• Project: hello_world_0
• Build Configuration: Release
6. Click the STDIO Connection tab and click the Connect STDIO to Console checkbox to enable the STDIO of the program to go to the SDK Console window. Set the COM port as appropriate for the host computer, and leave the BAUD rate at 9600.
7. Click Run. An XMD console appears which shows the hello_world_0 application being downloaded into memory and run.
8. The hello_world_0 application displays Hello World on the SDK Console.
4.1.3 Import an existing BSP and software application into a workspace (board_test_app_Console)
This exercise shows how to import the existing BSP and application provided with the embedded kit reference system into the SDK instead of creating a new BSP or application. This readily available application comes up with a menu appearing in the UART console. The user can select the test applications in the console by entering the test number and pressing Enter to run the test on target. The KC705 board runs the selected test. The results of the tests are displayed on the console. It is a simple design to start with. The BSP called board_test_app_console_platform is provided for the application built in console app.
This section describes the board_test_app_Console design flow. In this exercise, we use the SDK workspace created in above section. The design flow for the board test software application (console app) includes:
• Importing the Board Test Software Application and BSP,
• Board Test BSP Settings,
• Running the Board Test Software Application,
• Tests in the Board Test Application,
Importing the Board Test Software Application and BSP (Console App)
The SDK can import existing SDK projects into an SDK workspace. The application (board_test_app_Console) and BSP (board_test_app_Console_platform) are imported into the SDK workspace by following these steps:
1. In the SDK, select File > Import > General > Existing Projects into Workspace > Next.
3. To specify the root directory from which software projects are to be imported, click Browse... and specify the location where the software projects are stored. For this reference system, the board_test_app_Console and
board_test_app_Console_platform project are stored under $K7_TRD_HOME/software/standalone_app/board_test_app.This directory should be specified as the root directory.
4. Ensure that the board_test_app_Console and board_test_app_Console_platform projects are selected.
If the hello_world section is completed, the hw_platform project showed in grey color and cannot be selected.
If the hello_world section is not completed, select the hw_platform project also in the Import wizard.
Note: The hardware platform project (hw_platform) used for board_test_app_Console is the same as the hardware platform project created in previous section (hello_world)
5. Select the Copy projects into workspace check box to make a local copy of the projects in the workspace when the import is done.
6. Click Finish. SDK imports the selected projects. The BSP and software application are compiled during the import process.
When a BSP is imported into a workspace, the SDK looks for a hardware platform project in the workspace, that is associated with that BSP project.
When a software application is imported into a workspace, the SDK looks for a hardware platform project and a BSP in the workspace, that are associated with that Application project.
7. After the application and platform are imported and compiled, they appear in the Project Explorer tab.
Board Test BSP (Console App) Settings
The board_test_app_Console_platform (BSP) settings are modified to suite for the board_test_app_Console application. The changes are:
1. Right-click board_test_app_Console_platform and select Board Support Package Settings.
Under the Overview > Supported Libraries, select xilflash library.
The xilflash library provides read, write, erase, lock, and unlock functionality to access a parallel flash device.
3. Click OK.
4. This rebuilds the BSP and application.
Running the Board Test Software Application (Console App)
After the board test application and platform are imported and built, the application can be run on the KC705 board. Follow these steps to set up the serial terminal console, program the FPGA, and run the board test application:
1. The FPGA programming is done as described in section: Running the Hello World Software Project.
2. Set the configuration to Release, as described in section: Running the Hello World Software Project.
3. Start Run Configurations, as described in section: Running the Hello World Software Project.
Select files as below:
Name: board_test_app_Console Release
Project: board_test_app_Console
C/C++ Application: Release/board_test_app_Console.elf
4. Set the STDIO Connection settings as described in section: Running the Hello World Software Project.
5. Click Run. The board_test_app_Console application displays the test menu to the terminal screen.
Tests in the Board Test Application (Console App)
This section describes the tests included in the board test application. These tests are not extensive tests. They exercise the basic functionality of the hardware peripherals in the embedded kit reference system. Below Table describes the tests available in the board_test_app_console application.
Menu | Test | Description |
1 | UART test | Prints Hello World! to the terminal. |
2 | LED test | Flashes the LEDs on the board. |
3 | IIC test | Uses IIC to write to the EEPROM, read the data back, and compare the data. |
4 | Flash test | Tests flash memory by erasing a block in flash memory, writing to that block, reading the data back, and comparing the data. Uses the xilflash library. |
5 | Timer test | Initializes a timer counter and allows it to expire and generate an interrupt. |
6 | Rotary test | Rotary switch that supports detection of left turns, right turns and switch press is tested. |
7 | Switch test | Reads the value of the switches and prints out the ON/ OFF state of each switch. |
8 | SD Card test | Writing and reading blocks from the Secure Digital High Capacity (SDHC) card is tested. The hardware and software driver IPs are provided by Xylon. |
9 | LCD test | Displays a message on the LCD. The LCD supports 2 lines with 16 characters per line. |
A | XADC test | Reads current on-chip temperature and on-chip voltages (VCCINT and VCCAUX). |
B | Button test | Recognizes each push button press. |
C | Ethernet loopback test | Sets the Ethernet PHY to loopback mode and sends and receives a single frame. |
D | External memory test (minimal) | Writes and reads test patterns to a small chunk of memory in the DDR3 SDRAM. |
E | External memory test (complete) | Writes and reads test patterns to complete memory in the DDR3 SDRAM. This test takes a few minutes to complete. |
F | Block RAM memory test | Writes and reads test patterns to internal block RAM memory. |
0 | Exit | Exits the board test application. |
4.2 Application development based on the Xilkernel OS environment
For this part of tutorial, the workspace of previous sections can be used.
However, for simplicity and better understanding, we recommend to use a new workkspace: C:\Kintex-7\software\xilkernel_app\SDK_Workspace
Secondly, the hardware platform used for the board_test_app_Webserver application is same as the one used for board_test_app_Console application.
However, we demonstrated the import of all projects including the hardware platform as well.
The KC705 Embedded Kit has two applications, board_test_app_Webserver and video_demo_app, based on Xilkernel OS.
4.2.1 Import an existing BSP and software application into a workspace (board_test_app_Webserver)
The board_test_app_Webserver application for KC705 system is built on:
Xilkernel OS
Light weight IP (lwip) stack
Xilmfs (memory file system)
The target supports Webserver and is configured with a static IP address. When the host computer is connected to the KC705 target with an Ethernet cable and browsed with the static IP address, a Web page appears on the host computer with the board test applications menu. The user can select the test applications in the Web page by clicking various radio buttons to run the selected test on the target. The KC705 board runs the selected test, posts the results of the board test to the host computer, and the results are displayed in the Web page.
Create a new workspace. Specify the SDK workspace path as C:\Kintex-7\software\xilkernel_app\SDK_Workspace in the Workspace Launcher
Click OK.
Copy the $K7_TRD_HOME/software/xilkernel_app/board_test_app/memfs folder into the workspace folder: C:\Kintex-7\software\xilkernel_app\SDK_Workspace
Click on File > Import > General > Existing Projects into Workspace > Browse