RPi4 w/ RAK5146 (SPI) to TTN v3 (basicstation) - FAIL TO CONNECT BOARD

I am successfully running the UDP TTN-gateway on a Raspberry Pi 4 with the RAK PiHat and a RAK5146 concentrator card. I’m able to process up- and downlink messages, and after a few weeks of monkeying with it, everything Just Works. Proof here:

*** Packet Forwarder ***
Version: 2.1.0
*** SX1302 HAL library version info ***
Version: 2.1.0;
***
INFO: Little endian host
INFO: found configuration file global_conf.json, parsing it
INFO: global_conf.json does contain a JSON object named SX130x_conf, parsing SX1302 parameters
INFO: com_type SPI, com_path /dev/spidev0.0, lorawan_public 1, clksrc 0, full_duplex 0
INFO: antenna_gain 0 dBi
INFO: Configuring legacy timestamp
INFO: Configuring Tx Gain LUT for rf_chain 0 with 16 indexes for sx1250
INFO: radio 0 enabled (type SX1250), center frequency 904300000, RSSI offset -215.399994, tx enabled 1, single input mode 0
INFO: radio 1 enabled (type SX1250), center frequency 905000000, RSSI offset -215.399994, tx enabled 0, single input mode 0
INFO: Lora multi-SF channel 0>  radio 0, IF -400000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 1>  radio 0, IF -200000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 2>  radio 0, IF 0 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 3>  radio 0, IF 200000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 4>  radio 1, IF -300000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 5>  radio 1, IF -100000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 6>  radio 1, IF 100000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora multi-SF channel 7>  radio 1, IF 300000 Hz, 125 kHz bw, SF 5 to 12
INFO: Lora std channel> radio 0, IF 300000 Hz, 500000 Hz bw, SF 8, Explicit header
INFO: FSK channel 8 disabled
INFO: global_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
INFO: gateway MAC address is configured to AA555A0000000000
INFO: server hostname or IP address is configured to "nam1.cloud.thethings.network"
INFO: upstream port is configured to "1700"
INFO: downstream port is configured to "1700"
INFO: downstream keep-alive interval is configured to 10 seconds
INFO: statistics display interval is configured to 30 seconds
INFO: upstream PUSH_DATA time-out is configured to 100 ms
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
INFO: GPS serial port path is configured to "/dev/ttyUSB0"
INFO: Reference latitude is configured to 0.000000 deg
INFO: Reference longitude is configured to 0.000000 deg
INFO: Reference altitude is configured to 0 meters
INFO: Beaconing period is configured to 0 seconds
INFO: Beaconing signal will be emitted at 869525000 Hz
INFO: Beaconing datarate is set to SF9
INFO: Beaconing modulation bandwidth is set to 125000Hz
INFO: Beaconing TX power is set to 14dBm
INFO: Beaconing information descriptor is set to 0
INFO: global_conf.json does contain a JSON object named debug_conf, parsing debug parameters
INFO: got 2 debug reference payload
INFO: reference payload ID 0 is 0xCAFE1234
INFO: reference payload ID 1 is 0xCAFE2345
INFO: setting debug log file name to loragw_hal.log
INFO: found configuration file local_conf.json, parsing it
INFO: local_conf.json does contain a JSON object named gateway_conf, parsing gateway parameters
INFO: gateway MAC address is configured to E45F01FFFE02212C
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
This is uart for GPS.
INFO: [main] TTY port /dev/ttyUSB0 open for GPS synchronization
CoreCell reset through GPIO17...
Opening SPI communication interface
Note: chip version is 0x12 (v1.2)
INFO: using legacy timestamp
INFO: LoRa Service modem: configuring preamble size to 8 symbols
ARB: dual demodulation disabled for all SF
INFO: [main] concentrator started, packet can now be received
INFO: concentrator EUI: 0x0016c001ff195717
INFO: [down] PULL_ACK received in 18 ms
INFO: [down] PULL_ACK received in 22 ms

This is all built from the repo at https://github.com/RAKWireless/rak_common_for_gateway

Now, for various reasons, I’d like to upgrade to TTN v3 and run the basicstation code. I’ve pulled the code from here https://github.com/lorabasics/basicstation, followed the instructions, and have compiled and installed it mainly following this well-written guide: https ://www.beyondlogic.org/lorawan-upgrading-to-basic-station-and-the-things-network-v3-stack/.
But, it doesn’t work. :frowning:

Here’s the station config:

{
   "radio_conf": {                  /* Actual channel plan is controlled by the server */
       "lorawan_public": true,      /* is default */
       "clksrc": 1,                 /* radio_1 provides clock to concentrator */
       "device": "/dev/spidev0.0",  /* default SPI device is platform specific */
       "pps": true,
       "radio_0": {
           /* freq/enable provided by LNS - only hardware-specific settings are listed here */
           "type": "SX1257",
           "rssi_offset": -215.4,
           "tx_enable": true
       },
       "radio_1": {
           "type": "SX1257",
           "rssi_offset": -215.4,
           "tx_enable": false
       }
       /* chan_multiSF_X, chan_Lora_std, chan_FSK provided by LNS */
   },
   "station_conf": {
     "log_file":    "stderr",
     "log_level":   "DEBUG",
     "log_size":    10e6,
     "log_rotate":  3
   }
}

Which leads to this output when I run ‘station’:

pi@rak-gateway:~/TTN $ LORAGW_SPI_SPEED=2000000 ~/src/basicstation/build-rpi-std/bin/station 
2022-02-27 02:14:57.608 [SYS:INFO] Logging     : stderr (maxsize=10000000, rotate=3)
2022-02-27 02:14:57.608 [SYS:INFO] Station Ver : 2.0.6(rpi/std) 2022-02-27 01:49:05
2022-02-27 02:14:57.608 [SYS:INFO] Package Ver : (null)
2022-02-27 02:14:57.608 [SYS:INFO] mbedTLS Ver : 2.28.0
2022-02-27 02:14:57.608 [SYS:INFO] proto EUI   : 0:e45f:102:212c        (/sys/class/net/eth0/address)
2022-02-27 02:14:57.608 [SYS:INFO] prefix EUI  : ::1    (builtin)
2022-02-27 02:14:57.609 [SYS:INFO] Station EUI : e45f:1ff:fe02:212c
2022-02-27 02:14:57.609 [SYS:INFO] Station home: ./     (builtin)
2022-02-27 02:14:57.609 [SYS:INFO] Station temp: /var/tmp/      (builtin)
2022-02-27 02:14:57.609 [SYS:WARN] Station in NO-CUPS mode
2022-02-27 02:14:57.810 [TCE:INFO] Starting TC engine
2022-02-27 02:14:57.814 [AIO:INFO] ./tc.trust: 
cert. version     : 3
serial number     : 82:10:CF:B0:D2:40:E3:59:44:63:E0:BB:63:82:8B:00
issuer name       : C=US, O=Internet Security Research Group, CN=ISRG Root X1
subject name      : C=US, O=Internet Security Research Group, CN=ISRG Root X1
issued  on        : 2015-06-04 11:04:38
expires on        : 2035-06-04 11:04:38
signed using      : RSA with SHA-256
RSA key size      : 4096 bits
basic constraints : CA=true
key usage         : Key Cert Sign, CRL Sig2022-02-27 02:14:57.814 [TCE:INFO] Connecting to INFOS: wss://nam1.cloud.thethings.network:8887
2022-02-27 02:14:58.374 [TCE:INFO] Infos: e45f:1ff:fe02:212c muxs-::0 wss://nam1.cloud.thethings.network:8887/traffic/eui-E45F01FFFE02212C
2022-02-27 02:14:58.374 [AIO:DEBU] [3] ws_close reason=1000
2022-02-27 02:14:58.374 [AIO:DEBU] Echoing close - reason=1000
2022-02-27 02:14:58.375 [AIO:ERRO] Recv failed: SSL - The peer notified us that the connection is going to be closed
2022-02-27 02:14:58.375 [AIO:DEBU] [3] WS connection shutdown...
2022-02-27 02:14:58.376 [AIO:INFO] ./tc.trust: 
cert. version     : 3
serial number     : 82:10:CF:B0:D2:40:E3:59:44:63:E0:BB:63:82:8B:00
issuer name       : C=US, O=Internet Security Research Group, CN=ISRG Root X1
subject name      : C=US, O=Internet Security Research Group, CN=ISRG Root X1
issued  on        : 2015-06-04 11:04:38
expires on        : 2035-06-04 11:04:38
signed using      : RSA with SHA-256
RSA key size      : 4096 bits
basic constraints : CA=true
key usage         : Key Cert Sign, CRL Sig2022-02-27 02:14:58.376 [TCE:VERB] Connecting to MUXS...
2022-02-27 02:14:59.153 [TCE:VERB] Connected to MUXS.
2022-02-27 02:14:59.163 [RAL:INFO] Lora gateway library version: Version: 5.0.1;
2022-02-27 02:14:59.168 [RAL:INFO] [LGW lgw1] clksrc=1 lorawan_public=1
2022-02-27 02:14:59.168 [RAL:INFO]  RX/TX RF0:    904.3MHz rssi_offset=-215.4 type=2 tx_notch_freq=0
2022-02-27 02:14:59.169 [RAL:INFO]  RX    RF1:    905.0MHz rssi_offset=-215.4 type=2 tx_notch_freq=0
2022-02-27 02:14:59.169 [RAL:INFO]  [mSF]   0:    903.9MHz rf=0 freq=-400.0 datarate=0
2022-02-27 02:14:59.169 [RAL:INFO]  [mSF]   1:    904.1MHz rf=0 freq=-200.0 datarate=0
2022-02-27 02:14:59.169 [RAL:INFO]  [mSF]   2:    904.3MHz rf=0 freq=  +0.0 datarate=0
2022-02-27 02:14:59.169 [RAL:INFO]  [mSF]   3:    904.5MHz rf=0 freq=+200.0 datarate=0
2022-02-27 02:14:59.169 [RAL:INFO]  [mSF]   4:    904.7MHz rf=1 freq=-300.0 datarate=0
2022-02-27 02:14:59.169 [RAL:INFO]  [mSF]   5:    904.9MHz rf=1 freq=-100.0 datarate=0
2022-02-27 02:14:59.169 [RAL:INFO]  [mSF]   6:    905.1MHz rf=1 freq=+100.0 datarate=0
2022-02-27 02:14:59.169 [RAL:INFO]  [mSF]   7:    905.3MHz rf=1 freq=+300.0 datarate=0
2022-02-27 02:14:59.169 [RAL:INFO]  [STD]   8:    904.6MHz rf=0 freq=+300.0 datarate=4 bw=1 
2022-02-27 02:14:59.169 [RAL:INFO]  channel 9 disabled
2022-02-27 02:14:59.169 [RAL:INFO] SX130x LBT not enabled
2022-02-27 02:14:59.169 [RAL:INFO] Station device: /dev/spidev0.0 (PPS capture enabled)
2022-02-27 02:14:59.169 [HAL:INFO] [lgw_spi_open:101] Setting SPI speed to 2000000
2022-02-27 02:14:59.170 [HAL:INFO] [lgw_spi_open:135] Note: SPI port opened and configured ok
2022-02-27 02:14:59.170 [HAL:ERRO] [lgw_start:742] FAIL TO CONNECT BOARD
2022-02-27 02:14:59.170 [RAL:ERRO] Concentrator start failed: lgw_start
2022-02-27 02:14:59.170 [RAL:ERRO] ral_config failed with status 0x08
2022-02-27 02:14:59.170 [any:ERRO] Closing connection to muxs - error in s2e_onMsg
2022-02-27 02:14:59.170 [AIO:DEBU] [3] ws_close reason=1000
2022-02-27 02:14:59.170 [AIO:DEBU] Echoing close - reason=1000
2022-02-27 02:14:59.187 [AIO:DEBU] [3|WS] Server sent close: reason=1000
2022-02-27 02:14:59.187 [AIO:DEBU] [3] WS connection shutdown...
2022-02-27 02:14:59.187 [TCE:VERB] Connection to MUXS closed in state -1
2022-02-27 02:14:59.187 [TCE:INFO] INFOS reconnect backoff 10s (retry 1)

