osmocom-bb - free software finally comes to GSM stack!

osmocom-bb-motorola-c118.jpg This weekend, we had our first meeting about osmocom-bb, Free Software GSM Baseband implementation at mama hacklab. We had 3.3V TTL serial cables with 2.5mm jack ready and Motorola C115 and C118 to try it. Goal was simple: make a phone call from one Motorola phone with free stack to another one. And we made it :-)

It was not easy as it sounds. For a start, without Lovro, there wouldn't be following setup included in the picture. He managed to persuade my usb serial adapter which reports itself as:

067b:2303 Prolific Technology, Inc. PL2303 Serial Port
to become 3.3 TTL serial cable. Audio connector also required some manual work to fit into Motorola.

From software side of thing, we needed to use testing branch of project to get SIM card support (because private network key is stored inside SIM card). Than I made mistake and didn't follow OsmocomBB Getting Started Guide and I decided to use ARM compiler which I had on disk as opposed to suggested one on page. This produced semi-working firmware which wasn't able to connect to network. Changing compiler (after few days of experimentation) fixed problem, just in time for our meeting.

compile osmocom-bb

For a start, checkout source code

git clone git://git.osmocom.org/osmocom-bb.git
cd osmocom-bb
git checkout -b testing remotes/origin/sylvain/testing
Now, enable sending of data to network (we want to make a phone call, after all)
--- a/src/target/firmware/Makefile
+++ b/src/target/firmware/Makefile
@@ -73,7 +73,7 @@ ANY_APP_LIBS+=calypso/libcalypso.a layer1/liblayer1.a lib/libmini.a comm/libc
 -include Makefile.inc
 
 # Uncomment this line if you want to enable Tx (Transmit) Support.
-#CFLAGS += -DCONFIG_TX_ENABLE
+CFLAGS += -DCONFIG_TX_ENABLE
 
 # Uncomment this line if you want to write to flash.
 #CFLAGS += -DCONFIG_FLASH_WRITE
Don't forget to add gnuarm-3.4.3/bin tool chain to your PATH and build it:
cd src
make

wireshark gsmtap support

Last step was compiling wireshark with support for gsmtap. This is useful if you want to decode GSM protocols and understand bits, since wireshark included in Debian is too old (1.2) and doesn't support it. However, compiling wireshark was simple:

svn co http://anonsvn.wireshark.org/wireshark/trunk/ wireshark
cd wireshark
sudo apt-get build-dep wireshark
sudo ./debian/rules binary

In the process, I wrote a couple of helper scripts to make easy demos really easy which I will include here for future reference.

start layer1 firmware on Motorola

dpavlin@t61p:/rest/cvs/osmocom-bb$ cat 1-layer1.sh 
#!/bin/sh

cd src/host/osmocon/
echo "press power of cell phone to load layer1"
./osmocon -p /dev/ttyUSB0 -m c123xor ../../target/firmware/board/compal_e88/layer1.compalram.bin #-d tr #2>&1 | tee /tmp/layer1.log

start layer23 on computer with gsmtap enabled

dpavlin@t61p:/rest/cvs/osmocom-bb$ cat 2-layer23.sh 
#!/bin/sh
cd ./src/host/layer23/src/mobile
./mobile -i 127.0.0.1 -d 2>&1 | tee /tmp/mobile.log

start gsmtap sink and wireshark

dpavlin@t61p:/rest/cvs/osmocom-bb$ cat 3-tap.sh 
#!/bin/sh -x

nc -u -l 4729 > /dev/null &
sudo wireshark -k -i lo -f 'port 4729'
Alternative usage with multicast group 224.0.0.1 mentioned on Wireshark integration page isn't applicable to me, because I don't want to stream gsmtap over my local wifi to router.

So was it worth it? If you get kick from watching protocol dumps (as I do) it sure is. This is major milestone for free software, because you can have fully free GSM stack (osmocom-bb on phone side and OpenBSC on provider side).