Skip to content

Instantly share code, notes, and snippets.

@lachesis
Last active May 30, 2024 07:11
Show Gist options
  • Save lachesis/1cf23f87902fab986f70fd3770799505 to your computer and use it in GitHub Desktop.
Save lachesis/1cf23f87902fab986f70fd3770799505 to your computer and use it in GitHub Desktop.

Overview

Here's some docs on how I connected to OCTOI using a Raspberry Pi, an icE1usb, and my Cisco 2921 voice router.

Getting a config file

I contacted LaF0rge from #retronetworking on libera.chat. He asked me to email him at (redacted). He asked me to wait to email him until I had everything ready to go.

I believe all he really needs is the desired 4-digit prefix and some evidence that you're seriously interested and not wasting his time.

Hardware

You can buy an icE1usb here:

https://shop.sysmocom.de/Osmocom-icE1usb-E1-interface-for-USB/icE1usb-kit

There is a discount code that brings the cost down substantially. You can get this code by emailing sales@sysmocom.de. The cost for me was then 90 EUR + 40 EUR shipping to USA.

You'll also need to provide your own GPS patch antenna. The receiver seems fairly good. It works with the antenna sitting in my basement window.

Plug a E-1 crossover cable into the right-most port of the icE1usb and a port on the Cisco 2921. I used the left most port on my 2921, which is 0/3/0.

Plug the icE1usb into one of the USB 2 ports on the Pi.

Plug the Pi into ethernet and install Raspberry Pi OS Lite 32-bit.

icE1usb and osmo-e1d on Pi

On octoi-pi, put this in /etc/osmo-e1d-octoi-client.cfg

!
! osmo-e1d (0.3.0.17-07c2) configuration saved from vty
!!
!
log stderr
 logging filter all 1
 logging color 1
 logging print category-hex 0
 logging print category 1
 logging timestamp 0
 logging print file basename last
 logging print level 1
 logging level e1d info
 logging level linp info
!
!
line vty
 no login
!
e1d
 interface 0 icE1usb
  usb-serial dc(redacted)
  line 0
   mode e1oip
octoi-client (redacted) (redacted)
 local-bind 0.0.0.0 3245
 account (redacted)
  mode ice1usb
  ice1usb serial-number dc(redacted)

Put this in /etc/systemd/system/osmo-e1d.service:

[Unit]
Description=Osmocom E1 Interface Daemon
Wants=osmo-e1d.service
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
Restart=always
ExecStart=/usr/local/bin/osmo-e1d -c /etc/osmo-e1d-octoi-client.cfg
RestartSec=2

[Install]
WantedBy=multi-user.target

Then run something like this:

# Prereqs
sudo apt-get install -y \
    build-essential libtool libtalloc-dev libsctp-dev shtool autoconf automake \
    git-core pkg-config make gcc gnutls-dev python3-dev python-is-python3 \
    libusb-1.0.0-dev libmnl-dev liburing-dev \
    dfu-util tshark bwm-ng minicom vim-nox tmux git \
    libtool pkg-config libosmocore libusb-1.0-0-dev libtalloc-dev

# Get sources
mkdir build && cd build
git clone https://gitea.osmocom.org/osmocom/libosmocore
git clone https://gitea.osmocom.org/retronetworking/osmo-e1d

# Build libosmocore
cd libosmocore
autoreconf -fi && ./configure --disable-pcsc && make && sudo make install
sudo ldconfig
cd ..

# Build osmo-e1d
cd osmo-e1d
autoreconf -fi && ./configure && make && sudo make install

# get the gateware for the FPGA & latest stock firmware
wget https://people.osmocom.org/tnt/ice1usb/icE1usb-202210-5890f3e4.bin
wget https://downloads.osmocom.org/binaries/icE1usb/firmware/all/icE1usb-fw-0.2-71-gf1e228d.bin

# enter DFU mode
sudo dfu-util -e

# flash the gateware
sudo dfu-util -d 1d50:6144 -a 0 -D icE1usb-202210-5890f3e4.bin

# flash the firmware & back to run mode
sudo dfu-util -d 1d50:6144 -a 1 -D icE1usb-fw-0.2-71-gf1e228d.bin -R

# start & enable osmo-e1d
sudo systemctl enable --now osmo-e1d

Cisco 2921

On the Cisco 2921, do something like this:

card type e1 0 3
network-clock-participate wic 3
network-clock-select 1 E1 0/3/0
trunk group OCTOI
controller E1 0/3/0
 pri-group timeslots 1-20
 trunk-group OCTOI timeslots 1-20
interface Serial0/3/0:15
 no ip address
 encapsulation hdlc
 no cdp enable
 isdn switch-type primary-ni
 isdn incoming-voice voice
voice-port 0/3/0:15
dial-peer voice 40 pots
 trunkgroup OCTOI
 huntstop
 destination-pattern 500........
 forward-digits 8

Now any 8 digits starting with 500 will immediately route to OCTOI over the E1. Note that you probably want 1-30 instead of 1-20 in both spots. I don't have enough DSP resources for that right now. Will improve. Then make your Asterisk box route 500XXXXXXXX to Cisco 2921. And make your Asterisk box handle 7920XXXX from Cisco as from-octoi

PPS

The icE1usb can output USB interrupts with PPS information. This can be used to synchronize the system clock with ntpd/chrony. There will be a lot of jitter as USB is only polled every 1ms. Over very long averaging times, this might be okay.

First you need an experimental firmware on the icE1usb:

wget https://people.osmocom.org/~tnt/ice1usb/pps/icE1usb-fw-0.2-71-gf1e228d-dirty.bin
sudo dfu-util -e
sudo dfu-util -d 1d50:6144 -a 1 -D icE1usb-fw-0.2-71-gf1e228d-dirty.bin -R

You'll want to restart the Pi after that, as it will move the device to ttyACM1 and that's annoying.

gpsd and chrony have a bit of a dependency loop. What I came up with was some small mods to the chrony.service file:

[Unit]
...
StartLimitInterval=200
StartLimitBurst=10

[Service]
Restart=always
RestartSec=30
...

Then put this in /etc/default/gpsd:

# Devices gpsd should collect to at boot time.
# They need to be read/writeable, either by user gpsd or the group dialout.
DEVICES="/dev/ttyACM0"

# Other options you want to pass to gpsd
GPSD_OPTIONS="-n"

# Automatically hot add/remove USB GPS devices via gpsdctl
USBAUTO="true"

And this at end of /etc/chrony/chrony.conf:

refclock PPS /dev/pps0 lock NMEA refid PPS
refclock SHM 0 refid NEMA precision 1e-1 offset 0.0 noselect
allow

Finally, just run:

sudo systemctl enable --now gpsd chronyd

Monitor with something like:

sudo chronyc -n sources; sudo chronyc -n sourcestats; sudo chronyc -n tracking

Links

The following links were helpful to me at one point or another:

https://osmocom.org/projects/octoi/wiki/Getting_Started
https://downloads.osmocom.org/docs/latest/icE1usb-usermanual.pdf
https://downloads.osmocom.org/binaries/icE1usb/firmware/latest/

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