Example application using DSP Link on OMAPL1x legacy

From Texas Instruments Embedded Processors Wiki

Jump to: navigation, search
Translate this page to   

This page is provided to help developers use peripherals directly from the DSP side when using OMAP-L1x family of devices. Since it uses extensively DSP/Link and DSP/BIOS as well as the POOL memory allocator, it is highly desirable to have a good understanding on these software technologies.

Note: This is an example application and is provided as-is but is being continuously improved. Please check back anytime.

Contents

Introduction

For many developers that have extensive background on TI DSPs, going to an ARM+DSP processor platform usually imposes a difficult learning curve due to the complexity of the interactions between a High Level Operating System (HLOS) and the familiar DSP/BIOS - not to mention the different development environment (usually Linux).

In order to help with such big learning curve, this article covers in detail an example application that not only loads and runs the DSP from the ARM (using the PROC mechanism of DSP/Link) but also allows the DSP to access hardware peripherals directly (either via CSL or BSL). It also shows a safe method of sharing memory (POOL) and passing control messages (Message Queue or MSGQ) between the two operating systems - Linux on the ARM and DSP/BIOS on the DSP.

Required Software:

https://www-a.ti.com/downloads/sds_support/applications_packages/helloDSP/index.htm (requires my.ti.com registration)

Useful references:

This article extensively uses the following references:

<DSPLink_install_dir>/packages/dsplink/doc/UserGuide.pdf
%BIOS_INSTALL_DIR%/packages/ti/bios/examples/advanced/msgq_tsk2tsk
<DSPLink_install_dir>/packages/dsplink/doc/design/LNK_082_DES.pdf

Outside of the scope of this article is the setup of the Linux machine and the development environment. For details on how to do this, please check:

Overview

The example application is comprised (obviously) of two main processes: a Linux application that loads and starts the DSP using PROC calls, as well as exchanges messages and data through message queues (MSGQ) through a shared memory region configured using POOL; a DSP/BIOS application that starts its execution after being loaded by the Linux application and a task (TSK) receives and sends back messages to it using the same MSGQ and POOL structures. The messages exchanged contain simple Integer commands (0x01 and 0x02) and an Array of Chars that carries the string messages between the two processors.

In essence it is a heavily modified (and simplified) MESSAGE example supplied by DSP/Link, but the concepts are the same. Additional details can be seen in chapter 17 of the DSP/Link User's Guide for details on the example workflow.

ARM side application

For easier comprehension, the ARM side contains three source files:

DSP side application

In the DSP side there are also three source files:

Installation and usage

Requirements

Installation procedures

The example application is supplied in two files: <HelloDSPdsp.tar.gz> for the DSP and <HelloDSPgpp.tar.gz> for the ARM. Extract both to the desired working directory on the host PC.

The DSP executables are located at: <./Debug/helloDSP.out> or <./Release/helloDSP.out>
The ARM executables are located at: <./Debug/helloDSPgpp> or <./Release/helloDSPgpp>

Before running any DSP/Link application, it is also necessary to load its corresponding linux module on your target board.

<DSPLink_install_dir>/packages/dsplink/gpp/export/BIN/Linux/OMAPL1XX/RELEASE

Running the supplied binaries

From the target board command prompt, the application can be executed as follows:

./loadmodules.sh
insmod dsplinkk.ko
rm -f /dev/dsplink
mknod /dev/dsplink c 230 0
./helloDSPgpp helloDSP.out 2
The number "2" in the command above specifies the number of iterations the DSP main routine will execute.

The screen would show something similar to:

root@192.168.1.79:/opt# ./helloDSPgpp helloDSP.out 2
========== Sample Application : helloDSP ==========
Entered helloDSP_Create ()
Leaving helloDSP_Create ()
Entered helloDSP_Execute ()
Message received: DSP is awake!
Message received: Iteration 0 is complete.
Message received: Iteration 1 is complete.
Transferring 2 iterations took 0 seconds 254132 microseconds.
RoundTrip Time for 1 message is 127066 microseconds.
Leaving helloDSP_Execute ()
Entered helloDSP_Delete ()
Leaving helloDSP_Delete ()
====================================================
root@192.168.1.79:/opt#

Note that there is a time measurement for the message passing, and probably the 127066 microseconds seems very large for a simple memory copy operation. However, this value also takes into consideration the total time of the operations including the LED blinking execution time - a much slower process. If desired, these measurements may be prevented by removing the definition -DPROFILE from the CFLAGS variable of the GPP side makefile:

#   ----------------------------------------------------------------------------
#   General options, sources and libraries
#   ----------------------------------------------------------------------------
SRCS := helloDSP.c system_os.c main.c
OBJS :=
DEBUG :=
LDFLAGS := -lpthread
CFLAGS := -DPROFILE
LIBS :=
BIN := helloDSPgpp

Additional steps for building

To build the application, it is necessary to download the EVMOMAPL137 Test Code package from the Spectrum Digital website. This package contains the Board Support Library (BSL) and the LED blinking source code.

At last, before moving on to the build process make sure the Makefiles for both the DSP and the GPP contain the correct installation directories of the Linux compiler, TI's CGT tools, DSP/BIOS, DSP/LINK and BSL.

