SMP HiFi 2 Development Board: Difference between revisions

From Linux/Xtensa
Jump to navigation Jump to search
 
(94 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This is the "communitee"" guide for how to use HiFi-2 Codec Development environment on an LX200 FPGA board.
This is a "community" guide for how to use the LX200 board based 3-core SMP HiFi-2 Development environment.
If somethinig doesn't work ir isn't vovered in these guides, please feel free to ask at the [http://lists.linux-xtensa.org/mailman/listinfo Linux//Xtensa Mailing List]]
If something doesn't work or isn't covered in this guide, please feel free to ask at the [http://lists.linux-xtensa.org/mailman/listinfo Linux/Xtensa Mailing List].


<div style="margin:0; margin-top:10px; margin-right:10px; border:1px solid #dfdfdf; padding:0 1em 1em 1em; background-color:#ffffcc; align:right; ">
<div style="margin:0; margin-top:10px; margin-right:10px; border:1px solid #dfdfdf; padding:0 1em 1em 1em; background-color:#ffffcc; align:right; ">
Line 7: Line 7:
Some general notes on these instructions:
Some general notes on these instructions:


*  They are a work in progress.
*  They are a work in progress, though virtually complete. Just needs to have an a another engineer at Tensilica run through this procedure and make sure that we haven't missed anything.


*  The following was tested on x86 machines running RedHat Fedora Core 5.
*  The following was tested on x86 machines running RedHat Fedora Core 5 and Fedora Core 9. Test done while using the Fedora 9 based kernel and the stable branch of the Xtensa kernel appear, so far, to be a bit better. Not seeing any compile errors while stressing the system with LTP, two compiles, two mplayers, hifitest, top, pstree, and top for the
 
first 18 hours; appears to be running perfect till then. No gcc commands or ssh sessions getting killed until almost a day of testing. Only the Unaligned memory access warning on gethostid01 that a staff engineer diagnosed as being a mistake in the gethostid01 LTP test program.  
* Buildroot build with Fedora Core 9 also seems to be fine.
 
* NOTE for Internal Tensilica pre-release Testers:
** Codecs available at /fac/vol6/audio/release/bin/l32r_LE5_pic.
** LX200 bitstream available at /home/marc/XTAV200/test_mmuhifi_c3.3core.
** Instructions to install and set up U-Boot available at http://wiki.linux-xtensa.org/index.php/Setting_up_U-Boot.
*** Checkout the snapshot_2+SMP branch of the U-Boot git repo for pre-built binaries.


</div>
</div>
Line 19: Line 25:


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


This document goes over the steps needed to set up the LX200 board for codec development.
This document goes over the steps needed to set up the LX200 board for HiFi2 development.
To summarize:  
To summarize:  
* Setup the board.  It likely comes with U-boot preinstalled, ready to boot a linux kernel.
* Setup the board.  It likely comes with U-boot pre-installed, ready to boot a linux kernel.
* Install '''git'''.
* Install '''git'''.
* Download buildroot and linux kernel trees, pre-configured and built for HiFi-2 development.
* Download buildroot and linux kernel trees, pre-configured and built for HiFi-2 development.
Line 29: Line 35:
* Setup an NFS server to export a linux root file system.
* 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.
* Setup the Linux kernel to boot from the root file system provided by the NFS server.
* Suggests a possible way to tailor the board for easy codec development just before booting.
Once the development board is up and running, this document:
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.
* 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.
* Demonstrates two procedures for compiling, linking, and debugging codecs.
* Suggest how to add their code to buildroot and come up again with their same development environment.


All development is expected to be done on a Linux host.  (One can in principle use Windows to
All development is expected to be done on a Linux host.  (One can in principle use Windows to
Line 38: Line 46:




== Downloading the Latest HiFI-2 Buildroot and Kernel Snapshots ==
== 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.
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.
Line 82: Line 90:
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:
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'''
     $ '''git clone git://git.linux-xtensa.org/git/buildroot/buildroot-xtensa-HiFi2-Snapshot.git'''
     $ '''cd buildroot-xtensa-HiFi2-Snapshot'''
     $ '''cd buildroot-xtensa-HiFi2-Snapshot'''
     $ '''git branch --track snapshot_2+SMP origin/snapshot_2+SMP'''                           [56 key strokes]
     $ '''git branch --track snapshot_2+SMP origin/snapshot_2+SMP'''  
     $ '''git checkout snapshot_2+SMP'''                                                       [28 key strokes]
     $ '''git checkout snapshot_2+SMP'''  
 
                               
The last two lines checkout the latest branch (preconfigured for the 3-core HiFi2 on the LX200).
The last two lines checkout the latest branch (preconfigured for the 3-core HiFi2 on the LX200).


Line 92: Line 100:
The git GUI is a faster and more convenient method for checking out the HiFi-2 snapshot.  To check out the snapshot_2+SMP branch simply run the command 'git gui' and then pull down the branch->create menu. Next select <>Match Tracking Branch Name  and click on ''origin/snapshot_2+SMP''. Finally hit the Create Button.
The git GUI is a faster and more convenient method for checking out the HiFi-2 snapshot.  To check out the snapshot_2+SMP branch simply run the command 'git gui' and then pull down the branch->create menu. Next select <>Match Tracking Branch Name  and click on ''origin/snapshot_2+SMP''. Finally hit the Create Button.


     $ '''git gui'''''                                                                               [8 key strokes]
     $ '''git gui'''''                                                                      
       [Branch] -> Create...                                                                 [2 key strokes]
       [Branch] -> Create...                                                                
           <> Match Tracking Branch Name                                                     [1 key stroke]
           <> Match Tracking Branch Name                                                    
           <> Tracking Branch                                                                [1 key stroke]
           <> Tracking Branch                                                                 
                 origin/snapshot_2+SMP                                                       [1 key stroke]
                 origin/snapshot_2+SMP                                                        
           [Create]                                                                           [1 key stroke]
           [Create]                                                                          
       [Reposirory]--> Quit                                                                   [2 key strokes]
       [Reposirory]--> Quit                                                                  


If there are issues installing '''git''', as a last resort, an alternative is ftp (may not always get updated, is currenty our of date, waste disk space, so may be dropped at some point):
If there are issues installing '''git''', as a last resort, an alternative is ftp (may not always get updated, is currently our of date, waste disk space, 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         [NOTE: TO BE UPDATED]




Line 109: Line 117:
To install the Linux kernel environment (kernel src, config, and HiFi-2 kernel U-Boot image), <tt>cd</tt> to a location with a few GB of available disk space, and do:
To install the Linux kernel environment (kernel src, config, and HiFi-2 kernel U-Boot image), <tt>cd</tt> to a location with a few GB of available disk space, and do:


     $ '''git clone git://git.linux-xtensa.org/git/kernel/xtensa-2.6.29-smp'''
     $ '''git clone git://git.linux-xtensa.org/git/kernel/xtensa-2.6.29-smp.git'''
     $ '''cd kernel/xtensa-2.6.29-smp'''
     $ '''cd kernel/xtensa-2.6.29-smp'''
     $ '''git branch --track snapshot_2+SMP origin/snapshot_2+SMP'''
 
     $ '''git branch --track snapshot_2+SMP origin/snapshot_2+SMP'''                               [NOTE: The snapshot_2+SMP-stable so far appears to be a bit better]
     $ '''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).  
The last two lines checkout the latest branch (preconfigured for the 3-core HiFi2 on the LX200).
As in the build root case, you can also do it from via git gui using the same proceedure
There is also a more up-to-date branch named '''snapshot_2+SMP-stable''' that has more recent kernel bug-fixes from kernel.org
mantioned above.
but it hasn't been tested as extensively but so far may be show to be a bit more stable than the well tested snapshot_2+SMP branch
when memory gets tight under very heavy loads. This preconfigured 3-core HiFi2 branch has a few NFS bug fixes but nothing that immediately appears to have been a
problem in this environment. Test up to now appear to be a bit better under heavy memory congestion. If you want to use this branch use the following git commands:
 
    $ '''git branch --track snapshot_2+SMP-stable origin/snapshot_2+SMP-stable'''
    $ '''git checkout snapshot_2+SMP-stable'''
   
 
As in the build root case, you can also checkout the branch easily from via '''git gui''' using the same procedure
mentioned above.


Now, assuming we are still in the kernel '''xtensa-2.6.29-smp''' directory
Now, assuming we are still in the kernel '''xtensa-2.6.29-smp''' directory
copy the kernel U-Boot Image ('''uImage''') to the tftp directory; Ex:
copy the kernel U-Boot Image ('''uImage''') to the tftp directory; Ex:


     $ '''cp arch/xtensa/boot/uImage /tftpboot/uImage.xtensa-2.6.29-smp.test_mmuhifi_c3'''
     $ '''cp arch/xtensa/boot/uImage /tftpboot/uImage.xtensa-2.6.29-smp.test_mmuhifi_c3'''         [Note: You may have to make dir /tftpboot]


NOTE: On some system, like Fedora Core 9, the tftpboot directory has been moved to /var/lib/tftpboot.
NOTE: On some system, like Fedora Core 9, the tftpboot directory has been moved to /var/lib/tftpboot.
In this case we recomend that you just added a symbolic pointer from /etc to  /var/lib/tftpboot:
In this case we recommend that you just added a symbolic pointer from /etc to  /var/lib/tftpboot:


     $ su
     $ '''su'''
     # cd /etc
     # '''cd /etc'''
     # /var/lib/tftpboot/ tftpboot
     # '''ln -s /var/lib/tftpboot/ tftpboot'''
     # ls -ld tftpboot
     # '''ls -ld tftpboot'''
         lrwxrwxrwx 1 root root 18 2009-11-23 21:14 tftpboot -> /var/lib/tftpboot/
         lrwxrwxrwx 1 root root 18 2009-11-23 21:14 tftpboot -> /var/lib/tftpboot/
     #  
     #
 
 


== 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 ==
Line 160: Line 176:
                 .
                 .
                 rsync:          off
                 rsync:          off
                 '''tftp:          on'''                                                     [NOTE that tftp is enabled]
                 '''tftp:          on'''                                                                 [NOTE that tftp is enabled]
                 time:          off
                 time:          off
                 time-udp:      off
                 time-udp:      off
Line 177: Line 193:
         .
         .
         .
         .
         '''tftp-server.i386                        0.41-1.2.1            installed'''       [NOTE that tftp server is installed as part of the inet daemon]
         '''tftp-server.i386                        0.41-1.2.1            installed'''     [NOTE that tftp server is installed as part of the inet daemon]
         Matched from:
         Matched from:
         tftp-server
         tftp-server
Line 186: Line 202:
         enabled unless it is expressly needed.  The TFTP server is run from
         enabled unless it is expressly needed.  The TFTP server is run from
         /etc/xinetd.d/tftp, and is disabled by default on Red Hat Linux systems.
         /etc/xinetd.d/tftp, and is disabled by default on Red Hat Linux systems.
        [piet@pdelaney_fc5 ~]$
      $




Line 203: Line 219:
                 wait                    = yes
                 wait                    = yes
                 user                    = root
                 user                    = root
                 server                  = /usr/sbin/in.tftpd                                       [NOTE: /var/lib/tftpboot on Fedora Core 9]
                 server                  = /usr/sbin/in.tftpd                               [NOTE: /var/lib/tftpboot on Fedora Core 9]
                 server_args            = -s /tftpboot
                 server_args            = -s /tftpboot
                 '''disable                = no'''
                 '''disable                = no'''
Line 214: Line 230:
== Setting up an NFS Server to export the Root Filesystem ==
== Setting up an NFS Server to export the Root Filesystem ==


The LX200 board running Linux needs to mount its root filesystem over NFS.
The LX200 board running Linux needs to mount its root file-system over NFS.
This filesystem was built using buildroot into a cpio format file,
This file system was built using buildroot into a compressed cpio format file,
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.gz
 
We will also be adding two additional small files-systems to make your development environment more comfortable
and less time consuming to get started:
 
    /usr/default                                                                    [Home Directory for user 'default']
    /usr/local                                                                      [File system to place enhancements not done by buildroot]
 


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 boards file-systems and unpack the cpio and tar files.
For example here we will export three files-systems in /export:


    '''/exports/LINUX_ROOT.HiFi-2_DemoBoard.buildroot-xtensa-smp'''
    '''/exports/hifi-2_home_default'''
    '''/exports/hifi-2_usr_local'''


Pick a place on your workstation to export your root and unpack the cpio file into that directory.
Here's and example of unpacking the three files-systems:
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''' [Getting binary files in buildroot git repository]
    $
    $ '''gunzip rootfs.xtensa_test_mmuhifi_c3.cpio.gz'''                            [Uncompressing file-system cpio file]
    $ '''gunzip hifi-2_home_default.tar.gz'''                                      [Uncompress /home/default tar ball]
    $ '''gunzip hifi-2_usr_local.tar.gz'''                                          [Uncompress /usr/local tar ball]
    $
     $ '''WHERE=$PWD'''
     $ '''WHERE=$PWD'''
     $ '''mkdir -p /exports/LINUX_ROOT.HiFi-2'''
     $ '''mkdir -p /exports/LINUX_ROOT.HiFi-2'''
    $
     $ '''cd /exports/LINUX_ROOT.HiFi-2'''
     $ '''cd /exports/LINUX_ROOT.HiFi-2'''
     $ '''cpio -i < $WHERE/rootfs.xtensa_test_mmuhifi_c3.cpio'''
     $ '''cpio -i < $WHERE/rootfs.xtensa_test_mmuhifi_c3.cpio'''
    $
    $ '''cd /export'''
    $ '''tar xf hifi-2_home_default.tar'''                                          [Tar in boards /home/default for export]
    $ '''tar xf hifi-2_usr_local.tar'''                                            [Tar in boards /usr/local for export]


Next add a line to /etc/exports:
Next add two lines to /etc/exports:


     /exports                *(rw,no_root_squash,sync,no_wdelay)
     /exports                *(rw,no_root_squash,sync,no_wdelay)                     [Boards File-systems]
    /export                *(rw,no_root_squash,sync,no_wdelay)                    [Buildroot source code]


and restart you nfs services:
and restart you nfs services:
Line 242: Line 279:
     $ '''/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 systems now being exported:


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


== Configuring U-Boot to Boot Linux ==
== Configuring U-Boot to Boot Linux ==


Your LX200 board should have arrived with U-Boot installed in the flash ready to use.  
Your LX200 board should have arrived with U-Boot installed in the flash ready to use.  
The board has a DIP switch next to the power on/of switch that provideds the 6 LSB's
If it fails to boot U-Boot or you happen to have a board without it there are instructions
of the Ethernet MAC in switch positions 1 thru 6.  
at http://wiki.linux-xtensa.org/index.php/Setting_up_U-Boot to make it easy to install.
 
The board has a DIP switch (next to the power on/off switch) that provides the 6 LSBs
of the Ethernet MAC, in switch positions 1 thru 6.  


               DIP Swithes for MAC: 1 2 3 4 5 6 7 8    ethaddr=00:50:C2:13:6f:0a
               DIP Swithes for MAC: 1 2 3 4 5 6 7 8    ethaddr=00:50:C2:13:6f:0a
Line 262: Line 302:
                                                 +------ Enables booting U-Boot from Flash
                                                 +------ Enables booting U-Boot from Flash


DIP switch 8 should arrive with DIP switch 8 on to enable U-Boot booting from flash.
DIP switch 8 should be shipped in the ON position to enable U-Boot booting from flash.
See sections 4.2.3 and 4.2.4 of the '''Tensilica Avnet (XT-AV200) Board User's Guide'''  
See Sections 4.2.3 and 4.2.4 of the '''Tensilica Avnet (XT-AV200) Board User's Guide'''  
for details. Make sure you pick a unique MAC for you board.  
for details. Make sure to select a unique MAC address for you board.
 
Next, connect a serial interface to a text based terminal emulation program,
set to 38400 bps, no parity, 1 stop bit, no handshaking.
For an example of setting [http://en.wikipedia.org/wiki/Minicom minicom]
for this, see [[minicom_xtboard_setup|here]].
 
When you initially power on your LX200 board it will come with a very long wait period before booting and will be waiting to be configured.
You can also hit one of the blue buttons next to the blue LED that's next to the PCI connector to reset the board.
 
The minicom session should look like the following:


The '''arp''' command can be helpfull for detecting aliases:
    U-Boot 2009.08 (Nov 15 2009 - 22:03:26)
   
    CPU:    Xtensa test_mmuhifi_c3 at 41.6777 MHz
    Board:  XT-AV200: Avnet board + Xilinx LX200 FPGA + Tensilica bitstream
    SysRAM: 96 MB
    Flash: 16 MB
    In:    serial
    Out:  serial
    Err:  serial
    MAC:    00:50:C2:13:6f:07
    IP:    192.168.11.105
    open_ethernet
    Autobooting in 999999 seconds, press <SPACE> to stop '''<SPACE>'''
   
    U-Boot> '''printenv'''
    baudrate=38400
    ethaddr=00:50:C2:13:6f:07
    ethact=open_ethernet
    serverip=192.168.11.55
    nfsroot_server=192.168.11.55
    root-path=/exports/LINUX_ROOT.HiFi-2
    bootargs_using_bootp=console=ttyS0,38400 ip=bootp root=nfs coredump_filter=0xff
    bootcmd=tftpboot; bootm
    netmask=255.255.255.0
    gatewayip=192.168.11.1
    nfs_boot_args=root=/dev/nfs rw nfsroot=192.168.11.55:/exports/LINUX_ROOT.HiFi-2
    bootfile=uImage.xtensa-2.6.29-smp.test_mmuhifi_c3-stable
    autostart=no
    bootdelay=999999
    ipaddr=192.168.11.105
    misc_boot_args=debug coredump_filter=0xff
    hostname=HiFi-2
    nfsaddrs=192.168.11.105:192.168.11.55:192.168.11.1:255.255.255.0:HiFi-2
    bootargs=console=ttyS0,38400 ip=192.168.11.105:192.168.11.55:192.168.11.1:255.255.255.0:HiFi-2 root=/dev/nfs rw nfsroot=192.168.11.55:/exports/LINUX_ROOT.HiFi-2 debug coredump_filter=0xff
    stdin=serial
    stdout=serial
    stderr=serial
    ver=U-Boot 2009.08 (Nov 15 2009 - 22:03:26)
   
    Environment size: 788/131068 bytes
    U-Boot>


    $ '''arp -e'''
Here's how to configure U-Boot to automatically boot the Linux kernel on power-up (using the root file system exported over NFS as described further above).
    Address                  HWtype  HWaddress          Flags Mask            Iface
You need to configure UBoot with the IP addresses that are practical in your environment. When using BOOTP or DHCP many of the IP addresses are in the DHCP
    oz.hq.tensilica.com      ether  00:06:5B:18:D8:7A  C                    eth0
config file. Here we first present the simple case where all of the addresses are provided in the U-Boot environment variables:
    192.168.11.1            ether  00:1C:F9:90:13:FC  C                    eth0
    gums.hq.tensilica.com    ether  00:11:43:BB:85:46  C                    eth0
    rtos13.hq.tensilica.com  ether  00:50:C2:13:6F:0F  C                    eth0
    192.168.11.205          ether  00:50:C2:13:6F:07  C                    eth0
    hifi2                            (incomplete)                              eth0
    rtos-lab2.hq.tensilica.  ether  00:19:B9:48:79:32  C                    eth0
    $


Next, connect a serial interface to a text based terminal emulation program like [http://en.wikipedia.org/wiki/Minicom minicom]. We usually just type:
    U-Boot> '''setenv serverip        192.168.11.55'''                                                        [TFTP server IP Address: My Workstation]
    U-Boot> '''setenv nfsroot_server  192.168.11.55'''                                                        [Root NFS Servers IP Address: My Workstation]
    U-Boot> '''setenv ipaddr          192.168.11.105'''                                                        [HOST IP address]
    U-Boot> '''setenv netmask        255.255.255.0'''                                                        [Network Mask for a Internet Class C local network]
    U-Boot> '''setenv gatewayip      192.168.11.1'''                                                          [Gateway address for default route]
    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      /export2/DC_B_330HiFi_3Core_MMU/LINUX_ROOT.HiFi-2'''                    [Location of root filesystem on NFS Server; Limit ~50 bytes]
    U-Boot> '''setenv nfs_boot_args  root=/dev/nfs rw nfsroot=${nfsroot_server}:${root-path}'''              [NFS Args used in bootargs]
    U-Boot> '''setenv hostname        HiFi-2_NFS_Based'''                                                      [Hostname]
    U-Boot> '''setenv nfsaddrs        ${ipaddr}:${nfsroot_server}:${gatewayip}:${netmask}:${hostname}'''      [IP addresses needed by NFS when not using DHCP or BOOTP]
    U-Boot> '''setenv misc_boot_args  debug coredump_filter=0xff'''                                            [Enable kernel debug messages and core files on a SEGV sig]
    U-boot> '''setenv bootargs        console=ttyS0,38400 ip=${nfsaddrs} ${nfs_boot_args} ${misc_boot_args}''' [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      5'''                                                                    [Delay 5 seconds before booting automatically]
    U-Boot> '''setenv autostart      yes'''                                                                  [Boot automatically on power-up/reset]
    U-Boot>


  '''minicom xtboard'''
Alternatively, if you don't feel like setting up an NFS exports you can could use a root filesystem simply located in the kernel RAM.
In this case only TFTP will be used on the local Ethernet to load the kernel. This could be set up with these commands:


which initializes with parameters from /etc/minirc.xtboard:
    U-Boot> '''setenv serverip        192.168.11.55'''                                                          [TFTP server IP Address: My Workstation]
    U-Boot> '''setenv ipaddr          192.168.11.105'''                                                          [HOST IP address]
    U-Boot> '''setenv netmask        255.255.255.0'''                                                          [Network Mask for a Internet Class C local network]
    U-Boot> '''setenv gatewayip      192.168.11.1'''                                                            [Gateway address for default route]
    U-Boot> '''setenv bootfile        uImage.xtensa-2.6.29-smp.test_mmuhifi_c3.ramfs'''                          [File to fetch with TFTP and pass to bootm]
    U-Boot> '''setenv root-path      /export2/DC_B_330HiFi_3Core_MMU/LINUX_ROOT.HiFi-2'''                      [Location of root filesystem on NFS Server; Limit ~50 bytes]
    U-Boot> '''setenv ramfs_boot_args root=/dev/ramfs'''                                                        [RAMFS Args used in bootargs]
    U-Boot> '''setenv hostname        HiFi-2_RamFS_Based'''                                                      [Hostname]
    U-Boot> '''setenv nfsaddrs        ${ipaddr}:${nfsroot_server}:${gatewayip}:${netmask}:${hostname}'''        [IP addresses needed by NFS when not using DHCP or BOOTP]
    U-Boot> '''setenv misc_boot_args  debug coredump_filter=0xff'''                                              [Enable kernel debug messages and core files on a SEGV sig]
    U-boot> '''setenv bootargs        console=ttyS0,38400 ip=${nfsaddrs} ${ramfs_boot_args} ${misc_boot_args}''' [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      5'''                                                                      [Delay 5 seconds before booting automatically]
    U-Boot> '''setenv autostart      yes'''                                                                    [Boot automatically on power-up/reset]
    U-Boot>




        # Machine-generated file - use "minicom -s" to change parameters.
You can also set up your dhcp server with your domain information and boot with much less information
        pr port            /dev/ttyS0
and it's no longer necessary to edit the targets /etc/resolve.conf with your domain server information:
        pu minit
        pu mreset
        pu mdialpre
        pu mconnect
        pu mhangup
        pu mdialcan
        pu hasdcd          No
        pu rtscts          No
~                                               
The LX200 board expects to communicate at with a baud rate of 38400 without parity and with 1 stop bit,
so the minicom '''Comm Parameters''' should be "Current: 38400 8N1" and can be displayed with <Ctrl-A> p:


      Welcome to minicom 2.00.0
    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]
                            ┌───────────[Comm Parameters]────────────┐
   
        OPTIONS: History Buf│                                        │
    U-Boot> '''setenv bootargs_using_bootp console=ttyS0,38400 ip=dhcp root=nfs coredump_filter=0xff'''      [Args passed to Linux while booting with DHCP proto]
        Compiled on Jun 15 2│ Current: 38400 8N1                    │
                            │                                        │
        Press CTRL-A Z for h│  Speed          Parity          Data  │
                            │                                        │
                            │ A: 300          L: None        S: 5  │
                            │ B: 1200          M: Even        T: 6  │
                            │ C: 2400          N: Odd          U: 7  │
                            │ D: 4800          O: Mark        V: 8  │
                            │ E: 9600          P: Space              │
                            │ F: 19200                      Stopbits │
                            │ G: 38400                         W: 1
                            │ H: 57600                        X: 2
                            │ I: 115200        Q: 8-N-1              │
                            │ J: 230400        R: 7-E-1              │
                            │                                        │
                            │                                        │
                            │ Choice, or <Enter> to exit?            │
                            └────────────────────────────────────────┘


Many users of this board are interested in developing codecs and/or HiFi 2 software 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.
If you want to boot with bootp or dhcp you may want your /etc/dhcp.conf file to look something like this:


     U-Boot> '''setenv serverip 192.168.11.55'''                                                                        [TFTP server IP Address: RTOS-LAB2]
     allow bootp;
    U-Boot> '''setenv nfsroot_server 192.168.11.55'''                                                                  [Root NFS Servers IP Address: My Workstation]
    boot-unknown-clients off;
    U-Boot> '''setenv ipaddr 192.168.11.155'''                                                                        [HOST IP address]
    ignore unknown-clients;
    U-Boot> '''setenv bootfile uImage.xtensa-2.6.29-smp.test_mmuhifi_c3'''                                            [File to fetch with TFTP and pass to bootm]
    not authoritative;
    U-Boot> '''setenv root-path /exports/LINUX_ROOT.HiFi-2'''                                                          [WARNING: Limit path to < 50 characters]
    ddns-update-style ad-hoc;
    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]
    option domain-name "hq.tensilica.com";
    U-boot> '''setenv bootcmd tftpboot\; bootm'''                                                                      [Boot Linux after fetching it with TFTP]
   
    U-Boot> '''setenv bootdelay 20'''                                                                                  [Delay 20 seconds before booting automaticaly]
    subnet 192.168.11.0 netmask 255.255.255.0 {
    U-Boot> '''setenv autostart yes'''                                                                                [Boot automatically on power-up/reset]
        default-lease-time 2592000;    # 30 days
     U-Boot> '''saveenv'''
        max-lease-time 31557600;        # 1 year
    U-Boot>
        next-server = option dhcp-server-identifier;
        option routers 192.168.11.1;
        group {
                use-host-decl-names on;
                    ##
                    ## RTOS13  192.168.11.105: HelloSoft LX200 SMP Board on Piet's Desk
                    ##              DIP Swithes for MAC: 1 2 3 4 5 6 7 8    ethaddr=00:50:C2:13:6f:0F
                    ##              Little Endian:       1 1 1 1 0 0 * *
                    ##          Running HiFi-2
                    ##
                    ## hifi2.hq.tensilica.com:192.168.11.105::0x9b0ba8c0
   
                    host hifi2 {
                        hardware ethernet 00:50:c2:13:6f:07;
                        fixed-address hifi2.hq.tensilica.com;
                        next-server pdelaney_fc5.hq.tensilica.com;
                            option root-path "/exports/LINUX_ROOT.HiFi-2
                        option domain-name "hq.tensilica.com";
                        option domain-name-servers 192.168.15.20,192.168.15.21;
                    }
        }
     }


'''[REMIND: Update the above proceedure, show two or thee approaches (ip, dhcp, bootp)]'''
For more information on setting up the Linux Kernel boot parameters see the http://www.linuxdocs.org/HOWTOs/BootPrompt-HOWTO-3.html webpage.


== Tailoring your system prior to Booting ==
== Tailoring your system prior to Booting ==


There are a few tweaks that developers have found convenient to add to the the root file-system before booting.
There are a few tweaks we mentioned that developers have found convenient to add to the the root file-system before booting.
As an initial environment for developing we suggest mounting a /home/default files-system that has number of
As an initial environment for developing we are suggesting to mounting /home/default and /usr/local files-systems which have
files useful for getting started. Find another place to tar in the tar ball with the default users file system.
a number of files useful for getting started.
We chose to include this close to the cpio file with the root file-system. Copy the tar bar to where you are
 
exporting you root file-system and next to it add the 'default' users file-system:
    $ '''cd /export/hifi-2_home_default'''
    $ '''ls -l'''
    drwxrwxrwx  12 root    root        4096 Dec  1 23:33 Audio_Tests/
    drwxr-xr-x    2 default  default     4096 Oct 28 17:46 Files/
    drwxr-xr-x    6 root    root        4096 Dec  2 02:46 LTP_Test/
    drwxr-xr-x    2 root    root        4096 Nov 20 15:13 Music/
    -rw-r--r--    1 10415    10000        841 Nov 20 01:18 SSH_Keys
    drwxr-xr-x    2 root    root         4096 Nov 13 12:14 Tests/
    drwxr-xr-x    2 10415    10000        4096 Nov 19 23:23 hifitest/
    drwxr-xr-x    5 root    root         4096 Dec  2 05:33 mplayer_packages/
    -rwxr-xr-x    1 10415    10000        544 Dec  2 03:01 save_root_files*
    -rw-r--r--   1 root    root        37888 Dec  2 03:13 saved_root_files.tar


    $ cd /export
    $ cp /export/src/HiFi-2_DemoBoard/buildroot-xtensa-HiFi2-Snapshot.10/binaries/default.tar .
    $ tar xf default.tar
    $ cd default
    $ ls
      [TO BE ADDED]


Notice a file tar ball called '''saved_files.tar'''. This ia a tar file of files that
Notice a file tar ball in the /home/default file system called '''saved_root_files.tar'''.  
developers have found convenient to add and replace on the root file system after
This is a tar file of files that developers have found convenient to add and replace on the root file system after
adding a new buildroot file system. Here is a list of the files and a brief
adding a new buildroot file system. Here is a list of the files and a brief explanation on why it's convenient to add or replace them:
explanation on why it's convenient to add or replace them:


     root/.bash_profile                                         [added 'ulimit -c unlimited to allow core dumps to be created]
     root/.bash_profile                           [added 'ulimit -c unlimited to allow core dumps to be created]
     root/.bashrc
     root/.bashrc
     etc/profile                                                 [added 'ulimit -c unlimited to allow core dumps to be created]                                         
     etc/profile                                 [added 'ulimit -c unlimited to allow core dumps to be created]                                         
     etc/fstab                                                   [Tells the system how to mount extra NFS file systems like /home/default]
     etc/fstab                                   [Tells the system how to mount extra NFS file systems like /home/default]
     etc/init.d/S90local                                         [Mounts /home/default]
     etc/init.d/S90local                         [Mounts /home/default]
     etc/resolv.conf                                             [Location of DNS servers when your not using DHCP to boot the kernel]
     etc/resolv.conf                             [Your locations of DNS servers; used when your not using DHCP to boot the kernel]
     etc/TZ                                                     [Your time zone, currently set to California TZ]
                                                [NOTE: restore symlink  /etc/resolv.conf -> /proc/net/pnp if using DHCP]
     etc/dropbear/dropbear_rsa_host_key                         [Old DropBrer keys, useful if you prefer Dropbear of sshd]
     etc/TZ                                       [Your time zone, currently set to California TZ]
     etc/dropbear/dropbear_dss_host_key                         [Old DropBrer keys, useful if you prefer Dropbear of sshd]
     etc/dropbear/dropbear_rsa_host_key           [Old DropBrer keys, useful if you prefer Dropbear of sshd]
     etc/ssh_config                                             [Typically tailored with things like allowing root logins via ssh]
     etc/dropbear/dropbear_dss_host_key           [Old DropBrer keys, useful if you prefer Dropbear of sshd]
     etc/ssh_host_dsa_key                                       [sshd keys - Takes 30 minutes to generate, saves time on initial boot]
     etc/ssh_config                               [Typically tailored with things like allowing root logins via ssh]
     etc/ssh_host_dsa_key.pub                                   [sshd keys - Takes 30 minutes to generate, saves time on initial boot]
     etc/ssh_host_dsa_key                         [sshd keys - Takes 30 minutes to generate, saves time on initial boot]
     etc/ssh_host_dsa_key.pub                     [sshd keys - Takes 30 minutes to generate, saves time on initial boot]
     etc/ssh_host_key                                             
     etc/ssh_host_key                                             
     etc/ssh_host_key.pub
     etc/ssh_host_key.pub
     etc/ssh_host_rsa_key
     etc/ssh_host_rsa_key
     etc/ssh_host_rsa_key.pub
     etc/ssh_host_rsa_key.pub
     etc/sshd_config                                             [Typically tailored with things like allowing root logins via ssh]
     etc/sshd_config                             [Typically tailored with things like allowing root logins via ssh]
     etc/rndc.key                                                 
     etc/rndc.key                                                 
     etc/random-seed                                             [Generated during 1st boot]
     etc/random-seed                             [Generated during 1st boot]
     etc/passwd                                                 [Changed default user's shell to bash]
     etc/passwd                                   [Changed root and default user's shell to bash; runs std bash RC files to set ulimits; adds /usr/local/bin to search path]
     etc/shadow                                                 [Changed default and root users login password to 'linux1', need to ssh to the board]
     etc/shadow                                   [Changed default and root users login password to 'linux1', needed to ssh to the board]
     exports/                                                   [The path to where the board can mount extra file systems like /home/default.
     exports/                                     [The path to where the board can mount extra file systems like /home/default.
     fac/                                                       [Where we get the HiFi-2 codec from to install and build mplayer plugins]
     usr/local                                    [Makes /usr/local so it can be mounted on; it has local additions, including /usr/local/src]
    fac/vol6/                                                  [Where we get the HiFi-2 codec from to install and build mplayer plugins]
    codecs                                      [Makes /codecs for a NFS partition with Tensilica HiFi-2 Codecs to be mounted; the file-system should contain ...
                                                  ... /codecs/xa_hifi2_l32r_LE5_pic_mp3_dec_lib_3_1_api_1_15_lib.tgz
                                                   ... /codecs/xa_hifi2_l32r_LE5_pic_aacplus_v2_dec_lib_2_2_api_1_15_lib.tgz ]
   
Now lets assume your going to stay with mosts of these changes and modify a few of them after tar'ing in these changes to the root file-system.
So here we add the tar ball files to the boards root filesystem.
 
    $ '''cd /exports/LINUX_ROOT.HiFi-2'''
    $ '''tar xf /exports/hifi-2_home_default/saved_root_files.tar'''


Now lets assume your going to stay with these changes and modify them after taring in these changes.
This is a good time to edit a few files on the boards file system before booting it.
Here we add the tar ball files to the boards root filesystem.


     $ '''cd /exports/LINUX_ROOT.HiFi-2'''
     $ '''cd /exports/LINUX_ROOT.HiFi-2'''
     $ '''tar xf /exports/default/'''
     $ '''vi etc/resolv.conf'''                  [Place your domain information if not using a DHCP boot]
                                                [Restore symlink resolv.conf -> /proc/net/pnp if using DHCP]
    $ '''vi etc/fstab'''                        [Change fstab entry for boards root filesystem, and others to your taste]
    $ '''vi etc/init.d/S90local'''              [You might want to disable mounting of non-root NFS file systems ...
                                                  ... on the 1st Boot and add this once you try it manually]
 
== Booting Linux for the 1st Time ==
 
We should now be ready to boot linux on your LX200. You have exported the root file-system and made the
kernel available to a TFTP server. Now let's start with hitting the reset button on the LX200 and it should
auto-boot the kernel, resulting in output such as [[HiFi2_Board_Example_Linux_Boot_Log|this example log]].
 
== Tailoring your system prior to developing for HiFi 2 ==
 
To make your experience more pleasant we suggest you tailoring your environment.
Here are some of the changes that we have found helpful and provided in the '''saved_root_files''':
 
  1. Added a root password to that you can login with ssh.
  2. Running rdate with an ntp server on booting.
  3. Adding 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-in build environment from Buildroot modified slightly to make installation easy.
      d. Misc audio test programs.
  6. Mounting Tensilica HiFi-2 Codecs to easily get mplayer working with HiFi-2 TIE instructions.


This is a good time to edit a few files on the boards file system
== Building Linux Applications ==
before boot it.


    $ '''cd /exports/LINUX_ROOT.HiFi-2'''
=== Building Linux Applications Using GCC on the Host ===
    $ '''vi etc/fstab'''                                       [Change fstab entry for /home/default and others to your taste]
 
    $ '''vi etc/init.d/S90local'''                             [You might want to disable mounting of NFS file systems on the 1st Boot and add this once you try it manually]
You can use the open source toolchain included in the buildroot tree.
 
Given the location of the buildroot tree and the name of the core:
 
  $ '''setenv BUILDROOT_DIR  /export/src/HiFi-2_DemoBoard/buildroot-xtensa-HiFi2-Snapshot.12'''
  $ '''setenv CORENAME      test_mmuhifi_c3'''
 
You can either set the PATH and invoke tools prefixed with <tt>xtensa_${CORENAME}-linux-</tt> :
 
  $ '''setenv PATH  ${BUILDROOT_DIR}/build_xtensa_${CORENAME}/staging_dir/usr/bin:${PATH}
  $ '''xtensa_test_mmuhifi_c3-linux-gcc -g hello.c -o hello'''
  $ '''xtensa_test_mmuhifi_c3-linux-gdb hello'''
 
or alternatively invoke the tools with absolute paths:
 
  $ '''${BUILDROOT_DIR}/build_xtensa_test_mmuhifi_c3/staging_dir/usr/bin/xtensa_test_mmuhifi_c3-linux-gcc -g hello.c -o hello'''
  $ '''${BUILDROOT_DIR}/build_xtensa_test_mmuhifi_c3/staging_dir/usr/bin/xtensa_test_mmuhifi_c3-linux-gdb hello'''
 
=== Building Linux Applications Using GCC on the Target ===
This is the simplest.  (Much slower of course at 45 MHz across a slow Ethernet link than on a workstation,
but very convenient.)  Just login to the target system and use the native <tt>gcc</tt>.
 
=== Building Linux Applications Using XCC (Xtensa Tools) ===
 
There are two approaches to compiling with Tensilica's XCC compiler (part of Xtensa Tools).
The normal one, described below, is to initially setup a virtual core
that has built-in references to the library and include files for the target Linux system.
Alternatively, one could skip this initial setup and just use Xtensa Tools to create
object files and link them using host or target GCC tools.
However, such objects must be built without dependencies on such things as the C library,
which can be harder than it sounds (for example, flags and structures, such as <tt>open()</tt>'s <tt>O_EXCL</tt>
and <tt>stat()</tt>'s <tt>struct stat</tt>, must be avoided because their definitions likely differ between the
Xtensa Tools' default C library and the Linux uClibc library).
''('''Note''': Codecs such as MP3 and AAC are typically written in C with TIE extensions and can only be compiled with XCC.)''
 
 
Section 4.3 of the latest ''Xtensa OSKit Guide'' (from Tensilica's
RC-2009.0 release) describes how to setup XCC to compile Linux applications.
For full details, see the guide.  A summary follows.
 
==== Initial Setup ====


== Booting Linux for the 1st Time ===
The XTENSA_TOOLS_ROOT, XTENSA_ROOT, BUILDROOT_DIR, and TARGET_SYSROOT
environment variables must be set according to where things were installed;
values shown here are for illustration only.  The CORENAME variable, set correctly
below for this board, reflects
the name of the core as known to open source tools (as opposed to XTENSA_CORE
which is the core name as known to Xtensa Tools; both happen to match here).


We should now be ready to boot linux on your LX200. You have exported the root filesystem and made the
kernel avaiable to a TFTP server. Now lets start with hitting the reset button on the X200 and it should
auto-boot the kernel:


     U-Boot 2009.08 (Nov 15 2009 - 22:03:26)
     $ '''setenv USER              someuser'''
    $ '''setenv XTENSA_ROOT      /home/${USER}/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3'''
    $ '''setenv XTENSA_TOOLS_ROOT /home/${USER}/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools'''
    $ '''setenv TARGET_SYSROOT    /exports/LINUX_ROOT.HiFi-2'''
    $ '''setenv BUILDROOT_DIR    /export/src/HiFi-2_DemoBoard/buildroot-xtensa-HiFi2-Snapshot'''
      
      
     CPU:    Xtensa test_mmuhifi_c3 at 41.6777 MHz
     $ '''setenv CORENAME        test_mmuhifi_c3
    Board:  XT-AV200: Avnet board + Xilinx LX200 FPGA + Tensilica bitstream
    SysRAM: 96 MB
    Flash: 16 MB
    In:    serial
    Out:  serial
    Err:  serial
    MAC:    00:50:C2:13:6f:07
    IP:    192.168.11.105
    open_ethernet
    Autobooting in 5 seconds, press <SPACE> to stop
    Using open_ethernet device
    TFTP from server 192.168.11.55; our IP address is 192.168.11.105
    Filename 'uImage.xtensa-2.6.29-smp.test_mmuhifi_c3'.
    Load address: 0xd2000000
    Loading: #################################################################
            ###############
    done
    Bytes transferred = 1161826 (11ba62 hex)
    Automatic boot of image at addr 0xD2000000 ...
    ## Booting kernel from Legacy Image at d2000000 ...
      Image Name:  Linux-2.6.29-rc7
      Image Type:  Xtensa Linux Kernel Image (gzip compressed)
      Data Size:    1161762 Bytes =  1.1 MB
      Load Address: d0001000
      Entry Point:  d0001000
      Verifying Checksum ... OK
      Uncompressing Kernel Image ... OK
   
    ## Linux Boot Params Starting At Address:0xd5f50000
      MEMORY:          tag:0x1003, type:0X1000, start:0X0, end:0X6000000
      COMMAND_LINE:    tag:0x1001, size:188, data:'console=ttyS0,38400 ip=192.168.11.105:192.168.11.55:192.168.11.1:255.255.255.0:"HiFi-2 Demo" root=/dev/nfs rw nfsroot=192.168.11.55:/exports/LINUX_ROOT.HiFi-2 debug coredump_filter=0xff'
      SERIAL_BAUDRATE: tag:0x1004, size:4, baudrate:38400
      
      
     ## Transferring Control to Linux Kernel At Address 0xd0001000 ...
     $ '''cd ${BUILDROOT_DIR}
    $ '''${XTENSA_ROOT}/xtensa-elf/src/linux/bin/xt-xcc-linux-install                                \'''
        '''--sysroot=./build_xtensa_${CORENAME}/staging_dir'                                        \'''
        '''--linux-gcc=./build_xtensa_${CORENAME}/staging_dir/usr/bin/xtensa_${CORENAME}-linux-gcc
 
==== Regular Use ====
 
Assuming the above completed successfully, you can now build applications using Xtensa Tools.  First set the usual environment variables (assuming values of XTENSA_ROOT and XTENSA_TOOLS_ROOT used earlier):
 
    $ '''setenv XTENSA_CORE      default'''
    $ '''setenv XTENSA_SYSTEM    ${XTENSA_ROOT}-linux/config'''
    $ '''setenv PATH            ${XTENSA_TOOLS_ROOT}/bin:${PATH}'''
 
Now you can use Xtensa Tools to assemble, compile, and link applications for the Linux target specified during setup.  For example:
 
    $ '''echo '#include <stdio.h>' > hello.c'''
    $ '''echo 'int main() {printf("Hello!\\n");return 0;}' >> hello.c'''
    $ '''xt-xcc -g hello.c -o hello'''
 
Then copy it where the target can see it:
 
    $ '''cp hello ${TARGET_SYSROOT}/root'''                            [NOTE: This step isn't necessary if your src file system is mounted on the targer; Ex: /export]
 
And run it on the target:
 
    [root@hifi ~]# '''/root/hello'''
    Hello!
    [root@hifi ~]#
 
Here's a more interesting example that uses Tensilica TIE features.
(This cannot be compiled using GCC.)
 
    $ cd ${TARGET_SYSROOT}/home/default/Audio_Tests
    $ xt-xcc -g hifitest.c -o hifitest
 
In a ssh termulator window on the board you can now run hifitest:
 
    [root@hifi ~]# '''cd /home/default/Audio_Tests/'''
    [root@hifi Audio_Tests]# '''./hifitest'''
    cnt:0x0, pid:23178; Eatting cpu; time:0 '''<control-C>'''
      
      
    [root@hifi Audio_Tests]#
Here is the source code for the [[hifitest.c|hifitest.c source file]] used above.
=== Limited (No Setup) Use of Xtensa Tools for Linux Targets ===
Below we illustrate compiling a simple audio test program on a workstation.
We start by referring to the XTENSA tools build by Xplorer, putting XCC into our search path and set the standard XTENSA_* environment variables.
For example:
    '''setenv XTENSA_CORE      test_mmuhifi_c3'''
    '''setenv XTENSA_ROOT      /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3'''
    '''setenv XTENSA_SYSTEM    /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/config'''
    '''setenv XTENSA_TOOLS    /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/bin'''
      
      
    '''setenv PATH ${XTENSA_TOOLS}:${PATH}
   
      
      
     parse_bootparam: Ignoring tag 0x1004
     [piet@fc9desktop Tests]     $ '''cd /exports/hifi-2_home_default/Audio_Tests'''                          [NOTE: This is being done on a Workstation]
    lx60 platform_init(bootparams:d5f50000)
     [piet@fc9desktop Audio_Tests]$ '''xt-xcc -g3 -O0 -fPIC -c hifitest.c'''
    Linux version 2.6.29-rc7 (pdelaney@pdelaney_fc5.hq.tensilica.com) (gcc version 4.2.1) #201 SMP Tue Nov 17 23:49:39 PST 2009
 
    lx60 platform_setup(cmdline[0]:'console=ttyS0,38400 ip=192.168.11.105:192.168.11.55:192.168.11.1:255.255.255.0:"HiFi-2 Demo" root=/dev/nfs rw nfsroot=192.168.11.55:/exports/LINUX_ROOT.HiFi-2 debug coredump_filter=0xff')
 
    smp_init_cpus: Core Count = 3
Next we link the object on the LX200 board and run gdb on the TIE enhanced code:
    smp_init_cpus: Core Id = 9320
 
    On node 0 totalpages: 24576
  [root@hifi Audio_Tests]# '''gcc -g hifitest.o -o hifitest'''
    free_area_init_node: node 0, pgdat d0196540, node_mem_map d01fa000
  [root@hifi Audio_Tests]# '''./hifitest'''
      Normal zone: 216 pages used for memmap
                            cnt:0x0, pid:4640; Eatting cpu; time:0
      Normal zone: 24360 pages, LIFO batch:3
                            cnt:0x0, pid:4640; Eating Tie; time:7
    smp_prepare_boot_cpu:
  ^C
    Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 24360
  [root@hifi Audio_Tests]# '''gdb ./hifitest'''                                                              [NOTE: This is being done on the LX200 board]
     Kernel command line: console=ttyS0,38400 ip=192.168.11.105:192.168.11.55:192.168.11.1:255.255.255.0:"HiFi-2 Demo" root=/dev/nfs rw nfsroot=192.168.11.55:/exports/LINUX_ROOT.HiFi-2 debug coredump_filter=0xff
  GNU gdb 6.6
    trap_init 0
  Copyright (C) 2006 Free Software Foundation, Inc.
    PID hash table entries: 512 (order: 9, 2048 bytes)
  GDB is free software, covered by the GNU General Public License, and you are
    time_init: Platform Calibrating CPU frequency
   welcome to change it and/or distribute copies of it under certain conditions.
    time_init: ccount_per_jiffy:416777 [41.67 MHz], nsec_per_ccount:23
  Type "show copying" to see the conditions.
    Console: colour dummy device 80x25
  There is absolutely no warranty for GDBType "show warranty" for details.
    console [ttyS0] enabled
  This GDB was configured as "xtensa_test_mmuhifi_c3-linux-uclibc"...
    Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
     Using host libthread_db library "/lib/libthread_db.so.1".
    Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
  (gdb) '''break main'''
    Memory: 95196k/98304k available (1229k kernel code, 3040k reserved, 28k data, 72k init 0k highmem)
  Breakpoint 1 at 0x400401: file /exports/default/Audio_Tests/hifitest.c, line 20.
    Calibrating delay loop... 41.26 BogoMIPS (lpj=206336)
  (gdb) '''run'''
    Mount-cache hash table entries: 512
  Starting program: /home/default/Audio_Tests/hifitest
    cpu 1 fffd
    secondary_trap_init 1
    Calibrating delay loop... 41.67 BogoMIPS (lpj=208384)
    secondary_irq_init: set cached_irq_mask and enable interrupts))
    secondary_time_init()
    secondary_irq_enable(intrnum:6): cpu:1, INTENABLE:7c
    secondary_irq_enable(intrnum:0): cpu:1, INTENABLE:7d
    cpu 2 fff9
    secondary_trap_init 2
    Calibrating delay loop... 41.57 BogoMIPS (lpj=207872)
    secondary_irq_init: set cached_irq_mask and enable interrupts))
    secondary_time_init()
    secondary_irq_enable(intrnum:6): cpu:2, INTENABLE:7c
    secondary_irq_enable(intrnum:0): cpu:2, INTENABLE:7d
    Brought up 3 CPUs
    smp_cpus_done:
    net_namespace: 304 bytes
    NET: Registered protocol family 16
    lx60_init()
    bio: create slab <bio-0> at 0
    NET: Registered protocol family 2
    IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
    TCP established hash table entries: 4096 (order: 3, 32768 bytes)
    TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
    TCP: Hash tables configured (established 4096 bind 4096)
    TCP reno registered
   NET: Registered protocol family 1
    msgmni has been set to 186
    alg: No test for md5 (md5-generic)
    alg: No test for des (des-generic)
    alg: No test for des3_ede (des3_ede-generic)
    alg: No test for stdrng (krng)
    io scheduler noop registered (default)
    Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
    serial8250: ttyS0 at MMIO 0x0 (irq = 3) is a 16550A
    oeth_probe: {
    oeth_setup: Open Ethernet Core Version 1.0.1
    : oeth_setup: Found id1:2000, id2:5c30 at phy_id:3.
    : Hardware MAC Address: 00:50:c2:13:6f:0f
    eth0 (): not using net_device_ops yet
    oeth_probe: }
    mice: PS/2 mouse device common for all mice
    TCP cubic registered
    NET: Registered protocol family 17
    RPC: Registered udp transport module.
    RPC: Registered tcp transport module.
    oeth_open: Ready to process packets now on dev->name:'eth0', dev:d597d800;
    IP-Config: Complete:
        device=eth0, addr=192.168.11.105, mask=255.255.255.0, gw=192.168.11.1,
        host="HiFi-2 Demo", domain=, nis-domain=(none),
        bootserver=192.168.11.55, rootserver=192.168.11.55, rootpath=
     Looking up port of RPC 100003/2 on 192.168.11.55
    Looking up port of RPC 100005/1 on 192.168.11.55
    VFS: Mounted root (nfs filesystem) on device 0:11.
    Freeing unused kernel memory: 72k freed
    Starting portmap: done
    Initializing random number generator... done.
    Starting network...
    ip: RTNETLINK answers: File exists
    Starting sshd: OK
    Starting NFS statd: done
    Starting NFS services: done
    Starting NFS daemon: done
    Starting NFS mountd: done
    Starting domain name daemon: namedwarning: `named' uses 32-bit capabilities (legacy support in use)
    failed
    Fri Nov 20 17:10:37 2009
    Mounting Other NFS Filesystems
      
      
    Welcome to your custom Xtensa HiFi-2 Codec Developemnt System
  Breakpoint 1, main (argc=1, argv=0x3fb3fab4)
    hifi login: '''root'''
      at /exports/default/Audio_Tests/hifitest.c:20
    Password: '''linux1'''
  20     time_t time0 = time(NULL);
  (gdb) '''step'''
  21   time_t time1 = time(NULL);
 
== Compiling Generic GPL Packages ==
 
For your development you may want to add a few GPL packages that you find helpful.
This can be done on the LX200 just as you would on a normal workstation, though
much slower. For example here we configure and build a few common GPL packages
with the standard:
 
  $ '''ssh root@hifi'''
  [root@hifi ~] # '''cd /usr/local/src'''
  [root@hifi src] # '''mkdir <package>'''
  [root@hifi src] # '''wget <url_to_package>'''
  [root@hifi src] # '''gunzip <package.tgz>'''
  [root@hifi src] # '''cd package'''
  [root@hifi <package> ] # '''.configure'''
  [root@hifi <package> ] # '''make'''
  [root@hifi <package> ] # '''make install'''


== Tailoring your system prior to developing your codec ==
Here are two examples, the invaluable strace and vim GPL packages:


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


  1. Add a root password to that you can login with ssh.
  [[Building the vim Package]]
  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]
This can be a useful effort prior to adding a package to buildroot or
for compiling packages with debug enabled. For example on of our developers
compiled uClibc with -g to debug problems in this package.


== Compiling the Mplayer Plugins and linking them with MPEG-1 Audio Layer 3 (MP3) and MPEG-4 AAC Codecs ==
== Compiling the Mplayer Plugins and linking them with MPEG-1 Audio Layer 3 (MP3) and MPEG-4 AAC Codecs ==
Line 608: Line 764:
                 --enable-dynamic-plugins
                 --enable-dynamic-plugins


We are currently able to compile most of mplayer on the XL200 but
We are currently able to compile mplayer on the LX200 but
due to space limitations it's not possible to compile it -O0.  
due to space limitations it's not possible to compile it -O0.  




Now, lets focus on compiling linking the plugins. They are a nice
Now, let's focus on compiling linking the plugins. They are a nice
example of compiling a audio application on the LX200.
example of compiling an audio application on the LX200.


We modified the Makefile of the codes slightly, and will make it available.
We modified the plugin Makefile slightly, and they are available in /home/default/mplayer_packages.
These additions just instruct make how to install the plugins as explained
These additions just instruct make how to fetch the codecs and build and install the plugins as explained
in the Chapter 7 of the Linux HiFi application note.
in the Chapter 7 of the Linux HiFi application note. With these Makefile additions and the Tensilica
codecs available in the /plugins directory is very easy.


For example the mp3 plugin has this addition:
For example the mp3 plugin has this addition:


     target_install::
      
        -mkdir /etc/mplayer
    # We assume Tensilica Codecs have been mounted at /codecs
        cp codecs.conf /etc/mplayer
    # via /etc/fstab during boot.
        -mkdir /usr/lib/mplayer
    #
        cp ad_xa_mp3_dec.so /usr/lib/mplayer/
    CODEC_PACKAGE=xa_hifi2_l32r_LE5_pic_mp3_dec_lib_3_1_api_1_15_lib
        cp xa_mp3_dec.so /usr/lib/mplayer
    CODEC_PACKAGE_LOCATION=/codecs
        chmod 755 /usr/lib/mplayer/ad_xa_mp3_dec.so
    MPLAYER_DEVEL_LOCATION=/home/default/buildroot_mplayer_stuff
        chmod 755 /usr/lib/mplayer/xa_mp3_dec.so
   
    all: '''$(XA_CODEC_NAME)''' $(SLIBNAME) $(XA_CODEC_NAME).so
    .
    .
    .
    $(CODEC_PACKAGE).tgz:
            cp $(CODEC_PACKAGE_LOCATION)/$(CODEC_PACKAGE).tgz .
   
    $(CODEC_PACKAGE).tar:: $(CODEC_PACKAGE).tgz
            gunzip $(CODEC_PACKAGE).tgz
   
    $(XA_CODEC_NAME):: $(CODEC_PACKAGE).tar
              tar xf $(CODEC_PACKAGE).tar
   
    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
 
The make file will be 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
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,
config file just copy your codec that was compiled with '''xcc''' to the directory, compile it,
and install.
and install. To add mp3 and aac plugins to mplayer you just type '''make''' followed by '''make install''':
 
    [root@hifi mplayer_hifi2_mp3_plugin]# '''make'''
    cp /codecs/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
    cc -I../libavcodec -I../libavformat -I. -I.. -I../libavutil -W -Wall -O2  -pipe -g3  -D_REENTRANT -DHAVE_CONFIG_H -I/usr/include  -DNDEBUG -fvisibility=hidden -Ixa_mp3_dec/include -I../MPlayer-1.0rc2 -Ic
    xa_mp3_dec_sample_testbench.c: In function 'xa_mp3_decode_frame':
    xa_mp3_dec_sample_testbench.c:185: warning: pointer targets in passing argument 1 of 'xa_mp3_audio_read' differ in signedness
    xa_mp3_dec_sample_testbench.c:163: warning: unused variable 'j'
    xa_mp3_dec_sample_testbench.c: In function 'mp3_codec_init':
    xa_mp3_dec_sample_testbench.c:517: warning: pointer targets in passing argument 1 of 'xa_mp3_audio_read' differ in signedness
    xa_mp3_dec_sample_testbench.c: At top level:
    xa_mp3_dec_sample_testbench.c:112: warning: 'pack_32_to_24_bits' defined but not used
    cc -I../libavcodec -I../libavformat -I. -I.. -I../libavutil -W -Wall -O2  -pipe -g3  -D_REENTRANT -DHAVE_CONFIG_H -I/usr/include  -DNDEBUG -fvisibility=hidden -Ixa_mp3_dec/include -I../MPlayer-1.0rc2 -Ic
    ad_xa_mp3_dec.c: In function 'xa_mp3_audio_read':
    ad_xa_mp3_dec.c:26: warning: pointer targets in passing argument 2 of 'demux_read_data' differ in signedness
    ad_xa_mp3_dec.c: In function 'init':
    ad_xa_mp3_dec.c:42: warning: pointer targets in passing argument 1 of 'xa_mp3_decode_frame' differ in signedness
    ad_xa_mp3_dec.c: At top level:
    ad_xa_mp3_dec.c:52: warning: unused parameter 'sh'
    ad_xa_mp3_dec.c:56: warning: unused parameter 'arg'
    ad_xa_mp3_dec.c:78: warning: unused parameter 'sh_audio'
    cc -I../libavcodec -I../libavformat -I. -I.. -I../libavutil -W -Wall -O2  -pipe -g3  -D_REENTRANT -DHAVE_CONFIG_H -I/usr/include  -DNDEBUG -fvisibility=hidden -Ixa_mp3_dec/include -I../MPlayer-1.0rc2 -Im
    cc -I../libavcodec -I../libavformat -I. -I.. -I../libavutil -W -Wall -O2  -pipe -g3  -D_REENTRANT -DHAVE_CONFIG_H -I/usr/include  -DNDEBUG -fvisibility=hidden -Ixa_mp3_dec/include -I../MPlayer-1.0rc2 -Ie
    [root@hifi mplayer_hifi2_mp3_plugin]#
 
    [root@hifi mplayer_hifi2_mp3_plugin]# '''make install'''
    mkdir: cannot create directory '/etc/mplayer': File exists
    make: [install] Error 1 (ignored)
    cp codecs.conf /etc/mplayer
    mkdir: cannot create directory '/usr/lib/mplayer': File exists
    make: [install] Error 1 (ignored)
    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
    [root@hifi mplayer_hifi2_mp3_plugin]#
 


        # '''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 codec tar ball will install the following files:
The makefile unpacked of the Tensilica mp3 codec tarball will installed the following files:
   
   
     xa_mp3_dec/
     xa_mp3_dec/
Line 683: Line 891:
     xa_mp3_dec/doc/HiFi2-MP3-DecoderProgrammersGuide.pdf
     xa_mp3_dec/doc/HiFi2-MP3-DecoderProgrammersGuide.pdf


[TO BE DONE - Add missing C file, make clean deletes it!]
Now, having built and installed the mp3 plugin, do the same for the AAC codec.


The xa_mp3_dec.a archive will be used by the Makefile in
    [root@hifi ~]# cd /home/default/mplayer_packages/mplayer_hifi2_aacplus_v2_plugin/
the mplayer_hifi2_mp3_plugin directory to make the mplayer plug-in.
    [root@hifi mplayer_hifi2_aacplus_v2_plugin]# '''make'''
Section 6 of the '''Using Tensilica HiFi 2 Codec on Xtensa Linux with MPlayer'' Application Note
    [root@hifi mplayer_hifi2_aacplus_v2_plugin]# '''make install'''
has a detailed description of the encapsulation process used by the plug-ins.


== Compiling Tie Code with XCC ==
Additional codecs can be downloaded from the mplayer web site, configured,
compiled and can be installed as usual.


Codecs like MP3 and AAC have been written in C with TIE extensions and can only be compiled with '''xcc'''.
  http://www.mplayerhq.hu/DOCS/HTML/en/codec-installation.html
XCC is likely to large to run on the board without virtual memory. There are two approaches to compiling
Linux TIE code with '''xcc'''. The simple approach assumes the host workstation and target code running of the board
are similar enough that the library interfaces defined by the include files are compatable. This is often the
case for standard system calls, libc, and stdio.The proper approach uses a virtual core that we will create
that has built in references to the library and include files on the target code running on the LX200.


=== Simply using Xtensa Tools to compile the TIE code on a workstation ===
  [opencore-amr | opencore-amr]


Below we illustrate compiling a simple audio test program on a workstation.
opencore-amr builds fine and the x264-snapshot compiles completely
We start by referring to the XTENSA tools build by Xplorer, putting '''xcc''' into our search path and set the standard XTENSA_* environement variables.
but the Makefile and code needs to be set up for ARCH xtensa. The
For example:
GPL AAC decoder, faad, has out of date autoconf files, config.sub
and config.guess, need to be updated for Xtensa. This can be easily
done by copying config.sub and config.guess from the x264-snapshot
which had up to date versions recognizing xtensa correctly.  


    setenv XTENSA_CORE      test_mmuhifi_c3
Add on codec install by default to /usr/local/lib and the ldconfig
    setenv XTENSA_ROOT      /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3
config file /etc/ld.so.conf needs to have /usr/local/lib added.
    setenv XTENSA_SYSTEM    /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/config
    setenv XTENSA_TOOLS    /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/bin
   
    setenv PATH ${XTENSA_TOOLS}:${PATH}
   
   
    [piet@fc9desktop Tests]      $ '''cd /exports/default/Audio_Tests'''                                      [NOTE: This is being done on a Workstation]
    [piet@fc9desktop Audio_Tests]$ '''xt-xcc -g3 -O0 -fPIC -c hifitest.c'''


Lots of opportunity likely exists for optimizing these codec for
Xtensa extensibility.


Next we link the object on the XL200 board and run gdb on the TIE enhanced code:


  [root@hifi Audio_Tests]# '''gcc -g hifitest.o -o hifitest'''
[TO BE DONE - Add missing C file, make clean deletes it!]
  [root@hifi Audio_Tests]# '''./hifitest'''
                            cnt:0x0, pid:4640; Eatting cpu; time:0
                            cnt:0x0, pid:4640; Eating Tie; time:7
  ^C
  [root@hifi Audio_Tests]# '''gdb ./hifitest'''                                                              [NOTE: This is being done on the LX200 board]
  GNU gdb 6.6
  Copyright (C) 2006 Free Software Foundation, Inc.
  GDB is free software, covered by the GNU General Public License, and you are
  welcome to change it and/or distribute copies of it under certain conditions.
  Type "show copying" to see the conditions.
  There is absolutely no warranty for GDB.  Type "show warranty" for details.
  This GDB was configured as "xtensa_test_mmuhifi_c3-linux-uclibc"...
    Using host libthread_db library "/lib/libthread_db.so.1".
  (gdb) '''break main'''
  Breakpoint 1 at 0x400401: file /exports/default/Audio_Tests/hifitest.c, line 20.
  (gdb) '''run'''
  Starting program: /home/default/Audio_Tests/hifitest
   
  Breakpoint 1, main (argc=1, argv=0x3fb3fab4)
      at /exports/default/Audio_Tests/hifitest.c:20
  20     time_t time0 = time(NULL);
  (gdb) '''step'''
  21   time_t time1 = time(NULL);


=== The Proper Approach of Building TIE code for Linux Targets ===
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.  
In section 4.3 of the '''Xtensa OSKit Guide''' there is a detailed description
Section 6 of the '''Using Tensilica HiFi 2 Codec on Xtensa Linux with MPlayer'' Application Note
of this intense procedure of building target binaries. As the founding father
has a detailed description of the encapsulation process used by the plug-ins.
of Java, Jim Gosling,
once wrote, '''"Not for Pregnant Woman or men with weak hearts"'''.
 
A summary of the procedure is available from the --help message of the
install script that set up a cloned core.
 
 
 
    [piet@fc9desktop test_mmuhifi_c3]$ '''${XTENSA_ROOT}/xtensa-elf/src/linux/bin/xt-xcc-linux-install --help'''
    Usage:
      <fullpath>/xt-xcc-linux-install  --sysroot=<target_sysroot>
                                      [--clone-core=<corename>]
                                      [--clone-root=<rootdir>]
                                      [--clone-registry=<registrydir>]
                                      [--c-include=<dir>]
                                      [--cxx-include=<dir>]
                                      [--lib-include=<dir>]
                                      [--linux-gcc=<path_to_target_gcc>]
                                      [--help]
      --sysroot=<target_sysroot>
            Specify the target sysroot directory, the root of a tree containing
            target header files and libraries for use by the compiler.  Although
            this can be the target filesystem as it appears on the host (for
            targets supporting native development), it is typically a different
            but similarly structured tree (for cross-development).  Xtensa Tools
            look for target headers in <target_sysroot>/usr/include, and for
            target libraries in <target_sysroot>/lib and <target_sysroot>/usr/lib.
            There is no default and this directory must be specified.
      [--c-include=<dir>]
            Specify an additional directory for the default C header search path.
   
      [--cxx-include=<dir>]
            Specify an additional directory for the default C++ header search path.
     
      [--lib-include=<dir>]
            Specify an extra dir. for the default library+startfile search path.
     
      [--linux-gcc=<path_to_target_gcc>]
            Specify the path to a host GCC targeting the Xtensa Linux system,
            which this script invokes to obtain additional lists of include
            directories for C headers, C++ headers, and libraries.
            This is often a convenient shorthand to specifying multiple
            --c-include , --cxx-include, and --lib-include options.
      [--clone-core=<corename>]
            Name of the clone core to install.  If omitted, the default is
            the original core name specified in the Xtensa Processor
            Generator with '-linux' appended to the name.
      [--clone-root=<rootdir>]
            Specify the directory where the clone core package will be
            installed.  If omitted, the default is a path derived by replacing
            the leaf directory of the original core package, <xtensa_root>,
            with the name of the clone core.
      [--clone-registry=<registrydir>]
            Specify the Xtensa core registry in which to register the new
            clone core name.  If omitted, the default core registry is
            used, located in Xtensa Tools at <xtensa_tools_root>/config.
     
      [--help]
            Display this message and exit without installing anything.
    This installer clones its containing Xtensa core package (using symlinks),
    and modifies the clone to make XCC build applications that run on Linux.
    For this to work, XCC must select this clone core name, and use the default
    Xtensa Linker Support Package (that is, avoid the -mlsp parameter).
    The installer registers the new clone core in the specified Xtensa core
    registry. The clone core can be selected using either the XTENSA_CORE
    environment variable or the --xtensa-core=<corename> parameter to run
    xt-xcc (the XCC C/C++ compiler) and other Xtensa Tools.
    [piet@fc9desktop test_mmuhifi_c3]$
 
 
Below illustrates two attempts as using this '''core cloning''' procedure:
 
    $ '''setenv XTENSA_CORE      test_mmuhifi_c3'''
    $ '''setenv XTENSA_ROOT      /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3'''
    $ '''setenv XTENSA_SYSTEM    /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/config'''
    $ '''setenv XTENSA_TOOLS    /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/bin'''
   
    $ '''setenv PATH ${XTENSA_TOOLS}:${PATH}'''
   
    $ '''setenv TARGET_SYSROOT  /exports/LINUX_ROOT.HiFi-2'''
    $ '''setenv BUILDROOT_DIR    /export/src/HiFi-2_DemoBoard/buildroot-xtensa-HiFi2-Snapshot.12'''
   
    $ '''${XTENSA_ROOT}/xtensa-elf/src/linux/bin/xt-xcc-linux-install                                                        \'''
        '''--sysroot=${BUILDROOT_DIR}/build_xtensa_${XTENSA_CORE}/staging_dir                                                \'''
        '''--clone-core=test_mmuhifi_c3-linux-clone                                                                          \'''
        '''--linux-gcc=${BUILDROOT_DIR}/build_xtensa_${XTENSA_CORE}/staging_dir/usr/bin/xtensa_test_mmuhifi_c3-linux-gcc'''                  [NOTE: Maxim used this for some reason on the C++ problem]
   
    @@ touch /var/tmp/_test_null.c
    @@ touch /var/tmp/_test_null.cc
    Did not find LIBRARY_PATH in GCC -v output


 
== Adding Packages and/or Codec to Buildroot ==
    [piet@fc9desktop buildroot-xtensa-HiFi2-Snapshot.12]$ '''${XTENSA_ROOT}/xtensa-elf/src/linux/bin/xt-xcc-linux-install        \'''
                                                            '''--sysroot=${BUILDROOT_DIR}/build_xtensa_${XTENSA_CORE}/staging_dir  \'''
                                                            '''--clone-core=test_mmuhifi_c3-linux-clone'''
    Xtensa core package clone installer.
    Clones and modifies core packages for building GNU/Linux applications with XCC.
   
    Xtensa Tools:    /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools
    Xtensa Root:      /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3
    Tools:            /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/Tools
    Default core:    test_mmuhifi_c3
    Clone core:      test_mmuhifi_c3-linux-clone
    Clone registry:  /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/config
    Clone root:      /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone
    Target sysroot:  /export/src/HiFi-2_DemoBoard/buildroot-xtensa-HiFi2-Snapshot.12/build_xtensa_test_mmuhifi_c3/staging_dir
    Extra C includes: /export/src/HiFi-2_DemoBoard/buildroot-xtensa-HiFi2-Snapshot.12/build_xtensa_test_mmuhifi_c3/staging_dir/usr/include
    Extra C++ incl: 
    Extra lib incl:  /export/src/HiFi-2_DemoBoard/buildroot-xtensa-HiFi2-Snapshot.12/build_xtensa_test_mmuhifi_c3/staging_dir/lib
                      /export/src/HiFi-2_DemoBoard/buildroot-xtensa-HiFi2-Snapshot.12/build_xtensa_test_mmuhifi_c3/staging_dir/usr/lib
   
    @@ rm -fr /var/tmp/xt-xcc-linux-install-tmp
    @@ mkdir /var/tmp/xt-xcc-linux-install-tmp
    @@ mkdir /var/tmp/xt-xcc-linux-install-tmp/build-libgcc
   
   
    ************************************************************
    * Creating clone core package installation
    ************************************************************
    @@ mkdir /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone
    @@ mkdir /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/config
    @@ mkdir /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/xtensa-elf
    @@ mkdir /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/xtensa-elf/include
    @@ mkdir /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/xtensa-elf/lib
    @@ mkdir /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/xtensa-elf/lib/linux
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/control /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/control
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/examples /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/examples
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/lib /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/lib
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/misc /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/misc
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/src /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/src
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/xtensa-elf/arch /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/xtensa-elf/arch
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/xtensa-elf/src /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/xtensa-elf/src
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/xtensa-elf/lib/linux/ldscripts /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/xtensa-elf/lib/linux/ldscripts
    @@ cp -f /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/xtensa-elf/lib/linux/specs-uclibc /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/xtensa-elf/lib/linux/specs
    @@ cd /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/config
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/config/core.xparm /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/config/core.xparm
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/config/init_code.c /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/config/init_code.c
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/config/libcas-core.so /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/config/libcas-core.so
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/config/libcas-ref-core.so /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/config/libcas-ref-core.so
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/config/libfiss-base.so /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/config/libfiss-base.so
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/config/libfiss-ref-base.so /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/config/libfiss-ref-base.so
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/config/libisa-core-hw.so /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/config/libisa-core-hw.so
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/config/libisa-core.so /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/config/libisa-core.so
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/config/libtie-core.so /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/config/libtie-core.so
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/config/libtie-Xtensa-msem.so /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/config/libtie-Xtensa-msem.so
    @@ cp -f /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/config/default-params /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/config/test_mmuhifi_c3-params
    @@ cp -f /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/config/default-params /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/config/test_mmuhifi_c3-linux-clone-params
    @@ symlink /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/xtensa-elf /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/xtensa-linux-uclibc
    @@ cp -f /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone/config/default-params /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/config/test_mmuhifi_c3-linux-clone-params
   
   
    ************************************************************
    * Rebuilding libgcc
    ************************************************************
    @@ cd /var/tmp/xt-xcc-linux-install-tmp/build-libgcc
    @@ /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/configure --target=xtensa-linux-uclibc --prefix=/home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3-linux-clone --enable-languages="c,c++" --enable-shared --with-sysroot=/export/src/HiFi-2_DemoBoard/buildroot-xtensa-HiFi2-Snapshot.12/build_xtensa_test_mmuhifi_c3/staging_dir
    checking build system type... i686-pc-linux-gnu
    checking host system type... i686-pc-linux-gnu
    checking target system type... xtensa-unknown-linux-uclibc
    checking for a BSD-compatible install... /usr/bin/install -c
    checking for gawk... gawk
    checking whether ln -s works... yes
    configure: creating ./config.status
    config.status: creating Makefile
    config.status: creating mklibgcc
    @@ make all-target install-target
    TARGET_CPU_DEFAULT="" \
    HEADERS="options.h config/xtensa/xtensa.h config/dbxelf.h config/elfos.h config/svr4.h config/linux.h config/xtensa/linux.h defaults.h" DEFINES="UCLIBC_DEFAULT=1" \
    /bin/sh /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/mkconfig.sh tm.h
    touch stmp-int-hdrs
    objext='.o' \
    LIB1ASMFUNCS='_mulsi3 _mulsi3hifi2 _divsi3 _modsi3 _udivsi3 _umodsi3 _divsi3_dfp_accel _modsi3_dfp_accel _udivsi3_dfp_accel _umodsi3_dfp_accel _umulsidi3 _clz _clzsi2 _ctzsi2 _ffssi2 _ashldi3 _ashrdi3 _lshrdi3 _negsf2 _addsubsf3 _mulsf3 _divsf3 _cmpsf2 _fixsfsi _fixsfdi _fixunssfsi _fixunssfdi _floatsisf _floatunsisf sqrt _floatdisf _floatundisf _negdf2 _addsubdf3 _muldf3 _divdf3 _cmpdf2 _fixdfsi _fixdfdi _fixunsdfsi _fixunsdfdi _floatsidf _floatunsidf _floatdidf _floatundidf _truncdfsf2 _extendsfdf2' \
    LIB2FUNCS_ST='_eprintf __gcc_bcmp' \
    LIB2FUNCS_EXCLUDE='' \
    LIBGCOV='' \
    LIB2ADD='/home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/config/xtensa/lib2funcs.S' \
    LIB2ADD_ST='' \
    LIB2ADDEH='/home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/config/xtensa/unwind-dw2-xtensa.c /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/unwind-dw2-fde.c /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/unwind-sjlj.c /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/unwind-c.c' \
    LIB2ADDEHSTATIC='/home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/config/xtensa/unwind-dw2-xtensa.c /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/unwind-dw2-fde.c /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/unwind-sjlj.c /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/unwind-c.c' \
    LIB2ADDEHSHARED='/home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/config/xtensa/unwind-dw2-xtensa.c /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/unwind-dw2-fde.c /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/unwind-sjlj.c /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/unwind-c.c' \
    LIB2ADDEHDEP='unwind.inc unwind-dw2-fde.h unwind-dw2-fde.c' \
    LIB2_SIDITI_CONV_FUNCS='' \
    LIBUNWIND='' \
    LIBUNWINDDEP='' \
    SHLIBUNWIND_LINK='' \
    SHLIBUNWIND_INSTALL='' \
    FPBIT='' \
    FPBIT_FUNCS='' \
    LIB2_DIVMOD_FUNCS='_divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4' \
    DPBIT='' \
    DPBIT_FUNCS='' \
    TPBIT='' \
    TPBIT_FUNCS='' \
    DFP_ENABLE='' \
    DFP_CFLAGS='' \
    D32PBIT='' \
    D32PBIT_FUNCS='' \
    D64PBIT='' \
    D64PBIT_FUNCS='' \
    D128PBIT='' \
    D128PBIT_FUNCS='' \
    MULTILIBS='.;' \
    EXTRA_MULTILIB_PARTS='crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o' \
    SHLIB_LINK='xt-xcc -O2  -DIN_GCC -DCROSS_COMPILE  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include  -fPIC -INLINE:aggressive -Wa,--schedule -g  -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED  -shared -nodefaultlibs -Wl,--soname=@shlib_base_name@.so.1 -Wl,--version-script=@shlib_map_file@ -o @multilib_dir@/@shlib_base_name@.so.1.tmp @multilib_flags@ @shlib_objs@ -lc && rm -f @multilib_dir@/@shlib_base_name@.so && if [ -f @multilib_dir@/@shlib_base_name@.so.1 ]; then mv -f @multilib_dir@/@shlib_base_name@.so.1 @multilib_dir@/@shlib_base_name@.so.1.backup; else true; fi && mv @multilib_dir@/@shlib_base_name@.so.1.tmp @multilib_dir@/@shlib_base_name@.so.1 && ln -s @shlib_base_name@.so.1 @multilib_dir@/@shlib_base_name@.so' \
    SHLIB_INSTALL='$(mkinstalldirs) $(DESTDIR)$(slibdir)@shlib_slibdir_qual@; /usr/bin/install -c -m 644 @multilib_dir@/@shlib_base_name@.so.1 $(DESTDIR)$(slibdir)@shlib_slibdir_qual@/@shlib_base_name@.so.1; rm -f $(DESTDIR)$(slibdir)@shlib_slibdir_qual@/@shlib_base_name@.so; ln -s @shlib_base_name@.so.1 $(DESTDIR)$(slibdir)@shlib_slibdir_qual@/@shlib_base_name@.so' \
    SHLIB_EXT='.so' \
    SHLIB_MULTILIB='' \
    SHLIB_MKMAP='/home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/mkmap-symver.awk' \
    SHLIB_MKMAP_OPTS='' \
    SHLIB_MAPFILES='/home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/libgcc-std.ver /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/config/libgcc-glibc.ver /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/config/xtensa/libgcc-xtensa.ver' \
    SHLIB_NM_FLAGS='' \
    MULTILIB_OSDIRNAMES='' \
    mkinstalldirs='mkdir -p' \
    ASM_HIDDEN_OP='' \
    GCC_FOR_TARGET='xt-xcc' \
      /bin/sh mklibgcc > tmp-libgcc.mk
    mv tmp-libgcc.mk libgcc.mk
    TARGET_CPU_DEFAULT="" \
    HEADERS="auto-host.h ansidecl.h" DEFINES="USED_FOR_TARGET " \
    /bin/sh /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/mkconfig.sh tconfig.h
    make \
      CFLAGS="-g -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wold-style-definition" \
      CONFIG_H="tconfig.h auto-host.h ansidecl.h" TM_H="tm.h      options.h /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/config/xtensa/xtensa.h /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/config/dbxelf.h /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/config/elfos.h /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/config/svr4.h /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/config/linux.h /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/config/xtensa/linux.h /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/defaults.h" \
      INCLUDES="-I. -I/home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc" \
      MAKEOVERRIDES= \
      -f libgcc.mk all
    make[1]: Entering directory `/var/tmp/xt-xcc-linux-install-tmp/build-libgcc'
    for d in libgcc; do \
      if [ -d $d ]; then true; else mkdir -p $d; fi; \
    done
    if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi
    make GCC_FOR_TARGET="xt-xcc" \
      AR_FOR_TARGET="xt-ar" \
      AR_CREATE_FOR_TARGET="xt-ar  rc" \
      AR_EXTRACT_FOR_TARGET="" \
      AR_FLAGS_FOR_TARGET="" \
      CC="cc" CFLAGS="-g -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wold-style-definition" \
      BUILD_PREFIX="" \
      BUILD_PREFIX_1="" \
      LANGUAGES="" \
      LIBGCC2_CFLAGS="-O2  -DIN_GCC -DCROSS_COMPILE  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include  -fPIC -INLINE:aggressive -Wa,--schedule -g  -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED  "  \
      MULTILIB_CFLAGS="" T= crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o
    make[2]: Entering directory `/var/tmp/xt-xcc-linux-install-tmp/build-libgcc'
    xt-xcc -O2  -DIN_GCC -DCROSS_COMPILE  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include  -I. -I/home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc  -g0 -finhibit-size-directive -fno-inline-functions -fno-exceptions -fno-zero-initialized-in-bss  -INLINE:=none \
      -c /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/crtstuff.c -DCRT_BEGIN \
      -o crtbegin.o
    xt-xcc WARNING:  -finhibit-size-directive is ignored
    In file included from /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/crtstuff.c:68:
    /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/tsystem.h:47:20: error: stddef.h: No such file or directory
    /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/tsystem.h:48:19: error: float.h: No such file or directory
    /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/tsystem.h:87:20: error: stdarg.h: No such file or directory
    In file included from /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/tsystem.h:108,
                    from /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/xtensa-elf/src/libgcc-xcc/crtstuff.c:68:
    /export/src/HiFi-2_DemoBoard/buildroot-xtensa-HiFi2-Snapshot.12/build_xtensa_test_mmuhifi_c3/staging_dir/usr/include/limits.h:124:26: error: no include path in which to search for limits.h
    make[2]: *** [crtbegin.o] Error 2
    make[2]: Leaving directory `/var/tmp/xt-xcc-linux-install-tmp/build-libgcc'
    make[1]: *** [extra] Error 2
    make[1]: Leaving directory `/var/tmp/xt-xcc-linux-install-tmp/build-libgcc'
    make: *** [libgcc.a] Error 2
    @@ (command failed with exit code 2, error 512 at /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/xtensa-elf/src/linux/bin/xt-xcc-linux-install.pl line 691)
    *** Error executing: make all-target install-target
    [piet@fc9desktop buildroot-xtensa-HiFi2-Snapshot.12]$
 
Hopefully we will work out this problem shortly. The simple procedure should work as long as you keep your tie code in files without
significant system include files. Consider /home/default/AUDIO_Tests/hifitest.c as an example:
 
    #include <stdio.h>
    #include <time.h>
    #include <xtensa/tie/xt_hifi2.h>
   
    #define INC 1
   
    main(int argc, char **argv)
    {
      int inc;
      int inc2;
      register ae_p24x2s p24_cnt;
      register ae_p24x2s p24_inc;
      register ae_p24x2s p24_pid;
      int cnt;
      int cnt2;
      int pid;
      int pid2;
      volatile int i, j, k, l;
      time_t time0 = time(NULL);
      time_t time1 = time(NULL);
   
    restart:
      cnt = 0;
      cnt2 = 0;
      inc = INC;
      pid = getpid();
      p24_cnt = AE_ZEROP48();
      p24_inc = AE_MOVPA24(inc);
      p24_pid = AE_MOVPA24(pid);
   
      while (1)
        {
          int errors = 0;
   
          if ((cnt & 0xffffff) == 0) {
    time0 = time1;
    time1 = time(NULL);
    printf("cnt:0x%x, pid:%d; Eatting cpu; time:%ld\n", cnt, pid, (time1 - time0));
    for(i = 0; i<1000; i++) {
        for(j = 0; j < 1000; j++) {
            for(k = 0; k < 10; k++) {
    l++;
        }
        }
    }
    time0 = time1;
    time1 = time(NULL);
    printf("cnt:0x%x, pid:%d; Eating Tie; time:%ld\n", cnt, pid, (time1 - time0));
          }
          cnt = (cnt + inc) & 0xffffff;
          p24_cnt = AE_ADDP24(p24_cnt, p24_inc);
          cnt2 = AE_MOVAP24S_L(p24_cnt) & 0xffffff;
          pid2 = AE_MOVAP24S_L(p24_pid) & 0xffffff;
          inc2 = AE_MOVAP24S_L(p24_inc) & 0xffffff;
   
          if (cnt2 != cnt)
    {
      swapon("/tmp/cmt2", 0);
      printf("Error: cnt2:0x%x != cnt:0x%x\n", cnt2, cnt);
      errors++;
    }
          if (inc2 != inc)
    {
      swapon("/tmp/inc2", 0);
      printf("Error: inc2:%d != inc:%d\n", cnt2, cnt);
      errors++;
    }
          if ( pid2 != pid)
    {
      swapon("/tmp/pid2", 0);
      printf("Error: pid2:%d != pid:%d\n", pid2, pid);
      errors++;
    }
   
    if (errors) {
        printf("for...\n");
        for(i=0; i < 0x3FFFF; i++)
    j++;
        printf("sleep 10\n");
        sleep(10);
        printf("for...\n");
    for(i=0; i < 0x3FFFF; i++)
    j++;
        printf("restart\n");
        goto restart;
    }
        }
    }
$
 
== Adding your codec to Buildroot ==


Xtensa developers provide detailed instructions on building the root filesystem and the Linux kernel.
Xtensa developers provide detailed instructions on building the root filesystem and the Linux kernel.
* [[Buildroot_Build_Instructions|Instructions for building and booting Linux (buildroot)]].
* [[Buildroot_Build_Instructions|Instructions for building and booting Linux (buildroot)]].


Building a comprehensive development environment with buildroot can be a chalanging experience and worthy of providing some tips on process.
Building a comprehensive development environment with buildroot can be a challenging experience and
worthy of providing some tips on process.
Here are notes of the configs used for the three menuconfigs in this 2nd snapshot
Here are notes of the configs used for the three menuconfigs in this 2nd snapshot
provided with SMP additions:
provided with SMP additions:
Line 1,132: Line 945:
        
        
       '''vers=2,rsize=4096,wsize=4096,hard,nointr,nolock,nolock,timeo=11,retrans=3,noauto'''
       '''vers=2,rsize=4096,wsize=4096,hard,nointr,nolock,nolock,timeo=11,retrans=3,noauto'''
   
    this is extremely important to add to your /etc/fstab on the target.
      
      
   2. Can't swap over NFS yet, memory can get tight and cause application to be killed.
   2. Can't swap over NFS yet, under extreme conditions memory can get tight and cause application to be killed.
     a. Trying proceedure documented in U-Boot Manual.
     a. We will be trying procedure documented in U-Boot Manual to swap over NFS.
    
    
   3. Building the C development with X11 doesn't work with buildroot.
   3. Building the complete C development with X11 doesn't work with buildroot.
    
    
   4. Though Mplayer plug-in can be compiled, Mplayer still has a few issues.
   4. Though Mplayer plug-in can be compiled, Mplayer can be compiled but still has a few issues:
     a. Can't be compiled -O0
     a. Can't be compiled -O0 due to limited memory while compiling one file,
     b. Compiler infrequently crashes and make has to be restarted.
     b. Compiler was crashing and make had to be restarted.
      We are not seeing this problem with root build on Fedore Core 9.
      Perhaps this was caused by debug kernel being enabled or LTP using all of the memory.
    
    
   5. U-boot has flash problems:
   5. U-boot has flash problems:
     a. Sectors marked Read-Only come up Writeable after a reset/reboot.
     a. Sectors marked Read-Only come up Writeable after a reset/reboot.
     b. Flashing a large numner of sectors (like the kernel) sometimes
 
     b. Flashing a large number of sectors (like the kernel) sometimes
       results in an Error (Ex: Vcc) and had to be retried.
       results in an Error (Ex: Vcc) and had to be retried.
     c. Saw enviroment variables trashed on reset/reboot once.
 
     c. We saw environment variables trashed on reset/reboot once.
       It's possible that U-boot in flash could get whacked
       It's possible that U-boot in flash could get whacked
       and the board will need to be re-flashed.
       and the board will need to be re-flashed. During weeks
      of testing we haven't seen the U-Boot environment getting whacked.
      
      
   6. gdb appears to be crashing on target when debugging  
   6. gdb appears to be crashing on target when debugging  
     on latest root with uclibc left unstripped and with debug;
     on latest root with uclibc left unstriped and with debug;
     core dump sent to maxim.
     core dump sent to maxim.
     
  7. U-Boot was hanging periodically when loading the kernel with
    tftp; appears to have be worse when network activity is high.
    This problem also seems to have gone away in the past few weeks.
    It may have been a duplication with MAC addresses.
    
    
  7. U-Boot seems to hang periodically when loading the kernel with
    tftp; appears to be worse when network activity is high.
   8. 'top' command only shows all cpu's or cpu0; cpu 1 and 2 missing.
   8. 'top' command only shows all cpu's or cpu0; cpu 1 and 2 missing.
                
                
Line 1,162: Line 984:
     which is a link to bash but causes it to skip running the bash
     which is a link to bash but causes it to skip running the bash
     startup scripts. Changing root to /bin/bash seems to mess up
     startup scripts. Changing root to /bin/bash seems to mess up
     ssh logins.  
     ssh logins.
   
  10. For kernel to be compiled on the LX200 (for self checking:
      a. Xtensa makefile needs to be fixed:
          CC      init/do_mounts.o
          LD      init/mounts.o
        /bin/sh: xtensa_test_mmuhifi_c3-linux-uclibc-ld: command not found
        make[1]: *** [init/mounts.o] Error 127
     
      b. Need to add ncurses-devel package for 'make menuconfig'
 
   
  11. The busybox vesion of vi doesn't work very good, we are using symbolic pointer
   
      /usr/local/bin/vi ---> /usr/local/bin/vim
   
      /usr/local/bin is searched first via bash profile and rc.
      The vim version works great and doesn't seem to use very much memory.
 
  12. mplayer codecs by default install to /usr/local/lib but
      the '''ldconfig''' config file needs to be updated to search /usr/local/lib.
          Ex:
                /etc/ld.so.conf:
                    # /usr/local/src/faad2-2.7/:
                    #              libfaad.a        libfaad.la        libfaad.so@
                    #              libfaad.so.2@    libfaad.so.2.0.0* libmp4ff.a
                    #
                    /usr/local/lib
       
      /etc/ld.so.conf.d exist but is being ignored by '''ldconfig''' even if included via ld.so.conf:
                include ld.so.conf.d/*.conf
     
      REMIND: update /home/default/save_root_files
 


=Further reading=
=Further reading=
Line 1,180: Line 1,035:
* marc
* marc
* dan
* dan
* maxim


And the rest of the people in the Linux-Xtensa mailing list, if you cannot go through some of the steps, don't hesitate to ask on the mailing list, there's always somebody willing to help you!
And the rest of the people in the Linux-Xtensa mailing list, if you cannot go through some of the steps, don't hesitate to ask on the mailing list, there's always somebody willing to help you!

Latest revision as of 05:52, 21 March 2012

This is a "community" guide for how to use the LX200 board based 3-core SMP HiFi-2 Development environment. If something doesn't work or isn't covered in this guide, please feel free to ask at the Linux/Xtensa Mailing List.

NEWS:

Some general notes on these instructions:

  • They are a work in progress, though virtually complete. Just needs to have an a another engineer at Tensilica run through this procedure and make sure that we haven't missed anything.
  • The following was tested on x86 machines running RedHat Fedora Core 5 and Fedora Core 9. Test done while using the Fedora 9 based kernel and the stable branch of the Xtensa kernel appear, so far, to be a bit better. Not seeing any compile errors while stressing the system with LTP, two compiles, two mplayers, hifitest, top, pstree, and top for the

first 18 hours; appears to be running perfect till then. No gcc commands or ssh sessions getting killed until almost a day of testing. Only the Unaligned memory access warning on gethostid01 that a staff engineer diagnosed as being a mistake in the gethostid01 LTP test program.

  • NOTE for Internal Tensilica pre-release Testers:
    • Codecs available at /fac/vol6/audio/release/bin/l32r_LE5_pic.
    • LX200 bitstream available at /home/marc/XTAV200/test_mmuhifi_c3.3core.
    • Instructions to install and set up U-Boot available at http://wiki.linux-xtensa.org/index.php/Setting_up_U-Boot.
      • Checkout the snapshot_2+SMP branch of the U-Boot git repo for pre-built binaries.



Introduction

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

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

  • Setup the board. It likely comes with U-boot pre-installed, 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.
  • Suggests a possible way to tailor the board for easy codec development just before booting.

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

  • 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.
  • Suggest how to add their code to buildroot and come up again with their same development environment.

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. Here we show how to install it to your ~/bin directory:

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

The git makefile can be instructed to install git to /usr/local/bin as root for system wide access:

       $ cp git-1.6.5.tar.gz /tmp
       $ su
       Password: 
       # cd /usr/local/src/
       # mkdir git
       # cd git
       # cp /tmp/git-1.6.5.tar.gz .
       # gunzip git-1.6.5.tar.gz
       # tar xf git-1.6.5.tar
       # cd git-1.6.5
       # make prefix=/usr/local
       # make install

See the 'INSTALL instruction at the top of the git src directory for details.


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.git
   $ 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. The git GUI is a faster and more convenient method for checking out the HiFi-2 snapshot. To check out the snapshot_2+SMP branch simply run the command 'git gui' and then pull down the branch->create menu. Next select <>Match Tracking Branch Name and click on origin/snapshot_2+SMP. Finally hit the Create Button.

   $ git gui                                                                        
      [Branch] -> Create...                                                                  
         <> Match Tracking Branch Name                                                     
         <> Tracking Branch                                                                 
               origin/snapshot_2+SMP                                                         
         [Create]                                                                            
     [Reposirory]--> Quit                                                                    

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

        http://www.linux-xtensa.org/pub/snapshots/buildroot-xtensa-smp.2-Nov-2009.tar.gz         [NOTE: TO BE UPDATED]


Installing the Linux Kernel Snapshot

To install the Linux kernel environment (kernel src, config, and HiFi-2 kernel U-Boot image), cd to a location with a few GB of available disk space, and do:

   $ git clone git://git.linux-xtensa.org/git/kernel/xtensa-2.6.29-smp.git
   $ cd kernel/xtensa-2.6.29-smp
   $ git branch --track snapshot_2+SMP origin/snapshot_2+SMP                               [NOTE: The snapshot_2+SMP-stable so far appears to be a bit better]
   $ git checkout snapshot_2+SMP

The last two lines checkout the latest branch (preconfigured for the 3-core HiFi2 on the LX200). There is also a more up-to-date branch named snapshot_2+SMP-stable that has more recent kernel bug-fixes from kernel.org but it hasn't been tested as extensively but so far may be show to be a bit more stable than the well tested snapshot_2+SMP branch when memory gets tight under very heavy loads. This preconfigured 3-core HiFi2 branch has a few NFS bug fixes but nothing that immediately appears to have been a problem in this environment. Test up to now appear to be a bit better under heavy memory congestion. If you want to use this branch use the following git commands:

   $ git branch --track snapshot_2+SMP-stable origin/snapshot_2+SMP-stable
   $ git checkout snapshot_2+SMP-stable
   

As in the build root case, you can also checkout the branch easily from via git gui using the same procedure mentioned above.

Now, assuming we are still in the kernel xtensa-2.6.29-smp directory copy the kernel U-Boot Image (uImage) to the tftp directory; Ex:

   $ cp arch/xtensa/boot/uImage /tftpboot/uImage.xtensa-2.6.29-smp.test_mmuhifi_c3          [Note: You may have to make dir /tftpboot]

NOTE: On some system, like Fedora Core 9, the tftpboot directory has been moved to /var/lib/tftpboot. In this case we recommend that you just added a symbolic pointer from /etc to /var/lib/tftpboot:

   $ su
   # cd /etc
   # ln -s /var/lib/tftpboot/ tftpboot
   # ls -ld tftpboot
       lrwxrwxrwx 1 root root 18 2009-11-23 21:14 tftpboot -> /var/lib/tftpboot/
   #

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

The TFTP service is part of the xinetd and is installed on Fedora workstations. You can see that it's installed with the check config command which manages the /etc/rc.d/init.d startup scripts and with the yum search command:

    $ chkconfig --list
       NetworkManager  0:off   1:off   2:off   3:off   4:off   5:off   6:off
       NetworkManagerDispatcher        0:off   1:off   2:off   3:off   4:off   5:off   6:off
       acpid           0:off   1:off   2:off   3:on    4:on    5:on    6:off
       .
       .
       .
       xfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off
       xinetd          0:off   1:off   2:off   3:on    4:on    5:on    6:off
       ypbind          0:off   1:off   2:off   3:on    4:on    5:on    6:off
       yum             0:off   1:off   2:off   3:off   4:off   5:off   6:off

       xinetd based services:
               amanda:         off
               auth:           off
               .
               .
               .
               rsync:          off
               tftp:           on                                                                 [NOTE that tftp is enabled]
               time:           off
               time-udp:       off
               uucp:           off
      $
      $
      $
      $ yum search tftp-server
       Loading "installonlyn" plugin
       Searching Packages:
       .
       .
       .
       Reading repository metadata in from local files
       .
       .
       .
       tftp-server.i386                         0.41-1.2.1             installed     [NOTE that tftp server is installed as part of the inet daemon]
       Matched from:
       tftp-server
       The Trivial File Transfer Protocol (TFTP) is normally used only for
       booting diskless workstations.  The tftp-server package provides the
       server for TFTP, which allows users to transfer files to and from a
       remote machine. TFTP provides very little security, and should not be
       enabled unless it is expressly needed.  The TFTP server is run from
       /etc/xinetd.d/tftp, and is disabled by default on Red Hat Linux systems.
     $


TFTP is not normally enabled, to enable it just edit the file /etc/xinetd.d/tftp and change the disable field to no:

       # default: off
       # description: The tftp server serves files using the trivial file transfer \
       #       protocol.  The tftp protocol is often used to boot diskless \
       #       workstations, download configuration files to network-aware printers, \
       #       and to start the installation process for some operating systems.
       service tftp
       {
               socket_type             = dgram
               protocol                = udp
               wait                    = yes
               user                    = root
               server                  = /usr/sbin/in.tftpd                                [NOTE: /var/lib/tftpboot on Fedora Core 9]
               server_args             = -s /tftpboot
               disable                 = no
               per_source              = 11
               cps                     = 100 2
               flags                   = IPv4
       }


Setting up an NFS Server to export the Root Filesystem

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

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

We will also be adding two additional small files-systems to make your development environment more comfortable and less time consuming to get started:

   /usr/default                                                                    [Home Directory for user 'default']
   /usr/local                                                                      [File system to place enhancements not done by buildroot]


Pick a place on your workstation to export your boards file-systems and unpack the cpio and tar files. For example here we will export three files-systems in /export:

   /exports/LINUX_ROOT.HiFi-2_DemoBoard.buildroot-xtensa-smp
   /exports/hifi-2_home_default
   /exports/hifi-2_usr_local

Here's and example of unpacking the three files-systems:

   $ cd buildroot-xtensa-HiFi2-Snapshot/buildroot-xtensa-smp/binaries/HiFi-2 [Getting binary files in buildroot git repository]
   $
   $ gunzip rootfs.xtensa_test_mmuhifi_c3.cpio.gz                            [Uncompressing file-system cpio file]
   $ gunzip hifi-2_home_default.tar.gz                                       [Uncompress /home/default tar ball]
   $ gunzip hifi-2_usr_local.tar.gz                                          [Uncompress /usr/local tar ball]
   $
   $ WHERE=$PWD
   $ mkdir -p /exports/LINUX_ROOT.HiFi-2
   $
   $ cd /exports/LINUX_ROOT.HiFi-2
   $ cpio -i < $WHERE/rootfs.xtensa_test_mmuhifi_c3.cpio
   $
   $ cd /export
   $ tar xf hifi-2_home_default.tar                                          [Tar in boards /home/default for export]
   $ tar xf hifi-2_usr_local.tar                                             [Tar in boards /usr/local for export]

Next add two lines to /etc/exports:

   /exports                *(rw,no_root_squash,sync,no_wdelay)                     [Boards File-systems]
   /export                 *(rw,no_root_squash,sync,no_wdelay)                     [Buildroot source code]

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 systems now being exported:

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

Configuring U-Boot to Boot Linux

Your LX200 board should have arrived with U-Boot installed in the flash ready to use. If it fails to boot U-Boot or you happen to have a board without it there are instructions at http://wiki.linux-xtensa.org/index.php/Setting_up_U-Boot to make it easy to install.

The board has a DIP switch (next to the power on/off switch) that provides the 6 LSBs of the Ethernet MAC, in switch positions 1 thru 6.

             DIP Swithes for MAC: 1 2 3 4 5 6 7 8    ethaddr=00:50:C2:13:6f:0a
             Little Endian:       0 1 0 1 0 0 * *
                                                ^
                                                |
                                                +------ Enables booting U-Boot from Flash

DIP switch 8 should be shipped in the ON position to enable U-Boot booting from flash. See Sections 4.2.3 and 4.2.4 of the Tensilica Avnet (XT-AV200) Board User's Guide for details. Make sure to select a unique MAC address for you board.

Next, connect a serial interface to a text based terminal emulation program, set to 38400 bps, no parity, 1 stop bit, no handshaking. For an example of setting minicom for this, see here.

When you initially power on your LX200 board it will come with a very long wait period before booting and will be waiting to be configured. You can also hit one of the blue buttons next to the blue LED that's next to the PCI connector to reset the board.

The minicom session should look like the following:

   U-Boot 2009.08 (Nov 15 2009 - 22:03:26)
   
   CPU:    Xtensa test_mmuhifi_c3 at 41.6777 MHz
   Board:  XT-AV200: Avnet board + Xilinx LX200 FPGA + Tensilica bitstream
   SysRAM: 96 MB
   Flash: 16 MB
   In:    serial
   Out:   serial
   Err:   serial
   MAC:    00:50:C2:13:6f:07
   IP:     192.168.11.105
   open_ethernet
   Autobooting in 999999 seconds, press <SPACE> to stop <SPACE>
    
   U-Boot> printenv
   baudrate=38400
   ethaddr=00:50:C2:13:6f:07
   ethact=open_ethernet
   serverip=192.168.11.55
   nfsroot_server=192.168.11.55
   root-path=/exports/LINUX_ROOT.HiFi-2
   bootargs_using_bootp=console=ttyS0,38400 ip=bootp root=nfs coredump_filter=0xff
   bootcmd=tftpboot; bootm
   netmask=255.255.255.0
   gatewayip=192.168.11.1
   nfs_boot_args=root=/dev/nfs rw nfsroot=192.168.11.55:/exports/LINUX_ROOT.HiFi-2
   bootfile=uImage.xtensa-2.6.29-smp.test_mmuhifi_c3-stable
   autostart=no
   bootdelay=999999
   ipaddr=192.168.11.105
   misc_boot_args=debug coredump_filter=0xff
   hostname=HiFi-2
   nfsaddrs=192.168.11.105:192.168.11.55:192.168.11.1:255.255.255.0:HiFi-2
   bootargs=console=ttyS0,38400 ip=192.168.11.105:192.168.11.55:192.168.11.1:255.255.255.0:HiFi-2 root=/dev/nfs rw nfsroot=192.168.11.55:/exports/LINUX_ROOT.HiFi-2 debug coredump_filter=0xff
   stdin=serial
   stdout=serial
   stderr=serial
   ver=U-Boot 2009.08 (Nov 15 2009 - 22:03:26)
    
   Environment size: 788/131068 bytes
   U-Boot>

Here's how to configure U-Boot to automatically boot the Linux kernel on power-up (using the root file system exported over NFS as described further above). You need to configure UBoot with the IP addresses that are practical in your environment. When using BOOTP or DHCP many of the IP addresses are in the DHCP config file. Here we first present the simple case where all of the addresses are provided in the U-Boot environment variables:

   U-Boot> setenv serverip        192.168.11.55                                                         [TFTP server IP Address: My Workstation]
   U-Boot> setenv nfsroot_server  192.168.11.55                                                         [Root NFS Servers IP Address: My Workstation]
   U-Boot> setenv ipaddr          192.168.11.105                                                        [HOST IP address]
   U-Boot> setenv netmask         255.255.255.0                                                         [Network Mask for a Internet Class C local network]
   U-Boot> setenv gatewayip       192.168.11.1                                                          [Gateway address for default route]
   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       /export2/DC_B_330HiFi_3Core_MMU/LINUX_ROOT.HiFi-2                     [Location of root filesystem on NFS Server; Limit ~50 bytes]
   U-Boot> setenv nfs_boot_args   root=/dev/nfs rw nfsroot=${nfsroot_server}:${root-path}               [NFS Args used in bootargs]
   U-Boot> setenv hostname        HiFi-2_NFS_Based                                                      [Hostname]
   U-Boot> setenv nfsaddrs        ${ipaddr}:${nfsroot_server}:${gatewayip}:${netmask}:${hostname}       [IP addresses needed by NFS when not using DHCP or BOOTP]
   U-Boot> setenv misc_boot_args  debug coredump_filter=0xff                                            [Enable kernel debug messages and core files on a SEGV sig] 
   U-boot> setenv bootargs        console=ttyS0,38400 ip=${nfsaddrs} ${nfs_boot_args} ${misc_boot_args} [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       5                                                                     [Delay 5 seconds before booting automatically]
   U-Boot> setenv autostart       yes                                                                   [Boot automatically on power-up/reset]
   U-Boot>

Alternatively, if you don't feel like setting up an NFS exports you can could use a root filesystem simply located in the kernel RAM. In this case only TFTP will be used on the local Ethernet to load the kernel. This could be set up with these commands:

   U-Boot> setenv serverip        192.168.11.55                                                           [TFTP server IP Address: My Workstation] 
   U-Boot> setenv ipaddr          192.168.11.105                                                          [HOST IP address]
   U-Boot> setenv netmask         255.255.255.0                                                           [Network Mask for a Internet Class C local network]
   U-Boot> setenv gatewayip       192.168.11.1                                                            [Gateway address for default route]
   U-Boot> setenv bootfile        uImage.xtensa-2.6.29-smp.test_mmuhifi_c3.ramfs                          [File to fetch with TFTP and pass to bootm]
   U-Boot> setenv root-path       /export2/DC_B_330HiFi_3Core_MMU/LINUX_ROOT.HiFi-2                       [Location of root filesystem on NFS Server; Limit ~50 bytes]
   U-Boot> setenv ramfs_boot_args root=/dev/ramfs                                                         [RAMFS Args used in bootargs]
   U-Boot> setenv hostname        HiFi-2_RamFS_Based                                                      [Hostname]
   U-Boot> setenv nfsaddrs        ${ipaddr}:${nfsroot_server}:${gatewayip}:${netmask}:${hostname}         [IP addresses needed by NFS when not using DHCP or BOOTP]
   U-Boot> setenv misc_boot_args  debug coredump_filter=0xff                                              [Enable kernel debug messages and core files on a SEGV sig] 
   U-boot> setenv bootargs        console=ttyS0,38400 ip=${nfsaddrs} ${ramfs_boot_args} ${misc_boot_args} [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       5                                                                       [Delay 5 seconds before booting automatically]
   U-Boot> setenv autostart       yes                                                                     [Boot automatically on power-up/reset]
   U-Boot>


You can also set up your dhcp server with your domain information and boot with much less information and it's no longer necessary to edit the targets /etc/resolve.conf with your domain server information:

   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_using_bootp console=ttyS0,38400 ip=dhcp  root=nfs coredump_filter=0xff       [Args passed to Linux while booting with DHCP  proto]

If you want to boot with bootp or dhcp you may want your /etc/dhcp.conf file to look something like this:

   allow bootp;
   boot-unknown-clients off;
   ignore unknown-clients;
   not authoritative;
   ddns-update-style ad-hoc;
    
   option domain-name "hq.tensilica.com";
    
   subnet 192.168.11.0 netmask 255.255.255.0 {
       default-lease-time 2592000;     # 30 days
       max-lease-time 31557600;        # 1 year
       next-server = option dhcp-server-identifier;
       option routers 192.168.11.1;
       group {
               use-host-decl-names on;
                   ##
                   ## RTOS13   192.168.11.105: HelloSoft LX200 SMP Board on Piet's Desk
                   ##              DIP Swithes for MAC: 1 2 3 4 5 6 7 8    ethaddr=00:50:C2:13:6f:0F
                   ##              Little Endian:       1 1 1 1 0 0 * *
                   ##          Running HiFi-2
                   ##
                   ## hifi2.hq.tensilica.com:192.168.11.105::0x9b0ba8c0
    
                   host hifi2 {
                       hardware ethernet 00:50:c2:13:6f:07;
                       fixed-address hifi2.hq.tensilica.com;
                       next-server pdelaney_fc5.hq.tensilica.com;
                           option root-path "/exports/LINUX_ROOT.HiFi-2
                       option domain-name "hq.tensilica.com";
                       option domain-name-servers 192.168.15.20,192.168.15.21;
                   }
       }
   }

For more information on setting up the Linux Kernel boot parameters see the http://www.linuxdocs.org/HOWTOs/BootPrompt-HOWTO-3.html webpage.

Tailoring your system prior to Booting

There are a few tweaks we mentioned that developers have found convenient to add to the the root file-system before booting. As an initial environment for developing we are suggesting to mounting /home/default and /usr/local files-systems which have a number of files useful for getting started.

   $ cd /export/hifi-2_home_default
   $ ls -l
   drwxrwxrwx   12 root     root         4096 Dec  1 23:33 Audio_Tests/
   drwxr-xr-x    2 default  default      4096 Oct 28 17:46 Files/
   drwxr-xr-x    6 root     root         4096 Dec  2 02:46 LTP_Test/
   drwxr-xr-x    2 root     root         4096 Nov 20 15:13 Music/
   -rw-r--r--    1 10415    10000         841 Nov 20 01:18 SSH_Keys
   drwxr-xr-x    2 root     root         4096 Nov 13 12:14 Tests/
   drwxr-xr-x    2 10415    10000        4096 Nov 19 23:23 hifitest/
   drwxr-xr-x    5 root     root         4096 Dec  2 05:33 mplayer_packages/
   -rwxr-xr-x    1 10415    10000         544 Dec  2 03:01 save_root_files*
   -rw-r--r--    1 root     root        37888 Dec  2 03:13 saved_root_files.tar


Notice a file tar ball in the /home/default file system called saved_root_files.tar. This is a tar file of files that developers have found convenient to add and replace on the root file system after adding a new buildroot file system. Here is a list of the files and a brief explanation on why it's convenient to add or replace them:

   root/.bash_profile                           [added 'ulimit -c unlimited to allow core dumps to be created]
   root/.bashrc
   etc/profile                                  [added 'ulimit -c unlimited to allow core dumps to be created]                                        
   etc/fstab                                    [Tells the system how to mount extra NFS file systems like /home/default]
   etc/init.d/S90local                          [Mounts /home/default]
   etc/resolv.conf                              [Your locations of DNS servers; used when your not using DHCP to boot the kernel]
                                                [NOTE: restore symlink  /etc/resolv.conf -> /proc/net/pnp if using DHCP]
   etc/TZ                                       [Your time zone, currently set to California TZ]
   etc/dropbear/dropbear_rsa_host_key           [Old DropBrer keys, useful if you prefer Dropbear of sshd]
   etc/dropbear/dropbear_dss_host_key           [Old DropBrer keys, useful if you prefer Dropbear of sshd]
   etc/ssh_config                               [Typically tailored with things like allowing root logins via ssh]
   etc/ssh_host_dsa_key                         [sshd keys - Takes 30 minutes to generate, saves time on initial boot]
   etc/ssh_host_dsa_key.pub                     [sshd keys - Takes 30 minutes to generate, saves time on initial boot]
   etc/ssh_host_key                                            
   etc/ssh_host_key.pub
   etc/ssh_host_rsa_key
   etc/ssh_host_rsa_key.pub
   etc/sshd_config                              [Typically tailored with things like allowing root logins via ssh]
   etc/rndc.key                                                 
   etc/random-seed                              [Generated during 1st boot]
   etc/passwd                                   [Changed root and default user's shell to bash; runs std bash RC files to set ulimits; adds /usr/local/bin to search path]
   etc/shadow                                   [Changed default and root users login password to 'linux1', needed to ssh to the board]
   exports/                                     [The path to where the board can mount extra file systems like /home/default.
   usr/local                                    [Makes /usr/local so it can be mounted on; it has local additions, including /usr/local/src]
   codecs                                       [Makes /codecs for a NFS partition with Tensilica HiFi-2 Codecs to be mounted; the file-system should contain ...
                                                 ... /codecs/xa_hifi2_l32r_LE5_pic_mp3_dec_lib_3_1_api_1_15_lib.tgz
                                                 ... /codecs/xa_hifi2_l32r_LE5_pic_aacplus_v2_dec_lib_2_2_api_1_15_lib.tgz ]
    

Now lets assume your going to stay with mosts of these changes and modify a few of them after tar'ing in these changes to the root file-system. So here we add the tar ball files to the boards root filesystem.

   $ cd /exports/LINUX_ROOT.HiFi-2
   $ tar xf /exports/hifi-2_home_default/saved_root_files.tar

This is a good time to edit a few files on the boards file system before booting it.

   $ cd /exports/LINUX_ROOT.HiFi-2
   $ vi etc/resolv.conf                   [Place your domain information if not using a DHCP boot]
                                                [Restore symlink resolv.conf -> /proc/net/pnp if using DHCP]
   $ vi etc/fstab                         [Change fstab entry for boards root filesystem, and others to your taste]
   $ vi etc/init.d/S90local               [You might want to disable mounting of non-root NFS file systems ...
                                                 ... on the 1st Boot and add this once you try it manually]

Booting Linux for the 1st Time

We should now be ready to boot linux on your LX200. You have exported the root file-system and made the kernel available to a TFTP server. Now let's start with hitting the reset button on the LX200 and it should auto-boot the kernel, resulting in output such as this example log.

Tailoring your system prior to developing for HiFi 2

To make your experience more pleasant we suggest you tailoring your environment. Here are some of the changes that we have found helpful and provided in the saved_root_files:

  1. Added a root password to that you can login with ssh.
  2. Running rdate with an ntp server on booting.
  3. Adding 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-in build environment from Buildroot modified slightly to make installation easy.
     d. Misc audio test programs.
  6. Mounting Tensilica HiFi-2 Codecs to easily get mplayer working with HiFi-2 TIE instructions.

Building Linux Applications

Building Linux Applications Using GCC on the Host

You can use the open source toolchain included in the buildroot tree.

Given the location of the buildroot tree and the name of the core:

  $ setenv BUILDROOT_DIR  /export/src/HiFi-2_DemoBoard/buildroot-xtensa-HiFi2-Snapshot.12
  $ setenv CORENAME       test_mmuhifi_c3

You can either set the PATH and invoke tools prefixed with xtensa_${CORENAME}-linux- :

  $ setenv PATH   ${BUILDROOT_DIR}/build_xtensa_${CORENAME}/staging_dir/usr/bin:${PATH}
  $ xtensa_test_mmuhifi_c3-linux-gcc -g hello.c -o hello
  $ xtensa_test_mmuhifi_c3-linux-gdb hello

or alternatively invoke the tools with absolute paths:

  $ ${BUILDROOT_DIR}/build_xtensa_test_mmuhifi_c3/staging_dir/usr/bin/xtensa_test_mmuhifi_c3-linux-gcc -g hello.c -o hello
  $ ${BUILDROOT_DIR}/build_xtensa_test_mmuhifi_c3/staging_dir/usr/bin/xtensa_test_mmuhifi_c3-linux-gdb hello

Building Linux Applications Using GCC on the Target

This is the simplest. (Much slower of course at 45 MHz across a slow Ethernet link than on a workstation, but very convenient.) Just login to the target system and use the native gcc.

Building Linux Applications Using XCC (Xtensa Tools)

There are two approaches to compiling with Tensilica's XCC compiler (part of Xtensa Tools). The normal one, described below, is to initially setup a virtual core that has built-in references to the library and include files for the target Linux system. Alternatively, one could skip this initial setup and just use Xtensa Tools to create object files and link them using host or target GCC tools. However, such objects must be built without dependencies on such things as the C library, which can be harder than it sounds (for example, flags and structures, such as open()'s O_EXCL and stat()'s struct stat, must be avoided because their definitions likely differ between the Xtensa Tools' default C library and the Linux uClibc library). (Note: Codecs such as MP3 and AAC are typically written in C with TIE extensions and can only be compiled with XCC.)


Section 4.3 of the latest Xtensa OSKit Guide (from Tensilica's RC-2009.0 release) describes how to setup XCC to compile Linux applications. For full details, see the guide. A summary follows.

Initial Setup

The XTENSA_TOOLS_ROOT, XTENSA_ROOT, BUILDROOT_DIR, and TARGET_SYSROOT environment variables must be set according to where things were installed; values shown here are for illustration only. The CORENAME variable, set correctly below for this board, reflects the name of the core as known to open source tools (as opposed to XTENSA_CORE which is the core name as known to Xtensa Tools; both happen to match here).


   $ setenv USER              someuser
   $ setenv XTENSA_ROOT       /home/${USER}/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3
   $ setenv XTENSA_TOOLS_ROOT /home/${USER}/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools
   $ setenv TARGET_SYSROOT    /exports/LINUX_ROOT.HiFi-2
   $ setenv BUILDROOT_DIR     /export/src/HiFi-2_DemoBoard/buildroot-xtensa-HiFi2-Snapshot
   
   $ setenv CORENAME         test_mmuhifi_c3
   
   $ cd ${BUILDROOT_DIR}
   $ ${XTENSA_ROOT}/xtensa-elf/src/linux/bin/xt-xcc-linux-install                                \
       --sysroot=./build_xtensa_${CORENAME}/staging_dir'                                         \
       --linux-gcc=./build_xtensa_${CORENAME}/staging_dir/usr/bin/xtensa_${CORENAME}-linux-gcc

Regular Use

Assuming the above completed successfully, you can now build applications using Xtensa Tools. First set the usual environment variables (assuming values of XTENSA_ROOT and XTENSA_TOOLS_ROOT used earlier):

   $ setenv XTENSA_CORE      default
   $ setenv XTENSA_SYSTEM    ${XTENSA_ROOT}-linux/config
   $ setenv PATH             ${XTENSA_TOOLS_ROOT}/bin:${PATH}

Now you can use Xtensa Tools to assemble, compile, and link applications for the Linux target specified during setup. For example:

   $ echo '#include <stdio.h>' > hello.c
   $ echo 'int main() {printf("Hello!\\n");return 0;}' >> hello.c
   $ xt-xcc -g hello.c -o hello

Then copy it where the target can see it:

   $ cp hello ${TARGET_SYSROOT}/root                             [NOTE: This step isn't necessary if your src file system is mounted on the targer; Ex: /export]

And run it on the target:

   [root@hifi ~]# /root/hello
   Hello!
   [root@hifi ~]#

Here's a more interesting example that uses Tensilica TIE features. (This cannot be compiled using GCC.)

   $ cd ${TARGET_SYSROOT}/home/default/Audio_Tests
   $ xt-xcc -g hifitest.c -o hifitest

In a ssh termulator window on the board you can now run hifitest:

   [root@hifi ~]# cd /home/default/Audio_Tests/
   [root@hifi Audio_Tests]# ./hifitest
   cnt:0x0, pid:23178; Eatting cpu; time:0 <control-C>
   
   [root@hifi Audio_Tests]#


Here is the source code for the hifitest.c source file used above.

Limited (No Setup) Use of Xtensa Tools for Linux Targets

Below we illustrate compiling a simple audio test program on a workstation. We start by referring to the XTENSA tools build by Xplorer, putting XCC into our search path and set the standard XTENSA_* environment variables. For example:

   setenv XTENSA_CORE      test_mmuhifi_c3
   setenv XTENSA_ROOT      /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3
   setenv XTENSA_SYSTEM    /home/pdelaney/Xplorer/XtDevTools/install/builds/RC-2009.0-linux/test_mmuhifi_c3/config
   setenv XTENSA_TOOLS     /home/pdelaney/Xplorer/XtDevTools/install/tools/RC-2009.0-linux/XtensaTools/bin
    
   setenv PATH ${XTENSA_TOOLS}:${PATH}
   
   
   [piet@fc9desktop Tests]      $ cd /exports/hifi-2_home_default/Audio_Tests                           [NOTE: This is being done on a Workstation]
   [piet@fc9desktop Audio_Tests]$ xt-xcc -g3 -O0 -fPIC -c hifitest.c


Next we link the object on the LX200 board and run gdb on the TIE enhanced code:

  [root@hifi Audio_Tests]# gcc -g hifitest.o -o hifitest
  [root@hifi Audio_Tests]# ./hifitest
                            cnt:0x0, pid:4640; Eatting cpu; time:0
                            cnt:0x0, pid:4640; Eating Tie; time:7
  ^C
  [root@hifi Audio_Tests]# gdb ./hifitest                                                               [NOTE: This is being done on the LX200 board]
  GNU gdb 6.6
  Copyright (C) 2006 Free Software Foundation, Inc.
  GDB is free software, covered by the GNU General Public License, and you are
  welcome to change it and/or distribute copies of it under certain conditions.
  Type "show copying" to see the conditions.
  There is absolutely no warranty for GDB.  Type "show warranty" for details.
  This GDB was configured as "xtensa_test_mmuhifi_c3-linux-uclibc"...
   Using host libthread_db library "/lib/libthread_db.so.1".
  (gdb) break main
  Breakpoint 1 at 0x400401: file /exports/default/Audio_Tests/hifitest.c, line 20.
  (gdb) run
  Starting program: /home/default/Audio_Tests/hifitest 
   
  Breakpoint 1, main (argc=1, argv=0x3fb3fab4)
      at /exports/default/Audio_Tests/hifitest.c:20
  20	     time_t time0 = time(NULL);
  (gdb) step
  21	  time_t time1 = time(NULL);

Compiling Generic GPL Packages

For your development you may want to add a few GPL packages that you find helpful. This can be done on the LX200 just as you would on a normal workstation, though much slower. For example here we configure and build a few common GPL packages with the standard:

  $ ssh root@hifi
  [root@hifi ~] # cd /usr/local/src
  [root@hifi src] # mkdir <package>
  [root@hifi src] # wget <url_to_package>
  [root@hifi src] # gunzip <package.tgz>
  [root@hifi src] # cd package
  [root@hifi <package> ] # .configure
  [root@hifi <package> ] # make
  [root@hifi <package> ] # make install

Here are two examples, the invaluable strace and vim GPL packages:

 Building the Strace Package
 Building the vim Package

This can be a useful effort prior to adding a package to buildroot or for compiling packages with debug enabled. For example on of our developers compiled uClibc with -g to debug problems in this package.

Compiling the Mplayer Plugins and linking them with MPEG-1 Audio Layer 3 (MP3) and MPEG-4 AAC Codecs

Mplayer is provided as an example environment for developing and testing Codecs and HiFi 2 software. 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="-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="-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

We are currently able to compile mplayer on the LX200 but due to space limitations it's not possible to compile it -O0.


Now, let's focus on compiling linking the plugins. They are a nice example of compiling an audio application on the LX200.

We modified the plugin Makefile slightly, and they are available in /home/default/mplayer_packages. These additions just instruct make how to fetch the codecs and build and install the plugins as explained in the Chapter 7 of the Linux HiFi application note. With these Makefile additions and the Tensilica codecs available in the /plugins directory is very easy.

For example the mp3 plugin has this addition:


   # We assume Tensilica Codecs have been mounted at /codecs
   # via /etc/fstab during boot.
   #
   CODEC_PACKAGE=xa_hifi2_l32r_LE5_pic_mp3_dec_lib_3_1_api_1_15_lib
   CODEC_PACKAGE_LOCATION=/codecs
   MPLAYER_DEVEL_LOCATION=/home/default/buildroot_mplayer_stuff
    
   all: $(XA_CODEC_NAME) $(SLIBNAME) $(XA_CODEC_NAME).so
   .
   .
   .
   $(CODEC_PACKAGE).tgz:
           cp $(CODEC_PACKAGE_LOCATION)/$(CODEC_PACKAGE).tgz .
   
   $(CODEC_PACKAGE).tar:: $(CODEC_PACKAGE).tgz
           gunzip $(CODEC_PACKAGE).tgz
   
   $(XA_CODEC_NAME):: $(CODEC_PACKAGE).tar
             tar xf $(CODEC_PACKAGE).tar
   
   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


The make file will be 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. To add mp3 and aac plugins to mplayer you just type make followed by make install:

   [root@hifi mplayer_hifi2_mp3_plugin]# make
   cp /codecs/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
   cc -I../libavcodec -I../libavformat -I. -I.. -I../libavutil -W -Wall -O2   -pipe -g3  -D_REENTRANT -DHAVE_CONFIG_H -I/usr/include  -DNDEBUG -fvisibility=hidden -Ixa_mp3_dec/include -I../MPlayer-1.0rc2 -Ic
   xa_mp3_dec_sample_testbench.c: In function 'xa_mp3_decode_frame':
   xa_mp3_dec_sample_testbench.c:185: warning: pointer targets in passing argument 1 of 'xa_mp3_audio_read' differ in signedness
   xa_mp3_dec_sample_testbench.c:163: warning: unused variable 'j'
   xa_mp3_dec_sample_testbench.c: In function 'mp3_codec_init':
   xa_mp3_dec_sample_testbench.c:517: warning: pointer targets in passing argument 1 of 'xa_mp3_audio_read' differ in signedness
   xa_mp3_dec_sample_testbench.c: At top level:
   xa_mp3_dec_sample_testbench.c:112: warning: 'pack_32_to_24_bits' defined but not used
   cc -I../libavcodec -I../libavformat -I. -I.. -I../libavutil -W -Wall -O2   -pipe -g3  -D_REENTRANT -DHAVE_CONFIG_H -I/usr/include  -DNDEBUG -fvisibility=hidden -Ixa_mp3_dec/include -I../MPlayer-1.0rc2 -Ic
   ad_xa_mp3_dec.c: In function 'xa_mp3_audio_read':
   ad_xa_mp3_dec.c:26: warning: pointer targets in passing argument 2 of 'demux_read_data' differ in signedness
   ad_xa_mp3_dec.c: In function 'init':
   ad_xa_mp3_dec.c:42: warning: pointer targets in passing argument 1 of 'xa_mp3_decode_frame' differ in signedness
   ad_xa_mp3_dec.c: At top level:
   ad_xa_mp3_dec.c:52: warning: unused parameter 'sh'
   ad_xa_mp3_dec.c:56: warning: unused parameter 'arg'
   ad_xa_mp3_dec.c:78: warning: unused parameter 'sh_audio'
   cc -I../libavcodec -I../libavformat -I. -I.. -I../libavutil -W -Wall -O2   -pipe -g3  -D_REENTRANT -DHAVE_CONFIG_H -I/usr/include  -DNDEBUG -fvisibility=hidden -Ixa_mp3_dec/include -I../MPlayer-1.0rc2 -Im
   cc -I../libavcodec -I../libavformat -I. -I.. -I../libavutil -W -Wall -O2   -pipe -g3  -D_REENTRANT -DHAVE_CONFIG_H -I/usr/include  -DNDEBUG -fvisibility=hidden -Ixa_mp3_dec/include -I../MPlayer-1.0rc2 -Ie
   [root@hifi mplayer_hifi2_mp3_plugin]#
   [root@hifi mplayer_hifi2_mp3_plugin]# make install
   mkdir: cannot create directory '/etc/mplayer': File exists
   make: [install] Error 1 (ignored)
   cp codecs.conf /etc/mplayer
   mkdir: cannot create directory '/usr/lib/mplayer': File exists
   make: [install] Error 1 (ignored)
   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
   [root@hifi mplayer_hifi2_mp3_plugin]#


The makefile unpacked of the Tensilica mp3 codec tarball will installed 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

Now, having built and installed the mp3 plugin, do the same for the AAC codec.

   [root@hifi ~]# cd /home/default/mplayer_packages/mplayer_hifi2_aacplus_v2_plugin/
   [root@hifi mplayer_hifi2_aacplus_v2_plugin]# make
   [root@hifi mplayer_hifi2_aacplus_v2_plugin]# make install

Additional codecs can be downloaded from the mplayer web site, configured, compiled and can be installed as usual.

  http://www.mplayerhq.hu/DOCS/HTML/en/codec-installation.html
  [opencore-amr | opencore-amr]

opencore-amr builds fine and the x264-snapshot compiles completely but the Makefile and code needs to be set up for ARCH xtensa. The GPL AAC decoder, faad, has out of date autoconf files, config.sub and config.guess, need to be updated for Xtensa. This can be easily done by copying config.sub and config.guess from the x264-snapshot which had up to date versions recognizing xtensa correctly.

Add on codec install by default to /usr/local/lib and the ldconfig config file /etc/ld.so.conf needs to have /usr/local/lib added.

Lots of opportunity likely exists for optimizing these codec for Xtensa extensibility.


[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 Packages and/or Codec to Buildroot

Xtensa developers provide detailed instructions on building the root filesystem and the Linux kernel.

Building a comprehensive development environment with buildroot can be a challenging experience and worthy of providing some tips on process. Here are notes of the configs used for the three menuconfigs in this 2nd snapshot provided with SMP additions:

    $ make  menuconfig
    $ make  uclibc-menuconfig
    $ make  busybox-menuconfig

[TO BE DONE - making a new tar ball of saved files, building buildroot, ...]

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

 1. Using NFS mounts with default parameters causes memory congestion. Use these mount options:
     
     vers=2,rsize=4096,wsize=4096,hard,nointr,nolock,nolock,timeo=11,retrans=3,noauto
   
    this is extremely important to add to your /etc/fstab on the target.
    
 2. Can't swap over NFS yet, under extreme conditions memory can get tight and cause application to be killed.
   a. We will be trying procedure documented in U-Boot Manual to swap over NFS.
 
 3. Building the complete C development with X11 doesn't work with buildroot.
  
 4. Though Mplayer plug-in can be compiled, Mplayer can be compiled but still has a few issues:
   a. Can't be compiled -O0 due to limited memory while compiling one file,
   b. Compiler was crashing and make had to be restarted.
      We are not seeing this problem with root build on Fedore Core 9.
      Perhaps this was caused by debug kernel being enabled or LTP using all of the memory.
  
 5. U-boot has flash problems:
   a. Sectors marked Read-Only come up Writeable after a reset/reboot.
  
   b. Flashing a large number of sectors (like the kernel) sometimes
      results in an Error (Ex: Vcc) and had to be retried.
  
   c. We saw environment variables trashed on reset/reboot once.
      It's possible that U-boot in flash could get whacked
      and the board will need to be re-flashed. During weeks
      of testing we haven't seen the U-Boot environment getting whacked.
    
 6. gdb appears to be crashing on target when debugging 
    on latest root with uclibc left unstriped and with debug;
    core dump sent to maxim.
     
 7. U-Boot was hanging periodically when loading the kernel with
    tftp; appears to have be worse when network activity is high.
    This problem also seems to have gone away in the past few weeks.
    It may have been a duplication with MAC addresses.
  
 8. 'top' command only shows all cpu's or cpu0; cpu 1 and 2 missing.
              
 9. Program dore dump require ulimit -c to be set but root uses /bin/sh
    which is a link to bash but causes it to skip running the bash
    startup scripts. Changing root to /bin/bash seems to mess up
    ssh logins.
   
 10. For kernel to be compiled on the LX200 (for self checking:
     a. Xtensa makefile needs to be fixed:
          CC      init/do_mounts.o
          LD      init/mounts.o
        /bin/sh: xtensa_test_mmuhifi_c3-linux-uclibc-ld: command not found
        make[1]: *** [init/mounts.o] Error 127
      
     b. Need to add ncurses-devel package for 'make menuconfig'
  
   
 11. The busybox vesion of vi doesn't work very good, we are using symbolic pointer
    
      /usr/local/bin/vi ---> /usr/local/bin/vim
    
      /usr/local/bin is searched first via bash profile and rc. 
      The vim version works great and doesn't seem to use very much memory.
  
  12. mplayer codecs by default install to /usr/local/lib but
      the ldconfig config file needs to be updated to search /usr/local/lib. 
          Ex:
               /etc/ld.so.conf:
                    # /usr/local/src/faad2-2.7/:
                    #               libfaad.a         libfaad.la        libfaad.so@
                    #               libfaad.so.2@     libfaad.so.2.0.0* libmp4ff.a
                    #
                    /usr/local/lib
       
      /etc/ld.so.conf.d exist but is being ignored by ldconfig even if included via ld.so.conf:
               include ld.so.conf.d/*.conf
      
      REMIND: update /home/default/save_root_files


Further reading

Main Xtensa Linux resources are:

Thanks to

  • piet
  • marc
  • dan
  • maxim

And the rest of the people in the Linux-Xtensa mailing list, if you cannot go through some of the steps, don't hesitate to ask on the mailing list, there's always somebody willing to help you!