Sep 8, 2009

How to build Valgrind for Beagleboard

1) Get Valgrind source code from SVN using revision 9648 and 1888 for VEX
svn co -r 9648 svn://
cd VEX
svn update -r 1888

3) Apply the patch into the source code
cd valgrind
patch -p1 < [path to the patch]

4) Run to run autotools

5) Configure the source code
./configure --host=arm-angstrom-linux-gnueabi

The patch still has some bugs such as CPU instruction alignment you can 'cat /proc/cpu/alignment' to find out if the kernel is configured to fix unaligned accesses, and you can enable it by executing 'echo 2 > /proc/cpu/alignment' but it's enough to use for simple application.
Have fun with Valgrind :-)

Sep 4, 2009

How to build Clutter for Beagleboard

The Clutter need to be configured with =flavour=eglnative= so that it can work with SGX driver
The following is the configure command
./configure --with-flavour=eglnative --host=arm-angstrom-linux-gnueabi PKG_CONFIG=/data/workspace/OE/tmp/staging/i686-linux/usr/bin/pkg-config PKG_CONFIG_PATH=/data/workspace/OE/tmp/staging/armv7a-angstrom-linux-gnueabi/usr/lib/pkgconfig CFLAGS="--sysroot=/data/workspace/OE/tmp/staging/armv7a-angstrom-linux-gnueabi/ -I/data/workspace/OE/tmp/staging/armv7a-angstrom-linux-gnueabi/usr/include" --with-x=no --with-gles=1.1 --with-imagebackend=internal

  • --host: set the target for the build, need to be arm-angstrom-linux-gnueabi
  • PKG_CONFIG: use the pgk-config command from OE distribution
  • PKG_CONFIG_PATH: the path to search for *.pc file, need to be pointed to OE distribution
  • --with-x: not using X
  • --with-imagebackend: specific the image backend to use
  • --with-gles: specific the GLES version to use (1.1 or 2.0)
  • CFLAGS: override some C compiler flags
  • --sysroot: the root directory to search for library and header files
  • -I[include_dir]: some optional include directories to search for

Fix undefined rpl_malloc on autoconf tool in cross compile mode

When using autoconf tool in cross compile environment, sometime there is error like this `undefined reference to `rpl_malloc'`

It is the bug of autoconf tool in the test function AC_FUNC_MALLOC. To fix it we need define an environment variable that forces the test to pass. Define it in the environment prior to calling ./configure and the script will act as if the AC_FUNC_MALLOC check has passed.

export ac_cv_func_malloc_0_nonnull=yes

Aug 16, 2009

Draw Text with OpenGL and Cairo

The OpenGL just supports capability to draw primitive, not text. In order to draw text on screen we need support of other package such as Cairo or Pango. The following topic describe how to use Cairo with OpenGL.
1 First we need to create a Cairo surface for drawing (text)
2 Then we will load the surface into GL texture using glTextureXXX function
3 After all, we will apply texture mapping into our primitive (for example a rectangle for displaying text)

Create Cairo Context
inline cairo_t*
create_cairo_context (int width,
int height,
int channels,
cairo_surface_t** surf,
unsigned char** buffer)
cairo_t* cr;

/* create cairo-surface/context to act as OpenGL-texture source */
*buffer = (unsigned char*)calloc (channels * width * height, sizeof (unsigned char));
if (!*buffer)
printf ("create_cairo_context() - Couldn't allocate surface-buffer\n");
return NULL;

*surf = cairo_image_surface_create_for_data (*buffer,
channels * width);
if (cairo_surface_status (*surf) != CAIRO_STATUS_SUCCESS)
free (*buffer);
printf ("create_cairo_context() - Couldn't create surface\n");
return NULL;

cr = cairo_create (*surf);
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
free (*buffer);
printf ("create_cairo_context() - Couldn't create context\n");
return NULL;

return cr;

Draw text into the Cairo surface and then load it into GL Texture
inline int DrawText(int x, int y, int width, int height, char *string, COLOR &textColor, COLOR &background)
cairo_surface_t* surface = NULL;
cairo_t* cr;
unsigned char* surfData;
GLuint textureId;

