Compile PJSIP (and pjsua VoIP client) for Kindle 3

Prerequisites:

  • a jailbroken Kindle 3
  • access to a shell on the Kindle (by running a terminal, or connecting via SSH)
  • a Debian chroot on the Kindle
    Cross compilation tools will also be needed. This is how to do it under Debian Squeeze:

Add the emdedian repository[1]:

1
2
vi /etc/apt/sources.list
apt-get install emdebian-archive-keyring

Install ARM cross compilation tools:

1
2
3
4
apt-get update
apt-get install build-essential
apt-get install linux-libc-dev-armel-cross libc6-armel-cross libc6-dev-armel-cross binutils-arm-linux-gnueabi  gcc-4.3-arm-linux-gnueabi g++-4.3-arm-linux-gnueabi gdb-arm-linux-gnueabi uboot-mkimage

Compile the sources:

Prepare the build directory that will contain the ARM binaries:

1
2
cd src/
mkdir build

Download, configure and compile the alsa library[2]:

1
2
3
4
5
6
7
wget ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.0.25.tar.bz2
tar xzf alsa-lib-1.0.25.tar.bz2
cd alsa-lib-1.0.25
CC=arm-linux-gnueabi-gcc ./configure --target=arm-linux --host=i686-linux --prefix=/
make
make install DESTDIR=/usr/arm-linux-gnueabi/
make install DESTDIR=$(pwd)/../build

Download and configure pjsip:

1
2
3
4
5
cd ..
wget http://www.pjsip.org/release/1.12/pjproject-1.12.tar.bz2
tar xf pjproject-1.12.tar.bz2
cd pjproject-1.12
CC=arm-linux-gnueabi-gcc ./configure --target=arm-linux --host=i686-linux --prefix=/usr

Make sure that alsa was found:

1
grep alsa config.log

You should see something like:

1
2
3
...
ac_cv_header_alsa_version_h=yes
ac_pa_use_alsa='1'

Compile pjsip:

1
2
3
4
5
make dep
make
make install DESTDIR=$(pwd)/../build
cp pjsip-apps/bin/pjs* ../build/usr/bin/
rename 's/-arm-.*//' ../build/usr/bin/pjs*

To save precious space, you can delete the include directories that shouldn’t be needed on the device:

1
2
rm -r build/include
rm -r build/usr/include

Copy the contents of the build directory into the root directory of the chroot running on the Kindle.

Create a configuration pjsua file with options that optimize for running on a slow device[3]:

1
2
3
4
5
6
7
8
cat > pjsua-kindle.conf << EOF
--capture-dev 1
--add-codec pcma
--snd-auto-close -1
--clock-rate 8000
--quality 2
--ec-tail 0
EOF

pjsua should now be able to make VoIP calls:

1
pjsua --config-file pjsua-kindle.conf

References:

[1] http://wiki.micromint.com/index.php/Debian_ARM_Cross-compile
[2] http://omappedia.org/wiki/ALSA_Setup#ALSA_library
[3] https://trac.pjsip.org/repos/wiki/audio-check-cpu