Skip to content

Basic MAC

Overview

Basic MAC is a very lightweight and compact LoRaWAN stack supporting STM32L0 MCU and SX1272 as well as SX126x transceivers. It was developed by Semtech, but has been put end of live and is no longer maintained.

You can use Basic MAC to develop applications on the FMLR-72-STM module. It will also work for FMLR-61-STM, but it's recommended to use LoRa Basic Modem.

Miromico is providing a port of Basic Mac on github. It is a fork of the original Basic MAC from Semtech with support for the FMLR-72-STM module.

Preparing Development Environment

Basic MAC has been written using Linux. The recommended way to develop Basic MAC under Windows is using WSL. Follow the guide to install WSL on your computer.

Getting the source code

Miromico is providing Basic MAC-based example firmware on gitlab This is a fork of the official release from Semtech, ported to Miromico FMLR modules.

Clone the repository and update all submodules using the following git commands

git clone https://gitlab.com/fmlr/fmlr-basicmac/ex-join
cd ex-join
git submodule update --init --recursive
Note

If you want to use a native Windows IDE or text editor to write your code, it is recommended, to clone your code outside WSL in your regular Windows file system. Your Windows file system is mounted in /mnt/c (for C:) within WSL.

Building the Project

Basic MAC applications always consist of a bootloader basicloader and a main application. Bootloader has to be built and flashed into the MCU only once.

To build it, change to the basicloader directory and type make:

cd basicmac/basicloader/build/boards/FMLR-72-X-STL0/
make
cd -

To build the application, change to the application directory

$ cd application

Make sure the correct module is specified in the Makefile as shown below

TARGET := fmlr_72_x_stl0

Now build the project

make

In the build-eu868 folder you can find the build-output and binaries (hex files).

Download Application

The EVK is providing an on-board J-Link programmer. Follow the guide using the on-board J-Link on how to install all necessary drivers and download your application onto the target device.

The EVK getting started guide explains how to use the EVK software and send data through LoRaWAN.

Commissioning your Device

In LoRaWAN® a device needs to be identified:

  • DevEUI: The Devices Extended Unique Identifier
  • JoinEUI (Or AppKey): links the device to back-end-application
  • NwKey: security key known by the device and the back-end to encode/decode the messages.

In Basic MAC this is hard coded in the persodata.c file.

void pd_init (void) {

    persodata_v1* ppd = pd_check_v1((void*) PERSODATA_BASE);
    if( ppd ) {
        pd = *ppd;
    } else {
        uint64_t eui;
        eui = 0x1aa72bf228286c1bULL;
        memcpy(pd.deveui, &eui, 8);
        eui = 0xC41BF8F9B18348DAULL;
        memcpy(pd.joineui, &eui, 8);
        uint8_t nwkkey[16] = {0xc3, 0x7f, 0xdd, 0xee, 0x5c, 0xce, 0x29, 0x88, 0xdf, 0x84, 0xea, 0xe3, 0x41, 0xd1, 0xbe, 0x4a};
        memcpy(pd.nwkkey, nwkkey, 16);
        memcpy(pd.appkey, nwkkey, 16);
    }
}
Important

Make sure you configure consistent LoRaWAN parameters such as DevEUi, AppEUI/JoinEUI and AppKey on your device and the network server.