SMP HiFi 2 Development Board: Difference between revisions
No edit summary |
No edit summary |
||
Line 388: | Line 388: | ||
U-Boot 2009.08 (Nov 15 2009 - 22:03:26) | U-Boot 2009.08 (Nov 15 2009 - 22:03:26) | ||
CPU: Xtensa test_mmuhifi_c3 at 41.6777 MHz | CPU: Xtensa test_mmuhifi_c3 at 41.6777 MHz | ||
Board: XT-AV200: Avnet board + Xilinx LX200 FPGA + Tensilica bitstream | Board: XT-AV200: Avnet board + Xilinx LX200 FPGA + Tensilica bitstream | ||
Line 417: | Line 417: | ||
Verifying Checksum ... OK | Verifying Checksum ... OK | ||
Uncompressing Kernel Image ... OK | Uncompressing Kernel Image ... OK | ||
## Linux Boot Params Starting At Address:0xd5f50000 | ## Linux Boot Params Starting At Address:0xd5f50000 | ||
MEMORY: tag:0x1003, type:0X1000, start:0X0, end:0X6000000 | 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' | 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 | SERIAL_BAUDRATE: tag:0x1004, size:4, baudrate:38400 | ||
## Transferring Control to Linux Kernel At Address 0xd0001000 ... | ## Transferring Control to Linux Kernel At Address 0xd0001000 ... | ||
parse_bootparam: Ignoring tag 0x1004 | parse_bootparam: Ignoring tag 0x1004 | ||
lx60 platform_init(bootparams:d5f50000) | lx60 platform_init(bootparams:d5f50000) |
Revision as of 01:57, 21 November 2009
This is the "communitee"" guide for how to use HiFi-2 Codec Development environment on an LX200 FPGA board. If somethinig doesn't work ir isn't vovered in these guides, please feel free to ask at the Linux//Xtensa Mailing List]
NEWS:
Some general notes on these instructions:
- They are a work in progress.
- The following was tested on x86 machines running RedHat Fedora Core 5.
Introduction
This document is addressed to someone who received an LX200 board setup by Tensilica for HiFi2 codec development.
This document goes over the steps needed to set up the LX200 board for codec development. To summarize:
- Setup the board. It likely comes with U-boot preinstalled, ready to boot a linux kernel.
- Install git.
- Download buildroot and linux kernel trees, pre-configured and built for HiFi-2 development.
- Setup a TFTP server to provide the linux kernel to U-Boot.
- Setup an NFS server to export a linux root file system.
- Setup the Linux kernel to boot from the root file system provided by the NFS server.
Once the development board is up and running, this document:
- Suggests a possible way to tailor the board for easy codec development.
- Shows how to add the Tensilica provided codec packages to the Mplayer packages used by Buildroot, including building and installing.
- Demonstrates two procedures for compiling, linking, and debugging codecs.
All development is expected to be done on a Linux host. (One can in principle use Windows to develop target libraries. However, linking and subsequent steps need to be done in Linux.)
Downloading the Latest HiFI-2 Buildroot and Kernel Snapshots
The HiFi-2 development environment is maintained in a source code version control system named 'git'. The git tools are useful when working with this development environment, though they are not strictly necessary. This document generally assumes the use of git, which provides more opportunities for modifying this environment as needed (e.g. building more optional buildroot packages). But points out alternatives to allow getting up and running without having to set it up.
Installing git
To install git, download a recent tarball from the official site. For example, cd to a location with enough disk space, and do:
$ wget http://www.kernel.org/pub/software/scm/git/git-1.6.5.tar.gz
Unpack the tarball, and make and install it. 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 $ cd buildroot-xtensa-HiFi2-Snapshot $ git branch --track snapshot_2+SMP origin/snapshot_2+SMP [56 key strokes] $ git checkout snapshot_2+SMP [28 key strokes]
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 [8 key strokes] [Branch] -> Create... [2 key strokes] <> Match Tracking Branch Name [1 key stroke] <> Tracking Branch [1 key stroke] origin/snapshot_2+SMP [1 key stroke] [Create] [1 key stroke] [Reposirory]--> Quit [2 key strokes]
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):
http://www.linux-xtensa.org/pub/snapshots/buildroot-xtensa-smp.2-Nov-2009.tar.gz
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 $ cd kernel/xtensa-2.6.29-smp $ 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). As in the build root case, you can also do it from via git gui using the same proceedure mantioned 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
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. [piet@pdelaney_fc5 ~]$
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 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 filesystem over NFS. This filesystem was built using buildroot into a cpio format file, and left in:
buildroot-xtensa-HiFi2-Snapshot/buildroot-xtensa-smp/binaries/HiFi-2/rootfs.xtensa_test_mmuhifi_c3.cpio
We will also be adding an additional minor changes to make your development environment more comfortable.
Pick a place on your workstation to export your root and unpack the cpio file into that directory.
For example here we will set up an export in /exports/LINUX_ROOT.HiFi-2_DemoBoard.buildroot-xtensa-smp:
$ cd buildroot-xtensa-HiFi2-Snapshot/buildroot-xtensa-smp/binaries/HiFi-2 $ WHERE=$PWD $ mkdir -p /exports/LINUX_ROOT.HiFi-2 $ cd /exports/LINUX_ROOT.HiFi-2 $ cpio -i < $WHERE/rootfs.xtensa_test_mmuhifi_c3.cpio
Next add a line to /etc/exports:
/exports *(rw,no_root_squash,sync,no_wdelay)
and restart you nfs services:
$ /etc/rc.d/init.d/nfs restart
or
$ /sbin/chkconfig nfs on
The showmount command should show your NFS file system now being exported:
$ showmount -e Export list for mypc.foobar.com: /exports * $
Configuring U-Boot to Boot Linux
Your LX200 board should have arrived with U-Boot installed in the flash ready to use. The board has a DIP switch next to the power on/of switch that provideds the 6 LSB's 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 arrive with DIP switch 8 on 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 you pick a unique MAC for you board.
The arp command can be helpfull for detecting aliases:
$ arp -e Address HWtype HWaddress Flags Mask Iface oz.hq.tensilica.com ether 00:06:5B:18:D8:7A C eth0 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 minicom. We usually just type:
minicom xtboard
which initializes with parameters from /etc/minirc.xtboard:
# Machine-generated file - use "minicom -s" to change parameters. pr port /dev/ttyS0 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 ┌───────────[Comm Parameters]────────────┐ OPTIONS: History Buf│ │ 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.
U-Boot> setenv serverip 192.168.11.55 [TFTP server IP Address: RTOS-LAB2] U-Boot> setenv nfsroot_server 192.168.11.55 [Root NFS Servers IP Address: My Workstation] U-Boot> setenv ipaddr 192.168.11.155 [HOST IP address] U-Boot> setenv bootfile uImage.xtensa-2.6.29-smp.test_mmuhifi_c3 [File to fetch with TFTP and pass to bootm] U-Boot> setenv root-path /exports/LINUX_ROOT.HiFi-2 [WARNING: Limit path to < 50 characters] U-Boot> setenv bootargs_using_bootp console=ttyS0,38400 ip=bootp root=nfs coredump_filter=0xff [Args passed to Linux while booting with BOOTP proto] U-boot> setenv bootargs console=ttyS0,38400 ip=dhcp root=/dev/nfs rw nfsroot=${nfsroot_server}:${root-path} [Args passed to Linux while booting with DHCP proto] U-boot> setenv bootcmd tftpboot\; bootm [Boot Linux after fetching it with TFTP] U-Boot> setenv bootdelay 20 [Delay 20 seconds before booting automaticaly] U-Boot> setenv autostart yes [Boot automatically on power-up/reset] U-Boot> saveenv U-Boot>
Tailoring your system priot to Booting =
There are a few tweaks that developers have found convenient to add to the the root filesystem before booting. As an initail enviroment for developing we suggest mounting a /home/default filesystem that has number of files useful for getting started. Find another place to tar in the tar ball with the default users file system. We chose to include this close to the cpio file with the root filesystem. Copy the tar bar to where you are exporting you root filesystem and next to it add the 'default' users filesyste:
$ cd /export $ cp /export/src/HiFi-2_DemoBoard/buildroot-xtensa-HiFi2-Snapshot.10/binaries/default.tar . $ tar xf default.tar $ cd detault $ ls [TO BE ADDED]
Notice a file tar ball called saved_files.tar. This ia 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 explaination on why it's convenient to add or replace them:
root/.bash_profile [added 'ulimit -c unlimited to allo core dumps to be created] root/.bashrc etc/profile [added 'ulimit -c unlimited to allo 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 [Location of DNS servers when your not using DHCP to boot the kerenl] etc/TZ [Your time zone, currently set to California TZ] etc/dropbear/dropbear_rsa_host_key [Old DropBrer keys, usefull if you prefer Dropbear of sshd] etc/dropbear/dropbear_dss_host_key [Old DropBrer keys, usefull 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 minuts to generate, saves time on initial boot] etc/ssh_host_dsa_key.pub [[sshd keys - Takes 30 minuts 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 default user's shell to bash] etc/shadow [Changed default and root users login passowrd to 'linux1', need to ssh to the board] 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] fac/vol6/ [Where we get the HiFi-2 codec from to install and build mplayer plugins]
Now lets assume your going to stay with these changes and modify them after taring in these changes. Here we add the tar ball files to the boards root filesystem.
$ cd /exports/LINUX_ROOT.HiFi-2 $ tar xf /exports/default/
This is a good time to edit a few files on the boards file system before boot it.
$ cd /exports/LINUX_ROOT.HiFi-2 $ 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]
Booting Linux for the 1st Time =
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) 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 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 ... parse_bootparam: Ignoring tag 0x1004 lx60 platform_init(bootparams:d5f50000) 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 smp_init_cpus: Core Id = 9320 On node 0 totalpages: 24576 free_area_init_node: node 0, pgdat d0196540, node_mem_map d01fa000 Normal zone: 216 pages used for memmap Normal zone: 24360 pages, LIFO batch:3 smp_prepare_boot_cpu: Built 1 zonelists in Zone order, mobility grouping on. Total pages: 24360 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 trap_init 0 PID hash table entries: 512 (order: 9, 2048 bytes) time_init: Platform Calibrating CPU frequency time_init: ccount_per_jiffy:416777 [41.67 MHz], nsec_per_ccount:23 Console: colour dummy device 80x25 console [ttyS0] enabled Dentry cache hash table entries: 16384 (order: 4, 65536 bytes) Inode-cache hash table entries: 8192 (order: 3, 32768 bytes) Memory: 95196k/98304k available (1229k kernel code, 3040k reserved, 28k data, 72k init 0k highmem) Calibrating delay loop... 41.26 BogoMIPS (lpj=206336) Mount-cache hash table entries: 512 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 hifi login:
Tailoring your system prior to developing your codec
To make your experience more pleasant we suggest you tailor you environment. Here are some of the changes that we have found helpful:
1. Add a root password to that you can login with ssh. 2. Run rdate with an ntp server on booting. 3. Add NFS mounts to /etc/fstab for your code and buildroot code. 4. Copy in previous ssh server encryption keys to /etc/dropbear to speed up your initial boot. 5. Mount a 'default' user home directory with: a. Linux Test Suite pre-patch to test the system b. Audio test example files c. Copies of Mplayer and its Plug-ins from Buildroot modified slightly to make installation easy. d. Misc audio test programs.
[TO BE DONE - Where to get 'default' user home directory tar ball and 1st boot patch]
Compiling your codec and linking it with Mplayer
Mplayer is provided as an example environment for developing and testing Codecs 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 most of mplayer on the XL200 but due to space limitations it's not possible to compile it -O0.
Now, lets focus on compiling linking the plugins. They are a nice
example of compiling a audio application on the LX200.
We modified the Makefile of the codes slightly, and will make it available. These additions just instruct make how to install the plugins as explained in the Chapter 7 of the Linux HiFi application note.
For example the mp3 plugin has this addition:
target_install:: -mkdir /etc/mplayer cp codecs.conf /etc/mplayer -mkdir /usr/lib/mplayer cp ad_xa_mp3_dec.so /usr/lib/mplayer/ cp xa_mp3_dec.so /usr/lib/mplayer chmod 755 /usr/lib/mplayer/ad_xa_mp3_dec.so chmod 755 /usr/lib/mplayer/xa_mp3_dec.so
It's just providing a codec config file for mplayer at /etc/mplayer/codecs.conf and copying the plug-in to /usr/lib/mplayer. To install the mp3 codec plugin and mplayer config file just copy your codec that was compiled with xcc to the directory, compile it, and install.
# cd /fac/vol6/audio/release/bin/l32r_LE5_pic # cp xa_hifi2_l32r_LE5_pic_mp3_dec_lib_3_1_api_1_15_lib.tgz /tmp # # cd /home/default/buildroot_mplayer_stuff # cd mplayer_hifi2_mp3_plugin # cp /tmp/xa_hifi2_l32r_LE5_pic_mp3_dec_lib_3_1_api_1_15_lib.tgz . # gunzip xa_hifi2_l32r_LE5_pic_mp3_dec_lib_3_1_api_1_15_lib.tgz # tar xf xa_hifi2_l32r_LE5_pic_mp3_dec_lib_3_1_api_1_15_lib.tar # make # make target_install
The unpacking of the Tensilica mp3 codec tar ball will install the following files:
xa_mp3_dec/ xa_mp3_dec/README xa_mp3_dec/include/ xa_mp3_dec/include/mp3_dec/ xa_mp3_dec/include/mp3_dec/xa_mp3_dec_api.h xa_mp3_dec/include/xa_apicmd_standards.h xa_mp3_dec/include/xa_error_handler.h xa_mp3_dec/include/xa_error_standards.h xa_mp3_dec/include/xa_memory_standards.h xa_mp3_dec/include/xa_type_def.h xa_mp3_dec/test/ xa_mp3_dec/test/build/ xa_mp3_dec/test/build/ldscript_stream_data.txt xa_mp3_dec/test/build/makefile_testbench_sample xa_mp3_dec/test/build/paramfilesimple.txt xa_mp3_dec/test/include/ xa_mp3_dec/test/include/id3_tag_decode.h xa_mp3_dec/test/src/ xa_mp3_dec/test/src/xa_mp3_dec_sample_testbench.c xa_mp3_dec/test/src/id3_tag_decode.c xa_mp3_dec/test/src/stream_data.c xa_mp3_dec/test/src/xa_mp3_dec_error_handler.c xa_mp3_dec/test/test_inp/ xa_mp3_dec/test/test_inp/compl.mp3 xa_mp3_dec/test/test_inp/hihat.mp3 xa_mp3_dec/test/test_out/ xa_mp3_dec/test/test_out/force_mkdir.txt xa_mp3_dec/test/test_ref/ xa_mp3_dec/test/test_ref/compl_24bit.wav xa_mp3_dec/test/test_ref/hihat_16bit.wav xa_mp3_dec/lib/ xa_mp3_dec/lib/xa_mp3_dec.a xa_mp3_dec/doc/ xa_mp3_dec/doc/HiFi2-MP3-DecoderProgrammersGuide.pdf
[TO BE DONE - Add missing C file, make clean deletes it!]
The xa_mp3_dec.a archive will be used by the Makefile in the mplayer_hifi2_mp3_plugin directory to make the mplayer plug-in. Section 6 of the 'Using Tensilica HiFi 2 Codec on Xtensa Linux with MPlayer Application Note has a detailed description of the encapsulation process used by the plug-ins.
Adding your codec to Buildroot
Xtensa developers provide detailed instructions on building the root filesystem and the Linux kernel.
Building a comprehensive development environment with buildroot can be a chalanging 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]
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 2. Can't swap over NFS yet, memory can get tight and cause application to be killed. a. Trying proceedure documented in U-Boot Manual. 3. Building the C development with X11 doesn't work with buildroot. 4. Though Mplayer plug-in can be compiled, Mplayer still has a few issues. a. Can't be compiled -O0 b. Compiler infrequently crashes and make has to be restarted. 5. U-boot has flash problems: a. Sectors marked Read-Only come up Writeable after a reset/reboot. b. Flashing a large numner of sectors (like the kernel) sometimes results in an Error (Ex: Vcc) and had to be retried. c. Saw enviroment 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. 6. gdb appears to be crashing on target when debugging on latest root with uclibc left unstripped and with debug; core dump sent to maxim. 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. 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.
Further reading
Main Xtensa Linux resources are:
- Linux/Xtensa Wiki
- Buildroot Build Instructions
- Kernel Build Instructions
- Setting up U-Boot
- Linux/Xtensa Mailing List
- http://git.linux-xtensa.org/cgi-bin/git.cgi GIT Repositories]
Thanks to
- piet
- marc
- dan
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!