OTA Upgrade Guide

Lightweight Mesh stack OTA upgrade guide
1. Overview
General network configuration during OTA programming is presented on the following figure:
Running network must consist of nodes that support OTA programming (include OTA client).
At the moment only non-sleeping nodes can be upgraded; it is up to the main application to
ensure that node that is being upgraded does not go to sleep.
OTA upgrade process is initiated by the server node. New firmware image is stored on the
PC and transferred to the server via UART under control of OTA Server Software which is
represented by a Python script.
Memory layout for 128 kB device is presented on the figure:
AVR architecture requires Flash programming code to reside in a Bootloader section, but
OTA code is too big to fit into this section, so only small programming API functions are placed in
a Bootloader section and they are called from the running application.
Received image is stored in a second half of MCU flash area and transferred into main
program location by Bootloader code under running application control. So it is possible to
receive a new image, but postpone actual upgrade until all nodes in the network have a new
image.
Bootloader code ABI (Application Binary Interface) must match ABI used in main program.
This means that Bootloader is compiler-dependant; the same compiler should be used for both
Bootloader and application. At the moment only GCC version of bootloader is available.
2. Preparing OTA-ready network nodes
1. Compile bootloader image using AS5
<lw_mesh>\apps\bootloader.
2. Program the board with bootloader image.
3. Set fuses as shown:
projects
or
Makefiles
located
in
4. Compile application image using AS5 projects or Makefiles located in
<lw_mesh>\apps\WSNDemo. Make necessary setting in config.h (Pan Id, address,
channel, etc). Check that APP_ENABLE_OTA is defined (default).
5. Connect serial port cable and open terminal emulator capable of sending files using
Xmodem protocol (for example HyperTerminal). Port settings are 38400 8N1.
6. To enter bootloader mode power on/reset the board while holding button down (the only
button in case of RCB and SW1 in case of MeshBean). Terminal emulator should receive
capital letter “C” every second.
7. Uploading binary image (.bin) obtained in a step 4. For HyperTerminal select “Transfer”,
“Send File…”, browse for file name and select “Xmodem” as protocol:
And press “Send”:
8. After upload is finished application will start automatically. Now node is ready to be
upgraded over the air.
3. Preparing OTA Server (embedded)
1. Compile OTA Server image using AS5 projects or Makefiles located
<lw_mesh>\apps\OTAServerDemo. You may choose different board and/or compiler.
2. Program the board with OTA Server image.
3. Set fuses as shown:
in
4. Connect serial port cable.
5. Run python <lw_mesh>\tools\otaServerDemo.py -d -p COM26 -i 0x1234 -c 15 -a 0x8555
-t 0x0001 WSNDemo.bin
Where options are:
-d, --debug
enable debug output
-p PORT, --port=PORT
communication port [default COM1]
-b BAUD, --baud=BAUD
communication baudrate [default 38400]
-m, --comm
perform only server communication check
-i PANID, --panid=PANID
PAN ID [default 0x1234]
-c CHANNEL, --channel=CHANNEL channel [default 15]
-a ADDR, --addr=ADDR
server network address [default 0x8555]
-t CLIENT, --client=CLIENT
client network address [default 0x0000]
You should see output like this:
Port
: COM26
Baudrate
: 38400
Server
: 0x8555
Client
: 0x0001
PAN ID
: 0x1234
Channel
: 15 (0x0f)
Firmware
: WSNDemo.bin
Firmware size: 8268 bytes
-> UART_COMMAND_COMM_CHECK
<- APP_UART_STATUS_CONFIRMATION
<- APP_UART_STATUS_PASSED
* Comm check passed
-> UART_COMMAND_START_REQUEST
<- APP_UART_STATUS_CONFIRMATION
<- OTA_CLIENT_READY_STATUS
* Upgrade started
-> UART_COMMAND_BLOCK_REQUEST
<- APP_UART_STATUS_CONFIRMATION
<- OTA_CLIENT_READY_STATUS
* Block sent
-> UART_COMMAND_BLOCK_REQUEST
<- APP_UART_STATUS_CONFIRMATION
<- OTA_CLIENT_READY_STATUS
* Block sent
..............................
-> UART_COMMAND_BLOCK_REQUEST
<- APP_UART_STATUS_CONFIRMATION
<- OTA_UPGRADE_COMPLETED_STATUS
* Block sent
* File sent
It takes only few seconds to complete upgrade and once it is finished node will upgrade the
firmware, automatically reset and start with the new firmware running.