Quality RTOS & Embedded Software

KERNEL
WHAT'S NEW
AWS Reference Integrations
FreeRTOS SMP:
FreeRTOS security certification:
Embedded World track keynote:

FreeRTOS / Xilinx SDK Integration
Integrating FreeRTOS Library and Project Creation into the Xilinx SDK
[RTOS Ports]


Xilinx Spartan 6 SP605 development board

Important information on using FreeRTOS on a MicroBlaze is detailed in the Configuration and Usage section of the main MicroBlaze demo application documentation page. Please refer to this MicroBlaze specific information before using FreeRTOS.


There are two ways of using FreeRTOS in the Xilinx SDK environment:

  1. Using a stand-alone BSP

    A stand-along board support package (BSP) is a library generated by the SDK that is specific to the hardware design (the FPGA configuration). It contains software drivers for the MicroBlaze soft processor itself and all the peripherals included in the design, but it is not FreeRTOS aware. FreeRTOS can be used with a stand-alone BSP by building the FreeRTOS source files as part of the application that references the BSP library. This method is used by the main FreeRTOS MicroBlaze demo application.

  2. Using a FreeRTOS BSP

    A FreeRTOS BSP extends the stand-alone BSP described above to also include the FreeRTOS source files. FreeRTOS can be used with a FreeRTOS BSP without having to include the FreeRTOS source files as part of the application that references the BSP library. This page describes how a FreeRTOS BSP is generated and used, and how the SDK can automatically generate a complete (but simple) FreeRTOS example application that makes use of a FreeRTOS BSP library.


  1. Integrating FreeRTOS into the SDK environment
  2. Using the SDK to create a complete (but simple) FreeRTOS application
  3. Creating a FreeRTOS BSP from within the SDK



Integrating FreeRTOS into the SDK environment

The files required to integrate FreeRTOS into the SDK environment (for versions of the SDK that are not shipped with FreeRTOS pre-integrated) are located in the FreeRTOS/Demo/MicroBlaze_Spartan-6_EthernetLite/KernelAwareBSPRepository directory. To make the SDK environment FreeRTOS aware, the KernelAwareBSPRepository directory must be registered as a repository directory. Before doing this, however, the latest FreeRTOS source files must be copied into the KernelAwareBSPRepository directory. To do this, execute the CreateProjectDirectoryStructure.bat batch file that is located in the FreeRTOS/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource directory. [NOTE: There is no need to run this batch file while the demo project is provided in a separate zip file - it will be required when the demo project is included in the main FreeRTOS.org download.]

CreateProjectDirectoryStructure.bat must be executed before performing any of the steps described below.

To register KernelAwareBSPRepository as a repository directory:

  1. Ensure CreateProjectDirectoryStructure.bat has been executed successfully.

  2. From within the SDK, click Xilinx Tools > Repositories to open the Software Repositories tab in the Preferences dialog box.

  3. To add a local or global repository, click New. Browse to and select the FreeRTOS/Demo/MicroBlaze_Spartan-6_EthernetLite/KernelAwareBSPRepository directory.

Adding the FreeRTOS source repository to the list of referenced repositories
Adding the FreeRTOS BSP repository directory to the list of
referenced repositories within the SDK



Using the SDK to create a complete (but simple) FreeRTOS application

With the repository installed as described above, the SDK menus can be used to create a complete, but very simple, FreeRTOS application. To do this:
  1. From within the SDK, click File > New > Xilinx C Project to open the New Project dialog. If a hardware project has not already been defined, you will be prompted to select one before the New Project dialog opens.

  2. Select "FreeRTOS Hello World" as the Project Template, before clicking Next

    Selecting FreeRTOS Hello World as the project template in the new project dialog
    Selecting FreeRTOS Hello World as the project template in the new project dialog

  3. The next dialog that opens allows the project to be named.

  4. Once the application has been created, the FreeRTOS configuration can be modified using the Board Support Package Settings dialog. To access the Board Support Package Settings dialogue, still within the SDK, click Xilinx Tools > Board Support Package Settings in the SDK. The dialog that opens is the same as depicted in the Creating a FreeRTOS BSP from within the SDK section below.

The simple application created by the SDK does not place any reliance on the hardware on which it is executed (other than the MicroBlaze soft core itself). As a result, there is no visible indication of its status when it is running. Its execution and behavior can, however, be inspected using a debugger.

A description of the applications behavior is contained at the top of the single source file, named FreeRTOS-main.c - which is replicated here for convenience:


/*
 * FreeRTOS-main.c (this file) defines a very simple demo that creates two tasks,
 * one queue, and one timer.
 *
 * The main() Function:
 * main() creates one software timer, one queue, and two tasks.  It then starts
 * the RTOS scheduler.
 *
 * The Queue Send Task:
 * The queue send task is implemented by the prvQueueSendTask() function in
 * this file.  prvQueueSendTask() sits in a loop that causes it to repeatedly
 * block for 200 milliseconds, before sending the value 100 to the queue that
 * was created within main().  Once the value is sent, the task loops back
 * around to block for another 200 milliseconds.
 *
 * The Queue Receive Task:
 * The queue receive task is implemented by the prvQueueReceiveTask() function
 * in this file.  prvQueueReceiveTask() sits in a loop that causes it to
 * repeatedly attempt to read data from the queue that was created within
 * main().  When data is received, the task checks the value of the data, and
 * if the value equals the expected 100, increments the ulRecieved variable.
 * The 'block time' parameter passed to the queue receive function specifies
 * that the task should be held in the Blocked state indefinitely to wait for
 * data to be available on the queue.  The queue receive task will only leave
 * the Blocked state when the queue send task writes to the queue.  As the queue
 * send task writes to the queue every 200 milliseconds, the queue receive task
 * leaves the Blocked state every 200 milliseconds, and therefore toggles the LED
 * every 200 milliseconds.
 *
 * The Software Timer:
 * The software timer is configured to be an "auto reset" timer.  Its callback
 * function simply increments the ulCallback variable each time it executes.
 */



Creating a FreeRTOS BSP from within the SDK

The simple application described above uses a FreeRTOS BSP library. The FreeRTOS BSP library can also be created by itself, without the simple application. To do this:
  1. Ensure KernelAwareBSPRepository is installed as a repository directory, as described previously.

  2. From within the SDK, click File > New > Xilinx Board Support Package to open the New Board Support Package Project dialog. If a hardware project has not already been defined, you will be prompted to select one before the New Board Support Package Project dialog opens.

  3. Select "freertos" as the Board Support Package OS, before clicking Finish.

    Selecting freertos as the board support package OS
    Selecting freertos as the board support package OS


  4. The Board Support Package Settings dialog will open, in which the FreeRTOS parameters can be adjusted as required.

    The board support package (BSP) settings dialog
    Configuring FreeRTOS using the board support package settings dialog.

Once the FreeRTOS BSP has been created, it can be referenced by other SDK projects, to quickly and simply add FreeRTOS controlled multitasking to any application.
















Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
Close Bitnami banner
Bitnami