NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

OMAP-L137 Audio Drivers in the DSP + Linux

From Texas Instruments Wiki
Jump to: navigation, search

Introduction[edit]

This article discusses implementing communication between the ARM and DSP processors within a highly integrated SoC device, using DSPLink. A demo is provided for the OMAP-L137 DSP + ARM processor. For more information, about this processor please see C674x/OMAPL1x Introductory Information.

In the traditional use for the multicore DSP + ARM devices with Codec Engine, the DSP works as a hardware accelerator to run algorithms that are 'too heavy' for the ARM to run by itself. So, in this case, the ARM has device drivers that control the peripherals (McASP, SPI, UART, etc), and the DSP acts as little more than an 'accelerator' peripheral to the ARM as seen in the figure below.

Codec Engine Application Block Diagram

If you are not using the Drivers on the DSP side, only using the DSP as a hardware accelerator to run algorithms, particularly if you want to work with multiple XDAIS compliant algorithms, please see:

Getting started with IUNIVERSAL

OMAP-L137 iUniversal + ALSA driver

Some developers might want more flexibility for specific applications where the DSP would be able to talk to the peripherals as well as shown in the figure below.

DSPLink Application Block Diagram

The demo provided in this article is an example application where this is implemented. The audio interface is controlled by the DSP, and a simple command line GUI is implemented by the ARM. The ARM and DSP communicate using DSPLink.

This application is a basic example provided "as is" to help developers get started.

Overview of the Application[edit]

Here is the diagram of how this example project operates:

DSPLink Audio Example Application Block Diagram


The ARM side of this application:

  • Loads the DSP execultable and runs it.
  • Sends messages to the DSP application to control the audio volume.
  • When user chooses the quit command ("q") or crtl + C, the ARM sends a message to the DSP side to finalize the application (turn off the audio, close the audio drivers, and free the resources allocated during the application's initialization), kills the DSP application, and after that it exits the ARM application.


The DSP side of this application:

  • Gets the audio from the input channel (it is necessary to feed the application audio in the "Line IN" conector in the board), applies a volume gain, and sends the audio to the output channel (it is necessary to plug speakers or a headset to the "Line OUT" audio connector on the board).
  • Receives messages from the ARM side to adjust volume.
  • Receives message from the ARM side to turn off the audio, close the audio drivers, and free the resources allocated during the application's initialization.

Prerequisites[edit]

Stop and make sure you have the prerequisites installed

Before you get started with this application:


After installing the software, make sure you are using a consistent version combination. Here are the combinations tested and approved:

1) For the versions below, use the installation part of the Getting Started Guides above:

  • bios_5_33_05
  • dsplink-1_61_03-prebuilt
  • cg6x_6_1_9
  • pspdrivers_01_20_00
  • xdctools_3_10_05_61
  • edma3_lld_01_07_00_01

2)

  • dsplink-1_61_03-prebuilt (rebuild with these versions and check)
  • bios_5_41_02_14
  • cg6x_6_1_9
  • Available (requires my.ti.com account) here
  • pspdrivers_01_30_00
  • xdctools_3_16_01_27
  • edma3_lld_01_10_00_01

Adapting your Linux Kernel to avoid conflicts [edit]

In this application, the DSP and the ARM access peripherals using device drivers. In this case, it is necessary to make sure that only one of the cores has control of a given peripheral to avoid access conflicts.

Resource conflict between ARM and DSP

For example, if the DSP is controlling the McASP port, than the ARM should not try to access it in order to avoid conflicts. So the first step in this case would be to identify all of the resources that are used in the DSP and disable it's use in the ARM side. It is possible to achieve that by disabling this resources in the Linux kernel.

Resource agreement between ARM and DSP


Resources used by the DSP[edit]

Here is the list of the peripherals that the DSP side uses:

  • Audio port (McASP1).
  • I2C0 (used to talk to the audio codec).
  • Timer1 (for DSP/BIOS scheduler clock)

Resources used by the ARM[edit]

This Linux side application does not directly touch any peripherals that could cause conflicts with the DSP side. If this example is used as a starting point to more complex applications, make sure to avoid conflitcs with the resources used by the DSP.

Disabling resources in the ARM[edit]

To change the Linux Driver configuration, please follow the steps in the page: Building the OMAP-L137 Linux Kernel. In the menuconfig step (host $ make ARCH=arm CROSS_COMPILE=arm_v5t_le- menuconfig), please make the changes below.

Necessary changes in the Linux kernel[edit]

Disabling Audio Driver[edit]

Necessary: If the Sound Card Support is not disabled, the DSP side can not access it's audio driver, so application does not work.

To change the Linux Driver configuration, please follow the steps in the page: Building the OMAP-L137 Linux Kernel

In menuconfig (see Configuring Linux Kernel in the page above) , disable Device Drivers -> Sound ---> Sound Card support:

Removing Sound Card support from the Linux kernel
Disabling I2C Driver[edit]

Necessary: If the I2C Support is not disabled, the DSP side I2C driver conflicts with the I2C Linux driver, so application does not work around 30% of the time it is called.


In menuconfig, disable CONFIG_I2C at Device Device Drivers -> I2C Support -> I2C support:

Removing I2C support from the Linux kernel

Optional changes in the Linux kernel[edit]

Disabling Timer1[edit]

Optional: Chaging the code and removing the watchdog timer from the Linux kernel configuration is optional. This Linux application did not present any conflicts.


The DSP side will have to use the Timer1 for the DSP/BIOS clock. To avoid possible conflicts, follow the steps bellow:

1) In the file /home/user/workdir/lsp/ti-davinci/linux-2.6.18_pro500/arch/arm/mach-da8xx/time.c, comment the usage of timer1 as the DSP is going to use this:

<syntaxhighlight lang='c'> static int da8xx_timer_irqs[NUM_TIMERS] = { IRQ_DA8XX_TINT12_0, IRQ_DA8XX_TINT34_0,

  1. if 0

IRQ_DA8XX_TINT12_1, IRQ_DA8XX_TINT34_1

  1. endif

}; </syntaxhighlight>

2) In the file /home/user/workdir/lsp/ti-davinci/linux-2.6.18_pro500/arch/arm/mach-da8xx/reset.c, comment the watchdog reset:

<syntaxhighlight lang='c'> void arch_reset(char mode) { // davinci_watchdog_reset(DA8XX_WDOG_BASE); } </syntaxhighlight>

3) In the file /home/user/workdir/lsp/ti-davinci/linux-2.6.18_pro500/include/asm-arm/arch-davinci/time.h, comment the TI_BOT and TI_TOP:

<syntaxhighlight lang='c'> enum { T0_BOT, T0_TOP, /* T1_BOT, */ /* T1_TOP, */ NUM_TIMERS }; </syntaxhighlight>


4) Remove the support for watchdog in the Linux kernel. To change the Linux Driver configuration, please follow the steps in the page: Building the OMAP-L137 Linux Kernel.

In menuconfig (see Configuring Linux Kernel in the page above), disable CONFIG_WATCHDOG at Device Drivers-> Character devices-> Watchdog Cards-> Watchdog Timer Support:

Removing Watchdog Timer Support from the Linux kernel
Disabling SPI Driver[edit]

Optional: Removing SPI support from the Linux kernel configuration is optional. This Linux application did not present any conflicts.

As the SPI and the I2C pins are muxed, it is prudent (but not necessary) to disable SPI support in the Linux kernel.

In menuconfig, disable CONFIG_SPI at Device Device Drivers -> SPI Support -> SPI support:

Removing SPI support from the Linux kernel

Rebuilding DSPLink[edit]

Because changes were made in the kernel, it is necessary to rebuild DSPLink. Follow the procedure at (just build DSPLINK, you are not going to use Codec engine for this application):

Manually building the SDK - DSPLink

Installing the Software[edit]

Linux only build installation[edit]

