FreeRTOS Cortex-A9 Demo for QEMU Realview PBX A9 and nVidia Tegra 2

Toradex Colibri T20

Contents

  1. Introduction
  2. Tools
  3. Build
    1. QEMU
    2. Tegra2
  4. Debug
    1. QEMU
    2. Tegra2
  5. Features
  6. Further Work

Introduction

This document is the Readme for the FreeRTOS Cortex-A9 Demo. The document details the development and deployment of the kernel port layer, with the intention of highlighting how open source tools can be used at all stages of the development.

The two Target platforms for this Demo are:

The source code has been compiled using CodeSourcery's 'Sourcery G++ Lite for ARM EABI' toolchain. The Development environment was Eclipse with CDT and GNU ARM C/C++ Development plug-ins. The U-Boot bootloader is utilised on the T20 to provide a stable boot environment from which the kernel can run.

Tools

Get started by acquiring the following tools:

Build

The Demo code has been developed and compiled on Microsoft Windows Vista SP2. QEMU was run on Ubuntu Linux IA64.

It may be necessary to compile QEMU. For more information try QEMU Manual

Build - QEMU

Before proceeding, ensure all of the tools are successfully installed.

Start Eclipse and create a new Workspace. If necessary, proceed to the workbench.

Select 'Import...' from the 'File' menu. Follow the Import wizard options:

  1. Select 'General->Existing projects into Workspace' and click 'Next'
  2. Click on 'Select archive file,' click 'Browse' and navigate to the 'FreeRTOS_Cortex-A9_20110826.zip' file.
  3. Tick the 'FreeRTOS_ARM_Cortex-A9' project and click 'Finish.'

The project will have been imported into the Workspace. Note: if you didn't import from the archive file you need to ensure that the 'Copy projects into workspace' option was ticked for the last step of the import.

Select 'Build All' from the 'Project' menu. If the compilation and linking succeeds then a binary image will be created called FreeRTOS_ARM_Cortex-A9.hex from an 'ELF' file of the same name. Note: there may be some warnings present but these are non-critical.

Build - Tegra2

First follow the build steps for the QEMU Demo.

The only real difference to the QEMU build is the memory mapping of some of the Peripherals. To ease the transition between the two, there is a definition that can be changed in one of the header files that will compile the code with the Tegra2 memory mappings. Edit FreeRTOSConfig.h and change #define configPLATFORM 0 to #define configPLATFORM 1

Perform a clean build of Project and the FreeRTOS_ARM_Cortex-A9.hex will be capable of running on the Tegra2

The Target Platform needs to be prepared to be able to execute the code, including installing the U-Boot bootloader onto the board. However, it is suggested that you ensure that the code is working in the QEMU environment first as there isn't a reliable way of debugging on the target.

Debug - QEMU

Debug Configuration - Step 1
Debug Configuration - Step 2
Debug Configuration - Step 3

Copy the file 'FreeRTOS_ARM_Cortex-A9.hex' from the 'Debug' directory in the project to a directory on the computer that will run QEMU.

Run the QEMU ARM Soft-MMU executable
qemu-system-arm -M realview-pbx-a9 -s -S -nographic -kernel FreeRTOS_ARM_Cortex-A9.hex

Select 'Debug Configurations' from the 'Run' menu and set the following options:

  1. Select 'C/C++ Attach to Application' and click the 'New launch configuration' button.
  2. Configure the launch configuration by finding the 'ELF' excutable within the project and disable 'auto build'.
  3. Switch to the 'Debugger' tab and in the 'Main' category, ensure that the appropriate Debugger has been found.
  4. Select the 'Connection' category from the 'Debugger' tab and ensure that the IP address and port number match the QEMU instance (port 1234 is default for -s)
  5. Click the 'Debug' button. Note: the configuration should be saved and accessible through the debug toolbar button or menu.

If the Debug session has been set-up correctly, the debugger should connect and show address 0x0 which is the reset address. Place a break-point on the entry to main() and click the 'Continue' button.

Once the code has entered main(), it is possible to step through and place other break-points within the code. For example, vCheckTask() is the highest priority task so it will run before any other. Place a break-point on the vTaskDelayUntil() instruction within vCheckTask() and this break-point will be triggered every five seconds.

The Demo consists of a set of tasks that are designed to exercise the operating system functionality. They can be safely removed and replaced with application specific code.

U-Boot with QEMU

U-Boot can be used with QEMU in the same way that it is used for Tegra2.

To use U-Boot, the Hex file needs to be encoded into a bootable image that U-Boot understands. The image is prepared by using the mkimage tool that is compiled as part of U-Boot or is available as part of Linux distribution in the uboot-mkimage package.

Create an uImage that U-Boot understands: mkimage -A arm -O linux -T kernel -C none -a 0x10000 -e 0x10000 -d FreeRTOS_ARM_Cortex-A9.hex -n FreeRTOS FreeRTOS_Demo.uimg
The important options are -a which specifies the address in RAM where to unpack the image and -e specifies the address to start executing the image from. These options must match how the linker script is configured.

Start QEMU with the: qemu-system-arm -M realview-pbx-a9 -s -nographic -kernel u-boot_bin_u-boot_realview.axf -net nic -net user,tftp="." booting the U-Boot image from the ARM Linux Support site. Once it has booted, type tftpboot FreeRTOS_Demo.uimg pressing return then bootm to boot the image.

Executing on the Tegra2

The target needs to have U-Boot installed, a uImage containing the Demo code, downloaded to RAM and then loaded and executed.

Tegra2 Preparation

The Flash on the target needs to be programmed to run the U-boot bootloader. To program the bootloader, the target needs to be placed in Recovery Mode and the nvflash tool is used to program the flash. In theory, you can follow the instructions and use the Config file available from the AntMicro Blog but if that doesn't work, try programming the Linux Image available from Toradex and replacing the third partition (Id=4) with the U-Boot binary. Programming of the Linux image takes a long time. You can program the Linux Image first, try it out and then replace the fastbin bootloader after using recovery mode and nvflash again.

Booting Tegra2

Once the U-Boot bootloader is installed, a uImage of the Tegra2 build of the demo code is required and it can be downloaded either by Serial using the Kermit protocol or via Ethernet and TFTP.

Using C-Kermit to connect through the UART to U-Boot, type in the following commands:

Once connected to the U-Boot prompt, type help to list the commands available. Type loadb followed by the Ctrl \ then c to drop back into the kermit command prompt. Finally type send FreeRTOS_Demo.uimg to download the uImage file.

To start the FreeRTOS Demo, type connect to go back to the U-Boot prompt and type bootm to execute the FreeRTOS Demo.

Missing Features

There are several features that are yet to be implemented/investigated: