Software Update via Ethernet - the mbed application can pull down an updated application binary from a web server and activate that binary. This library works only with the LPC1768, as it relies on the magic-chip boot-loader mechanism.

Dependents:   WattEye X10Svr PUB_SWUpdate

Success!! With this library, a network connection, and a web server hosting a new binary image, you can update the mbed firmware over the air (FOTA) - well, at least via Ethernet so far.

As of March 2015, it has been tested with the following mbed official libraries:

And a custom derivation:

  • HTTPClient v33, v32, which includes a custom HTTPFile.

Part of the update process involves checking the integrity of the downloaded binary file, for both a checksum and the program (file) size. To create this additional information, a small perl script is used (the important part is only 20 lines of code). See the documentation in the header file.

After the new binary is successfully downloaded, the checksum and the size are evaluated and if correct, then the old binary file is removed (this is the only way to cause the new binary to activate).

The mbed can then be automatically reset to activate the new image, or this may be deferred in case there is some other process necessary for an orderly restart.

Details are in the SWUpdate header file, and PUB_SWUpdate is a publicly accessible demonstration program for this library.

Revision:
17:1d318666246c
Parent:
16:de99e872fc9d
Child:
18:5f7667d63a27
--- a/SWUpdate.h	Sat Jul 05 16:06:55 2014 +0000
+++ b/SWUpdate.h	Sat Jul 05 22:27:09 2014 +0000
@@ -99,11 +99,13 @@
 /// close FT;
 /// @endcode
 ///
-#include "mbed.h"
 
 #ifndef SWUPDATE_H
 #define SWUPDATE_H
 
+#include "mbed.h"
+#include "HTTPClient.h"
+
 // This defines the maximum string length for a fully qualified
 // filename. Usually, this will be pretty short 
 // (e.g. "/local/myprog.bin"), which should be 19 max with 8.3 filename.
@@ -122,16 +124,18 @@
 /// Bit-Field return codes from the SoftwareUpdate API.
 ///
 /// Various things can go wrong in the software update process. The return
-/// value is a bit-field that flags the possibilities.
+/// value is a bit-field that flags the possibilities, although usually there
+/// will only be a single bit set.
+///
 typedef enum {
     SWUP_OK               = 0x00,   ///< Software Update succeeded as planned.
     SWUP_SAME_VER         = 0x01,   ///< Online version is the same as the installed version.
-    SWUP_BAD_URL          = 0x02,   ///< Bad URL provided, File missing on server, etc.
-    SWUP_OLD_STUCK        = 0x04,   ///< Old file could not be removed,
+    SWUP_HTTP_BIN         = 0x02,   ///< HTTP get returned an error while trying to fetch the bin file.
+    SWUP_OLD_STUCK        = 0x04,   ///< Old file could not be removed.
     SWUP_VER_STUCK        = 0x08,   ///< Old version number could not be updated.
     SWUP_VWRITE_FAILED    = 0x10,   ///< Can't open for write the version tracking file.
     SWUP_INTEGRITY_FAILED = 0x20,   ///< Integrity check of downloaded file failed.
-    SWUP_HTTP_ERR         = 0x40,   ///< HTTP get returned an error
+    SWUP_HTTP_VER         = 0x40,   ///< HTTP get returned an error while trying to fetch the version file.
 } SWUpdate_T;
 
 
@@ -172,4 +176,15 @@
 ///
 SWUpdate_T SoftwareUpdate(const char *url, const char * name, Reboot_T action = AUTO_REBOOT);
 
+/// Get the HTTP transaction return code.
+///
+/// If something goes wrong with the communications with the server, SoftwareUpdate will
+/// respond with an SWUP_HTTP_VER or SWUP_HTTP_BIN return value. To learn more about 
+/// what went wrong, this API will provide the actual return code from the HTTP transaction.
+///
+/// @returns @ref HTTPResult code from the server transaction.
+///
+HTTPResult SoftwareUpdateGetHTTPErrorCode(void);
+
+
 #endif // SWUPDATE_H