SMP HiFi 2 Development Board: Difference between revisions

From Linux/Xtensa
Jump to navigation Jump to search
No edit summary
(Rewording)
Line 1: Line 1:
These instructions explain how to use HiFi-2 Codec Development environment on a LX200 FPGA board.
These instructions explain how to use HiFi-2 Codec Development environment on an LX200 FPGA board.


Some general notes on these instructions:
Some general notes on these instructions:


*  They are a work in progress, it's currently being prepared for a Tensilica customer.
*  They are a work in progress.
 
*  The following was tested on x86 machines running RedHat Fedora Core 5.


*  The following was tested on x86 machines running RedHat Fedora Core 5.


== Introduction ==
== Introduction ==


We will be going over the steps needed to set up you LX200 board for codec development. Your board likely comes with U-boot preinstalled on it to boot a linux kernel. You will be downloading a copy of buildroot and a linux kernel that have been pre-configured and built for HiFi-2 development. You will be setting up a TFTP server to provide the linux kernle to U-Boot, setting up a NFS server to export a linux root file system and setting up the Linux kernel to boot from your root file system provided by your NFS file server. Once your running on your development board we will suggest how to taylor your board for easy development of your codecs. We will then show you how how to add the Tensilica provided codec packages to the same Mplayer packages used by Buildroot, and finally, builing and installing them. We will demonstrate two proceedured for compiling codecs with XCC, linking them for you development environment, and then debugging them.
This document is addressed to someone who received an LX200 board setup by Tensilica
for HiFi2 codec development.
 
This document goes over the steps needed to set up the LX200 board for codec development.
To summarize:
* Setup the board.  It likely comes with U-boot preinstalled, ready to boot a linux kernel.
* Install '''git'''.
* Download buildroot and linux kernel trees, pre-configured and built for HiFi-2 development.
* Setup a TFTP server to provide the linux kernel to U-Boot.
* Setup an NFS server to export a linux root file system.
* Setup the Linux kernel to boot from the root file system provided by the NFS server.
Once the development board is up and running, this document:
* Suggests a possible way to tailor the board for easy codec development.
* Shows how to add the Tensilica provided codec packages to the Mplayer packages used by Buildroot, including building and installing.
* Demonstrates two procedures for compiling, linking, and debugging codecs.
 
All development is expected to be done on a Linux host.  (One can in principle use Windows to
develop target libraries.  However, linking and subsequent steps need to be done in Linux.)
 


== Downloading The latest HiFI-2 Buildroot and Kernel Snapshots ==
== Downloading the Latest HiFI-2 Buildroot and Kernel Snapshots ==


The HiFi-2 development environment is maintain in a source code version control system named 'git' that is likely a good environemt for you to use when working with this development environemt, thought it can be done without it. We will assume you will be using 'git' but will point out allternatives for those not interested in investing the time to set it up. By introducing you to the git environment used to build this environment we leave you the opportunity to modify it for your needs. For example you might want to debug with a graphical gdb GUI like ddd or add a few more packages from buildroot.
The HiFi-2 development environment is maintained in a source code version control system named 'git'.  The '''git''' tools are useful when working with this development environment, though they are not strictly necessary. This document generally assumes the use of '''git''', which provides more opportunities for modifying this environment as needed (e.g. building more optional buildroot packages).  But points out alternatives to allow getting up and running without having to set it up.


=== Installing git ===
=== Installing git ===
    The Git source code Version Control System can be easily installed in a few minutes. Start by downloading a recient tar ball to your system from:


        http://www.kernel.org/pub/software/scm/git/
To install '''git''', download a recent tarball from the [http://www.kernel.org/pub/software/scm/git/ official site].  For example, <tt>cd</tt> to a location with enough disk space, and do:
 
        $ wget http://www.kernel.org/pub/software/scm/git/git-1.6.5.tar.gz


    Then simpley unpack the tar ball, drop into the git src code, and then make and install it.
Unpack the tarball, and make and install it.  Note:  the install step may need to be run as root.


        $ cp $HOME/Desktop/git-1.6.5.tar.gz .
         $ gunzip git-1.6.5.tar.gz
         $ gunzip git-1.6.5.tar.gz
         $ tar xf git-1.6.5.tar
         $ tar xf git-1.6.5.tar
Line 29: Line 48:
         $ make install
         $ make install


This will usually git to /usr/local/bin or $HOME/bin. It will provide you with easy access to the binariess used to bring up the codec development environment and leave you in place the infrastructure to modify it after you have some experience useing it. All of you changes will be easily seen with the git gui.
This usually installs '''git''' to <tt>/usr/local/bin</tt> or <tt>$HOME/bin</tt>.
 
Using '''git''' provides easy access to the binaries used to bring up the codec development environment, and leaves in place the infrastructure to modify and build this environment should you wish to. Any changes to '''git'''-managed source trees are easily observed with the '''git''' tools.


=== Installing the Buildroot Snapshot ===
=== Installing the Buildroot Snapshot ===


  The HiFi-2 snapshot is in the process of being made. Their are two major components, a Linux kernel git reposiory, and a buildroot git repository. We will download both preconfigured for easily running HiFi-2 codecs. Both the kernel and buildroot are available via git and compressed tar balls. With git being arguable preferable as it will allow you to easly see any changes you have made from this reference starting point.
''Note: The HiFi-2 snapshot is in the process of being made.''
 
The buildtoot environment can be downloaded with git by using the following command:
 
  $ git clone git://git.linux-xtensa.org/git/buildroot/buildroot-xtensa-HiFi2-Snapshot


once git is finished, do a cd to ''buildroot-xtensa-HiFi2-Snapshot'' and checkout the latest stuff; which is currently the snapshot_2+SMP branch. This can be done at the command line with:
To install the buildroot environment (toolchain and root filesystem), <tt>cd</tt> to a location with a few GB of available disk space, and do:


    $ git clone git://git.linux-xtensa.org/git/buildroot/buildroot-xtensa-HiFi2-Snapshot
     $ cd buildroot-xtensa-HiFi2-Snapshot
     $ cd buildroot-xtensa-HiFi2-Snapshot
     $ git branch --track snapshot_2+SMP origin/snapshot_2+SMP
     $ git branch --track snapshot_2+SMP origin/snapshot_2+SMP
     $ git checkout snapshot_2+SMP
     $ git checkout snapshot_2+SMP


The last two lines checkout the latest branch (preconfigured for the 3-core HiFi2 on the LX200).
You can examine the tree (git repository) and its history visually using <tt>git gui</tt>.
'''''No need to give two ways of doing the same thing? Delete this paragraph?'''''
The git GUI is also convenient for checking out the HiFi-2 snapshot and provides a comfortable way for viewing the state of the git repository. To check out the snapshot_2+SMP branch simply run the command 'git gui' and then pull down the branch->create menu. Next put ''snapshot_2+SMP'' into the Name block, select Tracking Branch in the Starting Revision section, and select the origin/snapshot_2+SMP branch. Finally hit the ''Create'' button. This will create your tracking branch which can be easy kept in sync with our git repository.
The git GUI is also convenient for checking out the HiFi-2 snapshot and provides a comfortable way for viewing the state of the git repository. To check out the snapshot_2+SMP branch simply run the command 'git gui' and then pull down the branch->create menu. Next put ''snapshot_2+SMP'' into the Name block, select Tracking Branch in the Starting Revision section, and select the origin/snapshot_2+SMP branch. Finally hit the ''Create'' button. This will create your tracking branch which can be easy kept in sync with our git repository.


Alternativly you can currently ftp a compress tar ball from our ftp server:
If there are issues installing '''git''', as a last resort, an alternative is ftp (may not always get updated, so may be dropped at some point):


         http://www.linux-xtensa.org/pub/snapshots/buildroot-xtensa-smp.2-Nov-2009.tar.gz
         http://www.linux-xtensa.org/pub/snapshots/buildroot-xtensa-smp.2-Nov-2009.tar.gz


but this isn't as clean and may be discontinued.
=== Installing the Linux Kernel Snapshot ===


=== Installing the Linux Kernel Snapshot ===
[TO BE DONE, including adding a snapshot_2+SMP branch]
  [TO BE DONE, including adding a snapshot_2+SMP branch]




== Setting up a TFTP Server to provide the Linux kernel to U-Boot ==
== Setting up a TFTP Server to provide the Linux kernel to U-Boot ==
  [TO BE DONE - Condider installing Kernel in FLASH to avoid need for TFTP]
 
[TO BE DONE - Condider installing Kernel in FLASH to avoid need for TFTP]




== Setting up a NFS Server to export the Root Filesystem ==
== Setting up an NFS Server to export the Root Filesystem ==


Your buildroot has a cpio file that we will use to build a root file system to export via NFS to your LX200 board.
The LX200 board running Linux needs to mount its root filesystem over NFS.
We will also be adding an additional minor changes to make your development environment more comfortable. The
This filesystem was built using buildroot into a cpio format file,
cpio file with your root file system was build and left in:
and left in:


     buildroot-xtensa-HiFi2-Snapshot/buildroot-xtensa-smp/binaries/HiFi-2/rootfs.xtensa_test_mmuhifi_c3.cpio
     buildroot-xtensa-HiFi2-Snapshot/buildroot-xtensa-smp/binaries/HiFi-2/rootfs.xtensa_test_mmuhifi_c3.cpio


Pick a place on your workstation to export you root and unpack the cpio file into that directory.
We will also be adding an additional minor changes to make your development environment more comfortable.
For exmaple here we will set up an export in '''/exports/LINUX_ROOT.HiFi-2_DemoBoard.buildroot-xtensa-smp''':
 
 
Pick a place on your workstation to export your root and unpack the cpio file into that directory.
For example here we will set up an export in '''/exports/LINUX_ROOT.HiFi-2_DemoBoard.buildroot-xtensa-smp''':


     $ cd buildroot-xtensa-HiFi2-Snapshot/buildroot-xtensa-smp/binaries/HiFi-2
     $ cd buildroot-xtensa-HiFi2-Snapshot/buildroot-xtensa-smp/binaries/HiFi-2
     $ cp rootfs.xtensa_test_mmuhifi_c3.cpio /tmp
     $ WHERE=$PWD
     $ cd '''/exports'''
     $ mkdir -p '''/exports/LINUX_ROOT.HiFi-2_DemoBoard.buildroot-xtensa-smp'''
     $ mkdir '''LINUX_ROOT.HiFi-2_DemoBoard.buildroot-xtensa-smp'''
     $ cd '''/exports/LINUX_ROOT.HiFi-2_DemoBoard.buildroot-xtensa-smp'''
     $ cp /tmp/rootfs.xtensa_test_mmuhifi_c3.cpio
     $ cpio -i < $WHERE/rootfs.xtensa_test_mmuhifi_c3.cpio
    $ cat rootfs.xtensa_test_mmuhifi_c3.cpio | cpio -i


Next add a line to /etc/exports:
Next add a line to /etc/exports:
Line 87: Line 112:
     $ /etc/rc.d/init.d/nfs restart
     $ /etc/rc.d/init.d/nfs restart
or
or
     $ sbin/chkconfig nfs on
     $ /sbin/chkconfig nfs on


The showmount command should show your NFS file system now being exported:
The showmount command should show your NFS file system now being exported:


     $ showmount -e
     $ showmount -e
       Export list for pdelaney_fc5.hq.tensilica.com:
       Export list for mypc.foobar.com:
       /exports *
       /exports *
     $
     $
Line 103: Line 128:
   '''minicom xtboard'''
   '''minicom xtboard'''


the boards expect to communicate at with a bauderate of 38400.
the boards expect to communicate at with a baud rate of 38400.


Most users of this board are interested in developing codecs on and will prefer to just boot linux with the root file system we just described how to export on you NFS server. We will use git now to pull a snapshot of a performace 2.6.29 linux kerenel and configure U-Boot to automatically boot it after a power cycle.
Most users of this board are interested in developing codecs on and will prefer to just boot linux with the root file system we just described how to export on you NFS server. We will use git now to pull a snapshot of a performace 2.6.29 linux kerenel and configure U-Boot to automatically boot it after a power cycle.
Line 122: Line 147:
[REMIND: '''Shorten /exports/LINUX_ROOT.HiFi-2_DemoBoard.buildroot-xtensa-smp to /exports/LINUX_ROOT.HiFi-2_DemoBoard''']    [Name to long for the kernel]
[REMIND: '''Shorten /exports/LINUX_ROOT.HiFi-2_DemoBoard.buildroot-xtensa-smp to /exports/LINUX_ROOT.HiFi-2_DemoBoard''']    [Name to long for the kernel]


== Tayloring your system prior to developing your codec ==
== Tailoring your system prior to developing your codec ==
To make your experience more plesant we suggest you tailor you environment.
 
Here are some of the changes that we have found helpfull:
To make your experience more pleasant we suggest you tailor you environment.
Here are some of the changes that we have found helpful:


   1. Add a root password to that you can login with ssh.
   1. Add a root password to that you can login with ssh.
   2. Run rdate with a ntp server on booting.
   2. Run rdate with an ntp server on booting.
   3. Add NFS mounts to /etc/fstab for your code and buildroot code.
   3. Add NFS mounts to /etc/fstab for your code and buildroot code.
   4. Copy in previous ssh server encryption keys to /etc/dropbear to speed up your initial boot.
   4. Copy in previous ssh server encryption keys to /etc/dropbear to speed up your initial boot.
Line 133: Line 159:
       a. Linux Test Suite pre-patch to test the system
       a. Linux Test Suite pre-patch to test the system
       b. Audio test example files
       b. Audio test example files
       c. Copies of Mplayer and it's Plug-ins from Buildroot modified slighly to make instalation easy.
       c. Copies of Mplayer and its Plug-ins from Buildroot modified slightly to make installation easy.
       d. Misc audio test programs.
       d. Misc audio test programs.


Line 140: Line 166:
== Compiling your codec and linking it with Mplayer ==
== Compiling your codec and linking it with Mplayer ==


Mplayer is provided as a example environment for developing and testing Codecs. There
Mplayer is provided as an example environment for developing and testing Codecs. There
are two ways to build Mplayer and the plug-in modules that use the codes. The buildroot
are two ways to build Mplayer and the plug-in modules that use the codecs. The buildroot
that you pulled with git has a copy of mplayer and the Plugins that can be built in the
tree (pulled with git) has a copy of mplayer and the plugins that can be built in the
snapshot via a 'make menuconfig'. This is a good environment to use once your codes are
snapshot via 'make menuconfig'. This is a good environment to use once codecs are
developed and debugged.  
developed and debugged.  


To facilitate developemnt the mplayer packages can be copied to you NFS mounted development
To facilitate development the mplayer packages can be copied to your NFS mounted development
environment. From there you can just configure mplayer to compile on the board and debug
environment. From there you can just configure mplayer to compile on the board and debug
mplayer and your codecs with gdb locally.  
mplayer and your codecs with gdb locally.  
Line 161: Line 187:
they were simply copied from the buildroot-xtensa-HiFi2-Snapshot.2/package directory.
they were simply copied from the buildroot-xtensa-HiFi2-Snapshot.2/package directory.


To get your development environment ready to compile the mplayer plug-in's you need  
To get your development environment ready to compile the mplayer plug-ins you need  
to configure Mplayer to use the local C compiler and linker:
to configure Mplayer to use the local C compiler and linker:


Line 167: Line 193:
     # CFLAGS="-O0 -g3" ./configure
     # CFLAGS="-O0 -g3" ./configure


This will take about 15 minutes to configure. After that you can build build the
This will take about 15 minutes to configure. After that you can build the
plugins or mplayer. If you want to recompile mplayer it's likely best/necessary
plugins or mplayer. If you want to recompile mplayer it's likely best/necessary
to use the same args to .configure as used by buildtoot:
to use the same args to .configure as used by buildroot:


         .CFLAGS="-O0 -g3" ./configure \
         .CFLAGS="-O0 -g3" ./configure \
Line 190: Line 216:




Lets focus on the plugins as they are closest to the goal of developing codecs.
Let's focus on the plugins as they are closest to the goal of developing codecs.
We modified the Makefile of the codes slightly, and hope to check this in
We modified the Makefile of the codes slightly, and hope to check this in
to buildroot. These additions just instruct make how to install the plugins.
to buildroot. These additions just instruct make how to install the plugins.
Line 262: Line 288:
the mplayer_hifi2_mp3_plugin directory to make the mplayer plug-in.  
the mplayer_hifi2_mp3_plugin directory to make the mplayer plug-in.  
Section 6 of the '''Using Tensilica HiFi 2 Codec on Xtensa Linux with MPlayer'' Application Note
Section 6 of the '''Using Tensilica HiFi 2 Codec on Xtensa Linux with MPlayer'' Application Note
has a detailed description of the encapsilation process used by the plug-ins.
has a detailed description of the encapsulation process used by the plug-ins.


== Adding your codec to Buildroot ==
== Adding your codec to Buildroot ==
[TO BE DONE]
[TO BE DONE]


== Know Problems being investiaged, suggested that you know about and possibly avoid ==
== Known Problems being investigated, suggested that you know about and possibly avoid ==


   1. Playing raw audio .wav files eats a lot of memory and can congest the system.
   1. Playing raw audio .wav files eats a lot of memory and can congest the system.
     a. Using NFS over TCP helps with access time, perhaps a ethernet driver bug.
     a. Using NFS over TCP helps with access time, perhaps an ethernet driver bug.
   2. Can't swap over NFS yet, memory can get tight and cause application to be killed.
   2. Can't swap over NFS yet, memory can get tight and cause application to be killed.
     a. Try proceedure documented in U-Boot Manual.
     a. Try proceedure documented in U-Boot Manual.
   3. Compressed files seem to be un-accessable over NFS.
   3. Compressed files seem to be un-accessable over NFS.
   4. Building the C development doesn't work with X11.
   4. Building the C development doesn't work with X11.
   5. Thought Mplayer plug-in can be compiled, Mplayer still has a few issues.
   5. Though Mplayer plug-in can be compiled, Mplayer still has a few issues.
     a. Can't be compiled -O0
     a. Can't be compiled -O0
     b. Compiler infrequently crashes and make has to be restarted.
     b. Compiler infrequently crashes and make has to be restarted.

Revision as of 16:43, 13 November 2009

These instructions explain how to use HiFi-2 Codec Development environment on an LX200 FPGA board.

Some general notes on these instructions:

  • They are a work in progress.
  • The following was tested on x86 machines running RedHat Fedora Core 5.


Introduction

This document is addressed to someone who received an LX200 board setup by Tensilica for HiFi2 codec development.

This document goes over the steps needed to set up the LX200 board for codec development. To summarize:

  • Setup the board. It likely comes with U-boot preinstalled, ready to boot a linux kernel.
  • Install git.
  • Download buildroot and linux kernel trees, pre-configured and built for HiFi-2 development.
  • Setup a TFTP server to provide the linux kernel to U-Boot.
  • Setup an NFS server to export a linux root file system.
  • Setup the Linux kernel to boot from the root file system provided by the NFS server.

Once the development board is up and running, this document:

  • Suggests a possible way to tailor the board for easy codec development.
  • Shows how to add the Tensilica provided codec packages to the Mplayer packages used by Buildroot, including building and installing.
  • Demonstrates two procedures for compiling, linking, and debugging codecs.

All development is expected to be done on a Linux host. (One can in principle use Windows to develop target libraries. However, linking and subsequent steps need to be done in Linux.)


Downloading the Latest HiFI-2 Buildroot and Kernel Snapshots

The HiFi-2 development environment is maintained in a source code version control system named 'git'. The git tools are useful when working with this development environment, though they are not strictly necessary. This document generally assumes the use of git, which provides more opportunities for modifying this environment as needed (e.g. building more optional buildroot packages). But points out alternatives to allow getting up and running without having to set it up.

Installing git

To install git, download a recent tarball from the official site. For example, cd to a location with enough disk space, and do:

       $ wget http://www.kernel.org/pub/software/scm/git/git-1.6.5.tar.gz

Unpack the tarball, and make and install it. Note: the install step may need to be run as root.

       $ gunzip git-1.6.5.tar.gz
       $ tar xf git-1.6.5.tar
       $ cd git-1.6.5
       $ make
       $ make install

This usually installs git to /usr/local/bin or $HOME/bin.

Using git provides easy access to the binaries used to bring up the codec development environment, and leaves in place the infrastructure to modify and build this environment should you wish to. Any changes to git-managed source trees are easily observed with the git tools.

Installing the Buildroot Snapshot

Note: The HiFi-2 snapshot is in the process of being made.

To install the buildroot environment (toolchain and root filesystem), cd to a location with a few GB of available disk space, and do:

   $ git clone git://git.linux-xtensa.org/git/buildroot/buildroot-xtensa-HiFi2-Snapshot
   $ cd buildroot-xtensa-HiFi2-Snapshot
   $ git branch --track snapshot_2+SMP origin/snapshot_2+SMP
   $ git checkout snapshot_2+SMP

The last two lines checkout the latest branch (preconfigured for the 3-core HiFi2 on the LX200).

You can examine the tree (git repository) and its history visually using git gui.

No need to give two ways of doing the same thing? Delete this paragraph? The git GUI is also convenient for checking out the HiFi-2 snapshot and provides a comfortable way for viewing the state of the git repository. To check out the snapshot_2+SMP branch simply run the command 'git gui' and then pull down the branch->create menu. Next put snapshot_2+SMP into the Name block, select Tracking Branch in the Starting Revision section, and select the origin/snapshot_2+SMP branch. Finally hit the Create button. This will create your tracking branch which can be easy kept in sync with our git repository.

If there are issues installing git, as a last resort, an alternative is ftp (may not always get updated, so may be dropped at some point):

        http://www.linux-xtensa.org/pub/snapshots/buildroot-xtensa-smp.2-Nov-2009.tar.gz

Installing the Linux Kernel Snapshot

[TO BE DONE, including adding a snapshot_2+SMP branch]


Setting up a TFTP Server to provide the Linux kernel to U-Boot

[TO BE DONE - Condider installing Kernel in FLASH to avoid need for TFTP]


Setting up an NFS Server to export the Root Filesystem

The LX200 board running Linux needs to mount its root filesystem over NFS. This filesystem was built using buildroot into a cpio format file, and left in:

   buildroot-xtensa-HiFi2-Snapshot/buildroot-xtensa-smp/binaries/HiFi-2/rootfs.xtensa_test_mmuhifi_c3.cpio

We will also be adding an additional minor changes to make your development environment more comfortable.


Pick a place on your workstation to export your root and unpack the cpio file into that directory. For example here we will set up an export in /exports/LINUX_ROOT.HiFi-2_DemoBoard.buildroot-xtensa-smp:

   $ cd buildroot-xtensa-HiFi2-Snapshot/buildroot-xtensa-smp/binaries/HiFi-2
   $ WHERE=$PWD
   $ mkdir -p /exports/LINUX_ROOT.HiFi-2_DemoBoard.buildroot-xtensa-smp
   $ cd /exports/LINUX_ROOT.HiFi-2_DemoBoard.buildroot-xtensa-smp
   $ cpio -i < $WHERE/rootfs.xtensa_test_mmuhifi_c3.cpio

Next add a line to /etc/exports:

   /exports                *(rw,no_root_squash,sync,no_wdelay)

and restart you nfs services:

   $ /etc/rc.d/init.d/nfs restart

or

   $ /sbin/chkconfig nfs on

The showmount command should show your NFS file system now being exported:

   $ showmount -e
     Export list for mypc.foobar.com:
     /exports *
   $


Configuring U-Boot to Boot Linux

Your LX200 board should have arrived with U-Boot installed in the flash ready to use. Just connect a serial interface to a text based terminal emulation program like minicom. We usually just type:

  minicom xtboard

the boards expect to communicate at with a baud rate of 38400.

Most users of this board are interested in developing codecs on and will prefer to just boot linux with the root file system we just described how to export on you NFS server. We will use git now to pull a snapshot of a performace 2.6.29 linux kerenel and configure U-Boot to automatically boot it after a power cycle.

   U-Boot> setenv serverip 192.168.11.78                                                                        [TFTP server IP Address: RTOS-LAB2]
   U-Boot> setenv nfsroot_server 192.168.11.55                                                                  [Root NFS Servers IP Address: My Workstation]
   U-Boot> setenv ipaddr 192.168.11.155                                                                         [HOST IP address]
   U-Boot> setenv bootfile uImage.xtensa-2.6.29-smp.test_mmuhifi_c3                                             [File to fetch with TFTP and pass to bootm]
   U-Boot> setenv root-path /exports/LINUX_ROOT.HiFi-2_DemoBoard.buildroot-xtensa-smp                           [WARNING: Limit path to < 50 characters]
   U-Boot> setenv bootargs_using_bootp=console=ttyS0,38400 ip=bootp root=nfs coredump_filter=0xff               [Args passed to Linux while booting with BOOTP proto]
   U-boot> setenv bootargs console=ttyS0,38400 ip=dhcp root=/dev/nfs rw nfsroot=${nfsroot_server}:${root-path}  [Args passed to Linux while booting with DHCP proto]
   U-boot> setenv bootcmd tftpboot\; bootm                                                                      [Boot Linux after fetching it with TFTP]
   U-Boot> setenv bootdelay=20                                                                                  [Delay 20 seconds before booting automaticaly]
   U-Boot> setenv autostart yes                                                                                 [Boot automatically on power-up/reset]
   U-Boot> saveenv
   U-Boot> 

[REMIND: Shorten /exports/LINUX_ROOT.HiFi-2_DemoBoard.buildroot-xtensa-smp to /exports/LINUX_ROOT.HiFi-2_DemoBoard] [Name to long for the kernel]

Tailoring your system prior to developing your codec

To make your experience more pleasant we suggest you tailor you environment. Here are some of the changes that we have found helpful:

  1. Add a root password to that you can login with ssh.
  2. Run rdate with an ntp server on booting.
  3. Add NFS mounts to /etc/fstab for your code and buildroot code.
  4. Copy in previous ssh server encryption keys to /etc/dropbear to speed up your initial boot.
  5. Mount a 'default' user home directory with:
     a. Linux Test Suite pre-patch to test the system
     b. Audio test example files
     c. Copies of Mplayer and its Plug-ins from Buildroot modified slightly to make installation easy.
     d. Misc audio test programs.
  [TO BE DONE - Where to get 'default' user home directory tar ball and 1st boot patch]

Compiling your codec and linking it with Mplayer

Mplayer is provided as an example environment for developing and testing Codecs. There are two ways to build Mplayer and the plug-in modules that use the codecs. The buildroot tree (pulled with git) has a copy of mplayer and the plugins that can be built in the snapshot via 'make menuconfig'. This is a good environment to use once codecs are developed and debugged.

To facilitate development the mplayer packages can be copied to your NFS mounted development environment. From there you can just configure mplayer to compile on the board and debug mplayer and your codecs with gdb locally.

In the default user home directory we have a directory /home/default/buildroot_mplayer_stuff with a copy of three of the mplayer packages.


   [root@hifi buildroot_mplayer_stuff]# ls -l
    drwxr-xr-x   34 root     root         4096 Nov 10 05:01 MPlayer-1.0rc2/
    drwxr-xr-x    4 root     root         4096 Nov 10 01:36 mplayer_hifi2_aacplus_v2_plugin/
    drwxr-xr-x    3 root     root         4096 Nov 10 00:57 mplayer_hifi2_mp3_plugin/

they were simply copied from the buildroot-xtensa-HiFi2-Snapshot.2/package directory.

To get your development environment ready to compile the mplayer plug-ins you need to configure Mplayer to use the local C compiler and linker:

   # cd /home/default/buildroot_mplayer_stuff/MPlayer-1.0rc2/
   # CFLAGS="-O0 -g3" ./configure

This will take about 15 minutes to configure. After that you can build the plugins or mplayer. If you want to recompile mplayer it's likely best/necessary to use the same args to .configure as used by buildroot:

       .CFLAGS="-O0 -g3" ./configure \
               --prefix=/usr \
               --confdir=/etc/mplayer \
               --with-extraincdir=/usr/include \
               --with-extralibdir=/lib \
               --disable-gui \
               --enable-mad \
               --enable-fbdev \
               --disable-mencoder \
               --disable-dvdnav \
               --disable-dvdread \
               --disable-dvdread-internal \
               --disable-libdvdcss-internal \
               --disable-big-endian \
               --disable-nemesi \
               --disable-tv \
               --enable-dynamic-plugins 


Let's focus on the plugins as they are closest to the goal of developing codecs. We modified the Makefile of the codes slightly, and hope to check this in to buildroot. These additions just instruct make how to install the plugins. For example the mp3 plugin has this addition:

   target_install::
       -mkdir /etc/mplayer
       cp codecs.conf /etc/mplayer
       -mkdir /usr/lib/mplayer
       cp ad_xa_mp3_dec.so /usr/lib/mplayer/
       cp xa_mp3_dec.so /usr/lib/mplayer
       chmod 755 /usr/lib/mplayer/ad_xa_mp3_dec.so
       chmod 755 /usr/lib/mplayer/xa_mp3_dec.so

It's just providing a codec config file for mplayer at /etc/mplayer/codecs.conf and copying the plug-in to /usr/lib/mplayer. To install the mp3 codec plugin and mplayer config file just copy your codec that was compiled with Xcc to the directory, compile it, and install.

       # cd /fac/vol6/audio/release/bin/l32r_LE5_pic
       # cp xa_hifi2_l32r_LE5_pic_mp3_dec_lib_3_1_api_1_15_lib.tgz /tmp
       # 
       # cd /home/default/buildroot_mplayer_stuff
       # cd mplayer_hifi2_mp3_plugin
       # cp /tmp/xa_hifi2_l32r_LE5_pic_mp3_dec_lib_3_1_api_1_15_lib.tgz .
       # gunzip xa_hifi2_l32r_LE5_pic_mp3_dec_lib_3_1_api_1_15_lib.tgz
       # tar xf xa_hifi2_l32r_LE5_pic_mp3_dec_lib_3_1_api_1_15_lib.tar
       # make
       # make target_install
      

The unpacking of the Tensilica mp3 code tar ball will install the following files:

   xa_mp3_dec/
   xa_mp3_dec/README
   xa_mp3_dec/include/
   xa_mp3_dec/include/mp3_dec/
   xa_mp3_dec/include/mp3_dec/xa_mp3_dec_api.h
   xa_mp3_dec/include/xa_apicmd_standards.h
   xa_mp3_dec/include/xa_error_handler.h
   xa_mp3_dec/include/xa_error_standards.h
   xa_mp3_dec/include/xa_memory_standards.h
   xa_mp3_dec/include/xa_type_def.h
   xa_mp3_dec/test/
   xa_mp3_dec/test/build/
   xa_mp3_dec/test/build/ldscript_stream_data.txt
   xa_mp3_dec/test/build/makefile_testbench_sample
   xa_mp3_dec/test/build/paramfilesimple.txt
   xa_mp3_dec/test/include/
   xa_mp3_dec/test/include/id3_tag_decode.h
   xa_mp3_dec/test/src/
   xa_mp3_dec/test/src/xa_mp3_dec_sample_testbench.c
   xa_mp3_dec/test/src/id3_tag_decode.c
   xa_mp3_dec/test/src/stream_data.c
   xa_mp3_dec/test/src/xa_mp3_dec_error_handler.c
   xa_mp3_dec/test/test_inp/
   xa_mp3_dec/test/test_inp/compl.mp3
   xa_mp3_dec/test/test_inp/hihat.mp3
   xa_mp3_dec/test/test_out/
   xa_mp3_dec/test/test_out/force_mkdir.txt
   xa_mp3_dec/test/test_ref/
   xa_mp3_dec/test/test_ref/compl_24bit.wav
   xa_mp3_dec/test/test_ref/hihat_16bit.wav
   xa_mp3_dec/lib/
   xa_mp3_dec/lib/xa_mp3_dec.a
   xa_mp3_dec/doc/
   xa_mp3_dec/doc/HiFi2-MP3-DecoderProgrammersGuide.pdf

[TO BE DONE - Add missing C file, make clean deletes it!]

The xa_mp3_dec.a archive will be used by the Makefile in the mplayer_hifi2_mp3_plugin directory to make the mplayer plug-in. Section 6 of the 'Using Tensilica HiFi 2 Codec on Xtensa Linux with MPlayer Application Note has a detailed description of the encapsulation process used by the plug-ins.

Adding your codec to Buildroot

[TO BE DONE]

Known Problems being investigated, suggested that you know about and possibly avoid

 1. Playing raw audio .wav files eats a lot of memory and can congest the system.
   a. Using NFS over TCP helps with access time, perhaps an ethernet driver bug.
 2. Can't swap over NFS yet, memory can get tight and cause application to be killed.
   a. Try proceedure documented in U-Boot Manual.
 3. Compressed files seem to be un-accessable over NFS.
 4. Building the C development doesn't work with X11.
 5. Though Mplayer plug-in can be compiled, Mplayer still has a few issues.
   a. Can't be compiled -O0
   b. Compiler infrequently crashes and make has to be restarted.