kindle

Native Baresip VoIP Client for Kindle 3

Download and configure alsa-lib to compile its static library (libasound.a):

1
2
3
4
5
wget ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.0.25.tar.bz2
tar xf alsa-lib-1.0.25.tar.bz2
cd alsa-lib-1.0.25/
mkdir ../alsa-static-build
CC=arm-linux-gnueabi-gcc ./configure --disable-shared --enable-static --target=arm-linux --host=i686-linux --prefix=/usr

Compile the library, and install it to the directory just created above (make sure to specify absolute path, in this case “/src/alsa-static-build”):

1
2
3
make
make install DESTDIR=/src/alsa-static-build
cd ..

Download and compile the re and rem libraries:

1
2
3
4
5
6
7
8
9
10
11
wget http://www.creytiv.com/pub/re-0.4.0.tar.gz
wget http://www.creytiv.com/pub/rem-0.4.0.tar.gz
tar xf re-0.4.0.tar.gz
mv re-0.4.0 re
cd re
CC=arm-linux-gnueabi-gcc LD=arm-linux-gnueabi-ld make
cd ..
tar xf rem-0.4.0.tar.gz
mv rem-0.4.0 rem
CC=arm-linux-gnueabi-gcc LD=arm-linux-gnueabi-ld make
cd ..

Download and compile baresip with the STATIC option:

1
2
3
4
wget http://www.creytiv.com/pub/baresip-0.4.0.tar.gz
tar xf baresip-0.4.0.tar.gz
cd baresip-0.4.0
CC=arm-linux-gnueabi-gcc LD=arm-linux-gnueabi-ld SYSROOT=/usr/arm-linux-gnueabi STATIC=yes make

The make above may fail in the linking because it can’t find the static alsa library — if so, it doesn’t matter. Now statically link the baresip binary to all the modules and libasound:

1
arm-linux-gnueabi-gcc -static-libgcc -Wl,-Bstatic -fPIC -rdynamic build-arm/src/aucodec.o build-arm/src/audio.o build-arm/src/aufile.o build-arm/src/aufilt.o build-arm/src/auloop.o build-arm/src/auplay.o build-arm/src/ausrc.o build-arm/src/calc.o build-arm/src/call.o build-arm/src/conf.o build-arm/src/contact.o build-arm/src/mctrl.o build-arm/src/menc.o build-arm/src/mnat.o build-arm/src/net.o build-arm/src/os.o build-arm/src/play.o build-arm/src/realtime.o build-arm/src/rtpkeep.o build-arm/src/stream.o build-arm/src/sipreq.o build-arm/src/ua.o build-arm/src/ui.o build-arm/src/uuid.o build-arm/src/vidcodec.o build-arm/src/vidisp.o build-arm/src/vidsrc.o build-arm/src/video.o build-arm/src/vidloop.o build-arm/src/static.o build-arm/src/main.o build-arm/modules/stun/stun.o build-arm/modules/turn/turn.o build-arm/modules/ice/ice.o build-arm/modules/natbd/natbd.o build-arm/modules/alsa/alsa.o build-arm/modules/alsa/alsa_src.o build-arm/modules/alsa/alsa_play.o build-arm/modules/cons/cons.o build-arm/modules/evdev/evdev.o build-arm/modules/evdev/print.o build-arm/modules/g711/g711.o build-arm/modules/l16/l16.o build-arm/modules/oss/oss.o build-arm/modules/stdio/stdio.o build-arm/modules/v4l/v4l.o -I../alsa-static-build/usr/include/ -L../alsa-static-build/usr/lib -L../re -lre -L../rem -lrem -lm -lasound -o baresip -Wl,-Bdynamic -ldl -lrt -lm -lresolv -lpthread -Wl,-Bstatic

This should create the binary “baresip”:

1
2
ls
Makefile baresip build-arm docs include mk modules share src

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