How to build a LoRaWAN gateway

Revision as of 10:58, 30 July 2019 by Registered User

Template:ArticleMainWriter Template:ArticleFirstDraftVersion

This LoRaWAN The Things Network gateway package contains the frameworks to enable a LoRaWAN gateway that could be run on STM32MP1 Series. This package consists in an OpenEmbedded meta layer, named meta-st-stm32mpu-app-lorawan, to be added on top of the STM32MP1 Distribution Package. It brings a complete and coherent, easy to build / install LoRaWAN gateway on STM32MP1 Series.
The meta layer contains frameworks, tools and applications to run The LoRaWAN The Things Network gateway. Different images are available targeting different use cases such as the single use of the Cortex-A7, the use of the Cortex-A7 and Cortex-M4 side by side and the possibility to choose between an Ethernet or a wifi connection.

STM32MP1 LoRaWan gateway

1. Hardware needed[edit source]

The concentrator LoRaWan RAK831

Concentrator LoRaWan

The antenna

Antenna
Warning white.png Warning
It is mandatory to plug the antenna on the concentrator before powering up the board

The converter board

Converter board

This bundle allows to start with all the hardware needed. (pick your geographic area)

You can now assemble the modules to the board.

Info white.png Information
STM32MP157X-DKX - hardware description and GPIO expansion connector for more informations

This is how it should look:

How to plug the modules

2. Prerequisites[edit source]

Install the STM32MP1 Distribution Package, but do not initialize the OpenEmbedded environment (sourcing the envsetup.sh) before having installed the meta-st-stm32mpu-app-lorawan meta layer (see next chapter).

3. Installation of the meta layer[edit source]

  • To start you need to clone the git repositories to <Distribution Package installation directory>/layers/meta-st.
 cd <Distribution Package installation directory>/layers/meta-st
 git clone https://gerrit.st.com/stm32mpuapp/meta/meta-st-stm32mpu-app-lorawan -b thud
  • The next step is to setup for the LoRaWan gateway build environment
 cd ../../
  • You can choose between two different machines: stm32mp1-lorawan-a7 to only use the Cortex-A7 or stm32mp1-lorawan-m4 to use the Cortex-A7 and the Cortex-M4 side by side.
 DISTRO=openstlinux-weston MACHINE=<add machine> source layers/meta-st/scripts/envsetup.sh
 bitbake st-image-lorawan

This may take some time.

3.1. How to create the SD card[edit source]

The final step is to 'populate the SD card with the binaries compiled previously:

 cd <working directory path of distribution>/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxwestonextra-stm32mp1-lorawan-a7
 cd tmp-glibc/deploy/images/stm32mp1-lorawan-a7/scripts/
 ./create_sdcard_from_flashlayout.sh ../flashlayout_st-image-lorawan/FlashLayout_sdcard_stm32mp1-lorawan-a7-mx-trusted.tsv
 sudo umount `lsblk --list | grep mmcblk0 | grep part | gawk '{ print $7 }' | tr '\n' ' '`
 sudo dd if=../flashlayout_st-image-lorawan/../flashlayout_st-image-lorawan_FlashLayout_sdcard_stm32mp1-lorawan-a7-mx-trusted.raw of=/dev/mmcblk0 bs=8M conv=fdatasync status=progress

(more informations in the How to populate the SD card with dd command page)

3.2. Launching the binaries on the board[edit source]

This part explains how to launch the LoRaWan service on the board.

 cd /usr/local/lorawan-gateway/

For the next command, you need to indicate if your board is connected to the internet with WiFi or Ethernet.

 ./LoRaWan_gateway_launcher.sh wifi | ethernet
  • During the launcher script, enter your preferred server, up and down ports when it is asked.
Info white.png Information
If you want to use https://www.thethingsnetwork.org in europe

Their server is router.eu.thethings.network
Up and down ports 1700

  • Important: copy your EUI before the restart of the gateway

All those informations can be found or changed manually in the global_conf.json and local_conf.json files in /usr/local/lorawan-gateway/ on the board.

Info white.png Information
If you choose a WiFi connection:

enter your SSID and password

To change those informations, refer to How_to_setup_wifi_connection

4. The LoRaWAN gateway with the Cortex-A7 and the Cortex-M4[edit source]

4.1. How to build the binaries[edit source]

The next step is to create the build for the LoRaWan gateway

 cd <working directory path of distribution>/openstlinux-4.19-thud-mp1-19-02-20
 DISTRO=openstlinux-weston MACHINE=stm32mp1-lorawan-m4 source layers/meta-st/scripts/envsetup.sh
 bitbake st-image-lorawan

This may take some time.

4.2. How to create the SD card[edit source]

The final step is to 'populate the SD card with the binaries compiled previously:

 cd <working directory path of distribution>/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxwestonextra-stm32mp1-lorawan-m4
 cd tmp-glibc/deploy/images/stm32mp1-lorawan-m4/scripts/
 ./create_sdcard_from_flashlayout.sh ../flashlayout_st-image-lorawan/FlashLayout_sdcard_stm32mp157c-lorawan-m4-mx-trusted.tsv
 sudo umount `lsblk --list | grep mmcblk0 | grep part | gawk '{ print $7 }' | tr '\n' ' '`
 sudo dd if=../flashlayout_st-image-lorawan/../flashlayout_st-image-lorawan_FlashLayout_sdcard_stm32mp157c-lorawan-m4-mx-trusted.raw of=/dev/mmcblk0 bs=8M conv=fdatasync status=progress

(more informations in the How to populate the SD card with dd command page)

4.3. Launching the binaries on the board[edit source]

This part explains how to launch the LoRaWan service on the board.

 cd /usr/local/lorawan-gateway/

For the next command, you need to indicate if your board is connected to the internet with WiFi or Ethernet.

 ./LoRaWan_gateway_m4_launcher.sh wifi | ethernet
  • During the launcher script, enter your prefered server, up and down ports when it is asked.
Info white.png Information
If you want to use https://www.thethingsnetwork.org in europe

Their server is router.eu.thethings.network
Up and down ports 1700

  • Important: copy your EUI before the restart of the gateway

All those informations can be found or changed manually in the global_conf.json and local_conf.json files in /usr/local/lorawan-gateway/ on the board.

Info white.png Information
If you choose a WiFi connection:

enter your SSID and password

To change those informations, refer to How_to_setup_wifi_connection

4.4. To Modify the firmware running on the M4[edit source]

If you want to access or modify the code of the firmware running on the M4

 cd <working directory>
 repo init -u https://gerrit.st.com/stm32mpuapp/fw/manifests -b lorawan -m default.xml
 repo sync


5. How to proceed on The Things Network[edit source]

Login or create an account on https://www.thethingsnetwork.org

  1. Go into your CONSOLE.
  2. Clic on GATEWAYS.
  3. Clic on register gateway.
  4. Check I'm using the legacy packet forwarder and enter your EUI you previously copied.
  5. Enter a description of the gateway, this is the name you can see on the map of the site.
  6. Select your Frequency Plan.
  7. Select your Router (for europe choose ttn-router-eu).
  8. You can place your gateway on the map by clicking on it or by entering directly the precise coordinates.
  9. Tell if your antenna is indoor or outdoor.
  10. For creating a test device. Be careful with your end node’s applications, the duty cycle is regulated by governments. This one is regulated so that it can send a new LoRaWAN message minimum every 3 minutes with this low amount of data. But you can change the APP_TX_DUTYCYCLE variable if you want to lengthen the delay between two dispatch.
  11. Not mandatory: for your application's devices, you can use cayenne, this is a framework that store the data and you can easily visualize them.
No categories assignedEdit