Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

XDC Runtime OSAL usage

From Texas Instruments Wiki
Jump to: navigation, search

Introduction

Many TI SW offerings are based upon the support of XDC Runtime modules that provide typical services for running embedded signal processing applications. Since these XDC modules are implemented as RTSC packages and RTSC modules, one needs to use the XDC build framework and configuration language to implement an application that takes advantage of the XDC Runtime environment.

While the XDC services allow for efficient configuration and portable application design, they are not a typical component in today's High Level OS (HLOS) SW development communities. They are also fairly heavyweight in terms of the XDC product contents and XDC tooling execution times.

Due to these issues, many authors of embedded processing code who wish to utilize the XDC Runtime model desire to do so without the need for non-standard configuration files and the extra layer of processing introduced by the XDC tooling.

This article demonstrates how application builders can utilize standard tooling and the OSAL product to build applications or libraries that utilize the XDC Runtime model.

The OSAL Product

The OSAL (Operating System Abstraction Layer) product, based on the XDC Runtime, serves several purposes:

  • Redistribute the XDC Runtime sources, pre-configured for HLOS's, and makefiles to build them
  • Provide backend ports (sometimes called 'delegates') of the XDC Runtime services to various HLOS's. An example is Linux GCC.

HLOS users of the OSAL don't require the XDC product; the XDC Runtime headers/sources are redistributed with the OSAL, and makefiles are provided so users can rebuild libraries from source using their own toolchains.

The OSAL product can be downloaded here.

Makefile contents & command line

The following Makefile can be used to build both your application (a simple test app is provided below), as well as the XDC Runtime libraries:

OSAL_INSTALL_DIR = ./osal_1_21_01_08
 
CC = $(CROSS_COMPILE)gcc
CFLAGS = -fPIC -Wall -fno-strict-aliasing -g -I. -I$(OSAL_INSTALL_DIR)/sources
CPPFLAGS = -Dxdc_target_name__=GCArmv5T -Dxdc_target_types__=gnu/targets/arm/std.h
 
test.xv5T: main.o test.o $(OSAL_INSTALL_DIR)/packages/linuxdist/build/lib/osal.a $(OSAL_INSTALL_DIR)/packages/linuxdist/cstubs/lib/cstubs.a
	$(CC) -o $@ $^ -lpthread -lrt -ldl -g
 
$(OSAL_INSTALL_DIR)/packages/linuxdist/build/lib/osal.a:
	$(MAKE) -C $(OSAL_INSTALL_DIR)/packages/linuxdist/build
 
$(OSAL_INSTALL_DIR)/packages/linuxdist/cstubs/lib/cstubs.a:
	$(MAKE) -C $(OSAL_INSTALL_DIR)/packages/linuxdist/cstubs

To build your application, issue the following command:

	% make CROSS_COMPILE=<CGDIR>/arm-2009q1-203/bin/arm-none-linux-gnueabi-

where <CGDIR> is the location in which you have installed your code generation tools. Note the trailing "-" for the CROSS_COMPILE variable definition, be sure to have that.

OSAL_INSTALL_DIR - Points to the location of your installed OSAL package

The target "test.xv5T" is the application that is built consisting of:

  • main.c - main() function
  • test.c - OSAL-calling functions
  • cstubs.a/osal.a - libraries needed from the OSAL tree

This Makefile assumes that you're using GCC, hence $(CROSS_COMPILE)gcc is defined for the CC (C Compile) macro. If you're using a compiler other than GCC, change the definition of CC accordingly.

Source files

Sources for a simple library (test.c) and executable (main.c) follow. This example shows how services from the XDC Runtime (e.g. Log_print()) can be used by an app without requiring the XDC product.

#define Registry_CURDESC    testDesc
 
#include <xdc/std.h>
 
#include <xdc/runtime/Registry.h>
#include <xdc/runtime/Log.h>
#include <xdc/runtime/Diags.h>
 
Registry_Desc testDesc;
 
void test_init()
{
    Registry_addModule(&testDesc, "myTestMod");
    Diags_setMask("myTestMod=EI1");
}
 
void test()
{
    Log_print0(Diags_USER1, "Hello from test USER1\n");
    Log_print0(Diags_ENTRY, "Hello from test ENTRY\n");
    Log_print0(Diags_INFO, "Hello from test INFO\n");
}

The contents of main.c are as follows:

#include <xdc/std.h>
 
int main()
{
  test_init();
 
  test();
 
  return 0;
}

Pre-defined XDC configuration

The XDC Runtime contains modules that need to be configured by XDC. The OSAL product contains pre-configured C files that are the result of a default XDC configuration. This default configuration is located in the following directories:

  • <OSAL_INSTALL_DIR>/packages/linuxdist/preconfig/development
  • <OSAL_INSTALL_DIR>/packages/linuxdist/preconfig/production

in a file named preConfig.cfg.

When run through XDC, preConfig.cfg produces a large C file that is then compiled and included in the OSAL library, available to be picked up by this application build.

Useful links