Example application using DSP Link on OMAPL1x

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.

Updated Release 1.10! Based on feedback received, some fixes and improvements were incorporated to the example application, including a Windows command line version. Please check the differences in the file <readme.txt> on the download page and highlighted in the text below.

The old page is still active at this link.

Required Software:

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
<DSPLink_install_dir>/packages/dsplink/doc/design/LNK_031_DES.pdf
...\dsplink\doc\index.html

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

The application requires all the components (OMAPL137 SDK, DSP/BIOS, Code Generation Tools, BSL, ARM compiler tools) to be installed in a host PC.

Installation procedures

The example application is supplied in two versions (Linux and Windows) that should be built in a command line window. Each version has two files: <helloDSPdsp_1_10> for the DSP and <helloDSPgpp_1_10> for the ARM (Linux has .tgz and Windows has .zip extensions). 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
The file ./loadmodules.sh must be executable. Type:
chmod +x *.sh
in the directory where the script is.
You can make this both on the host (PC) or on the device (ARM).
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.

Note: to allow easier observation of the blinking LED operation, the precompiled binaries add a longer delay to each LED transition (around 1 sec per LED) to the function EVMOMAPL137_waitusec() inside <led_test.c>, thus the measured time may be different.

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.

Note: if desired, add a longer delay to each LED transition (around 1 sec per LED) to ease the LED blinking observation. Increase the parameter passed to the function EVMOMAPL137_waitusec() inside <led_test.c>. Please note this change will also reflect in the measured message roundtrip time.


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 compiler, TI's CGT tools, DSP/BIOS, DSP/LINK and BSL.

Release 1.10 already uses the standard installation directory structure used in the Getting Started Guide for OMAP-L137, therefore changes to the Makefiles should not be needed.

Just for reference, the places to change directories are still shown below.

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 := /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/

NOTE: This article is about OMAPL137_arm_1_00_00_10, but you surely have a newer version. Now (Jan/2010) it is available OMAPL137_arm_1_00_00_11 version. So you must edit appropriate Makefiles both on helloDSPdsp and helloDSPgpp and both on Windows and Linux platform! Else the compilation ends with errors that tell it can't find some files.

#   ----------------------------------------------------------------------------
#   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 for Linux, you will have to add executable permissions to the <tconf> and <tconf.x86U> files in the bios directory. For example:

host $ cd /home/user/OMAPL137_arm_1_00_00_10/bios_5_33_05/xdctools
host $ chmod +x tconf
host $ chmod +x tconf.x86U

You can then recompile the DSP side code using:

host $ gmake clean
host $ gmake

On Windows you must replace the original SHELL = /bin/sh in Makefile by this:

SHELL=cmd.exe

