OpenEmbedded C++ (Gtkmm) Development

Last changed on Jan 9, 2007


Below is a collection of notes I assembled along the way of porting some of my own C++ Gtkmm-based software to Sharp Zaurus running OpenEmbedded distribution of GPE v.3.5.4.

Install and Configure Sharp Zaurus SL-5500 (Collie)

Some basic system information:


  Distro:  OpenZaurus 3.5.4
  Build:   2006-03-12 21:51

  CPU:     Intel StrongARM-111- rev9 (v4l)
  RAM:     64Mb    /media/ram
  Storage: 0Mb     /

  External storage (flash):
 
    Compact Flash:  1Gb Kingston card
    SD Card:        512Mb Kodak			

			

I use CF card as removable storage to keep data and distribution files on. The SD Card serves as a permanent harddrive with root filesystem installed on it via wonderful altboot bootstrapper. The instructions that follow assume that you will have your root partition on a removable SD storage card.

  1. Plug your CF card in the card reader, and format it first. I use two partitions:

    
    # fdisk /dev/hde
    
    ... create both partitions ...
    
    # mkfs.vfat -F 16 /dev/hde1
    # mke2fs /dev/hde2
    
    				

  2. For starters, read through Getting Started section of Collie/Install guide. Also, look at wiki instructions as well.
  3. Download and copy zImage to /dev/hde1 (fat16 partition of CF Card).

    The images come in zImage-collie-Xmemory-Ystorage.bin format.

    Rename zImage-collie-64-0.bin to zImage and then copy the file to the CF card.

    I max out on Xmemory (64Mb) to help GPE run smoother. The Ystorage is set to 0 - SD card is used instead.

  4. Plug in your SD card and format it as ext2 filesystem.

    
    # fdisk /dev/hdf
    
    ... create Linux ext2 partition ...
    
    # mke2fs /dev/hdf1
    
    				

    Download gpe-image-3.5.4-collie.rootfs.tar.gz from one of the mirrors and copy it to the root partition of your SD card. The card is going to be used as a permanent harddrive - it is important not to unplug it.

    You also might want to put create-cfext2-mount shell script on your SD card to ease the pain of configuring freshly installed system:

    
    
    # Name: create-cfext2-mount
    
    mkdir /media/cfext2
    chown root.users /media/cfext2
    chmod g+w /media/cfext2
    
    echo "created /media/cfext2"
    
    cat "/dev/hda2  /media/cfext2 auto defaults,sync,noauto,noatime 0  0" >> /etc/fstab
    
    echo "added /media/cfext2 to /etc/fstab"
    
    mount /dev/hda2 /media/cfext2
    
    echo "mounted /media/cfext2"
    
    cd /media/cfext2
    cp ipkg.conf /etc
    
    echo "copied ipkg.conf to /etc"
    
    				

  5. Flush the device:

    1. Plug in both SD and CF cards.
    2. Plug in the A/C POWER CABLE.
    3. Unlock and open the battery door.
    4. Hold down C+D keys and press the reset button on the back where the battary is. Both e-mail and battery lights should go solid.
    5. Wait for 5 to 10 minutes until the lights go out.
    6. PRESS the reset button again.
    7. Reboot and ...
  6. Follow the altboot installation procedure to setup root partition on SD card and install the software:

    1. Wait for altboot prompt, press a button and select Advanced option:

      
      
      Please press any key to launch altboot.... f
      
      altboot v1.0.5
      
        [1] Normal Boot
        [2] Don't launch GUI
        [3] Boot SD card
        [4] Boot CF card
        [5] Advanced:
      
      Please choose one of the above: 5
      
         [6] Boot from NFS
         [7] init=/bin/sh
         [8] Install RootFS from tar.gz
      
      Please choose one of the above: 8
      
      Mounting rootfs rw ... ok
      ...
      
      Please choose the target of this installation:
      
        [1] SD / MMC
        [2] Compact Flash
      
      Your target: 1
      
      Please choose the type of the installation:
      
        [1] Imagefile (loopfile)
        [2] Direct install
      
      Install type: 2
      
      ...
      Syncing drives ...done
      Press [Enter] to bring up the altboot menu
      
      altboot v1.0.5
      
        [1] Normal Boot
        [2] Don't launch GUI
        [3] Boot SD card
        [4] Boot CF card
        [5] Advanced:
      
      Please choose one of the above: 3
      
      					

      Choosing 1 (Normal Boot) would most likely get you hosed. Remeber, your image has 0 memory for the root partition!

      
      
      Choose altboot password:
      Repeat: 
      Press [Enter] to bring up the altboot menu
      
      altboot v1.0.5
      
        [1] Normal Boot
        [2] Don't launch GUI
        [3] Boot SD card
        [4] Boot CF card
        [5] Advanced:
      
      Please choose one of the above: 1
      
      
      					

      Now, that is a bit confusing, but at this point going with "Normal Boot" is the only right thing to do. Not only that, but also every time you reboot the system from xterm with shutdown, you must select "Normal Boot" from altboot menu.

  7. Congratulations! You are a proud owner of the latest GPE hand-held device running the world's best operating system - Linux.

  8. To check your system, start System Information service, and look at Storage configuration:

Install and Build SDK for Sharp Zaurus

A simpler configuration can be found on http://familiar.handhelds.org/build-setup.html.

Already pre-built packages (including granule!) can be found at http://www.openembedded.org/repo/org.openembedded.dev/packages/.

Some other sources of information:

It takes about 30 minutes to install development environment on Fedora Core machine.

  1. First, install all necessary software:

    
    # yum install monotone python-psyco ccache texi2html git
    				

  2. Download and upgrade 'patch' utility to 2.5.9 (if it is not already there).

    
    # wget http://rpmfind.net/linux/RPM/suse/9.3/i386/suse/i586/patch-2.5.9-145.i586.html
    # rpm -Uhv patch-2.5.9-145.i586.rpm 
    				

  3. Install the Open Embedded SDK.
  4. Create local configuration

    
    $ cd /extra/stuff
    $ org.openembedded.dev/conf/local.conf.sample build/conf/local.conf
    				

    Edit build/conf/local.conf appropriately (for 3.5.4 branch):

    
    
       DL_DIR = "/extra/stuff/sources"
       BBFILES = "/extra/stuff/org.openembedded.dev/packages/*/*.bb"
       BBMASK = ""
       MACHINE = "collie"
       DISTRO = "openzaurus-unstable"
       IMAGE_FSTYPES = "jffs2 tar"
       BBINCLUDELOGS = "yes"
    
       PREFERRED_PROVIDERS = "virtual/qte:qte virtual/libqpe:libqpe-opie"
       PREFERRED_PROVIDERS += " virtual/libsdl:libsdl-x11"
       PREFERRED_PROVIDERS += " virtual/${TARGET_PREFIX}gcc-initial:gcc-cross-initial"
       PREFERRED_PROVIDERS += " virtual/${TARGET_PREFIX}gcc:gcc-cross"
       PREFERRED_PROVIDERS += " virtual/${TARGET_PREFIX}g++:gcc-cross"
    
       ASSUME_PROVIDED += "virtual/arm-linux-gcc-2.95"
    
    				

    Don't forget to comment out the last line of the file.
  5. Setup the environment:

    1. Setup $PATH and $BBPATH environment variables

      
      $ export PATH=/extra/stuff/bitbake/bin:/usr/local/arm/2.95.3/bin:$PATH
      $ export BBPATH=/extra/stuff/build:/extra/stuff/org.openembedded.dev
      					

    2. *** VERY IMPORTANT *** Make sure you have $LD_LIBRARY_PATH unset

      
      $ export LD_LIBRARY_PATH=
      					

    3. Check your 'umask' and if not properly set, reset it to

      
      $ umask 022
      					

  6. This step is OpenZaurus specific and is documented by a separate openembedded.org wiki page.

Install Extra Software Packages

Whether you have an SDK or not, you can enhance your GPE setup with a plethora of open-source softeware available at your fingertips.

If, however, you are a software developer, like myself, you probably want to port an existing software you got used to and love to your PDA.