/* create cairo-surface/context to act as OpenGL-texture source */
cr = create_cairo_context (256,

/* clear background */
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
cairo_paint (cr);

cairo_move_to(cr, 256/10, 256/2);
cairo_set_font_size(cr, 30);
cairo_select_font_face(cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_show_text(cr, string);

glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_2D, textureId);

free (surfData);
cairo_destroy (cr);

return textureId;


Texture Mapping
The texture mapping is so simple, we need to provide them the UV coordinate. The UV coordinate is range from 0 to 1 which 0 is the start point, and 1 is the end point. The following is an example usage

GLfloat textureCoord[] = {
f2vt(0.0f), f2vt(0.35f),
f2vt(1.0f), f2vt(0.35f),
f2vt(0.0f), f2vt(0.55f),
f2vt(1.0f), f2vt(0.55f)
COLOR clrText = {255,255,255};
GLuint textureId = DrawText(clipRect[0], clipRect[1], clipRect[2], clipRect[3], data, clrText, this->m_clrBackground);

glVertexPointer(2, VERTTYPEENUM, 0, rect);
glTexCoordPointer(2, VERTTYPEENUM, 0, textureCoord);

glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);


glDeleteTextures(1, &textureId);

Aug 15, 2009

Enable 2D Over OpenGL

In OpenGL, if we want to 2D only, we can use the Ortho matrix to set ignore the z-list. The following code snippet demo how to do that

int vPort[4];

glGetIntegerv(GL_VIEWPORT, vPort);


glOrtho(0, vPort[2], 0, vPort[3], -1, 1);

void glDisable2D()

Aug 10, 2009

Boot beagleboard with S-Video output

Boot beagleboard with S-Video output

setenv bootargs console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw rootfstype=ext3 rootwait omapfb.mode=tv:1024x768-16@60 omapdss.def_disp=tv
fatload mmc 0:1 0x80300000
uImage-2.6.29 bootm 0x80300000

Aug 8, 2009

How To Share Network with Beagleboard through USB

1) Follow this link to setup network connection between Beagleboard and Host
2) Setup ip forwarding in the Host (linux)
echo "Remove any previous NAT setup"
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain

echo "Setup NAT to forward packets from usb0 <---> eth0"
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface usb0 -j ACCEPT

echo "Enable packet forwarding in the kernel"
echo 1 >> /proc/sys/net/ipv4/ip_forward

3) In the board add route to the host
route add default gw

4) In the board set the DNS search to be same as the host so that it can resolve host to name
cat /etc/resolve.conf

That's all :-)

How To Setup Beagleboard Network through USB

1) Boot up the board
2) In the board type
ifconfig usb0 [ip_here] netmask [mask here] up
i.e. ifconfig usb0 netmask up
3) In the host environment (linux) type
ifconfig usb0 [ip_here] netmask [netmask here] up
ifconfig usb0 netmask up