(See: Steve Kemp's Homepage about GNU Make for Windows)

Release 1.10. In Windows, it may be necessary to specify the entire path to a suitable gmake utility. For example for the one supplied with DSP/BIOS 5.33.05 the command would be:

winhost> C:\CCStudio_v3.3\bios_5_33_05\xdctools\gmake clean
winhost> C:\CCStudio_v3.3\bios_5_33_05\xdctools\gmake

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/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 := /home/user/OMAPL137_arm_1_00_00_10/dsplink-1_61_03-prebuilt/packages/dsplink

Release 1.10: changes to the Windows makefiles are very similar to their Linux counterparts shown above.

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

host $ gmake clean
host $ gmake

Release 1.10. In Windows, it may be necessary to specify the entire path to a suitable gmake utility. For example for the one supplied with DSP/BIOS 5.33.05 the command would be:

winhost> C:\CCStudio_v3.3\bios_5_33_05\xdctools\gmake clean
winhost> C:\CCStudio_v3.3\bios_5_33_05\xdctools\gmake

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.

Release 1.10 already contains comments and the correct lines on the Makefiles to ease the update. For example, the DSP side Makefile for Windows contains the following instructions:

#   ----------------------------------------------------------------------------
#   Linker library search path for Debug
#   ----------------------------------------------------------------------------
LDINCLUDES_D := $(LDINCLUDES) -i$(DSPLINK)\dsp\export\BIN\DspBios\OMAPL1XX\OMAPL1XXGEM_0\DEBUG\
# If the DSP/Link was rebuilt by the user, replace the line above
# with the one below to use the updated libraries
#LDINCLUDES_D := $(LDINCLUDES) -i$(DSPLINK)\dsp\BUILD\OMAPL1XXGEM_0\EXPORT\DEBUG\

#   ----------------------------------------------------------------------------
#   Linker library search path for Release
#   ----------------------------------------------------------------------------
LDINCLUDES_R := $(LDINCLUDES) -i$(DSPLINK)\dsp\export\BIN\DspBios\OMAPL1XX\OMAPL1XXGEM_0\RELEASE\
# If the DSP/Link was rebuilt by the user, replace the line above
# with the one below to use the updated libraries
#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.

Release 1.10 already contains comments in the Makefile to ease the update. For example, the DSP side Makefile for Windows contains the following instructions:

LIBS := -ldsplink.lib -ldsplinkpool.lib -ldsplinkmpcs.lib -ldsplinkmplist.lib -ldsplinkmsg.lib -ldsplinknotify.lib -ldsplinkringio.lib -levmomapl137bsl.lib 
# If the DSP/Link was rebuilt by the user, add -ldsplinkdata.lib to the line above

In the GPP side Makefile, the only need is to point to the correct library. For example, check the instructions below for the Windows version of the GPP side Makefile:

LIBS_D := "$(DSPLINK)\gpp\export\BIN\Linux\OMAPL1XX\DEBUG\dsplink.lib" $(LIBS)
# If the DSP/Link was rebuilt by the user, replace the line above
# with the one below to use the updated libraries
#LIBS_D := "$(DSPLINK)\gpp\BUILD\EXPORT\DEBUG\dsplink.lib" $(LIBS)
LIBS_R := "$(DSPLINK)\gpp\export\BIN\Linux\OMAPL1XX\RELEASE\dsplink.lib" $(LIBS)
# If the DSP/Link was rebuilt by the user, replace the line above
# with the one below to use the updated libraries
#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(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(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#
root@192.168.1.79:/opt# ./helloDSPgpp helloDSP.out 3
========== Sample Application : helloDSP ==========
Entered helloDSP_Create ()
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 ()
====================================================
ERROR:


 undefined          first referenced 

  symbol                in file

 ---------         ----------------

 _DSPLINKDATA_init /home/user/OMAPL137_arm_1_00_00_10/dsplink-1_61_03-prebuilt/packages/dsplink/dsp/BUILD/OMAPL1XXGEM_0/EXPORT/DEBUG/dsplink.lib<dsplink.obj>

error: unresolved symbols remain
error: errors encountered during linking; "Debug/helloDSP.out" not built

>> Compilation failure
make: *** [Debug/helloDSP.out] Error 1



Building DSP/BIOS file...
Compiling Debug...
<Linking>

undefined          first referenced
 symbol                in file
---------          ----------------
_EVMC6747_LED_init Debug/led_test.obj
_EVMC6747_LED_off  Debug/led_test.obj
_EVMC6747_LED_on   Debug/led_test.obj
_EVMC6747_waitusec Debug/led_test.obj

error: unresolved symbols remain error: errors encountered during linking; "Debug/helloDSP.out" not built


Building DSP/BIOS file...
js: "C:/CCStudio_v3.3/bios_5_33_05/xdctools/include/utils.tci", line 827: except
ion from uncaught JavaScript throw: Error: Can't find Platform.tc[ip] file for '
ti.platforms.evmOMAPL137'
    "C:/OMAPL137_dsp_1_00_00_10/dsplink-1_61_03-prebuilt/packages/dsplink/dsp/in
c/DspBios/5.XX/OMAPL1XXGEM/dsplink-omapl1xxgem-base.tci", line 28
    "C:/CCStudio_v3.3/bios_5_33_05/xdctools/include/utils.tci", line 588
    "C:/CCStudio_v3.3/bios_5_33_05/xdctools/include/utils.tci", line 506
    "./helloDSP.tcf", line 23
make: *** [helloDSPcfg.s62] Error 1
Building DSP/BIOS file...
js> Building DSP/BIOS file...
"tskMessage.c", line 21: fatal error #5: could not open source file
          "helloDSPcfg.h"
  #include "helloDSPcfg.h"
                          ^

1 fatal error detected in the compilation of "tskMessage.c".
Compilation terminated.
js> 
>> Compilation failure
make: *** [Debug/tskMessage.obj] Error 1
Building DSP/BIOS file...
C:\CCStudio_v3.3\bios_5_33_05\xdctools\tconf: can't create session manager: specified script is not a file
make: *** [helloDSPcfg.s62] Error 1
REG(PINMUX8) = 0x21122111; // UART2, McASP1, I2C0, I2C1
REG(PINMUX9) = 0x11011112; // RMII CLK, McASP0, USB_DRVVBUS, UART2
REG(PINMUX10) = 0x22222221; // RMII/ McASP0
REG(PINMUX11) = 0x11112222; // McASP1, UART1, McASP0, MDIO (last 2 digits 0x22 for MDIO instead of GPIO)
REG(PINMUX12) = 0x11111111; // McASP0 / McASP1
REG(PINMUX13) = 0x22111111; // SD / McASP1
REG(PINMUX14) = 0x88222222; // SD / EMIFA
REG(PINMUX15) = 0x21888888; // SD / EMIFA

These values are extracted fro the gel file for the evmomapl137.  It is also needed that SW5(6) be off to connect the LED to the EMIFA.

How to build u-boot.bin

After you make changes in the dv_board.c file, you must compile again the entire U-Boot project. Building U-Boot is possible only on Linux, not on Windows. Type this (replace the <user> with appropriate name):

cd /home/<user>/OMAPL137_arm_1_00_00_11/REL_LSP_02_20_00_07/PSP_02_20_00_07/board_utilities/u-boot-1.3.3
export CROSS_COMPILE=/opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/bin/arm_v5t_le-
make da830_omapl137_config
make all -s

A new u-boot.bin file appears in the directory. Then you will have to flash the u-boot.bin file on your OMAP-L137 board again. For detailed instructions on how to do this please see the Restoring/Flashing OMAP-L137 Bootloaders page. Only the spiflash_writer_ccsv3.out and then the new u-boot.bin are needed to use.

Note: If you use the new U-boot, you also will have to re-compile the DSP/Link libraries. For detailed instructions on how to do this please see Using the_re-compiled DSP/Link_libraries on this page and Building The OMAP-L137 SDK.

E2e.jpg For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Example application using DSP Link on OMAPL1x 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