Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: hardwario/lora-modem
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.3.1
Choose a base ref
...
head repository: hardwario/lora-modem
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.3.2
Choose a head ref
  • 8 commits
  • 4 files changed
  • 1 contributor

Commits on Mar 25, 2023

  1. Copy the full SHA
    14ec919 View commit details

Commits on Mar 26, 2023

  1. Update README.md

    janakj authored Mar 26, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    032a9af View commit details
  2. Update README.md

    janakj authored Mar 26, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    20fab70 View commit details
  3. Update README.md

    janakj authored Mar 26, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    401b5c1 View commit details
  4. Update README.md

    janakj authored Mar 26, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    4cf0d45 View commit details
  5. Update README.md

    janakj authored Mar 26, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c0d535e View commit details
  6. Update README.md

    janakj authored Mar 26, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    698b503 View commit details

Commits on May 20, 2023

  1. Fix LoRaWAN MAC internal initialization

    This commit fixes the internal initialization of the LoRaMAC-node
    library. This firmware aims to be backward compatible with Murata Modem
    firmware which initializes the MAC in ABP mode upon factory default. We
    attempted to do the same, but the code that reconfigured the MAC into
    ABP mode upon factory default was incorrect. It put the MAC into
    incorrect state.
    
    As a consequence, not all state previously saved in NVM was correctly
    recovered, including a previously saved application key.
    
    Closes #132
    janakj committed May 20, 2023
    Copy the full SHA
    205b7c1 View commit details
Showing with 52 additions and 33 deletions.
  1. +19 −20 README.md
  2. +30 −10 src/lrw.c
  3. +1 −1 src/nvm.c
  4. +2 −2 tools/release.sh
39 changes: 19 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
# Open LoRaWAN Modem for Murata Type ABZ Module

This project develops an open-source LoRaWAN modem firmware for the [Type ABZ](https://github.com/hardwario/lora-modem-abz/wiki/Type-ABZ-Modules) wireless module by Murata. The firmware provides an AT command interface backward compatible with Murata Modem, Murata's proprietary LoRaWAN firmware. The firmware can be used on all Type ABZ variants with an open (user-reprogrammable) microcontroller (also known as OpenMCU).

We provide binary firmware images tailored to the following platforms:
* HARDWARIO [LoRa Module](https://shop.hardwario.com/lora-module/)
* HARDWARIO [Chester](https://www.hardwario.com/chester/)
* Arduino [MKR WAN 1300](https://store-usa.arduino.cc/products/arduino-mkr-wan-1300-lora-connectivity)
* Arduino [MKR WAN 1310](https://store.arduino.cc/products/arduino-mkr-wan-1310)
* ST [B-L072Z-LRWAN1](https://www.st.com/en/evaluation-tools/b-l072z-lrwan1.html) Discovery Kit

Although all above platforms embed the same Type ABZ module, there are slight differences in the configuration of the module's I/O ports.
This project develops an open-source LoRaWAN modem firmware for the Type ABZ wireless module by Murata. The firmware provides an [AT command interface](https://github.com/hardwario/lora-modem-abz/wiki/AT-Command-Interface) backward compatible with Murata Modem, Murata's proprietary LoRaWAN firmware. The firmware can be used on all Type ABZ [variants](https://github.com/hardwario/lora-modem-abz/wiki/Type-ABZ-Modules) with an open (user-programmable) microcontroller (also known as OpenMCU).

## Main Features

* Support for [LoRaWAN 1.0.4](https://resources.lora-alliance.org/technical-specifications/ts001-1-0-4-lorawan-l2-1-0-4-specification), [LoRaWAN 1.1](https://resources.lora-alliance.org/technical-specifications/lorawan-specification-v1-1), and regional parameters [RP2-1.0.3](https://resources.lora-alliance.org/technical-specifications/rp2-1-0-3-lorawan-regional-parameters)
* Support for [LoRaWAN 1.0.4](https://resources.lora-alliance.org/technical-specifications/ts001-1-0-4-lorawan-l2-1-0-4-specification), [LoRaWAN 1.1](https://resources.lora-alliance.org/technical-specifications/lorawan-specification-v1-1) ([note on compatibility](https://github.com/hardwario/lora-modem-abz/wiki/LoRaWAN-1.1-Compatibility)), and regional parameters [RP2-1.0.3](https://resources.lora-alliance.org/technical-specifications/rp2-1-0-3-lorawan-regional-parameters)
* Based on the most recent version (4.7.0) of [LoRaMac-node](https://github.com/Lora-net/LoRaMac-node)
* Support for multiple regions configurable at runtime
* All persistent LoRaWAN MAC data stored in NVM (EEPROM)
* Very low [power consumption](https://github.com/hardwario/lora-modem-abz/wiki/Power-Consumption) (1.4 uA when idle)

[A note on LoRaWAN 1.1 compatibility](https://github.com/hardwario/lora-modem-abz/wiki/LoRaWAN-1.1-Compatibility)
The project also provides a high-level [Python library and command line tool](./python) for managing Type ABZ LoRa modems. See this [README](./python/README.md) for more information.

## Installation

Binary firmware images for several platforms embedding the Type ABZ module are available from the [release](https://github.com/hardwario/lora-modem-abz/releases) page. We generate a pre-configured firmware [variant](https://github.com/hardwario/lora-modem-abz/wiki/Supported-Platforms) for each of the following platforms:
* HARDWARIO [LoRa Module](https://shop.hardwario.com/lora-module/)
* HARDWARIO [Chester](https://www.hardwario.com/chester/)
* Arduino [MKR WAN 1300](https://store-usa.arduino.cc/products/arduino-mkr-wan-1300-lora-connectivity)
* Arduino [MKR WAN 1310](https://store.arduino.cc/products/arduino-mkr-wan-1310)
* ST [B-L072Z-LRWAN1](https://www.st.com/en/evaluation-tools/b-l072z-lrwan1.html) Discovery Kit

The project also provides a [Python library and command line tool](./python) for managing Type ABZ LoRa modems. See this [README](./python/README.md) for more information.
The [STM32 Cube Programmer](https://www.st.com/en/development-tools/stm32cubeprog.html) or the Hardwario [firmware flashing tool](https://tower.hardwario.com/en/latest/tools/hardwario-firmware-flashing-tool/) can be used to flash the firmware into the Type ABZ module. Steps to flash the firmware into Hardwario Tower LoRa Module are described in the [wiki](https://github.com/hardwario/lora-modem-abz/wiki/LoRa-Module-Firmware-Update). Firmware update tool for the Arduino MKR WAN 1310 can be found [here](https://github.com/disk91/mkr1310_openLoRaModem_fw_update).

## Building

You will need the the embedded gcc toolchain for ARM (arm-none-eabi), git, and make to build the firmware from the source code. First, clone the repository and initialize git submodules:
You will need the embedded gcc toolchain for ARM (arm-none-eabi), `git`, and `make` to build your own firmware binary from the source code. First, clone the repository and initialize git submodules:
```sh
git clone https://github.com/hardwario/lora-modem-abz
cd lora-modem-abz
git submodule update --init
```
If you wish to customize the build, edit the variables at the beginning of the Makefile. Next, build the firmware in release mode:
If you wish to customize the build, edit the variables at the beginning of the Makefile (or override them at the `make` command line). Then run `make` to build the firmware in release mode:
```sh
make release
make
```
If you wish to build a development version with logging and debugging enabled, run `make debug` instead. Running `make` without any arguments builds the release version by default. *Please note that development builds have higher [idle power consumption](https://github.com/hardwario/lora-modem-abz/wiki/Power-Consumption) than release builds.*

## Installation
Follow the steps outlined in this [wiki page](https://github.com/hardwario/lora-modem-abz/wiki/LoRa-Module-Firmware-Replacement) to replace the proprietary firmware in HARDWARIO's [LoRa Module](https://shop.hardwario.com/lora-module/) with the open firmware.
If you wish to build a development version with logging and debugging enabled, run `make debug` instead. *Please note that development builds have higher [idle power consumption](https://github.com/hardwario/lora-modem-abz/wiki/Power-Consumption) than release builds.*

## Documentation
* [The Things Network (TTN) provisioning](https://github.com/hardwario/lora-modem-abz/wiki/TTN-Provisioning)
* [AT command interface](https://github.com/hardwario/lora-modem-abz/wiki/AT-Command-Interface)
* Other [similar projects](https://github.com/hardwario/lora-modem-abz/wiki/Related-Work)

Additional documentation and notes can be found in the [wiki](https://github.com/hardwario/lora-modem-abz/wiki).

## Contributing
40 changes: 30 additions & 10 deletions src/lrw.c
Original file line number Diff line number Diff line change
@@ -229,7 +229,7 @@ static void restore_state(void)
};
int rc = LoRaMacMibSetRequestConfirm(&r);
if (rc != LORAMAC_STATUS_OK)
log_error("LoRaMac: Error while restoring NVM state: %d", rc);
log_error("LoRaMac: Error while restoring NVM contexts: %d", rc);
}


@@ -658,41 +658,57 @@ static void log_network_info(void)
* firmware. It is meant to be called after the MIB has been initialized from
* the defaults built in LoRaMac-node and before settings are restored from NVM.
*/
static void set_defaults(void)
static LoRaMacStatus_t set_defaults(void)
{
LoRaMacStatus_t rc;

// The original firmware has AppEUI set to 0101010101010101
MibRequestConfirm_t r = {
.Type = MIB_JOIN_EUI,
.Param = { .JoinEui = (uint8_t *)"\1\1\1\1\1\1\1\1" }
};
LoRaMacMibSetRequestConfirm(&r);
rc = LoRaMacMibSetRequestConfirm(&r);
if (rc != LORAMAC_STATUS_OK) return rc;

// The original firmware has ADR enabled by default
r.Type = MIB_ADR;
r.Param.AdrEnable = 1;
LoRaMacMibSetRequestConfirm(&r);
rc = LoRaMacMibSetRequestConfirm(&r);
if (rc != LORAMAC_STATUS_OK) return rc;

/// The original firmware configures the TRX with 14 dBm in RFO mode
r.Type = MIB_CHANNELS_TX_POWER;
r.Param.ChannelsTxPower = 1;
LoRaMacMibSetRequestConfirm(&r);
rc = LoRaMacMibSetRequestConfirm(&r);
if (rc != LORAMAC_STATUS_OK) return rc;

#ifdef LORAMAC_ABP_VERSION
// If we are in ABP mode and the application has defined a specific MAC
// version to be used in this mode, set it now. There is no automatic
// version negotiation in ABP mode, so this needs to be done manually.
r.Type = MIB_ABP_LORAWAN_VERSION;
r.Param.AbpLrWanVersion.Value = LORAMAC_ABP_VERSION;
LoRaMacMibSetRequestConfirm(&r);
rc = LoRaMacMibSetRequestConfirm(&r);
if (rc != LORAMAC_STATUS_OK) return rc;
#endif

// The original firmware configures the node in ABP mode by default
lrw_set_mode(0);
// The original firmware configures the node in ABP mode by default. We
// cannot use lrw_set_mode here because that function performs join
// internally. Performing join would put the MAC in a busy state. Here,
// where we are initializing from defaults, internal join is not necessary
// anyway.
r.Type = MIB_NETWORK_ACTIVATION;
r.Param.NetworkActivation = ACTIVATION_TYPE_ABP;
rc = LoRaMacMibSetRequestConfirm(&r);
if (rc != 0) return rc;

// Disable LoRaWAN certification port by default
r.Type = MIB_IS_CERT_FPORT_ON;
r.Param.IsCertPortOn = false;
LoRaMacMibSetRequestConfirm(&r);
rc = LoRaMacMibSetRequestConfirm(&r);
if (rc != LORAMAC_STATUS_OK) return rc;

return rc;
}


@@ -728,7 +744,11 @@ void lrw_init(void)
return;
}

set_defaults();
// Initializing the LoRa MAC to defaults should never fail. If it does, we
// have a serious problem.
if (set_defaults() != LORAMAC_STATUS_OK)
halt("LoRaMac: Error while initializing to defaults");

restore_state();

r.Type = MIB_SYSTEM_MAX_RX_ERROR;
2 changes: 1 addition & 1 deletion src/nvm.c
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@


/* The following partition sizes have been derived from the in-memory size of
* the corresponding data structures in our fork of LoRaMac-node v4.6.0. The
* the corresponding data structures in our fork of LoRaMac-node v4.7.0. The
* sizes have been rounded up to leave some space for expansion in future
* versions. Whenever LoRaMac-node is modified, these sizes need to be
* reevaluated to make sure that each part is large enough to hold its data
4 changes: 2 additions & 2 deletions tools/release.sh
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@ $tar --exclude .editorconfig \
--exclude .gitignore \
--exclude .gitmodules \
--exclude .vscode \
--exclude obj \
--exclude build \
--transform "s,^,$name/," \
-zcf $firmware_dir/$name.tar.gz .
echo "done."
@@ -219,4 +219,4 @@ echo "done."
# Upload a new version of the Python library to PyPI.
echo -n "Uploading new package version to PyPI ... "
"$PYTHON" -m twine upload -u __token__ -p "$PYPI_TOKEN" python/*
echo "done."
echo "done."