What I’m seeing is that the station software can’t find SOMETHING (the 1302?) over SPI. Clearly, I’ve set the SPI BUS speed to 2MHz, but that doesn’t seem to be doing the trick. Given that it works with the packet-forwarder, I’m confident my hardware is working.

There are a couple of things in the station.conf I’ve tried fiddling with, but I think I’m out of my depth at this point. If anyone has gotten a RPi with a RAK5146 in SPI mode working with TTN v3, please let me know how you did it.

Thank you!
John Gorkos

Hi
The RAK5146 is based on the SX1303 and it’s a Corecell concentrator. Looks like you built the BasicStation for SX1301 concentrators. Try building it for Corecell:

make platform=corecell variant=std

Or, you can also run it the “docker” way: https://github.com/xoseperez/basicstation.

1 Like

Thank you for the reply. I’ll look at running the docker image. Some things I think docker is great for, some things I hate it. I’d like to really understand what is going on here before I throw in the docker towel.

Running the corecell-std binary, I get this:

pi@rak-gateway:~/TTN $ sudo RAGW_SPI_SPEED=2000000 ~/src/basicstation/build-corecell-std/bin/station -i ./reset_gw.sh
2022-02-28 16:26:52.981 [SYS:INFO] Logging     : stderr (maxsize=10000000, rotate=3)
2022-02-28 16:26:52.981 [SYS:INFO] Station Ver : 2.0.6(corecell/std) 2022-02-28 00:46:25
2022-02-28 16:26:52.981 [SYS:INFO] Package Ver : (null)
2022-02-28 16:26:52.981 [SYS:INFO] mbedTLS Ver : 2.28.0
2022-02-28 16:26:52.982 [SYS:INFO] proto EUI   : 0:e45f:102:212c        (/sys/class/net/eth0/address)
2022-02-28 16:26:52.982 [SYS:INFO] prefix EUI  : ::1    (builtin)
2022-02-28 16:26:52.983 [SYS:INFO] Station EUI : e45f:1ff:fe02:212c
2022-02-28 16:26:52.983 [SYS:INFO] Station home: ./     (builtin)
2022-02-28 16:26:52.983 [SYS:INFO] Station temp: /var/tmp/      (builtin)
2022-02-28 16:26:52.984 [SYS:WARN] Station in NO-CUPS mode
2022-02-28 16:26:53.185 [TCE:INFO] Starting TC engine
2022-02-28 16:26:53.189 [AIO:INFO] ./tc.trust: 
cert. version     : 3
serial number     : 82:10:CF:B0:D2:40:E3:59:44:63:E0:BB:63:82:8B:00
issuer name       : C=US, O=Internet Security Research Group, CN=ISRG Root X1
subject name      : C=US, O=Internet Security Research Group, CN=ISRG Root X1
issued  on        : 2015-06-04 11:04:38
expires on        : 2035-06-04 11:04:38
signed using      : RSA with SHA-256
RSA key size      : 4096 bits
basic constraints : CA=true
key usage         : Key Cert Sign, CRL Sig2022-02-28 16:26:53.189 [TCE:INFO] Connecting to INFOS: wss://nam1.cloud.thethings.network:8887
2022-02-28 16:26:53.770 [TCE:INFO] Infos: e45f:1ff:fe02:212c muxs-::0 wss://nam1.cloud.thethings.network:8887/traffic/eui-E45F01FFFE02212C
2022-02-28 16:26:53.770 [AIO:DEBU] [3] ws_close reason=1000
2022-02-28 16:26:53.770 [AIO:DEBU] Echoing close - reason=1000
2022-02-28 16:26:53.771 [AIO:ERRO] Recv failed: SSL - The peer notified us that the connection is going to be closed
2022-02-28 16:26:53.771 [AIO:DEBU] [3] WS connection shutdown...
2022-02-28 16:26:53.771 [AIO:INFO] ./tc.trust: 
cert. version     : 3
serial number     : 82:10:CF:B0:D2:40:E3:59:44:63:E0:BB:63:82:8B:00
issuer name       : C=US, O=Internet Security Research Group, CN=ISRG Root X1
subject name      : C=US, O=Internet Security Research Group, CN=ISRG Root X1
issued  on        : 2015-06-04 11:04:38
expires on        : 2035-06-04 11:04:38
signed using      : RSA with SHA-256
RSA key size      : 4096 bits
basic constraints : CA=true
key usage         : Key Cert Sign, CRL Sig2022-02-28 16:26:53.772 [TCE:VERB] Connecting to MUXS...
2022-02-28 16:26:54.554 [TCE:VERB] Connected to MUXS.
2022-02-28 16:26:54.566 [SYS:VERB] ./reset_gw.sh: Forked, waiting...
2022-02-28 16:26:54.567 [SYS:DEBU] execvp argv[0]: <./reset_gw.sh>
2022-02-28 16:26:54.567 [SYS:DEBU]        argv[1]: </dev/spidev0.0>
2022-02-28 16:26:54.899 [SYS:INFO] Process ./reset_gw.sh (pid=31678) completed
2022-02-28 16:26:54.899 [RAL:INFO] Lora gateway library version: Version: 2.1.0;
2022-02-28 16:26:54.916 [RAL:INFO] [LGW sx1302] full_duplex=0 clksrc=1 lorawan_public=1
2022-02-28 16:26:54.916 [RAL:INFO]  RX/TX RF0:    904.3MHz rssi_offset=-215.4 type=2 rssi_tcomp=0.000 0.000 0.000 0.000 0.000
2022-02-28 16:26:54.916 [RAL:INFO]  RX    RF1:    905.0MHz rssi_offset=-215.4 type=2 rssi_tcomp=0.000 0.000 0.000 0.000 0.000
2022-02-28 16:26:54.916 [RAL:INFO]  [mSF]   0:    903.9MHz rf=0 freq=-400.0 datarate=0
2022-02-28 16:26:54.916 [RAL:INFO]  [mSF]   1:    904.1MHz rf=0 freq=-200.0 datarate=0
2022-02-28 16:26:54.916 [RAL:INFO]  [mSF]   2:    904.3MHz rf=0 freq=  +0.0 datarate=0
2022-02-28 16:26:54.916 [RAL:INFO]  [mSF]   3:    904.5MHz rf=0 freq=+200.0 datarate=0
2022-02-28 16:26:54.916 [RAL:INFO]  [mSF]   4:    904.7MHz rf=1 freq=-300.0 datarate=0
2022-02-28 16:26:54.916 [RAL:INFO]  [mSF]   5:    904.9MHz rf=1 freq=-100.0 datarate=0
2022-02-28 16:26:54.917 [RAL:INFO]  [mSF]   6:    905.1MHz rf=1 freq=+100.0 datarate=0
2022-02-28 16:26:54.917 [RAL:INFO]  [mSF]   7:    905.3MHz rf=1 freq=+300.0 datarate=0
2022-02-28 16:26:54.917 [RAL:INFO]  [STD]   8:    904.6MHz rf=0 freq=+300.0 datarate=8 bw=6 Explicit header
2022-02-28 16:26:54.917 [RAL:INFO]  channel 9 disabled
2022-02-28 16:26:54.917 [RAL:INFO] Station device: spi:/dev/spidev0.0 (PPS capture enabled)
2022-02-28 16:26:54.917 [HAL:INFO] [lgw_com_open:84] Opening SPI communication interface
2022-02-28 16:26:54.917 [HAL:INFO] [lgw_spi_open:88] Setting SPI speed to 2000000
2022-02-28 16:26:54.917 [HAL:INFO] [lgw_connect:1192] chip version is 0x12 (v1.2)
2022-02-28 16:26:56.110 [HAL:ERRO] [sx1302_agc_load_firmware:1187] AGC fw read/write check failed
2022-02-28 16:26:56.110 [HAL:ERRO] [sx1302_radio_calibrate:545] Failed to load calibration fw
2022-02-28 16:26:56.110 [HAL:ERRO] [lgw_start:878] radio calibration failed
2022-02-28 16:26:56.110 [RAL:ERRO] Concentrator start failed: lgw_start
2022-02-28 16:26:56.110 [RAL:ERRO] ral_config failed with status 0x08
2022-02-28 16:26:56.110 [any:ERRO] Closing connection to muxs - error in s2e_onMsg
2022-02-28 16:26:56.110 [AIO:DEBU] [3] ws_close reason=1000
2022-02-28 16:26:56.111 [AIO:DEBU] Echoing close - reason=1000
2022-02-28 16:26:56.126 [AIO:DEBU] [3|WS] Server sent close: reason=1000
2022-02-28 16:26:56.126 [AIO:DEBU] [3] WS connection shutdown...
2022-02-28 16:26:56.127 [TCE:VERB] Connection to MUXS closed in state -1
2022-02-28 16:26:56.127 [TCE:INFO] INFOS reconnect backoff 10s (retry 1)

So, I’m missing a firmware load of some sort for the AGC?
2022-02-28 16:26:56.110 [HAL:ERRO] [sx1302_agc_load_firmware:1187] AGC fw read/write check failed 2022-02-28 16:26:56.110 [HAL:ERRO] [sx1302_radio_calibrate:545] Failed to load calibration fw 2022-02-28 16:26:56.110 [HAL:ERRO] [lgw_start:878] radio calibration failed 2022-02-28 16:26:56.110 [RAL:ERRO] Concentrator start failed: lgw_start 2022-02-28 16:26:56.110 [RAL:ERRO] ral_config failed with status 0x08

Thanks for your time!
John Gorkos

By using the docker build scripts, I was able to build a corecell-based station that runs correctly. The patches to remove the calls to the non-existent temperature I2C sensor were critical to that success; hopefully those get pushed upstream at some point.
Thank you for your work on this, @xoseperez. I’m going to mark this closed, and share the information I learned on the TTN forum, as well.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.