If you are going to use Linux to build both DSP and ARM sides, than you do not need to download the AudioLink.zip.

  1. The software can be downloaded from the TI forum
  2. Extract the AudioDSPgpp.tgz to the desired working directory on the host Linux PC:
    host $ tar -xvzf AudioLinkLinux.tar.gz

About the software[edit]

This example has 2 parts: code for the DSP and code for the ARM.

The code provided for the ARM is inside the directory AudioDSP/AudioDSPgpp. This uses a Makefile in Linux to build the ARM side.

The code provided by the DSP in inside the directory AudioDSP/AudioDSPdsp. This uses Makefile in Linux to build the DSP side as well.

Building the application[edit]

ARM side[edit]

Adapt AudioDSP/Rules.make[edit]

Before moving on to the build process make sure the AudioDSP/Rules.make file contains the correct installation directories.

This release already uses the standard installation directory structure used in the Getting Started Guide for OMAP-L137, therefore changes to the Rules.Make should be minor.

For reference, the places to change directories are shown below.

In the Rules.make, changes should be needed at the following places:

  • Linux toolchain
#   ----------------------------------------------------------------------------
#   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_GPP := arm_v5t_le-gcc
#CC_GPP := arm-none-linux-gnueabi-gcc
  • SDK installation directory
#   ----------------------------------------------------------------------------
#   Base for SDK
#   This may have to be changed depending on your installation paths and SDK
#   version
#   ----------------------------------------------------------------------------
SDK_INSTALL_DIR = /home/user/OMAPL137_arm_1_00_00_10
  • DSP/Link installation directory
#   ----------------------------------------------------------------------------
#   Base for DSPLink
#   This may have to be changed depending on your installation paths
#   and DSPLink version
#   ----------------------------------------------------------------------------
DSPLINK = $(SDK_INSTALL_DIR)/dsplink-1_61_03-prebuilt/packages/dsplink
  • Make sure that the APP_INSTALL_DIR variable has the diredtory where you want to install the application in the target file system:
# Path to copy the executable on the target file system
APP_INSTALL_DIR = /home/user/workdir/filesys/opt/AudioDSPlink
  • If you did not rebuild DSPLink according to the page Building The OMAP-L1 SDK. Simply remove -ldsplinkdata.lib from the LIBS variable in the AudioDSP/Rules.make file.

Build ARM side[edit]

To build the ARM side of the application, please use the commands:

host $ cd AudioDSPgpp
host $ make clean
host $ make all

After the build is complete, the ARM executable will be at:

AudioDSPgpp/Debug
OR
AudioDSPgpp/Release

DSP side[edit]

Copy PSP[edit]

Because you are buillding the application in Linux and the PSP comes with a Windows installer (that was installed in the Getting Started Guide for C6747), you need to copy the files from your Windows machine to your Linux machine.

So choose your favorite method to tranfer the directory below from your Windows machine:

  • C:\Program Files\Texas Instruments\pspdrivers_01_xx_xx

To the directory below in your Linux machine:

  • /home/<user>/OMAPL137_arm_1_00_00_xx/pspdrivers_01_xx_xx
Adapt AudioDSP/Rules.make[edit]

Before moving on to the build process make sure the AudioDSP/Rules.make file contains the correct installation directories.

This release already uses the standard installation directory structure used in the Getting Started Guide for OMAP-L137, therefore changes to the Rules.Make should be minor.

For reference, the places to change directories are shown below.

In the Rules.make, changes should be needed at the following places:

  • Make sure that the TI toolchain directories are correct:
#   ----------------------------------------------------------------------------
#   Base for TI toolchain
#   This may change depending if you are using other versions of the compiler
#   ----------------------------------------------------------------------------
BASE_COMPILER = $(SDK_INSTALL_DIR)/cg6x_6_1_9
BASE_SABIOS = $(SDK_INSTALL_DIR)/bios_5_33_05

# Path to XDC Tools root dir
XDC_INSTALL_DIR = $(SDK_INSTALL_DIR)/xdctools_3_16_01_27