NOTE: If you followed the Getting Started Guide for OMAP-L137, you will have to set the proper directories in the makefiles.

HelloDSPdsp

For example, in the DSP side makefile changes should be needed at the following places:

#   ----------------------------------------------------------------------------
#   Base for TI toolchain
#   This may change depending if you are using other versions of the compiler
#   ----------------------------------------------------------------------------
BASE_TOOLCHAIN := /opt/ti
BASE_COMPILER := $(BASE_TOOLCHAIN)/c6000/cgt619
BASE_SABIOS := $(BASE_TOOLCHAIN)/bios_5_33_03
BASE_BSP:= $(BASE_TOOLCHAIN)/boards/evmomapl137_v1

If you followed the Getting Started Guide for OMAP-L137, please change it to:

#   ----------------------------------------------------------------------------
#   Base for TI toolchain
#   This may change depending if you are using other versions of the compiler
#   ----------------------------------------------------------------------------
BASE_TOOLCHAIN := /home/user/OMAPL137_arm_1_00_00_10
BASE_COMPILER := $(BASE_TOOLCHAIN)/cg6x_6_1_9
BASE_SABIOS := $(BASE_TOOLCHAIN)/bios_5_33_05
BASE_BSL := $(BASE_TOOLCHAIN)/boards/evmomapl137_v1

NOTE: This assumes that you downloaded the evmomapl137_v1 folder from Spectrum digital and placed it at /home/user/OMAPL137_arm_1_00_00_10/boards/

#   ----------------------------------------------------------------------------
#   Base for DSPLink
#   This may have to be changed depending on your installation paths 
#   and DSPLink version
#   ----------------------------------------------------------------------------
DSPLINK := /opt/OMAPL137_arm_1_00_00_09/dsplink-1_61_03-prebuilt/packages/dsplink

If you followed the Getting Started Guide for OMAP-L137, please change it to:

#   ----------------------------------------------------------------------------
#   Base for DSPLink
#   This may have to be changed depending on your installation paths 
#   and DSPLink version
#   ----------------------------------------------------------------------------
DSPLINK := $(BASE_TOOLCHAIN)/dsplink-1_61_03-prebuilt/packages/dsplink

Important! Due to a bug in DSP/BIOS 5.33.05, you will have to add executable permissions to the <tconf> and <tconf.x86U> files in the bios directory. For example:

You can then recompile the DSP side code using:

HelloDSPgpp

In the ARM side makefile, changes should be needed at the following places:

#   ----------------------------------------------------------------------------
#   Base for toolchain
#   This may change depending if you are using Montavista or Codesourcery
#   ----------------------------------------------------------------------------
BASE_TOOLCHAIN := /opt/mvl_pro_5_0_0/montavista/pro/devkit/arm/v5t_le
#BASE_TOOLCHAIN := /opt/arm/arm-2007q3       # Codesourcery tools

#   ----------------------------------------------------------------------------
#   Name of the Linux compiler
#   This may change depending if you are using Montavista or Codesourcery
#   ----------------------------------------------------------------------------
CC := arm_v5t_le-gcc
#CC := arm-none-linux-gnueabi-gcc

If you followed the Getting Started Guide for OMAP-L137, please change it to:

#   ----------------------------------------------------------------------------
#   Base for toolchain
#   This may change depending if you are using Montavista or Codesourcery
#   ----------------------------------------------------------------------------
BASE_TOOLCHAIN := /opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le
#BASE_TOOLCHAIN := /opt/arm/arm-2007q3       # Codesourcery tools

#   ----------------------------------------------------------------------------
#   Name of the Linux compiler
#   This may change depending if you are using Montavista or Codesourcery
#   ----------------------------------------------------------------------------
CC := arm_v5t_le-gcc
#CC := arm-none-linux-gnueabi-gcc
#   ----------------------------------------------------------------------------
#   Base for DSPLink
#   This may have to be changed depending on
#   your installation and DSPLink version
#   ----------------------------------------------------------------------------
DSPLINK := /opt/OMAPL137_arm_1_00_00_09/dsplink-1_61_03-prebuilt/packages/dsplink

If you followed the Getting Started Guide for OMAP-L137, please change it to:

#   ----------------------------------------------------------------------------
#   Base for DSPLink
#   This may have to be changed depending on
#   your installation and DSPLink version
#   ----------------------------------------------------------------------------
DSPLINK := /home/user/OMAPL137_arm_1_00_00_10/dsplink-1_61_03-prebuilt/packages/dsplink

The application can be built simply by running make or gmake from the command line. For example:

Using the re-compiled DSP/Link libraries

If you followed the procedure to re-compile the DSP/Link libraries in Building_The_OMAP-L137_SDK and want to use them to rebuild this application, please be sure that the correct include library directories are set in the Makefiles.

In the DSP side Makefile, the lines below must be changed from:

#   ----------------------------------------------------------------------------
#   Linker library search path for Debug
#   ----------------------------------------------------------------------------
LDINCLUDES_D := $(LDINCLUDES) -i$(DSPLINK)/dsp/export/BIN/DspBios/OMAPL1XX/OMAPL1XXGEM_0/DEBUG/

