Skip to content

Instantly share code, notes, and snippets.

@shimaore
Last active May 12, 2018 14:44
Show Gist options
  • Save shimaore/5021020 to your computer and use it in GitHub Desktop.
Save shimaore/5021020 to your computer and use it in GitHub Desktop.
Notes on how to build software and start UmTRXv2 (beta)

Note: I run Debian/testing on amd64 architecture. I use sudo to gain root access.

Prerequisites

sudo apt-get install \
  autoconf libtool libosip2-dev libortp-dev g++ sqlite3 libsqlite3-dev libreadline6-dev libboost-all-dev \
  libusb-1.0.0-dev python-cheetah doxygen docutils \
  libusb-dev libftdi-dev

Create a new directory to store all code and set UMTRX_BASE to that directory

mkdir umtrx
cd umtrx
UMTRX_BASE="`pwd`"

In my case

UMTRX_BASE=$HOME/Public/src/umtrx

UHD Build

This is the build of the UHD library for OpenBTS.

Install python-cheetah libusb-dev etc.

cd $UMTRX_BASE
cd UHD-Fairwaves/host/; mkdir build; cd build; 
cmake -DCMAKE_INSTALL_PREFIX=$UMTRX_BASE/uhd ..
make
make test
make install

OpenBTS

DO:

export LD_LIBRARY_PATH=$UMTRX_BASE/uhd/lib
export PKG_CONFIG_PATH=$UMTRX_BASE/uhd/lib/pkgconfig

before compiling OpenBTS.

cd $UMTRX_BASE
git clone git://github.com/fairwaves/openbts-2.8
cd openbts-2.8
git checkout umtrx
autoreconf -i
./configure --with-uhd
make
# Install the proper transceiver for UmTRXv2
cd apps/ && ln -s ../Transceiver52M/transceiver .

Hardware

Mini-USB connector = console on ZPU, 230400 8N1

Configured for 192.168.10.2

Startup

In order to run OpenBTS as own user (instead of root):

sudo mkdir /etc/OpenBTS
sudo chown `whoami` /etc/OpenBTS
DB=/etc/OpenBTS/OpenBTS.db
sqlite3 -init ./apps/OpenBTS.example.sql $DB ".quit"

# Debug via syslog (not a good idea in production!)
sqlite3 $DB "update config set ValueString = 'DEBUG' where keystring = 'Log.Level';"
# Default
sqlite3 $DB "update config set ValueString = 'INFO' where keystring = 'Log.Level';"

# Put everything in /etc/OpenBTS for now so that we don't have to start as root.
sqlite3 $DB "update config set ValueString = '/etc/OpenBTS/SubscriberRegistry.db' where keystring = 'SubscriberRegistry.db';"
sqlite3 $DB "update config set ValueString = '/etc/OpenBTS/ChannelTable.db'       where keystring = 'Control.Reporting.PhysStatusTable';"
sqlite3 $DB "update config set ValueString = '/etc/OpenBTS/Stats.db'              where keystring = 'Control.Reporting.StatsTable';"
sqlite3 $DB "update config set ValueString = '/etc/OpenBTS/TMSITable.db'          where keystring = 'Control.Reporting.TMSITable';"
sqlite3 $DB "update config set ValueString = '/etc/OpenBTS/Transaction.db'        where keystring = 'Control.Reporting.TransactionTable';"

# Make sure these are valid (otherwise OpenBTS stops with "ConfigurationTableKeyNotFound" error)
sqlite3 $DB "update config set ValueString = '/etc/OpenBTS/command'               where keystring = 'CLI.SocketPath';"
sqlite3 $DB "update config set ValueString = 'OpenBTS'                            where keystring = 'GSM.Identity.ShortName';"
sqlite3 $DB "insert into config(keystring,valuestring) values ('GSM.Radio.UHDargs','');"

# transceiver will complain if these are not set
sudo sysctl -w net.core.rmem_max=50000000
sudo sysctl -w net.core.rmem_max=50000000
sudo sysctl -w net.core.wmem_max=524288
sudo sysctl -w net.core.wmem_max=524288

Start OpenBTS:

cd $UMTRX_BASE/openbts-2.8/apps
export LD_LIBRARY_PATH=$UMTRX_BASE/uhd/lib
./OpenBTS

Subscribers Registry

(Note: I didn't get this to work; I'm planning to use OpenSIPS instead.)

libosmocore

sudo aptitude install dpkg-dev dh-autoreconf
cd $UMTRX_BASE
git clone git://git.osmocom.org/libosmocore.git 
cd libosmocore
dpkg-buildpackage
cd ..
sudo dpkg -i libosmocore_0.5.3+git1-6_amd64.deb
sudo dpkg -i libosmocore-dev_0.5.3+git1-6_amd64.deb

subscriberRegistry

cd $UMTRX_BASE
git clone git://github.com/fairwaves/subscriberRegistry-2.8.git
cd subscriberRegistry-2.8/
git checkout encryption
make

Databases:

# Subscriber Registry
sqlite3 --init configFiles/subscriberRegistryInit.sql /etc/OpenBTS/SubscriberRegistry.db .quit

# sipauthserver configuration
sqlite3 -init ./sipauthserve.example.sql /etc/OpenBTS/sipauthserve.db .quit
sqlite3 /etc/OpenBTS/sipauthserve.db "update config set valuestring = '/etc/OpenBTS/SubscriberRegistry.db' where keystring = 'SubscriberRegistry.db'"
sqlite3 /etc/OpenBTS/sipauthserve.db "update config set valuestring = 'DEBUG' where keystring = 'Log.Level'"

Start

Allow open registration

sqlite3 $DB "update config set valuestring = 'yes' where keystring = 'Control.LUR.OpenRegistration';"

Start sipauthserver and OpenBTS

cd $UMTRX_BASE/subscriberRegistry-2.8 && ./sipauthserve &

cd $UMTRX_BASE/openbts-2.8/apps
export LD_LIBRARY_PATH=$UMTRX_BASE/uhd/lib
./OpenBTS &

Note: The SIP packets that OpenBTS sends to port 5064 are broken (no "branch" value for example), so it's currently difficult to use something else than sipauthserve to process them. [I submitted a patch for this!]

Note: Look at traffic between OpenBTS and sipauthserve to gather your IMSI numbers:

sudo ngrep -qltd lo '' 'udp port 5064'

OpenBTS will send REGISTER messages; sipauthserve will reply with 401 messages (unauthorized), 404 messages (IMSI not found), or 200 messages (OK).

You will see IMSI in the traces, add them to the registry:

sqlite3 /etc/OpenBTS/SubscriberRegistry.db "insert into sip_buddies(name,host) values ('IMSI208340171193696','127.0.0.1');"

ZPU firmware

This is only needed if you plan to rebuild the firmware.

See http://opensource.zylin.com/zpudownload.html

cd $UMTRX_BASE
git clone http://repo.or.cz/w/zpugcc.git

The source is in zpugcc/

cd $UMTRX_BASE
cd zpugcc/toolchain; sh fixperm.sh; . env.sh; sh build.sh
tar cjvf ../../zpugcclinux_unstable.tar.bz2 install/

and export back in zpubin:

cd $UMTRX_BASE
mkdir zpubin; cd zpubin; tar xjvf ../zpugcclinux_unstable.tar.bz2

DO:

export PATH=$PATH:$UMTRX_BASE/zpubin/install/bin

FPGA Firmware

This is only needed if you want to follow Firmware development. The UmTRX card comes with firmware pre-loaded.

To compile the Firmware you will also need the Xilinx Tools. We'll call XILINX the location of the tools.

In my case

XILINX=/srv/Shared/stephane/Xilinx/14.4/ISE_DS

See https://code.google.com/p/umtrx/wiki/BuildingUHD

cd $UMTRX_BASE
git clone git://github.com/fairwaves/UHD-Fairwaves.git
cd UHD-Fairwaves/firmware/
git checkout fairwaves/umtrx
mkdir zpu_build; cmake ../zpu; make
cp UHD-Fairwaves/firmware/zpu_build/usrp2p/bootloader/bootloader.rmi UHD-Fairwaves/fpga/usrp2/top/N2x0/bootloader_umtrx.rmi

DO:

  . $XILINX/settings64.sh

See http://www.xilinx.com/support/answers/43865.htm if Map fails:

export LD_PRELOAD="$XILINX/ISE/lib/lin64/libXst_Core.so"

or maybe (found in UHD-Fairwave/README):

export LD_PRELOAD="$XILINX/ISE/lib/lin64/libboost_serialization-gcc41-mt-p-1_38.so.1.38.0"

Build the FPGA image:

cd $UMTRX_BASE/UHD-Fairwaves/fpga/usrp2/top/N2x0/ && make UmTRXv2

Program the FPGA

xc3sprog is

sudo aptitude install libusb-dev libftdi-dev
cd $UMTRX_BASE
svn co https://xc3sprog.svn.sourceforge.net/svnroot/xc3sprog/trunk xc3sprog
cd xc3sprog; cmake .; make

To program with a Diligent HS-2 cable:

cd $UMTRX_BASE
cd xc3sprog ; sudo ./xc3sprog -c jtaghs2 ../UHD-Fairwaves/fpga/usrp2/top/N2x0/build_UmTRXv2/u2plus_umtrx_v2.bin

Protocol Notes

transceiver interfaces the hardware (at IP 192.168.10.2) with OpenBTS:

# sudo netstat -tunap | grep transceiver, more-or-less:
udp     192.168.10.1:45439      192.168.10.2:49152      ESTABLISHED
udp     192.168.10.1:49912      192.168.10.2:49156      ESTABLISHED
udp     192.168.10.1:45976      192.168.10.2:49157      ESTABLISHED
udp     192.168.10.1:38152      192.168.10.2:49159      ESTABLISHED
udp     192.168.10.1:54798      192.168.10.2:49158      ESTABLISHED
udp     0.0.0.0:5700            0.0.0.0:*
udp     0.0.0.0:5701            0.0.0.0:*
udp     0.0.0.0:5702            0.0.0.0:*

Locally, OpenBTS connects to TRX.IP and TRX.Port (127.0.0.1 and 5700 resp.).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment