Build/Run Instructions for Codec Engine Examples
General Information
This page explains how to build example codecs and applications that
use those codecs.
Examples currently contain the simple pass-through (copy) codecs,
implemented in the xDM algorithm standard.
Requirements
See the release notes for the specific software and hardware components this
release of Codec Engine has been validated against.
Directory Structure
examples
+---codecs
| +---auddec_copy
| +---audenc_copy
| +---g711
| +---imgenc_copy
| +---imgdec_copy
| +---scale
| +---sphenc_copy
| +---sphdec_copy
| +---videnc_copy
| `---viddec_copy
|
+---extensions
| `---scale
|
+---servers
| +---all_codecs
| `---video_copy
|
`---apps
+---audio_copy
| +---dualcpu
| `---singlecpu
+---image_copy
+---scale
+---speech
+---speech_copy
+---video_copy
| +---dualcpu
| `---singlecpu
`---system_files
`---davinci
Building the example: step-by-step instructions
1. [Optional] Copy the entire "examples" tree out of the product
This step is optional, but recommended if you plan to modify the
samples in any way. It will ensure you have a backup copy of the
original examples, as provided by the Codec Engine product.
Important: throughout the rest of this text, we will use the
following notation:
- <CE_EXAMPLES_INSTALL_DIR> - absolute path of the
examples directory or the copy you made,
e.g. /usr/work/examples
- <CE_INSTALL_DIR> - root directory of your Codec Engine
installation. The original examples are in
<CE_INSTALL_DIR>/examples.
- <BIOS_INSTALL_DIR> - root directory of your DSP/BIOS
installation.
- <XDC_INSTALL_DIR> - root directory of your xdctools
installation.
- directory/file - position of the file relative to the
examples directory; for examples, codecs/makefile refers to
<CE_EXAMPLES_INSTALL_DIR>/codecs/makefile.
2. Edit XDC user build configuration file, user.bld
File user.bld at the root of the Examples directory informs
the XDC tools (tooling which the Codec Engine uses to build itself,
codecs, servers, etc) where to find compilers and other tools on the
user's system. Open this file in a text editor.
Build.targets
- The Codec Engine is very configurable and runs in many different
environments. The Build.targets array specifies which
targets you want to build for. By default, the C64P, MVArm9, and
Linux86 targets are enabled.
Toolchain roots - rootDir
- C64P.rootDir - Specify where your C64 tools are
Edit the string (directory name) assigned to the C64P.rootDir
variable. Note that both Windows and Linux builds are supported.
Note that this the directory that contains bin/, include/, and lib/
subdirectory. (Note that this is only necessary if "C64P" is
included in your "Build.targets" array)
- MVArm9.rootDir - Specify where your Montavista Arm9 tools are
Edit the string (directory name) assigned to the MVArm9.rootDir
variable. Note that this is the directory that contains bin/ and lib/
subdirectories (inside bin are gcc, as, cpp, and other prefix-free
tool names). (Note that this is only necessary if "MVArm9" is included
in your "Build.targets" array)
- UCArm9.rootDir - Specify where your uclibc-based Arm9 tools are
Edit the string (directory name) assigned to the UCArm9.rootDir
variable. (Note that this is only necessary if "UCArm9" is included
in your "Build.targets" array - it's not by default)
- Linux86.rootDir - Specify where your native, Linux-x86
tools are
Edit the string (directory name) assigned to the Linux86.rootDir
variable. (Note that this is only necessary if "Linux86" is included
in your "Build.targets" array)
3. Edit xdcpaths.mak to define the necessary variables
The xdcpaths.mak file, located at the root of the examples/
directory, defines where the Codec Engine is installed, where BIOS is,
where the XDC tools are, and where individual Codec Engine packages
are. Open this file in a text editor.
- Specify where your Codec Engine installation is:
Uncomment the CE_INSTALL_DIR= line and specify, as the value,
the absolute path to your Codec Engine installation directory.
- Specify where your BIOS installation is:
Uncomment the BIOS_INSTALL_DIR= line and specify the absolute
path to your DSP/BIOS installation directory (Currently, DSP/BIOS is
not available for ARM or x86, so this is only necessary when building
DSP-side content).
- Specify where your XDC tools are installed:
Uncomment the XDC_INSTALL_DIR= line and specify the absolute
path to your XDC tools installation directory.
If you're CE distribution does not include a cetools
directory, you may also have to define the following variables:
- Specify where your xDAIS installation directory is (note that
this must be xDAIS 5.00 or greater, as the ti.xdais.dm package is not
available in previous xDAIS releases):
Uncomment the XDAIS_INSTALL_DIR= line and specify, as the value, the
absolute path to your xDAIS installation directory.
- Specify where your DSP Link installation is:
Uncomment the DSPLINK_INSTALL_DIR= line and specify the absolute
path to your DSP Link installation directory.
- Specify where your CMEM installation is:
Uncomment the CMEM_INSTALL_DIR= line and specify the absolute path
to your CMEM installation directory.
- Specify where your Framework Components installation is:
Uncomment the FC_INSTALL_DIR= line and specify the absolute path to
your FC installation directory (Currently, Framework Components are
not available for ARM or x86, so this is only necessary when building
DSP-side content).
Each directory contains a GNU makefile which enables you to build
the sample in the current directory. Top-level directories also
contain a makefile which steps into subdirectories and builds
all the examples under the parent directory.
FYI, the xdcpaths.mak file is included by the individual makefiles
for all the example codecs, servers, and applications.
Please keep in mind that MOST
BUILD TROUBLES OCCUR WHEN ONE OF THE VARIOUS *_INSTALL_DIR
VARIABLES ARE INCORRECT!
Make sure there are no extra spaces, that every individual path
(segment separated by the semicolon) is correct, character for
character, and the build process is very likely to go smoothly.
4. Build example codecs
Change directory to codecs and type
gmake clean
gmake
Alternatively, you can change into a specific codec's directory
(e.g. codecs/viddec_copy), and type
gmake clean
gmake
5. Build example DSP servers
Note that this is only necessary for dual processor environments,
like DaVinci.
Change directory to servers and type
gmake clean
gmake
Alternatively, you can change into a specific server's directory
(e.g. servers/video_copy), and type
gmake clean
gmake
Note: when developing your own codecs and applications, you will
likely take one of the DSP server sample and modify it to suit your
needs.
These are the source files for this server application that you need to
know about:
- *.cfg: Configuration script that determines what codecs
should be included in the server, and how some of the components
(e.g. DSKT2 and DMAN3) will be configured.
- *.tcf: TConf file for the app. It is set to allow for a
generous heap of 122MB and for 4MB of static code and data. Be very
careful with changing the memory map.
- main.c: generic main()
- link.cmd: application specific linker command file.
7. Edit GPP video_copy client application makefile to specify
package paths for the GPP client application
File apps/video_copy/dualcpu/makefile
builds the GPP client application for the DSP server above. The GPP
(ARM, on DaVinci) application reads input video file "in.dat", calls
the
DSP video encoder codec via the Codec Engine, calls the DSP video
decoder codec on the intermediate data, and writes the resulting output
data to a file, "out.dat". Since both codecs are really just copy
codecs, in.dat and out.dat should be identical.
This makefile, however, is not generic: it is an example of a Linux
application building in a makefile (without XDC), with several
insertions in the makefile that enable inclusions of XDC-generated
portions of the application.
The application contains the following sources:
- app.cfg: RTSC configuration script that determines what codecs
will be made known to the CodecEngine running on the ARM
- app.c: the "meat" of the application, that initializes and uses
the Codec Engine, and also the CMEM (contiguous memory allocator)
module; in a real application, however, this would just be one of the
many modules
- main.c: the generic main() for the application
8. Build the GPP video_copy client application
Change directory to apps/video_copy/dualcpu
(where the makefile is) and type
gmake clean
gmake
Running the video_copy example application
We assume you have your DaVinci EVM properly set up, and that you
are able to mount an NFS.
You must pass the MEM=120M
(or less than 120M) parameter to your Linux kernel from your u-boot
prompt, or you must have your Linux kernel configured to use no more
than 120MB of physical memory. Read more in the following sections
about the memory map.
In an NFS directory visible from the DaVinci board, copy all the
files found in apps/system_files/davinci/. Those files are:
- dsplinkk.ko, a customized version of DSP/BIOS Link for
DaVinci, that allows for dynamic configuration of DSP memory sections.
- cmemk.ko, a Contiguous Memory allocator that allows
allocation of physically contiguous buffers of arbitrary sizes (even
several MB) on Linux. The Codec Engine requires buffers to be usable
by the processor on which the codec runs. In the DaVinci architecture,
where the ARM creates remote codecs on the DSP, the buffers must be
physically contiguous; Linux applications can use CMEM to obtain these
physically contiguous buffers.
- loadmodules.sh, an example loader for the two kernel
modules above.
Copy to the same directory as above the DSP client and GPP
server executables you have built (do it for simplicity; the
executables do not need to be in the same directory where kernel
modules are, but the executables themselves must sit in the same
directory together):
- servers/video_copy/video_copy.x64P
- apps/video_copy/dualcpu/app.out
Also copy the sample input video file to the same directory:
- apps/video_copy/dualcpu/in.dat
Boot the EVM, change to the directory where you have copied all
these files, and run
sh ./loadmodules.sh
This script creates /dev devices for CMEM and DSPLINK if they do not
exist already, and, more importantly, loads both modules with
appropriate information about the memory map. For your reference, here
is the contents of the script:
# insert cmemk, tell it to occupy physical 120MB-128MB, create
# 20 4K buffers, 10 128K buffers and two 1MB buffers
insmod cmemk.ko phys_start=0x87800000 phys_end=0x88000000 pools=20x4096,10x131072,2x1048576
# insert dsplinkk, tell it that DSP's DDR is at physical 250MB-254MB
insmod dsplinkk.ko ddr_start=0x8fa00000 ddr_size=0x400000
# make /dev/dsplink
rm -f /dev/dsplink
mknod /dev/dsplink c `awk "\\$2==\"dsplink\" {print \\$1}" /proc/devices` 0
You can find more information below about the default memory map.
The CMEM module above is instructed to set aside two pools, one
containing 20 4K buffers, the other containing two 1MB buffers. This is
good enough for the video_copy application; your application will
likely need different settings.
When you run the script, you should see the following output:
$ ./loadmodules.sh
cmemk: module license '(c) Texas Instruments' taints kernel.
cmem initialized 3 pools between 0x87800000 and 0x88000000
dsplinkk: no version for "struct_module" found: kernel tainted.
DDR_START 0x8fa00000 DDR_SIZE 0x400000
Next, run the client application, which will automatically load the
DSP server image:
./app.out
You will see several output lines:
App-> Application started.
CEapp-> Allocating contiguous buffer for 'input data' of size 1024...
CEapp-> Contiguous buffer allocated OK (phys. addr=0x87fff000)
CEapp-> Allocating contiguous buffer for 'encoded data' of size 1024...
CEapp-> Contiguous buffer allocated OK (phys. addr=0x87ffe000)
CEapp-> Allocating contiguous buffer for 'output data' of size 1024...
CEapp-> Contiguous buffer allocated OK (phys. addr=0x87ffd000)
App-> Processing frame 0...
App-> Processing frame 1...
App-> Processing frame 2...
App-> Processing frame 3...
App-> Processing frame 4...
App-> Finished encoding and decoding 4 frames
App-> Application finished successfully.
To verify that the application has executed correctly, verify the
newly created out.dat file against the input in.dat
file. They should be identical.
The internal memory map
The DSP has 64K + 80K of internal memory available for code/data
allocation and/or cache. A DSP server's TCONF (.tcf) file completely
controls how this memory space is partitioned.
By default, server examples (found in servers/ directory) are
configured to use:
- 64K for L2 cache
- 16K for L1 cache
- 64K for internal RAM memory, available to codecs for data
allocation
- The BIOS name of this segment is "L1DSRAM". Despite the name,
it is a regular BIOS memory segment.
- The segment has by default a 32K heap in it, so it only has
32K for static data and code.
Please refer to the individual .tcf files for more information about
these memory segments and how you can change them if you need to.
The external memory map
ARM and DSP applications must agree on how the physical memory is
partitioned between them, as they must use the same numbers. The memory
layout concerns the kernel-module loading script on the ARM side, and
the TCONF configuration and one linker command file on the DSP side.
The default memory map is set to provide generous amount of space for
DSP code and data, plenty of private heap for the DSP algorithms, and
large space for shared buffers between Arm and DSP:
- 0x80000000 .. 0x87800000 (0-120MB; size
120MB): Linux, booted with MEM=120M
- 0x87800000 .. 0x88000000 (120-128MB; size 8MB):
CMEM -- shared buffers between Arm, DSP
- 0x88000000 .. 0x8FA00000 (128-250MB; size 122MB):
DDRALGHEAP
(*)-- DSP segment used exclusively for algorithm heaps
- 0x8FA00000 .. 0x8FE00000 (250-254MB; size
4MB): DDR (*)-- DSP segment for code, stack, static
data, and system dynamic data
- 0x8FE00000 .. 0x8FF00000 (254-255MB; size
1MB): DSPLINKMEM (*) memory for DSPLINK
- 0x8FF00000 .. 0x8FF00080 (255MB-255MB; size 128B):
CTRLRESET (*) memory for reset vectors)
- 0x8FF00080 .. 0x8FFFFFFF (255MB-256MB; size 1MB):
waste
(*) are actual DSP linker segments.
Here are the rules for changing the segments:
- If you change any of the segments it is best that you reboot the
board and insert the modules from scratch; alternatively, if you did
not change the CMEM segment you can try removing the dsplinkk module
with "rmmod dsplinkk" and loading it again.
- For now, you cannot change DSPLINK and
CTRLRESET segments' position and size (without rebuilding
DSP Link).
- If you want to change position and size of DDR segment:
- update the TCF file of your DSP server image
- change the ddr_start and ddr_size parameters of the
loadmodules.sh script to reflect the new position of the DDR
segment
- If you want to change position and size of the DDRALGHEAP segment:
- update the TCF file of your DSP server image
- change the -heap parameter in your linker command file to set
how much of the DDR heap will be used for malloc() heap (current
XDAIS allocation is implemented via malloc(), which will change
soon)
- If you want to change position and size of the CMEM segment:
- reboot the board and insert cmemk (you can use loadmodules.sh)
with the proper values.
- In all cases make sure Linux kernel MEM= param is set
low enough.
The above rules assume apply to individual segments; if your memory map
change affects more than one segment, apply all the relevant rules.
Last updated: July 13, 2006