Arduino Pro Mini Library to embed a self update mechanism.
A serial connection with a host computer can put the device into an update mode where it continuously reboots to wait for the new program to be uploaded.
The library requires 2 pins :
- 1 for the reset command, it triggers the reset pin through a condenser/resistor buffer.
- and one for the cancel switch (or jumper). It can be used for another purpose after the library's setup method has been called.
###Software
####Arduino
The most simple Arduino Sketch is :
#include "ProMiniUpdate.h"
#include <EEPROM.h>
#define VERSION 1
#define APPLICATION "net.alexisisaac.arduino.pmu.test"
ProMiniUpdate pmu(VERSION, APPLICATION,A3,2,0);
void setup(){
pmu.setup();
}
void loop(){
pmu.loop();
}
The parameters for the constructor are :
- Application Version (
unsigned int
>0) - Application id (
String
only letters, numbers and dot symbol) - Reset pin(see hardware)
- Cancel pin (see hardware)
- EEPROM address offset
####Updating tool Steps :
- Finding the Serial port
- It can be done by multiple ways, for instance listing all the serias ports availabke before the user plugs the device then list them again once plugged.
- Conecting to the device
- using those parameters 960b bauds, 8 data bits, no parity, one stop bit.
- Requesting the current verstion of the libraryand checking the application id and current application version.
- Sending the command
HELLO PMU\n
will returnHELLO UPDATER(pmu_version, app_version, app_id)\n
- Putting the device in update mode
- Sending the command
UPDATE PMU\n
the device will respond with :READY FOR UPDATE\n
- Send the new program using thestandard avr tools
If a command isn't understood the device will respond with UNK command\n