# Path the DSP-side EDMA3 Low Level Driver root dir
EDMA3LLD_INSTALL_DIR = $(SDK_INSTALL_DIR)/edma3_lld_01_10_00_01
  • Make the BIOSPSP_INSTALL_DIR variable point to the directory that you copied the PSP:
# Path to the DSP-side Platform Support Package driver root dir
BIOSPSP_INSTALL_DIR = $(SDK_INSTALL_DIR)/pspdrivers_01_20_00
  • This example application comes with Rules.make for the case that DSPLink was rebuilt according to the page Building The OMAP-L1 SDK.

If you did not rebuild DSPLink it is necessary to adapt the variables LDINCLUDES_D and LDINCLUDES_R in the AudioDSP/Rules.make file:

#   ----------------------------------------------------------------------------
#   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/
Build DSP side in Linux[edit]
  1. To build the DSP side of the application, please use the commands:
    host $ cd AudioDSPdsp
    host $ make clean
    host $ make all
  2. If you have any problems, please see secion tips for "Build DSP side in Linux"
  3. After the build is complete, the DSP executable will be at:
    AudioDSPdsp/Debug
    OR
    AudioDSPdsp/Release

Calling the application[edit]

In this guide, commands are preceded by prompts that indicate the environment where the command is to be typed. For example:

  • host $
Indicates command to be typed into the shell window of the host Linux workstation.
  • target $
Indicates commands to be typed into the Linux shell in the terminal window connected to the EVM board's serial port.

Copy the files to the target filesystem[edit]

  1. Make the directory:
    • host $ mkdir /home/user/workdir/filesys/opt/AudioDSPlink
    • host $ cd home/user/workdir/filesys/opt/AudioDSPlink
    NOTE: the directory above has to be compatible with the APP_INSTALL_DIR variablen in the Rules.make file.
  2. Copy the file AudioDSPgpp from the installation directory AudioDSPgpp/Debug or AudioDSPgpp/Release to the /home/user/workdir/filesys/opt/AudioDSPlink, you can do that by using the "make installD" or make "InstallR" option:
    • cd to the AudioDSPgpp directory
    • To copy the Debug version (after version is built):
    • host $ make installD
    • To copy the Release version (after version is built):
    • host $ make installR
    NOTE: this will copy the the files to the install directory (APP_INSTALL_DIR) specified at the Rules.make file.
  3. Copy the file AudioLink.out to the /home/user/workdir/filesys/opt/AudioDSPlink directory in your Linux Machine:
    • If you chose to build the DSP side in Linux:
    • cd to the AudioDSPdsp directory
    • To copy the Debug version (after version is built):
    • host $ make installD
    • To copy the Release version (after version is built):
    • host $ make installR
    NOTE: this will copy the the files to the install directory (APP_INSTALL_DIR) specified at the Rules.make file.
  4. Copy the file loadmodules.sh from the installation application's installation directory to the /home/user/workdir/filesys/opt/AudioDSPlink
  5. Copy the dsplink module:
    Get the one you rebuilt according to page Building The OMAP-L1 SDK:
    • host $ cp /home/<useracct>/OMAPL137_arm_1_##_##_##/DSPLINK_DIR/packages/dsplink/gpp/export/BIN/Linux/OMAPL1XX/RELEASE/dsplinkk.ko .

Running the application[edit]

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

  • Go to the applications directory:
target $ cd /opt/AudioDSPlink
  • Load the DSP/Link module first.
target $ ./loadmodules.sh
OR
target $ insmod dsplinkk.ko
target $ rm -f /dev/dsplink
target $ mknod /dev/dsplink c 230 0
  • At last, execute the application:
target $ ./AudioDSPgpp AudioLink.out

The screen would show something similar to:

root@xx.xx.xx.xx:/opt/AudioDSPlink# ./AudioDSPgpp AudioLink.out
========== Sample Application : AudioDSP ==========
Entered AudioDSP_Create ()
Leaving AudioDSP_Create ()
Entered AudioDSP_Execute ()