Then you can ssh to the board with `ssh root@

Aug 1, 2009

Boot the Beagleboard with NFS through USB

You need a USB cable and serial cable to connect from Beagleboard to your Linux host
- bridge-utils

1) Add file ifcfg-usb0 into /etc/sysconfig/network-scripts/
IPADDR=            # Replace with your Linux host's IP address

2) Add the ifcfg-br0 into /etc/sysconfig/network-script
# Ethernet Bridge
SEARCH="localhost"              # Replace with your search domains
NETMASK=           # Replace with your subnet's netmask
IPADDR=           # Replace with your Linux host's IP address
GATEWAY=             # Replace with your subnet's gateway
DNS1=                # Replace with your subnet's DNS
DOMAIN='localhost'                 # Replace with your Linux host's domain(s)

4) Add br0 into /etc/init.d

# Source function library.
. /etc/rc.d/init.d/functions


# Check if all what named needs running
   /usr/sbin/brctl addbr br0
   /usr/sbin/brctl addif br0 eth0
   /sbin/ifup eth0
   /sbin/ifup br0
   return 0;

stop() {
   /sbin/ifdown br0
   /sbin/ifdown eth0
   /usr/sbin/brctl delbr br0

restart() {

# See how we were called.
case "$1" in
         echo $"Usage: $0 {start|stop|restart}"
  exit 3

exit $RETVAL

3) Setup NFS: add following line to /etc/exports
/data/nfs *(rw,no_root_squash,no_all_squash,async)

4) Create directory /data/nfs and tar your root filesystem to /data/nfs

5) Type following commands to restart the NFS service
#service rpcbind restart
#service nfs restart

6) On BeagleBoard console type following command.
OMAP3 # setenv bootargs console=ttyS2,115200n8 root=/dev/nfs rw nfsroot= ip= nolock,rsize=1024,wsize=1024 rootdelay=2

7) OMAP3 # saveenv

8) OMAP3 # mmcinit

9) OMAP3 # fatload mmc 0 0x80300000 uImage

10) OMAP3 # bootm 0x80300000

11) While the board is booting up, type ifconfig until you see the usb0 device is up. Then type `brctl addif br0 usb0`.

And enjoy the filesystem over NFS

Reference from

Jul 20, 2009

How to cross compile Perl

Download Perl from and extract it into a folder
The go to that folder and type
sh ./Configure -des -Dusecrosscompile \
-Dtargethost=[ip of the target] \
-Dtargetdir=/cross/bin \
-Dtargetuser=[user to SSH to the target]
-Dtargetarch=arm-linux \
-Dcc=/opt/crosstool/gcc-3.4.1-glibc-2.3.3/arm-9tdmi-linux-gnu/bin/arm-9tdmi-linux-gnu-gcc \
-Dincpth=/opt/crosstool/gcc-3.4.1-glibc-2.3.3/arm-9tdmi-linux-gnu/include \
-Dusrinc=/opt/crosstool/gcc-3.4.1-glibc-2.3.3/arm-9tdmi-linux-gnu/include \
And then type make to build the Perl

The other solution which is simpler is as following
Download the and extract it into existing Perl source code (5.10.0)

Then configure and compile it:
./configure --target=$target --sysroot=/mnt/target
make DESTDIR=... install

Jul 15, 2009

cygwin undefined reference to `_glEnd' and related OpenGL function

Sometime, when building OpenGL application under cygwin, we fail to compile with following message or relating OpenGL function message "undefined reference to `_glEnd' and related OpenGL function"

The simple test is such as following
#include <GL/gl.h>
int main() { glEnd(); return 0; }

$ gcc -lGL test.c -o test
/.../.../ccO7Cfcr.o:test.c:(.text+0x2b): undefined reference to `_glEnd'
collect2: ld returned 1 exit status

That is because the OpenGL library on cygwin is depended on GLU library also. We need to link with GLU when linking with GL
Change the link command to $ gcc -lGL -lGLU test.c -o test and everything is OK.

I met this issue while compiling ShivaVG package on cygwin

Jul 11, 2009

How to get stack trace of a function

In Java,
try {
throw new Exception();
} catch (Exception ex) {

In C++, we'll use backtrace function as following (note: the backtrace does not exist in uClibc so that if you want to use, you must patch the library to enable it)

#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
void print_trace (void)
void *array[10];
size_t size;
char **strings;
size_t i;

size = backtrace (array, 10);

strings = backtrace_symbols (array, size);
printf ("Obtained %zd stack frames.\n", size);

for (i = 0; i < size; i++)
printf ("%s\n", strings[i]);
free (strings);

Or we can use sigsegv as followin

Jun 20, 2009


Last few years, when I first saw the LinkedIn, I thought it is just another tools for social network. I registered an account and left it unupdate. Until last year, I received many update information and started thinking of LinkedIn. I updated my profile, connected people, created a page for GCS, and tried my best to get more connections. But I'm just an employee I don't see full of its benefits.
Recently, after I accepted a connection from friend, the issue has begun to rise. Many of my friends left GCS because of xxx reason. I don't know why but after talking to HR, I saw that it's a really difficult situation. Our HR is still using the old ways of recruitment.
I think that GCS and our management is too old and we don't catch up the trend effectively. It took times to let our manager know that the trend is really the trend. LinkedIn has recently raised up and with other social network tools, you can build up the relationship as easy as you want not as hard as the old way we did.
Let me think about it more clearly...

Update them cai nay nua, moi doc duoc tu 1 list cac technologies nhung thay cai nay co ve nhu la 1 strategic solution. Ma khong biet GCS co xem no nhu strategic khong nua
Social Media Becomes Strategic
"Social media is not new to any of us, but we are not using it as strategically as we can. In 2009 expect more businesses to use social media as a way to communicate with customers. While web sites and email newsletters are still important communication tools social media tools as a standard (not exception) communication tool will increase.
For example, more people will be aware of Twitter (beyond just geeks) and start to use it to receive information from businesses they want to keep in touch with. LinkedIn is a powerful tool for finding connections, but users often under-utilize it. In a recent conference, almost 80% of the hands went up that they were LinkedIn users and the same hands stayed up that they really didn’t know what to do with LinkedIn.
It is important that you learn as much as you can about enhancing your use of social media in order to network with other businesses, find new customers and better communicate with existing customers."

Final point
1. I know what is LinkedIn and its benefits but I've tried but can't do anything to help my GCS
2. I know Twitter but still confuse in its usage and benefits. Maybe it is just for marketing purpose, something like marketing campaign or product selling.
3. I know Facebook and currently get some ideas on its benefits to GCS :-)
4. Cau noi hay nhat trong ngay: You must be online and visible if you want to thrive and beat your competition

Apr 28, 2009

LinkedIn - Business In A Social Way

"LinkedIn is a business-oriented social networking site founded in December 2002 and launched in May 2003 mainly used for professional networking. As of February 2009, it had more than 35 million registered users, spanning 170 industries." - Wikipedia

How many of you have already known LinkedIn? Do you have a LinkedIn account? So what is LinkedIn anyway?

When you join, you create a profile that summarizes your professional expertise and accomplishments. You can then form enduring connections by inviting trusted contacts to join LinkedIn and connect to you. Your network consists of your connections, your connections’ connections, and the people they know, linking you to a vast number of qualified professionals and experts. Through your network you can:

  • Manage the information that’s publicly available about you as professional
  • Find and be introduced to potential clients, service providers, and subject experts who come recommended
  • Create and collaborate on projects, gather data, share files and solve problems
  • Be found for business opportunities and find potential partners
  • Gain new insights from discussions with likeminded professionals in private group settings
  • Discover inside connections that can help you land jobs and close deals
  • Post and distribute job listings to find the best talent for your company

From my point of view, I think that LinkedIn is a good business tools for marketing over the internet today. Most people use LinkedIn to “get to someone” in order to make a sale, form a partnership, or get a job.

Here are some tips for you to get the most out of LinkedIn

  1. Increase visibility by adding connections so that people will see your profile first when they’re searching for someone to hire or do business with. In addition to appearing at the top of search results, people would much rather work with people who their friends know and trust.
  2. Improve connectability by filling out your profile like it’s an executive bio, include past companies, education, affiliations, and activities
  3. Improve your Linkedin profile Search Engine ranking by creating a public profile and select "Full View". Also customize your public profile’s URL to be your actual name. To strengthen the visibility of this page in search engines, use this link in various places on the web.
  4. Gauge the health of a company by performing an advanced search for company name and uncheck the “Current Companies Only” box. This will enable you to scrutinize the rate of turnover and whether key people are abandoning ship. Former employees usually give more candid opinions about a company’s prospects than someone who’s still on board.
  5. Integrate into a new job. When people start a new job, ordinarily their roots aren’t that deep in the new company. However, with Linkedin, new employees can study fellow employees’ profiles and therefore help them get to know more people faster in a new company.
  6. Fill out your LinkeIn profile. First, some people search profiles for keywords, so make sure the words you hope people are seeking when they think of you exist inside your profile. Use real captivating words up front, not like a resume or CV, but instead, like an advertisement for you, because that’s what LinkedIN is!
  7. Ask and answer questions by using the Answers feature brings your name and profile around to people you’re not exposed to directly. This means more opportunities for someone to recognize your authority in some field, and to reach out and contact you for something further. It means sharing the fruits of your networking with others, and potentially connecting 3rd parties to each other for something bigger. This comes in handy when it becomes obvious that you’re also a good connector.
  8. Help others. The best way to network is to help others succeed. They’ll never forget you, and you will be paid back tenfold some day. Use LinkedIn to help others promote them, link to them, connect with them, recommend them, answer their questions.
  9. Use LinkedIn as Market research tool. Planning to launch a new product? Do a little research into what companies are offering similar things, about what kind of potential customers are out there, and what they’re like, and what their needs are, and what kind of demand there is for your type of product. It can take some creative searching, but the information is there, waiting to be mined. Talk to employees or former employees of similar businesses, or of potential customers, and you can get the answers you’re looking for.
  10. Check references for potential hires. Trying to hire the perfect widget maker? Well, you’re not likely to find out about an applicant’s sordid past mistakes by calling the references on their application. Do a search for others who worked at the same company at the same time, and get a better background check in minutes.

There are still many other tips it mostly depends on your usage.

By the way, the world has been changed. The raising of Web 2.0 makes social network goes up also. In a near future, you will see that the recruitment will happen on the internet, through Social Network tools. You will see a lot of messages like this “Oh, crap! We need to get on Twitter! And Facebook! And MySpace! And LinkedIn! Grab interns who know this stuff, quick!”.

Well, is it hot? Why don't you open the LinkedIn and create your own profile?

Here is my LinkedIn profile and if you're Global CyberSoft employee, make sure you enter Global CyberSoft network when joining LinkedIn


Apr 19, 2009

How to install Broadcom BCM43xx driver on Fedora Core 10

It has been tested on the bcm4318 card.

1. Configure NetworkManager to automatically start and start the service.
chkconfig NetworkManager on
service NetworkManager start
2. Download and extract the firmware
tar -jxvf broadcom-wl-
3. Cut the firmware
cd broadcom-wl-
/usr/bin/b43-fwcutter -w /lib/firmware wl_apsta.o
4. Restart NetworkManager
service NetworkManager restart
If you want to use the fedora system-config-network tool (System -> Administration -> Network) to configure the connection, run the following command as well.
echo "alias wlan0 b43" >> /etc/modprobe.conf
After that I was able to use the NetworkManager applet to enter my encryption key to finish connecting to my network.

If it does not work, check the /etc/sysconfig/network-scripts directory and remove the possible file ifcfg-wlan0

Then restart the network service;

service network restart

Mar 17, 2009

Global CyberSoft Joins Simax Semiconductor Alliance

Semiconductor fab services alliance Simax Global Services is pleased to announce that Global CyberSoft (GCS) has joined its ranks. Global CyberSoft is a California based and globally recognized provider of offshore IT outsourcing solutions, with strong operations based in Vietnam. GCS offers outstanding solutions for fab automation, embedded software and field service engineering against highly competitive rates. By joining the Simax alliance, GCS expands its international presence next to its existing sales offices in Tokyo, Singapore, USA and Europe.

Read more here

Jan 26, 2009

How to download Windows 7 beta

Windows 7 has been in beta release for months and here is how to download and test the BETA version.
  1. Register yourself a Live account
  2. Go to Microsoft Connect Website
  3. Search for Windows Ecosystem Readiness Program -
  4. Download and enjoy yourself :-)
Have fun,

Jan 1, 2009

How to install Red5 Server with Tomcat

  • Download Java from
  • Install java into a folder such as /opt/red5/jdk-1.6.0
  • Set JAVA_HOME point to that folder
export JAVA_HOME=/opt/red5/jdk-1.6.0
cd /opt/red5
tar -xf apache-tomcat-6.0.18.tar.gz
cd /opt/red5
tar -xf
  • The 3 WARs file will be extracted
    • ROOT.war: the main Red5 application
    • admin.war: the Red5 admin page
    • echo.war: the echo sample application
  • Move 3 WARs into tomcat/webapps folder
cd /opt/red5
mv ROOT.war admin.war echo.war apache-tomcat-6.0.18/webapps
  • Remove the default ROOT application of Tomcat
cd /opt/red5/apache-tomcat-6.0.18/webapps
rm -rf ROOT
  • Create a file for easy to startup with following content
export JAVA_HOME=/opt/red5/jdk-1.6.0
export CATALINA_HOME=/opt/red5/apache-tomcat-6.0.18
export PATH=$JAVA_HOME/bin:$PATH
  • Start Tomcat with
cd /opt/red5
  • Open the browser and browse to the following URL http://[ip]:8080/
  • The Red5 welcome page will be displayed
  • You can test the RTMP broadcast via web at http://[ip]:8080/demos/ofla_demo.html or via client application such as VideoLAN rtmp://[ip]/oflaDemo/DarkKnight.flv
  • You might want to create the to stop Tomcat with following contents
export JAVA_HOME=/opt/red5/jdk-1.6.0
export CATALINA_HOME=/opt/red5/apache-tomcat-6.0.18
export PATH=$JAVA_HOME/bin:$PATH