Sunday, August 20, 2023

GNU Radio software-defined radio (SDR) implementation of a LoRa transceiver

GitHub last commit gnuradio version arXiv Hits Build conda package License: GPL v3

Summary

This is the fully-functional GNU Radio software-defined radio (SDR) implementation of a LoRa transceiver with all the necessary receiver components to operate correctly even at very low SNRs. The transceiver is available as a module for GNU Radio 3.10. This work has been conducted at the Telecommunication Circuits Laboratory, EPFL.

In the GNU Radio implementation of the LoRa Tx and Rx chains the user can choose all the parameters of the transmission, such as the spreading factor, the coding rate, the bandwidth, the sync word, the presence of an explicit header and CRC.

  • The module contains convenient hierarchical blocks for both Tx and Rx.

  • In the Tx chain, the implementation contains all the main blocks of the LoRa transceiver: the header- and the CRC-insertion blocks, the whitening block, the Hamming encoder block, the interleaver block, the Gray demapping block, and the modulation block. tx_flow

  • On the receiver side there is the packet synchronization block, which performs all the necessary tasks needed for the synchronization, such as the necessary STO and CFO estimation and correction. The demodulation block follows, along with the Gray mapping block, the deinterleaving block, the Hamming decoder block and the dewhitening block, as well as a CRC verification block. rx_flow

  • The implementation can be used for fully end-to-end experimental performance results of a LoRa SDR receiver at low SNRs.

  • A simple simulation framework is available in the apps/simulation folder.

Functionalities

* Spreading factors 5 and 6 not compatible with SX1261/2.

Reference

J. Tapparel, O. Afisiadis, P. Mayoraz, A. Balatsoukas-Stimming and A. Burg, "An Open-Source LoRa Physical Layer Prototype on GNU Radio," 2020 IEEE 21st International Workshop on Signal Processing Advances in Wireless Communications (SPAWC), Atlanta, GA, USA, 2020, pp. 1-5.

IEEE Xplore link, arXiv link

If you find this implementation useful for your project, please consider citing the aforementioned paper.

Prerequisites

  • Gnuradio 3.10
  • python 3
  • cmake
  • libvolk
  • Boost
  • UHD
  • gcc > 9.3.0
  • gxx
  • pybind11

The conda environment used to develop this module is described by the environment.yml file.

Installation

The out of three module gr-lora_sdr can be installed from source or directly as a conda package.

From source

  • Clone this repository
     git clone https://github.com/tapparelj/gr-lora_sdr.git
  • Go to the cloned repository
  • A functionning environment with all dependencies can be installed with conda or you can install them individually and skip to the next step. You can follow this tutorial or simply following:
    • First download the latest release of conda, for example:
       wget https://repo.anaconda.com/miniconda/Miniconda3-py39_4.12.0-Linux-x86_64.sh
    • Now run the downloaded file which is the Anaconda Installer script
       bash Miniconda3-py39_4.12.0-Linux-x86_64.sh
    • And reload the Shell
    • Now copy our environment to install all the dependencies of the module automatically. Note that it will take quite some time (~20 min).
       conda env create -f environment.yml 
    • Start the conda environment GNU Radio 3.10 you just created
  • To build the code, create an appropriate folder and go in it:
  • Run the main CMakeLists.txt
     cmake .. -DCMAKE_INSTALL_PREFIX=<your prefix> # default to usr/local, CONDA_PREFIX or PYBOMB_PREFIX if no install prefix selected here
  • Finally compile the custom GNU Radio blocks composing the LoRa transceiver. Replacing <X> with the number of core you want to use to speed up the compilation.
     (sudo) make install -j<X>
  • if you installed as sudo run
  • You can test that the installation is successful by running
  • Now you should be able to run some codes. For example, open the GNU Radio Companion user interface and check if the blocks of gr-lora_sdr are available on the blocks list (e.g. under LoRa_TX).
  • A final verification of the transceiver functionning can be made by executing the following script, transmitting a frame every two seconds:
     python3 examples/tx_rx_functionnality_check.py 

Usage

  • An example of a LoRa transmitter and receiver can be found in gr-lora_sdr/examples/ (both python and grc).
  • The .grc files can be opened with gnuradio-companion to set the different transmission parameters.
  • The python file generated by grc can be executed with python3 ./{file_name}.py

From conda

Thanks to Ryan Volz this OOT module can also directly be installed as a Conda package. Note that gnuradio will also be installed in the conda environment.

  • Create or activate the conda environment you want to install this module in. Refer to the conda getting start guide if you are not familiar with it already.
  • Install the module from the anaconda channel tapparelj with:
     conda install -c tapparelj -c conda-forge gnuradio-lora_sdr
  • Depending on your needs you might want to install complementary packages for gnuradio with:
     conda install -c conda-forge gnuradio
  • The gnuradio metapackage installs all of the following subpackages:
    • gnuradio-grc
    • gnuradio-iio
    • gnuradio-qtgui
    • gnuradio-soapy
    • gnuradio-uhd
    • gnuradio-video-sdl
    • gnuradio-zeromq
  • If you don't want all of those and their dependencies, you can install the ones you'd like individually with:
     conda install -c conda-forge gnuradio-uhd

Usage

  • Example gnuradio-companinon flowgraphs are installed with the package and can be found in:
    • (Linux/macOS) $CONDA_PREFIX/share/gr-lora_sdr/examples
    • (Windows) %CONDA_PREFIX%\Library\share\gr-lora_sdr\examples

Frequent issues:

  • Fail to make after pulling a new version from git
    • If the parameters of a block have changed in the new version, you need to first clean the old installation before building the module again.
    • from within the build folder, run
       (sudo) make uninstall
       make clean
       make -j4
       (sudo) make install
      
  • "ImportError: No module named lora_sdr":
    • This issue comes probably from missing PYTHONPATH and LD_LIBRARY_PATH
    • Refer to https://wiki.gnuradio.org/index.php/ModuleNotFoundError to modify those variables. If you set a prefix during the "cmake" call, skip directly to point C.(Verifying that the paths exist in your folders might help.)
  • The OOT blocks doesn't appear in gnuradio-companion:
    • The new blocks can be loaded in gnuradio-companion by adding the following lines in home/{username}/.gnuradio/config.conf (If this file doesn't exist you need to create it):
       [grc]
       local_blocks_path=path_to_the_downloaded_folder/gr-lora_sdr/grc
      

Changelog

  • Added tagged stream input support (for frame definition of frame length)

  • Fixed LLR stream format between fft_demod and deinterleaver

  • added tags to crc verification output stream indication frame start, length and CRC result.

  • added separator option for file input

  • added preamble length option

  • added parameter for frame zero-padding

  • add low datarate optimisation support

  • add support of spreading factors smaller than 7

    ...

Credit

This work was inspired from https://github.com/rpp0/gr-lora by Pieter Robyns, Peter Quax, Wim Lamotte and William Thenaers. Which architecture and functionalities have been improved to better emulate the physical layer of LoRa.

Licence

Distributed under the GPL-3.0 License License. See LICENSE for more information.



from Hacker News https://ift.tt/IfvDXCJ

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.