Building for Linux iPAQ

From email from Todd Stiers: how he got Boodler compiled for the Linux iPAQ.

Steps I took:
1. Install the "Familiar GPE" Linux Distribution as per
http://www.handhelds.org

2. Establish network connectivity with the iPAQ. I used the USB
cradle/USBNet method to my iPAQ H3650 32MB w/128 MB CF sleeve. This way you
can ssh/scp into your Linux iPAQ as a server (too cool).

3. Find, install and get familiar with using Boodler on your Linux PC
platform. Be sure you have Python 2.4.

4. For the iPAQ, install python as per the ipkg packages available via the
search on www.handhelds.com. Again, Python 2.4

5. Try to install boodler on the iPAQ

   a. scp boodler.py root@ipaq:/usr/bin
   b. log right into the iPAQ: ssh root@ipaq
   c. create the launch script, point to vi /usr/bin/boodler (taken from the
original 1.4 ipk)
#!/bin/sh

set -e
set -o noglob

export BOODLER_SOUND_PATH=/media/cf/tas/boodler-snd
export BOODLER_EFFECTS_PATH=/media/cf/tas/boodler-effects

python /usr/bin/boodler.py $*

   d. try running "boodler". The imports attempts will fail. FOR each fail
do
      i. from the Linux PC: scp /usr/lib/python2.4/<failed import>.py
root@ipaq:/usr/lib/python2.4
          (use the .py files, let the iPAQ python generate any .pyc)
      ii. goto d until you get a failed attempt to load "cboodle_oss.so"
          (/usr/lib/python2.4/site-packages/boodle/cboodle_oss.so)
      iii. congrats, now it gets hairy

6. To make a working cboodle_oss.so, you will need to have a version
compiled for the ARM processor. To do this, you will need an ARM compiler.

7. Dan Kegel has a great tool called "crosstool" that will make a targetted
compiler for your system. (I only bothered to try because I interviewed Dan
several years ago to work at Idetic/MobiTV and he's a badass).
   a. http://kegel.com/crosstool
   b. I used "crosstool-0.43",
http://kegel.com/crosstool/crosstool-0.43/doc/crosstool-howto.html
   c. Following the instructions, I downloaded and untarred, cd'd and ran
./demo-arm.sh
   d. After answering questions about my various GCC paths, it ran for a
long time (I went to bed sleep). This thing basically downloads and compiles
a targetted cross compiler compatible with your system (I am running Fedora
Core 5)
   e. When I woke up, I had a full compiler:
/opt/crosstool/gcc-4.1.0-glibc-2.3.2

8. Knowing nothing about Python's distutils led me on a goose chase looking
for how the Boodler *.c files get built into .o and .so files,
or how to set the compilers or options sent to the compilers.
   a. "python setup.py build" is a call to the "distutils"
   b. my PC compiler kept being called to build the .o files.

9. SO I moved my stock /usr/bin/gcc asside and symlinked /usr/bin/gcc to my
new ARM compiler
   a. /usr/bin/gcc ->
/opt/crosstool/gcc-4.1.0-glibc-2.3.2/arm-unknown-linux-gnu/arm-unknown-linux
-gnu/bin/gcc

10. The OPTIONS distutils set up were still breaking the compile - specific
complaints were gcc arguments:
   a. -mtune=generic
   b. -m32
   c. -march=i386

11. When the arguments above were removed, the build process proceeded with
.o files generated in
Boodler-1.6.1.iPAQ/build/temp.linux-i686-2.4/src/cboodle

12. Again, this was a manual process of running "python setup.py build",
copy the failed gcc line, remove args, run again, so I got lazy:
   a. moved /usr/bin/gcc to /usr/bin/gcc.arm
   b. wrote script /usr/bin/gcc:
#!/bin/bash
#
#
args=$*
echo $args | sed -e 's/-mtune=generic//g' -e 's/-m32//g' -e
's/-march=i386//g' > /tmp/args
gcc.arm `cat /tmp/args`

13. After cranking out .o files, I got errors attempting to compile the
"audio_esd.c" code. I saw the audio_oss.o had succeeded, so my solution was
to comment out the extensions that were not of interest in "setup.py":

    # The list of driver extensions.
    all_extensions = [
    # ... comment out (or delete) all entries after 'file', 'stdout', and 'oss'
    ]

14. The "python setup.py build" finally was "clean"

15. I found the file:
Boodler-1.6.1/build/lib.linux-i686-2.4/boodle/cboodle_oss.so
and scp'd it into place on the iPAQ:
   a. scp cboodle_oss.so root@ipaq:/usr/lib/python2.4/site-packages/boodle/

16. On the iPAQ terminal, I was able to now run the /usr/bin/boodler
program:root@h3600:~# boodler
usage: /usr/bin/boodler.py [ options ] module.AgentClass [ data ... ]
root@h3600:~#

17. Using my CF card as the target (for space!), I copied over the
boodler-snd and effects/ directories from the Linux PC:
   a. scp *.py root@ipaq:/media/cf/tas/boodler-effects
   b. scp -r * root@ipaq:/media/cf/tas/boodler-snd/
   (you would want to optimize/be choosey if you lack a CF card)

18. Run boodler with some content
   a. root@h3600:~# boodler hardhat.MotorRun  - success!!
   b. my own effect: root@h3600:~# boodler revtest.Go - also success!!
   c. less than 10% of the CPU is being utilized on the iPAQ, very efficient
compared to my own audio generation attempts.
Building for Linux iPAQ - last changed 2007-11-18 20:07:28 by Andrew Plotkin (zarf)