#   ----------------------------------------------------------------------------
#   Linker library search path for Release
#   ----------------------------------------------------------------------------
LDINCLUDES_R := $(LDINCLUDES) -i$(DSPLINK)/dsp/export/BIN/DspBios/OMAPL1XX/OMAPL1XXGEM_0/RELEASE/

To:

#   ----------------------------------------------------------------------------
#   Linker library search path for Debug
#   ----------------------------------------------------------------------------
LDINCLUDES_D := $(LDINCLUDES) -i$(DSPLINK)/dsp/BUILD/OMAPL1XXGEM_0/EXPORT/DEBUG/

#   ----------------------------------------------------------------------------
#   Linker library search path for Release
#   ----------------------------------------------------------------------------
LDINCLUDES_R := $(LDINCLUDES) -i$(DSPLINK)/dsp/BUILD/OMAPL1XXGEM_0/EXPORT/RELEASE/

Also, if you followed the entire DSP/Link rebuild procedure you will have to include an additional library called <dsplinkdata.lib> on the DSP-side. Therefore add -ldsplinkdata.lib to the LIBS flag - check the fully modified line below:

LIBS := -ldsplink.lib -ldsplinkpool.lib -ldsplinkmpcs.lib -ldsplinkmplist.lib -ldsplinkmsg.lib -ldsplinknotify.lib -ldsplinkringio.lib -ldsplinkdata.lib -levmomapl137bsl.lib

In the GPP side Makefile, the only need is to point to the correct library. Locate the flags LIBS_D and LIBS_R:

LIBS_D := $(DSPLINK)/gpp/export/BIN/Linux/OMAPL1XX/DEBUG/dsplink.lib $(LIBS)

LIBS_R := $(DSPLINK)/gpp/export/BIN/Linux/OMAPL1XX/RELEASE/dsplink.lib $(LIBS)

And change them to:

LIBS_D := $(DSPLINK)/gpp/BUILD/EXPORT/DEBUG/dsplink.lib $(LIBS)

LIBS_R := $(DSPLINK)/gpp/BUILD/EXPORT/RELEASE/dsplink.lib $(LIBS)

Important! When copying the application to the target board, don't forget to also copy the recently compiled DSP/Link linux module <dsplinkk.ko>. It is located in the two directories above, together with <dsplink.lib>

Modifying the example application

The most obvious modification is to insert custom code in the main DSP code execution inside the TSKMESSAGE_execute() routine.

In file <tskMessage.c> look for the SYS_sprintf() calls that populate the message queue with data to be passed to the ARM side:

if (status == SYS_OK)
{
  MSGQ_setMsgId((MSGQ_Msg) msg, info->sequenceNumber);
  MSGQ_setSrcQueue((MSGQ_Msg) msg, info->localMsgq);
  msg->command = 0x01;
  SYS_sprintf((Char*)msg->arg1, "DSP is awake!");
 (...)
else
{
  /* Include your control flag or processing code here */
  /* LED test code from Board Support Library example  */
  led_test();
  msg->command = 0x02;
  SYS_sprintf((Char*)msg->arg1, "Iteration %d is complete.", i);
 (...)

Also, different types of messages can be passed between the two cores by modifying the struct ControlMsg. Any modifications must be done simultaneously in the files <helloDSP_config.c> on the DSP side and <helloDSP.c> on the GPP side.

typedef struct ControlMsg
{
  MSGQ_MsgHeader header;
  Uint16 command;
  Char* arg1[ARG_SIZE];
} ControlMsg;

To probe further

No application can really be considered finished, therefore some additional features and things to try can greatly add to the example shown above:

Troubleshooting

root@192.168.1.79:/opt# ./helloDSPgpp helloDSP.out 2
========== Sample Application : helloDSP ==========
Entered helloDSP_Create ()
dsplink driver open: /dev/dsplink: No such file or directory
PROC_setup () failed. Status = [0x80008008]
Leaving helloDSP_Create ()
Entered helloDSP_Delete ()
Assertion failed (IS_VALID_MSGQ (msgqQueue)). File : msgq.c Line : 484
MSGQ_release () failed. Status = [0x8000800b]
Assertion failed (((drvObj != NULL) && (IS_OBJECT_VALID (drvObj, SIGN_DRV))) ||
((drvObj == NULL) && (cmdId == CMD_PROC_ATTACH))). File : drv_api.c Line : 509
Assertion failed (IS_VALID_MSGQ (msgqQueue)). File : msgq.c Line : 335
Leaving helloDSP_Delete ()
====================================================
root@192.168.1.79:/opt#
E2e.jpg For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Example application using DSP Link on OMAPL1x legacy here.
Hyperlink blue.png Links
ARM Microcontroller MCU ARM Processor Digital Media Processor Digital Signal Processing Microcontroller MCU Multi Core Processor
Ultra Low Power DSP 8 bit Microcontroller MCU 16 bit Microcontroller MCU 32 bit Microcontroller MCU

Leave a Comment
Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox