This application implements multicast firmware updates over LoRaWAN. It runs on Multi-Tech xDot devices with external flash (AT45 SPI flash by default) like the L-TEK FF1705.
The application implements:
Create an account at the experimental The Things Network FOTA deployment.
Point your gateway to router.fotademo.thethings.network
.
Create a new device in the The Things Network console.
Set your application EUI and application key in main.cpp
.
Install Mbed CLI and either ARMCC 5 or GCC ARM 6 (not 4.9!), and import this application:
$ mbed import https://github.com/armmbed/lorawan-fota-demo
Generate a set of keys to sign updates:
$ cd package-signer
$ npm install
$ node generate-keys.js your-domain.com your-device-model
Compile this application:
# ARMCC
$ mbed compile -m xdot_l151cc -t ARM --profile=./profiles/develop.json
# GCC
$ mbed compile -m xdot_l151cc -t GCC_ARM --profile=./profiles/develop.json
Flash the application on your development board.
If you're using a different flash chip, you'll need to implement the BlockDevice interface. See AT45BlockDevice.h
in the at45-blockdevice
driver for more information.
Updates need to be signed using ECDSA/SHA256. The private key is held by the manufacturer of the device, whilst the public key is baked into the device firmware. When an update comes in the signature is verified by the public key. In addition, firmware is tagged with the manufacturer UUID and the device model UUID. These are also baked into the device firmware. This is a prevention mechanism designed to avoid flashing incompatible firmware to devices.
To generate a new key pair, and to generate the UUIDs, run (requires OpenSSL):
$ node package-signer/generate-keys.js your-domain.com your-device-model
The update file format is:
00
.0
, then this is not a delta update. If 1
it's a delta update.These scripts uses the keys / device IDs in the package-signer/certs
folder.
Full update
A full update file can be created via:
$ node package-signer/sign-package.js BUILD/PATH/TO/BINARY_application.bin > full-new-fw.bin
Diff update
A diff update file can be created via:
$ node package-signer/create-and-sign-diff.js OLD_FILE_application.bin NEW_FILE_application.bin > diff-new-fw.bin
Make sure to tag the applications with a version number, and store them somewhere, to make your life significantly easier.