Commands:
Change volume      - v <volume 0-256>  e.g. 'v 100'
Quit               - q

>

  • If you want to change the volume, type for example:
v 100
  • If you want to exit, type q OR <CRTL + C>

Debugging tips[edit]

tips for "Build DSP side in Linux"[edit]

  1. If you get the error below when building the application:
     <Linking>
     error: cannot find file "dsplinkdata.lib"
    
    It means that you did not rebuild DSPLink according to the page Building The OMAP-L1 SDK. Simply remove -ldsplinkdata.lib to the LIBS variable in the AudioDSP/Rules.make file.
  2. If you get the error below when building the application:
    
     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>
    
    It means that you rebuilt DSPLink according to the page Building The OMAP-L1 SDK. Simply add -ldsplinkdata.lib to the LIBS variable in the AudioDSP/Rules.make file.


  3. If you get the error below when building the application:
     /home/<useract>/OMAPL137_arm_1_00_00_11/bios_5_33_05/xdctools/tconf: Permission denied
     *** [AudioLinkcfg.s62] Error 126
     Leaving directory `/home/<useract>/workdir/omaplaudio/AudioDSP/AudioDSPdsp/build'
     make: *** [build/AudioLinkcfg.cmd] Error 2
    

    You probably have DSP/BIOS version 5.33.05. 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_xx/bios_5_33_05/xdctools
    host $ chmod +x tconf
    host $ chmod +x tconf.x86U
  4. If you get the error below when building the application:
     <Linking>
     undefined                        first referenced
      symbol                              in file
     ---------                        ----------------
    _EDMA3_DRV_disableLogicalChannel  /home/a0193480/OMAPL137_arm_1_00_00_11/pspdrivers_01_30_01/packages/ti/pspiom/i2c/lib/OMAPL137/Debug/ti.pspiom.i2c.a674<I2c.obj>
     error: unresolved symbols remain
     errors encountered during linking; "Debug/AudioLink.out" not built
     Compilation failure
     make: *** [Debug/AudioLink.out] Error 1
    
    Your EDMA version maybe old comared with your PSP version. Please get the latest EDMA version at this link.
  5. If you get the error below when building the application:
    <Linking>
    error: cannot find file "dsplink.lib"
    error: cannot find file "dsplinkpool.lib"
    error: cannot find file "dsplinkmpcs.lib"
    error: cannot find file "dsplinkmplist.lib"
    error: cannot find file "dsplinkmsg.lib"
    error: cannot find file "dsplinknotify.lib"
    error: cannot find file "dsplinkringio.lib"
      undefined     first referenced
     symbol           in file
     ---------     ----------------
    _DSPLINK_init Release/AudioLink_main.obj
    _SMAPOOL_FXNS Release/AudioDSP_config.obj
    _SMAPOOL_init Release/AudioDSP_config.obj
    _ZCPYMQT_FXNS Release/AudioDSP_config.obj
    _ZCPYMQT_init Release/AudioDSP_config.obj
    error: unresolved symbols remain
    error: errors encountered during linking; "Release/AudioLink.out" not built
    >> Compilation failure
    make: *** [Release/AudioLink.out] Error 1
    
    It means that you did not rebuild DSPLink according to the page [[Building_The_OMAP-L137_SDK#DSPLink | Building The OMAP-L1 SDK]. Please see Adapt AudioDSP/AudioDSPdsp/Rules.make
E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article OMAP-L137 Audio Drivers in the DSP + Linux here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article OMAP-L137 Audio Drivers in the DSP + Linux here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article OMAP-L137 Audio Drivers in the DSP + Linux here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article OMAP-L137 Audio Drivers in the DSP + Linux here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article OMAP-L137 Audio Drivers in the DSP + Linux here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article OMAP-L137 Audio Drivers in the DSP + Linux here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article OMAP-L137 Audio Drivers in the DSP + Linux here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article OMAP-L137 Audio Drivers in the DSP + Linux here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article OMAP-L137 Audio Drivers in the DSP + Linux here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity