Skip to content

Build TTN packet forwarder for Lite Gateway

kurta241 edited this page Aug 18, 2017 · 1 revision

Build TTN packet-forwarder for IMST Lite Gateway (LoRaWAN)

IMST Lite Gateway = Raspberry Pi B+ with Concentrator iC880A-SPI

Install manual for Raspberry Pi 3 + IMST ic880a doesn’t cover Raspberry Pi B+. The binaries are built for ARM7 architecture, Raspberry Pi B+ is ARM6.

Connect with ssh client

MacBook:$ ssh pi@xxx.xxx.xxx.xxx
    password: raspberry
Enable write access to the root filesystem
pi@LoRaGateway:~ $ ./enableWriteAccess.sh

Build packet-forwarder on Linux system

From Install the TTN Packet Forwarder on a Raspberry Pi with an IMST ic880a board.

Build new binary on AWS Ubuntu instance. Any other Linux system will do.

ssh ubuntu@35.157.111.111 -i /Users/testuser/cert/myAWS.pem

Install cross compiler

ubuntu@:~$ sudo apt install gcc-arm-linux-gnueabi -y

Install go

Get the Go binary distribution and install it. From: Install go

ubuntu@ip:~$ wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
ubuntu@ip:~$ sudo tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz 

Add path to /etc/profile (system-wide) or user:

ubuntu@ip:~$ vim .profile 
    export PATH=$PATH:/usr/local/go/bin

to add path immediately, execute on shell prompt:

ubuntu@ip:~$ export PATH=$PATH:/usr/local/go/bin
Test the Go installation (optional)
Create a workspace
ubuntu@ip:~$ mkdir go
ubuntu@ip:~$ cd go
ubuntu@ip:~/go$ mkdir -p src/hello
ubuntu@ip:~/go$ vim src/hello/hello.go
Create simple Programm:
package main
import "fmt"

func main() {
     fmt.Printf("hello, world\n")
}
Build with the go tool:
ubuntu@ip:~/go$ cd $HOME/go/src/hello
ubuntu@ip:~/go/src/hello$ go build
ubuntu@ip:~/go/src/hello$ ./hello

Build packet-forwarder from TheThingsNetwork source

Get source and change directory

ubuntu@ip:~/go$ go get -u github.com/TheThingsNetwork/packet_forwarder
ubuntu@ip:~/go$ cd src/github.com/TheThingsNetwork/packet_forwarder

Set platform and debug options in library.cfg

$ vim lora_gateway/libloragw/library.cfg 
    PLATFORM=imst_rpi

Set path

$ export PATH=$PATH:$(go env GOPATH)/bin 

Build for ARM6 architecture (Raspberry Pi B+) with IMST Board

$ make dev-deps
$ make deps
$ GOOS=linux GOARCH=arm GOARM=6 PLATFORM=imst_rpi CROSS_COMPILE=arm-linux-gnueabi- CC=arm-linux-gnueabi-gcc make build

New binary is now in directory release/

$ ls release/
packet-forwarder-linux-arm-imst_rpi-native

Copy this binary from AWS machine to gateway via local machine. You may scp from gateway —> you have to transfer the .pem to the gateway or use username/password (AWS requirers certificate). Write access on gateway is already enabled.

MacBook:$  scp -v -3 -i /Users/testuser/cert/myAWS.pem
ubuntu@35.157.111.111:/home/ubuntu/go/src/github.com/TheThingsNetwork/packet_forwarder/release/packet-forwarder-linux-arm-imst_rpi-native pi@192.168.1.53:/usr/bin/packet-forwarder
Enter password: raspberry

Configure and install service on gateway.

From Permanent installation with systemd

  1. Create a configuration file in a permanent location:

     $ mkdir /etc/ttn
     $ touch /etc/ttn/ttn.yml
    
  2. Set up this configuration file:

    $ /usr/bin/packet-forwarder configure /etc/ttn/ttn.yml
    
  3. Add reset-pin to the config:

     nano /etc/ttn/ttn.yml
     reset-pin: 5
    
  4. Use the install-systemd.sh script, with the binary as a first argument and the config file as a second argument:

     $ ./install-systemd.sh /usr/bin/packet-forwarder /etc/ttn/ttn.yml
    
  5. Take care for bug in ExecStart line in ttn-pkt-fwd.service

     pi@LoRaGateway:~ $ nano /etc/systemd/system/ttn-pkt-fwd.service
    

    change

     ExecStart=/usr/bin/packet-forwarder-linux-arm-imst_rpi-native start  --config="/etc/ttn/ttn.yml
    

    to (replace = with blank)

     ExecStart=/usr/bin/packet-forwarder-linux-arm-imst_rpi-native start  --config "/etc/ttn/ttn.yml
    
  6. Reload the systemd daemon, and start the service:

     sudo systemctl daemon-reload
     sudo systemctl enable ttn-pkt-fwd
     sudo systemctl start ttn-pkt-fwd