Over the air micro programming - OTAMP

OTAMP

Over the air micro programming allows you to use most serial bootloaders to program your micro as though your computer was connected by a cable. For instance, the Arduino IDE can be used without any modification or extra steps/applications, as was required with older solutions

OTAMP is not compatible with the Arduino Mega2560

How it works

The XRFs are configured to the required speed at both ends the PC XRF is set to send "remote reset requests". The remote reset is the key to making the magic happen. It senses a 'wiggle' on pin 16 of the XRF connected to your PC and then 'wiggles' pin 17 on the XRF at the remote end to perform a reset of the micro.

 

Configuring

  • First check you have serial comms between your PC and your remote micro. Don't go any further until you have done this; we have often seen people rush into remote programming and get very confused because this basic step had been missed
  • Connect the XRF you are going to use at the remote end to your PC. We will need to go into AT command mode (see here for how to do this, and make sure you've understood)
  • Find the baud rate for the bootloader you are using. Arduino(57.6K) is E100, later version UNO(115K) is 1C200
  • Decide on a 2 character name for this XRF from A-Z and A-Z. This is so you can have multiple devices that you can program by instructing the connected PC to "go program" xx

 

Before you start programming, there are two things to remember that will save you lots of confusion

  1. If you type too slowly the AT command mode will self exit after 5 seconds
  2. Once you have changed the baudrate, change your serial program also, or you'll be on the wrong speed.

 

  • Program the (remote) device with the settings:

In this example I'll set the ID to "GW" and the baudrate to 1C200 as I'm using an UNO loaded chip. The AT commands you need to issue are:

+++

ATBD1C200 (set baud rate to 115K)

ATMYGW (set this XRF ID to "GW)

ATRC3 (enable channel hop, moves the programming feature off the standard frequency; this is optional, but both ends need to match)

ATWR (write settings to flash)

ATAC (apply changes)

 

  • Remove the XRF, put it into/onto your remote micro
  • Plug in your second XRF, the one we will leave connected to your PC
  • Program the device with the settings:

In this example I'll set the ID to "GW" as before, and the baudrate to 1C200 as I'm using the Arduino IDE set to a UNO. The AT commands you need to issue are.

+++

ATBD1C200 (set baud rate to 115K)

ATRC3 (enable channel hop, moves the programming feature off the standard frequency, this is optional, both ends need to match)

ATRIGW (temporarily set the remote ID as "GW")

ATRP1 (turn on the generation of the remote reset request)

ATWR (write settings to flash)

ATAC (apply changes)

 

That's it, just remember in future to set the ATRI to the device you wish to program

 

Using ERF and URF for OTAMP

Both the ERF and the URF can be used for OTAMP, but there are a couple of subtle differences you need to be aware of

ERF - To issue AT commands to set the ERF you need to connect it to the PC via a serial connection.  This can be either an FTDI lead, XBee USB interface, or URF in wired serial mode.  The important thing here is that the TX and RX must be swapped

 

URF - The URF auto-detects the baud rate, so the ATBD should not be issued.

 

Remote reset: How do I know it's working?

By turning on a test mode at either end, you can see what is happening in plain text. We suggest using XCTU as it’s convenient and there’s a tick box to wiggle RTS (this is the pin connected on a ciseco USB interface - your interface may be using DTR instead). This control signal on pin 16 is identical to shorting pin 16 on the XRF to ground, so you can also do this manually with a wire.

When you have set up the XRF as shown below you will see MYRESETSENT. Once the far end is set to the settings below, you will get back MYRESETRCVD. You could also add an LED, which will flash for half a second (short leg to pin 17 and long leg to pin 1 (3v3)).


Master (PC Connected) XRF
+++
ATRP1
ATNT1 (testmode)
ATRIMY
ATWR
ATDN

Slave (Remote) XRF
+++
ATMYMY
ATNT1 (testmode)
ATWR
ATDN

 

How do I simulate Remote Reset?

If you suspect that a Remote Reset command is not being sent or received, you can manually reset the remote micro to see if it carries on programming.  The timing on this is critical though, so it might take a few tries to prove or disprove it

In the Arduino IDE, hold shift when clicking the 'Upload' button.  This turns on verbose mode, so you can see what's going on.  After a few seconds it will show avrdude: ser_open(): setting dtr followed by three lines showing avrdude: Send: 0 [30]   [20]  The reset button must be released whilst these 3 lines are showing.  

If the micro continues programming, then there is a problem with the reset not being sent, received, or acted upon.

 

Arduino's tested with XBS006 - XBEE shield

IOT Research OpenKontrol gateway - works out the box

Ciseco XINO basic for Atmel v1.5 - works, power via DC socket

Arduino UNO R3 - works, power via DC socket

Roboduino Duemilanove - works, power via DC socket

Wicked device Nanode 5 - works, power via USB socket (is just DC power)

 

What goes on under the covers

  • At the host end (PC)

ATRI sets the target for OTAMP

ATRP 1 says “When you detect DTR falling edge send a remote reset to the target and enter programming mode”

Programming mode uses a special PANID and also changes radio frequency by ATRC channels.

When in programming mode if no Serial data is received for ATRW seconds (default 5) exit programming mode

  • At the remote end

ATMY sets the ID of this device so that it can receive a remote reset

When a remote reset is received the host micro is reset and it enters programming mode

Programming mode uses a special PANID and also changes radio frequency by ATRC channels.

When in programming mode if no Radio data (on the remote programming PANID) is received for ATRW seconds (default 5) exit programming mode

 

RFµ-328 Default OTAMP Settings

As of 8th July 2013 the RFµ-328 ship with the following default settings for OTAMP

ATMY --

ATRC 3

ATBD 1C200 

Your Arduino Skectched will nedd to run at 115200 baud for serial

RFµ-328's shiped before this data had ATMY RF