Lorawan gateway GW-01. Developers guide. Armbian.

You can build Armbian image for GW-01 from source. This gives you way to customize lorawan gateway.

To do that:

Clone Armbian OS project

$ git clone —depth 1 https://github.com/armbian/build
$ cd build
Start image compilation process:
$ ./compile.sh
Configuration menu windows appears. Select «Full OS image for flashing» then press «OK»
Then choose «Do not change the kernel configuration» and select «ornagepizero»
«Mainline» kernel branch
and «stretch» release
After that compilation process starts. You need to wait while it will be finished. At the end of this process you should see following:

There is image to write on microSD  card.

Flashing image in microSD card
$ sudo dd if=output/images/Armbian_5.41_Orangepizero_Debian_stretch_next_4.14.40.img of=/dev/sdx
Replace /dev/sdx with address of microSD card at your PC. Make sure that you flash in SD card. After that plug microSD card to GW-01 and power up the lorawan gateway.
Remote access via SSH.

Look for orangepizero device on your DHCP server:

and connect to it via SSH:

$ ssh root@

User/pass to login: root/1234. Change password and add new user on first login. After that we are ready to configure spi interface and install all necessary libraries to get  working lorawan gateway.

Enabling SPI on armbian on first booting

Check that spidev not exist in list of devices in filesystem

$ ls /dev/spidev*

Add parameters to configuration file to enable SPI interface:

$ nano /boot/armbianEnv.txt

Change overlays param to:
overlays=usbhost2 usbhost3 spi-spidev spi-add-cs1

Add following at the end of file:

Exit and save file. Configure dts tree:

$ cp /boot/dtb/overlay/sun8i-h3-spi-spidev.dtbo ~
$ cd ~
$ dtc -I dtb -O dts -o sun8i-h3-spi-spidev.dts ./sun8i-h3-spi-spidev.dtbo
$ nano sun8i-h3-spi-spidev.dts
Set folowing in fragment@2:
status = «ok»;
reg = <0x1>;

Exit and save file.

Then compile new dtbo file and replace old one with that:

$ rm sun8i-h3-spi-spidev.dtbo
$ dtc -I dts -O dtb -o sun8i-h3-spi-spidev.dtbo ./sun8i-h3-spi-spidev.dts
$ sudo rm /boot/dtb/overlay/sun8i-h3-spi-spidev.dtbo
$ sudo cp sun8i-h3-spi-spidev.dtbo /boot/dtb/overlay/
After that reboot:
$ reboot
ant connect to the gateway again via ssh as user you created previously.
$ ssh al@
Now you should see spidev1.1 in list of your devices:
$ ls /dev/spidev*


SX1301 reset script.
Create SX1301 reset script:
$ cd ~
$ touch iC880-SPI_reset.sh
$ nano iC880-SPI_reset.sh
Type following to that file and save it:
echo «11» > /sys/class/gpio/export
sleep 2
echo «out» > /sys/class/gpio/gpio11/direction
echo «0» > /sys/class/gpio/gpio11/value
sleep 1
echo «1» > /sys/class/gpio/gpio11/value
sleep 1
echo «0» > /sys/class/gpio/gpio11/value
sleep 1
echo «2» > /sys/class/gpio/export
sleep 2
echo «out» > /sys/class/gpio/gpio1/direction
echo «1» > /sys/class/gpio/gpio1/value
sleep 5
echo «0» > /sys/class/gpio/gpio1/value
sleep 1
echo «0» > /sys/class/gpio/gpio1/value


Then set this file as executable:
$ sudo chmod +x iC880-SPI_reset.sh


Installing lora_gateway

Download and modify the library

$ cd ~
$ git clone https://github.com/Lora-net/lora_gateway.git
$ cd lora_gateway
$ nano libloragw/src/loragw_spi.native.c
Change /dev/spidev0.0 to /dev/spidev1.1 and save file. Complie the library.
$ make
Installing packet_forwarder
Download and compile the library
$ cd ~
$ git clone https://github.com/Lora-net/packet_forwarder.git
$ cd packet_forwarder/
$ ./compile.sh
Set lora server IP address:
$ cd lora_pkt_fwd/cfg/
$ cp global_conf.json.PCB_E286.EU868.basic ../global_conf.json
$ nano global_conf.json
Set «server_port_up» and «server_port_down» to port of your lora server. Set «server_address» to address of this server. For example:

«gateway_conf»: {

              «server_address»: «router.eu.thethings.network»,

              «server_port_up»: 1700,

             «server_port_down»: 1700,


in a case of using TTN cloud as server. In a case of 915MHz gateway set «server_address» it to «router.us.thethings.network». For cloud.m2m-tele.com set «server_address» to «m2m-tele.com». Explanation of this settings can be found here and here.
Now your lorawan gateway ready to start:
$ cd ~
$ sudo ./iC880-SPI_reset.sh
$ sudo chmod 777 /dev/spidev1.1
$ cd packet_forwarder/lora_pkt_fwd
$ ./lora_pkt_fwd

You should see something similar to:

INFO: global_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
INFO: gateway MAC address is configured to AA555A0000000005
INFO: server hostname or IP address is configured to «router.eu.thethings.network»
INFO: upstream port is configured to «1700»
INFO: downstream port is configured to «1700»
INFO: found local configuration file local_conf.json, parsing it
INFO: redefined parameters will overwrite global parameters
INFO: local_conf.json does not contain a JSON object named SX1301_conf
INFO: local_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
INFO: gateway MAC address is configured to AA555A0000000005
INFO: packets received with a valid CRC will be forwarded
INFO: packets received with a CRC error will NOT be forwarded
INFO: packets received with no CRC will NOT be forwarded
lgw_connect:532: INFO: no FPGA detected or version not supported (v0)
Note: success connecting the concentrator

Some useful links to work with GW-01: