Pinedio Project: Notes Sharing/Log
#1
Information 
Hello! Smile

Post to share things that are found helpful/work, progress/Notes along Pinedio Gateway/modules/Kit.

(Pinedio uses Rak Wireless "LoRa"/Mesh related/compatible hardware).

Pinedio's Wiki has been started and can be found here: https://wiki.pine64.org/wiki/Pinedio

Thread for sharing some found to be working notes that can be edited out/posted to WiKi as wanted.

The Pine64 Gateway's underlying hardware runs on the A64-LTS (this looked the best place to post this - feel free to move).

Working SOPINE/Patched Armbian image can be found at:

https://files.portabledev.xyz/f/c2895e3669bb481da9fd/  (278MB) (Source for this one: pfeerick: also added in wiki)

OR:

https://mega.nz/file/Wd5CGRhB#spBqSQrhLm...HopFs4Ho9o (576MB) (Uploaded this copy after patching it)

sx1302_hal compiles/installs on Armbian without issue.

EXPERIMENT: SET UP RAK_COMMON_FOR_GATEWAY (ORIGINALLY FOR RPI: SOME MOD REQUIRED - NOT QUITE FINISHED):

Run sudo armbian-config. Enter System to enable SPI/UART for sx1302/rak/GPS.

Then Add The Following Line To /boot/armbianEnv.txt:

Code:
param_spidev_spi_bus=0

***After this reboot Gateway***

NEXT:

Code:
clone https://github.com/RAKWireless/rak_common_for_gateway.git

Then:

Code:
cd rak_common_for_gateway

In rak/install.sh comment out the line (add hash mark in front of)

Code:
# systemctl stop hciuart
(or you will receive errors aborting your install)

Run the install.sh script in the main directory.

Select: 7 : rak2287/GPS without LTE

We can use gateway-config command to make some device location changes (if needed).

Before entering gateway-config -> edit packet forwarder, we need to grab our mac address based Gateway ID for all LoRa networks. To grab this Gateway ID run:

Code:
gateway-version

It will print out your Gateway ID (based on your unique mac address).

Inside gateway-config make the following changes:

Code:
{
    "SX130x_conf": {
        "com_type": "SPI",
        "com_path": "/dev/spidev0.0",
        "lorawan_public": true,

Set GPS to /dev/ttyS2 and grep -i reset to find reset pin swapping 17 with 71.

GPS section of the packet forwarding should look as below

Code:
/* GPS configuration */
        "gps_tty_path": "/dev/ttyS2",
        /* GPS reference coordinates */

Above GPS, replace the default GatewayID with your gateway ID retrieved from gateway-version (from earlier). The line looks like:
Code:
"gateway_conf": {
        "gateway_ID": "03BD3EFFFF21D2F",

Restart packet forwarder. You may need a reboot.

GPS Related:

If experimenting with The Things Network I discovered Gateway does not appear on the map until the GPS signal is stable. I ran a line towards a window to give it a clear line of sight for GPS. Using a temporary antenna I was able to get a better GPS reception. Immediately after setting up this stable GPS link, the Gateway appears on the map and the PPS counter begins.

journalctl log example (still more to look at):

Code:
Apr 24 23:45:14 rak-gateway ttn-gateway[10543]: Opening SPI communication interface
Apr 24 23:45:14 rak-gateway ttn-gateway[10543]: Note: chip version is 0x10 (v1.0)
Apr 24 23:45:14 rak-gateway ttn-gateway[10543]: INFO: using legacy timestamp
Apr 24 23:45:14 rak-gateway ttn-gateway[10543]: INFO: LoRa Service modem: configuring preamble size to 8 symbols
Apr 24 23:45:14 rak-gateway ttn-gateway[10543]: ARB: dual demodulation disabled for all SF
Apr 24 23:45:14 rak-gateway ttn-gateway[10543]: INFO: found temperature sensor on port 0x39
Apr 24 23:45:14 rak-gateway ttn-gateway[10543]: INFO: [main] concentrator started, packet can now be received
Apr 24 23:45:14 rak-gateway ttn-gateway[10543]: INFO: concentrator EUI: 0x00xxxxxxxx (masked)
Apr 22 16:57:19 rak-gateway ttn-gateway[6400]: CoreCell reset through GPIO71...
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: *** Packet Forwarder ***
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: Version: 2.0.1
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: *** SX1302 HAL library version info ***
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: Version: 2.0.1;
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: ***
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: Little endian host
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: found configuration file global_conf.json, parsing
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: global_conf.json does contain a JSON object named SX130x_conf, parsing SX1302 parameters
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: com_type SPI, com_path /dev/spidev0.0, lorawan_public 1, clksrc 0, full_duplex 0
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: antenna_gain 0 dBi
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: Configuring legacy timestamp
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: no configuration for SX1261
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: Configuring Tx Gain LUT for rf_chain 0 with 16 indexes for sx1250
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: radio 0 enabled (type SX1250), center frequency 904300000, RSSI offset -215.399994, tx enabled 1, single input mode 0
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: radio 1 enabled (type SX1250), center frequency 905000000, RSSI offset -215.399994, tx enabled 0, single input mode 0
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: Lora multi-SF channel 0>  radio 0, IF -400000 Hz, 125 kHz bw, SF 5 to 12
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: Lora multi-SF channel 1>  radio 0, IF -200000 Hz, 125 kHz bw, SF 5 to 12
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: Lora multi-SF channel 2>  radio 0, IF 0 Hz, 125 kHz bw, SF 5 to 12
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: Lora multi-SF channel 3>  radio 0, IF 200000 Hz, 125 kHz bw, SF 5 to 12
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: Lora multi-SF channel 4>  radio 1, IF -300000 Hz, 125 kHz bw, SF 5 to 12
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: Lora multi-SF channel 5>  radio 1, IF -100000 Hz, 125 kHz bw, SF 5 to 12
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: Lora multi-SF channel 6>  radio 1, IF 100000 Hz, 125 kHz bw, SF 5 to 12
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: Lora multi-SF channel 7>  radio 1, IF 300000 Hz, 125 kHz bw, SF 5 to 12
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: Lora std channel> radio 0, IF 300000 Hz, 500000 Hz bw, SF 8, Explicit header
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: FSK channel 8 disabled
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: global_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: gateway MAC address is configured to AAxxxxxxxxxxxx (mac masked)
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: server hostname or IP address is configured to "router.us.thethings.network"
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: upstream port is configured to "1700"
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: downstream port is configured to "1700"
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: downstream keep-alive interval is configured to 10 seconds
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: statistics display interval is configured to 30 seconds
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: upstream PUSH_DATA time-out is configured to 100 ms
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: packets received with a valid CRC will be forwarded
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: packets received with a CRC error will NOT be forwarded
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: packets received with no CRC will NOT be forwarded
Apr 22 16:57:23 rak-gateway ttn-gateway[6400]: INFO: GPS serial port path is configured to "/dev/ttyS2"
....
Apr 23 03:17:37 rak-gateway ttn-gateway[17110]: # PUSH_DATA datagrams sent: 1 (124 bytes)
Apr 23 03:17:37 rak-gateway ttn-gateway[17110]: # PUSH_DATA acknowledged: 100.00%

[OP actively being edited and may change - will clean up as I go]

(Thanks JF for sharing some hardware/SPI related information especially on GPS as I have not worked with an LTS/A64 board until now)

My thought is to continue looking at what may not yet work, change things along the way until all is functional.

Having some odd things happen where I make a small edit to packet forwarder and it resets to original RPI, leading me to have to re-edit leading to starting of concentrator (as far as can see - will end up testing a node on it coming up and checking more details that might differ between RPI/Pine64- if you have anything helpful to share, thanks).

(For now mainly looking at Gateway and using rak_gateway as a starting point to test hardware and make changes).

If you have anything/thoughts/suggestions to add, related, or unrelated, please do! Smile
- RTP

"In the beginner's mind there are many possibilities, in the expert's mind there are few." -Shunryu Suzuki

My Blog: https://politictech.wordpress.com
  Reply
#2
Thanks for sharing your experiments!

The GPS can be accessed independently from the Lora  gateway. It's connected on UART2 on the Pine A64 board. For example, you can listen to NMEA frames using cat:
Code:
cat /dev/ttyS2

Alternatively, you can use gpsd and gpsmon to display those frames in a human readable format.

So, the install script from RAK configures the gateway to connect on TTN, right? Do you know if it uses the legacy 'packet forwarder' protocol, or the new Basic Station protocol?

Also, I think the install script for the RPI can optionally install ChirpStack, which is an open source LoraWAN server stack that would be selfhosted on your A64-LTS board. Have you tried it yet?
Working on Pinetime with FreeRTOS (C/C++) : https://github.com/JF002/Pinetime

Mastodon : https://mastodon.codingfield.com/@JF
Twitter : https://twitter.com/codingfield
Matrix : @JF002atrix.org
  Reply
#3
(04-28-2021, 12:14 PM)JF002 Wrote: Thanks for sharing your experiments!

The GPS can be accessed independently from the Lora  gateway. It's connected on UART2 on the Pine A64 board. For example, you can listen to NMEA frames using cat:
Code:
cat /dev/ttyS2

Alternatively, you can use gpsd and gpsmon to display those frames in a human readable format.

So, the install script from RAK configures the gateway to connect on TTN, right? Do you know if it uses the legacy 'packet forwarder' protocol, or the new Basic Station protocol?

Also, I think the install script for the RPI can optionally install ChirpStack, which is an open source LoraWAN server stack that would be selfhosted on your A64-LTS board. Have you tried it yet?

Ah yes, thanks for sharing that - it was helpful for me getting the GPS to work reliably. Smile  First time working with LoRa gateway/GPS based hardware. I noticed once GPS signal becomes reliable (ran an antenna line to my window to get this) immediately my gateway appeared on The Things Network map.

Using latest rak_common_gateway packet forwarder (guessing this may answer that?) (recloning it to make some edits to reupload to github soon).

The gateway-config command it allows you to (at any time) set/change channel plan to either TTN or optionally chirpstack. Then from chirpstack option you have --->

1.) ChirpStack Channel-plan Configuration
2.) Chirpstack ADR configure.

(Then restart the packet forwarder).

I have not yet tried changing this yet and tbh am more interested in working towards self hosted than TTN but TTN is a nice starting experiment. Smile

At first had some issues starting concentrator, but now, so far, everything is looking good (at least according to journalctl starting beacons/tx/rc, tcpdump/logs TTN radius packets all looking good, The Things Network map also now shows my gateway on the map).

Unfortunately having no nodes/gateways within about 50 miles limited tests (journalctl itself showing radio starting for tx/rx).

For most part everything looks to be starting okay (without any errors- still may need more edits somewhere (any insight appreciated as this first time starting a lora gateway))

(minor edits below to prevent identifiable info from being public)

Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: ### [GPS] ###
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: # Valid time reference (age: 0 sec)
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: # GPS coordinates: latitude (COORDINATE ERASED FOR PRVCY longitude (COORDINATE ERASED FOR PRVCY), altitude 95 m
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: ##### END #####
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: JSON up: {"stat":{"time":"2021-04-29 17:52:31 GMT","lati": (COORDINATE ERASED FOR PRIVACY),"long":  (COORDINATE ERASED FOR PRIVACY),"rxnb":0,"rxok":0,"rxfw":0,"ackr":0.0,"dwnb":0,"txnb":0,"temp":0.0}}
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: INFO: [down] PULL_ACK received in 75 ms
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: INFO: Beacon dequeued (count_us=93850158)
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: INFO: Beacon queued (count_us=435550494, freq_hz=926300000, size=23):
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]:    => 00 00 00 00 00 80 B6 B4 C5 XX
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: INFO: [down] PULL_ACK received in 78 ms
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: INFO: [down] PULL_ACK received in 82 ms
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: ##### 2021-04-29 17:53:01 GMT #####
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: ### [UPSTREAM] ###
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: # RF packets received by concentrator: 0
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: # CRC_OK: 0.00%, CRC_FAIL: 0.00%, NO_CRC: 0.00%
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: # RF packets forwarded: 0 (0 bytes)
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: # PUSH_DATA datagrams sent: 1 (165 bytes)
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: # PUSH_DATA acknowledged: 0.00%
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: ### [DOWNSTREAM] ###
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: # PULL_DATA sent: 3 (100.00% acknowledged)
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: # PULL_RESP(onse) datagrams received: 0 (0 bytes)
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: # RF packets sent to concentrator: 1 (0 bytes)
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: # TX errors: 0
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: ### SX1302 Status ###
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: # SX1302 counter (INST): 109294901
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: # SX1302 counter (PPS):  108850234
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: # BEACON queued: 306
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: # BEACON sent so far: 297
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: # BEACON rejected: 0
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: ### [JIT] ###
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: src/jitqueue.c:444:jit_print_queue(): INFO: [jit] queue contains 3 packets:
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: src/jitqueue.c:445:jit_print_queue(): INFO: [jit] queue contains 3 beacons:
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: src/jitqueue.c:451:jit_print_queue():  - node[0]: count_us=23582325 - type=3
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: src/jitqueue.c:451:jit_print_queue():  - node[1]: count_us=34985234 - type=3
Apr 29 13:53:01 rak-gateway ttn-gateway[3603]: src/jitqueue.c:451:jit_print_queue():  - node[2]: count_us=45785234 - type=3

Starting some edits on fork + start readme w/things I've noticed to help/share on github hoping to provide some starting points. Smile

Any insights by anyone reading appreciated! Smile
- RTP

"In the beginner's mind there are many possibilities, in the expert's mind there are few." -Shunryu Suzuki

My Blog: https://politictech.wordpress.com
  Reply
#4
UPDATE: I forked rak_common_for_gateway (a nice package from Rak Wireless).

I will write up a guide to setting this up/installing and put together a possible video on this as things come together.

In the fork I edited the rak2287 option from RPI into a Pine64 Gateway option (as printed on the options of the fork).

You can take a look/check out what i have here: https://github.com/RightToPrivacy/rak_co...r_gateway/
- RTP

"In the beginner's mind there are many possibilities, in the expert's mind there are few." -Shunryu Suzuki

My Blog: https://politictech.wordpress.com
  Reply
#5
To work on web interface/Chirpstack, enter rak_common_for_gateway/chirpstack. (Rak_common_gateway package is setup for a Debian based installs)

Run the install.sh script there (as root/sudo). It will grab (Debian based) packages and install them for you. The output should look something like this (some previously installed in this rerun):


Reading package lists... Done
Building dependency tree     
Reading state information... Done
dialog is already the newest version (1.3-20190211-1).
dirmngr is already the newest version (2.2.12-1+deb10u1).
mosquitto is already the newest version (1.5.7-1+deb10u1).
mosquitto-clients is already the newest version (1.5.7-1+deb10u1).
postgresql is already the newest version (11+200+deb10u4).
redis-server is already the newest version (5:5.0.3-4+deb10u3).
redis-tools is already the newest version (5:5.0.3-4+deb10u3).
apt-transport-https is already the newest version (1.8.2.3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Executing: /tmp/apt-key-gpghome.kAyQZAlvVy/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 1CE2AFD36DBCCA00
gpg: key 1CE2AFD36DBCCA00: "Orne Brocaar <info@brocaar.com>" not changed
gpg: Total number processed: 1
gpg:              unchanged: 1
deb https://artifacts.chirpstack.io/packages/3.x/deb stable main
Get:1 http://security.debian.org buster/updates InRelease [65.4 kB]
Hit:2 http://deb.debian.org/debian buster InRelease                                     
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]                   
Get:4 http://deb.debian.org/debian buster-backports InRelease [46.7 kB]
Hit:5 https://mirrors.fossho.st/armbian/apt buster InRelease                       
Hit:6 https://artifacts.chirpstack.io/packages/3.x/deb stable InRelease
Get:7 http://deb.debian.org/debian buster-backports/main armhf Packages.diff/Index [27.8 kB]
Get:8 http://deb.debian.org/debian buster-backports/main arm64 Packages.diff/Index [27.8 kB]
Get:9 http://deb.debian.org/debian buster-backports/main armhf Packages 2021-05-05-0201.29.pdiff [890 B]
Get:9 http://deb.debian.org/debian buster-backports/main armhf Packages 2021-05-05-0201.29.pdiff [890 B]
Get:10 http://deb.debian.org/debian buster-backports/main arm64 Packages 2021-05-05-0201.29.pdiff [891 B]
Get:10 http://deb.debian.org/debian buster-backports/main arm64 Packages 2021-05-05-0201.29.pdiff [891 B]
Fetched 221 kB in 4s (53.0 kB/s)                 
Reading package lists... Done
Building dependency tree     
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree     
Reading state information... Done
chirpstack-network-server is already the newest version (3.12.3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree     
Reading state information... Done
chirpstack-gateway-bridge is already the newest version (3.10.0).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists... Done
Building dependency tree     
Reading state information... Done
chirpstack-application-server is already the newest version (3.14.0).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Install ChirpStack success!



Enter gateway-config command. ---> Setup Rak Channel Gateway Plan. Here you can select "server other than TTN" --> Chirpstack Channel Plan. Then select the plan that meets your local area (country codes abbreviated). Now go back to packet forwarder configuration and make sure the devices are still correct (including gps as /dev/ttyS2) and restart packet forwarder.

The concentrator should start and GPS should read (after a couple minutes).

You should be able to use your web browser to connect to the gateway from your LAN using https://gatewayIP-is-Here:8080

Logging in with admin:admin (default credentials can be changed) greets you with a nice web based Chirpstack interface where you can set things up for Applications, Gateway, API keys, and more.  Smile
- RTP

"In the beginner's mind there are many possibilities, in the expert's mind there are few." -Shunryu Suzuki

My Blog: https://politictech.wordpress.com
  Reply
#6
One more thing noticed I wanted to add:

GPS location shows the gateway as active once filling in the proper Gateway ID on Chirpstack.

Running 'gateway-version' on commandline will report back the Gateway ID. This should be added when adding the gateway on the Chirpstack interface. Will report more things when I get a chance. Smile
- RTP

"In the beginner's mind there are many possibilities, in the expert's mind there are few." -Shunryu Suzuki

My Blog: https://politictech.wordpress.com
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)