Tuesday, June 14, 2011

Running uBuntu Linux on Beagle Board xM-revC with DSP Bridge enabled for Gstreamer




About

This post is about video streaming on a hardware box with embedded Linux. After some efforts and helps from friends (Special thanks to Siva.V), finally the DSP on Beagle board seems to be working. Below I am logging few steps how it was done. Overall, this effort is for myself to learn how to set up an embedded system for video streaming using:
  • Hardware: Beagle Board xM (rev C) (SD ID: xMTEST beta 3-30)
  • Software: uBuntu linux 2.6.39 with Gstreamer 0.10 and DSP tools for onboard DSP 

Why This Log

Many websites list details how their projects were done but some information could be out-dated.  I have spent significant amount of time trying out different recipes; here I am listing one recipe that seems to work for me as of June/2011.  There are many approaches to achieve the same goal, e.g. build everything from open source codes. Here I only focus on how to put pieces together. This is a faster way to get overall  idea first and leave the details to explore later. Most steps leverage existing packages from other people's efforts. You certainly can explore further in more details how to build them from sources and gain better insights.

Hopefully this helps the people who are interested in a similar project and need some pointers to get started. 

The Big Picture

First, the overall idea of the steps involved in this recipe:

  • STEP1: Get the HW/SW needed for this project.
  • STEP2: Build a bootable SD for the Beagle Board
  • STEP3: Build the Linux Kernel
  • STEP4: Build the DSP & Gsteamer tools Needed
  • STEP5: Misc Stuffs (VNC/Networking)
  • STEP6: Try out some videos
  • STEP7: What Next


STEP1: Get the HW/SW needed for this project

If you are reading this post, I assume you have some ideas of Beagle board & Linux. If not, here are some good starters. I will be using the reference numbers in the second column through out this post.



Subject
Websites
Beagle Board website
Beginner’s wiki
Beagleboard  uBuntu
Beagleboard DSP from source
Felipe Contreas’ gst-dsp
Wiki gst-dsp
Wiki gst-omapfb
Wiki gst-dsptools
uBuntu VNC
Big Buck Bunny

This picture shows the environment setup. The laptop is the host machine, which can connect to the Beagle board through a USB-to-Serial and use minicom program to communicate with the board for initial installation and configuration. Once the embedded Linux is up and running, the host machine can use VNC to launch programs, e.g. Gstreamer, running on the Beagle board from the host machine. 


STEP2: Build a Bootable SD for the Beagle Board
Our goal here is to build a bootable SD card for Beagle board with 2 disk partitions. In wiki [4], Section 4 – “SD card boot” lists great details and pointer how this can be done. However, if you want to save time, you can jump ahead and load a working one directly from [3]. I followed section 5.1 in [3] for Natty 11.04.

You can play with it to get a taste but all we need is just it’s first partition without uImage (later will be overwritten).


STEP3: Build the Linux Kernel & Root File System

The goal here is to build an uImage file to be loaded into partition-1 of your SD card. Follow the instruction from [3]’s section 9.4 DSP. This is basically using RobertCNelson’s stable kernel git. It seems he had integrated everything needed to enable Beagleboard DSP from Felip Contras' projects - his website is [5].

Few things to clarify here.  Once you git Robert’s stable kernel,  you will find 3 scripts in the directory. You need to run all of them.  The purposes of them are:

  • build_kernel.sh – this is basically to build uImage. Refer to [4] section 6.3 “Deploy the kernel”. You will need to copy this to disk partition-1 of your SD card.
  • build_deb.sh – this is to build the "*.deb" for uBuntu rootstock to deploy userspace flie system, i.e. the disk partition-2 of your SD. You will find the *deb file in the deploy directory after you run the script. Refer to section 7 of [4] “Userspace File system” to see how this is done. The idea is that you need to enable webserver (lighttpd) on your host, copy the *dev to /var/www and build a tarball in a clean directory so later you can copy it to partition-2 to untar for your file system.  Wiki [4] section 6.2 and 7 describes enough details for this process. When you deploy your user space file system,  you can use the command in [4].   Section 7.1.1 lxde root files ystem. This gives you GUI environment so later you can remotely log in from VNC and playback video from there.
  • create_dsp_package.sh  - see next section. 
At this point, you should be delopying Linux kernel and file system to the SD card and able to boot up uBuntu on beagle board. You may want to enable VNC and networking first before installing the DSP stuffs - please refer to STEP5 Misc Stuffs.


STEP4: Build the DSP & Gsteamer Tools Needed

The script of create_dsp_package.sh  is to build the DSP tools and BIOS needed to enable the DSP hardware on beagle board. You need to build this and install in your beagle board Linux later. See [3]’s DSP section. There are essentially 3 steps involved in the script:
  1. build gst-dsp – for understanding purpose, see[6].
  2. build gst-omapfb – for understanding purpose, see[7]
  3. build dsp-tools – for understanding purpose, see[8]


Once the script completes, the DSP modules will be automatically load in next boot-up. You can see dspbridge and mailbox from “lsmod” command. Also check /opt/dsp to see what were loaded.


STEP5: Misc Stuffs (VNC/Networking)


VNC

In order to remotely log in your beagle board and play around stuffs just like on your desktop, a good solution is to use VNC.  [9] is a good post. There are one thing for you to decide – whether you want to have VNC server automatically running or not after boot up.  If not, all you need is just
 sudo apt-get install tightvncserver
to install vncserver in your beagle board linux and type “vncserver” after log in. You should be able to find a vncviewer to remotely login, e.g. "xtightvncviewer”. The step-2 on webpage [9] and following steps are needed if you want VNC automatically loaded. This is convenient later because all you need to do with beagle board later is just to power up – you don’t even need minicom to log in.

Enable Networking

It is likely that the networking is not enabled after you log in beagle board through minicom the first time. See section 8.4.1 of [3]. My recommendation is just to copy /etc/network/interfaces file from your orginal SD to the new SD card you are working on. 


STEP6: Try out some videos
If everything is setup right, you are ready to test out some videos. Few steps:


Test  DSP


  •   Perform “lsmod” to see if DSP modules are loaded (check bridgedriver and mailbox_mach).
  •   Have two terminals and run “sudo dsp-load” and “sudo dsp-test” separately to see if the loading picks up.

Play Some Videos:


There are only few video formats supported in this package (mp4, jpeg, wmv, h264 etc). You can easily find video with those formats, or download from [10]. I recommend the trailer for iphone – a small clip. Run the command to launch gstreamer
  sudo gst-launch playbin2 uri=”file://$PWD/trailer_iphone.m4v

Wala! You see your first video on your beagle board.



STEP7: What Next


See next post on performance tuning … enough typing for today..