RAK831 + ftdi + ubuntu

  • @KhaiNguyen You should not clone [https://github.com/Lora-net/packet_forwarder.git](link url)...
    Could you please just try the following steps:

    $ mkdir testRAK831
    $ cd testRAK831
    $ git clone https://github.com/RAKWireless/RAK831_LoRaGateway.git
    $ cd  RAK831_LoRaGateway/libmpsse/src
    $ ./configure
    $ make
    $ sudo make install
    $ cd ../../lora_gateway
    $ make

    ...and that's all :)

    make[1]: Entering directory '/home/userr/Devel/Lora/Raktest/RAK831_LoRaGateway/lora_gateway/libloragw'
    *** Checking libloragw library configuration ***
    Release version   : 1.5.0
    SPI interface     : FTDI SPI-over-USB bridge using libmpsse/libftdi/libusb
    Concentrator chip : Semtech SX1301 production chip
    Radio chip(s)     : Auto check front end.
    Frequency band    : Full range supported by the radio(s)
    Board misc. param : China LoRa 433MHz gateway for RPi
    Network type      : Private network
    *** Configuration seems ok ***
    gcc -c -O2 -Wall -Wextra -std=c99 -Iinc -I. src/loragw_hal.c -o obj/loragw_hal.o
    gcc -c -O2 -Wall -Wextra -std=c99 -Iinc -I. src/loragw_gps.c -o obj/loragw_gps.o
    gcc -O2 -Wall -Wextra -std=c99 -Iinc -I. -L. tst/test_loragw_full_duplex.c -o test_loragw_full_duplex -lloragw -lrt -lmpsse


  • Thank you @OlivierG
    I've tried your code but it seems to me that I got the same results as following @Twenyong without installing packet_forwarder? How can I check it please?

    Secondly, (if anyone can help) when I tried function test_loragw_rx, I always received problem with CRC, package damaged. I thought that it's due to missing a sender so I set up a sender with module Heltec Wifi Lora 32, and sender code from https://www.alictronix.com/archives/860 with frequency modified, but the concentrator still received damaged packet? Am I wrong at something?

    Thank you,

  • Hi @KhaiNguyen
    You have 2 different 2 problems:

    • Build the RAK stack: The log you sent is not from RAK's code...so it is not obvious to help you in building it :)
    • Heltec Wifi Lora 32 is just a LoRa sender, so, if you want to use it as a sensor (why not . :)), you have to set up the Heltec device with LMIC stack (see arduino lmic at [https://github.com/matthijskooijman/](link url))

    I set up the whole pack (Heltec -> RAK831 <-> TTN) and it works :)

  • Hi @KhaiNguyen

    The RAK831 module does work correctly with the RAK stack, so going with @OlivierG comments, I would definitely suggest to first get your RAK stack compiled and executed.

    Second, the CRC check failure is ok, as it happens when there is no sender to send a lora packet. However when testing the initial config, your spi_test and rx_test shouldn't throw "concentrator failure" during execution. So i would request you to build the RAK stack first and see if the above two commands work and show you a correct output

    BTW, I would like to understand if there is any particular requirement for running the RAK831 via FTDI instead of full speed SPI? If its an industrial use case, I would recommend getting a industrial chipset variants of the imx6 or from broadcom and run it on the board directly via SPI. Since the FTDI support is getting deprecated with the semtech gateway version code v3.2.0. Hence any changes to the sx1301 or future chipset revision will not have full support for the FTDI based development. Just a suggestion from my end.

    Official semtech repo notes:


    Added support for SX1301AP2 reference design (with FPGA and additional SX127x). When a FPGA is detected at startup, the HAL automatically adapts SPI communication requests (using SPI header or not).
    Added util_spectral_scan diagnostic tool to scan the spectral band in background, where the LoRa gateway operates. (can only be used with SX1301AP2 or similar design). By default it uses the same SPI device as the one used by the HAL, but it can be changed depending on the hardware architecture on which it is used by updating the SPI_DEV_PATH constant defined in file util_spectral_scan/src/loragw_fpga_spi.c. Note: when using same SPI device from 2 applications, we rely on the host SPI driver and OS to properly handle concurrent SPI requests. It has been tested on Raspberry Pi / Raspbian with spi_bcm2708 driver.* Removed SPI FTDI support due to lack of performances to properly handle heavy packet traffic. Only native SPI usage is recommended.
    HAL: added a check that SX1301 firmwares have been properly loaded at startup.

  • Thank you @OlivierG and @narioinc for your help,

    Look like it's a problem because I lack of experience with Linux, as a permanent windows user. I think I have succeed to build it, but I still don't know how can I execute it? Does it mean running the rx_test?

    @OlivierG I will use it as a sensor, I used to play a lot with arduinos :) but for now I just send some random number

  • @KhaiNguyen, for sure, Linux development is a little bit different from Windows :)
    if you want, we can go step by step:

    Part 1: you need to compile the library:

    (I assume you already got the git branch)
    $ cd RAK831_LoRaGateway/libmpsse/src
    Then, reconfigure the Makefile:
    $ ./configure
    The output should be like that:

    [10:51][oguiter:~/Devel/Lora/Raktest/RAK831_LoRaGateway/libmpsse/src]$ ./configure
    checking for gcc... gcc
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.out
    checking for suffix of executables... 
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ISO C89... none needed
    checking how to run the C preprocessor... gcc -E
    checking for grep that handles long lines and -e... /bin/grep
    checking for egrep... /bin/grep -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking for size_t... yes
    checking for stdlib.h... (cached) yes
    checking for GNU libc compatible malloc... yes
    checking libftdi1/ftdi.h usability... no
    checking libftdi1/ftdi.h presence... no
    checking for libftdi1/ftdi.h... no
    checking ftdi.h usability... yes
    checking ftdi.h presence... yes
    checking for ftdi.h... yes
    checking for ftdi_init in -lftdi... yes
    configure: creating ./config.status
    config.status: creating Makefile

    Now, run $ make

    gcc -Wall -fPIC -fno-strict-aliasing -g -O2 -shared -Wl,-soname,libmpsse.so *.o -o libmpsse.so -lftdi 
    ar rcs libmpsse.a *.o

    And the last thing to do with library is to "install it" with
    $ sudo make install

    After these steps, on my Ubuntu, i can find 3 files (new ly created), here:

    $ ll /usr/local/lib/libmp*
    -rw-r--r-- 1 root root 92K janv. 10 10:58 /usr/local/lib/libmpsse.a
    -rw-r--r-- 1 root root 68K janv. 10 10:58 /usr/local/lib/libmpsse.so
    $ ll /usr/local/include/mp*
    -rw-r--r-- 1 root root 5,2K janv. 10 10:58 /usr/local/include/mpsse.h

    Up to now, is it ok on your system ?

    Part 2:

    Now go back to the 2nd directory:
    $ cd RAK831_LoRaGateway/lora_gateway
    and just run $ make
    The beginning of the log should be like that:

    make[1]: Entering directory '/home/userr/Devel/Lora/Raktest/RAK831_LoRaGateway/lora_gateway/libloragw'
    *** Checking libloragw library configuration ***
    Release version   : 1.5.0
    SPI interface     : FTDI SPI-over-USB bridge using libmpsse/libftdi/libusb
    Concentrator chip : Semtech SX1301 production chip
    Radio chip(s)     : Auto check front end.
    Frequency band    : Full range supported by the radio(s)
    Board misc. param : China LoRa 433MHz gateway for RPi
    Network type      : Private network

    If everything seems to be fine, just check if it works with the following test:
    $ ./libloragw/test_loragw_reg
    If there's NO connection with the RAK831, you will get this kind of log:

    Beginning of test for loragw_reg.c
    IMPLICIT_PAYLOAD_LENGHT = 0 (should be 197)
    FRAME_SYNCH_PEAK2_POS = 0 (should be 11)
    PREAMBLE_SYMB1_NB = 0 (should be 49253)
    ADJUST_MODEM_START_OFFSET_SF12_RDX4 = 0 (should be 3173)
    IF_FREQ_1 = 0 (should be -1947)
    End of test for loragw_reg.c

    If you get a different message, it means It Works !

    Hope this will help. Feel free to ask if there a problem at any step !

  • Thank you @OlivierG , you are so kind,
    It seems to works after I followed your first comment, I just don't understand the log :)

    End of register verification
    IMPLICIT_PAYLOAD_LENGHT = 197 (should be 197)
    FRAME_SYNCH_PEAK2_POS = 11 (should be 11)
    PREAMBLE_SYMB1_NB = 49253 (should be 49253)
    ADJUST_MODEM_START_OFFSET_SF12_RDX4 = 3173 (should be 3173)
    IF_FREQ_1 = -1947 (should be -1947)
    End of test for loragw_reg.c

    Next, to connect to The thing network, what do you thing I should do to handle the packet forwarder?

    Kind regards,

  • Hi,
    After some efforts, I can receive some packages from a node like this

    Rcv pkt #1 >>freq:868100000
     if_chain: 0 tstamp:0119531196 size: 15 LoRa SF12 CR1(4/5)
     RSSI: -42.0 SNR: +6.0 (min: +4.5, max:+10.2) payload:
     40 04 00 00 71 80 0B 00 02 77 7B 0B 66 D2 A1 #

    So I proceeded with packet forwarder, from @OlivierG's link, I created and account on https://www.thethingsnetwork.org/docs/gateways/registration.html and successfully request my *.json file on https://github.com/ttn-zh/gateway-remote-config. I did try to follow from the this command on the link:

    $ git clone -b spi https://github.com/ttn-zh/ic880a-gateway.git ~/ic880a-gateway
    $ cd ~/ic880a-gateway
    $ sudo ./install.sh spi

    But it seems just to be used for RPi because I can't connect to TTN. Then I came back to the option of adding this floder https://github.com/Lora-net/packet_forwarder/tree/master/lora_pkt_fwd under RAK831_LoRaGateway repo with the same error log, like in the very long comment of mine before. @OlivierG are you sure that I should not clone the packet_forwarder? In addition, do you think my laptop installed both windows and ubuntu makes this problem?

    Thank you in advance,

  • Hi @KhaiNguyen
    Step by step, little by little :)
    Just one question: on the Heltec Lora module, are you using the default LoRa sender ? ... if "yes", the global behavior is the one expected. The Heltec send Lora frame, not LoRaWan.
    TTN expects LoRaWan frames, with all the needed settings (e.g.: APP EUI, DEV EUI, ... )
    So, now, let the gateway "as is" :)
    (on the RPI, if you look at syslog :
    sudo tail -f /var/log/syslog
    you should see log like this one:

    pi@ttn-gateway:/opt/ttn-gateway $ sudo tail -f /var/log/syslog
    Jan 12 09:39:12 ttn-gateway ttn-gateway[340]: INFO: [down] for server router.eu.thethings.network PULL_ACK received in 66 ms
    Jan 12 09:39:12 ttn-gateway ttn-gateway[340]: ##### 2018-01-12 09:39:12 GMT #####
    Jan 12 09:39:12 ttn-gateway ttn-gateway[340]: ### [UPSTREAM] ###
    Jan 12 09:39:12 ttn-gateway ttn-gateway[340]: # RF packets received by concentrator: 0
    Jan 12 09:39:12 ttn-gateway ttn-gateway[340]: # CRC_OK: 0.00%, CRC_FAIL: 0.00%, NO_CRC: 0.00%
    Jan 12 09:39:12 ttn-gateway ttn-gateway[340]: # RF packets forwarded: 0 (0 bytes)
    Jan 12 09:39:12 ttn-gateway ttn-gateway[340]: # PUSH_DATA datagrams sent: 2 (476 bytes)
    Jan 12 09:39:12 ttn-gateway ttn-gateway[340]: # PUSH_DATA acknowledged: 50.00%
    Jan 12 09:39:12 ttn-gateway ttn-gateway[340]: ### [DOWNSTREAM] ###
    Jan 12 09:39:12 ttn-gateway ttn-gateway[340]: # PULL_DATA sent: 6 (50.00% acknowledged)

    ... and focus on the Heltec Lora module:
    Use the IBM LMIC framework lib (see here: https://www.thethingsnetwork.org/forum/t/arduino-lmic-library-updated/1295/17

    Don't forget to change the Arduino code with the correct pin mapping:

    const lmic_pinmap lmic_pins = {
        .nss = 18,
        .rxtx = LMIC_UNUSED_PIN,
        .rst = 14,
        .dio = {26, 26, LMIC_UNUSED_PIN},

    and, of course, update the
    the NwkSKey and AppSKey as DEVADDR !


Log in to reply

Looks like your connection to RAK Support Center was lost, please wait while we try to reconnect.