So, here is how you would upgrade your system with extra stuff if you your PDA is not network-aware.

  1. On your development host, plug in your SD card and copy the software package you want to install and all its dependencies to the ext2 partition of the SD card:

    
    myhost> mount /dev/hde2 /media/CF2
    myhost> cd /extra/stuff/tmp/deploy/ipk
    myhost> cp /extra/stuff/ipkg-make-index .
    
    myhost> ipkg-make-index . > Packages
    myhost> cd /extra/stuff/tmp
    
    myhost> cp -R deploy /media/CF2
    myhost> umount /media/CF2
    				

    Note that we used modified version of ipkg-make-index to extract and collect all the package information to Packages file:

    
    #!/bin/sh
    
    set -e
    
    pkg_dir=$1
    
    if [ -z $pkg_dir ] || [ ! -d $pkg_dir ]; then
    	echo "Usage: ipkg-make-index "
    	exit 1
    fi
    
    for pkg in `find $pkg_dir -name '*.ipk' | sort`
    do
    	echo "Generating index for package $pkg" >&2
    
    	file_size=$(ls -l $pkg | awk '{print $5}')
    	md5sum=$(md5sum $pkg | awk '{print $1}')
    
    	# Take pains to make variable value sed-safe
    	sed_safe_pkg=`echo $pkg | sed -e 's/\\//\\\\\\//g'`
    
    	ar x $pkg control.tar.gz
    	tar xzOf control.tar.gz | sed -e "s/^Description:/Filename: $sed_safe_pkg\\
    Size: $file_size\\
    MD5Sum: $md5sum\\
    Description:/"
    	echo ""
    	rm -f control.tar.gz
    done
    				

  2. On the Z, open the terminal and logon as root. Plug in the CF card. Only FAT16 partition would be auto mounted.

    
    [Z]# cd /media 
    [Z]# mkdir cfext2 
    [Z]# chown root.users cfext2 
    [Z]# chmod g+w cfext2 
    [Z]# mount /dev/hda2 /media/cfext2 
    				

    Alternatively, you might want use the create-cfext2-mount from SD card to do the drudgery.

  3. Copy the 'fstab' and 'ipkg.conf' files from the CF to /etc.

    
    [Z]# cd cfext2 
    [Z]# cp ipkg.conf /etc 
    [Z]# cp fstab /etc 
    				

    'fstab' has a line added to mount the /media/cfext2 [Grr NOT WORKING]

    'ipkg.conf' has a new source (CF) and a new destination (CF) added:

    
    ...
    
    src unstable file:///media/cfext2/deploy/ipk/
    src unstable http://oz.leggewie.org/ipk/
    
    dest root /
    
    ...
    				

    If you have managed to configure your Z with a networking capabilities via USB or WiFi card, this would be the place to add other web repositories to pull software from. [TODO: provide syntax description.]

  4. OpenEmbedded uses Ipkg package management system which is a scaled-down version of Debian's Dpkg.
USB Networking with Sharp Zaurus
  1. Create a file /etc/sysconfig/network-scripts/ifcfg-usb0 with the following in it:

    
    
    # USB configuration for iPAQ
    DEVICE=usb0
    BOOTPROTO=none
    IPADDR=192.168.129.1
    NETMASK=255.255.255.255
    ONBOOT=yes
    MII_NOT_SUPPORTED=no
    
    				

  2. Restart hotplug

    
    # /sbin/service hotplug restart
    				

  3. Create configuration file /etc/sysconfig/network-scripts/route-usb0 with the following contents:

    
    
    192.168.129.1 scope host dev usb0
    
    				

  4. Plug in the handheld
  5. To enable routing from the handheld through the LINUX host, edit /etc/sysctl.conf and change line

    
    
    # net.ipv4.ip_forward = 0
    net.ipv4.ip_forward = 1
    
    				

  6. Modify iptables (BAD, BAD, BAD - locked myself out the web!)

    
    
    # /sbin/iptables -t nat -F
    # /sbin/iptables -t nat -A POSTROUTING -j SNAT -o eth0 --to 192.168.129.1
    # /etc/init.d/iptables save
    
    				

  7. Configure your PDA with networking parameters:

    
    
    + IP (192.168.129.201), 
    + gateway (192.168.129.1), and 
    + DNS on the handheld
    
    				


Vlad Grinchenko
Last modified: Tue Jan 9 23:02:02 EST 2007