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:
27:3d3089b8212d
Parent:
26:f2bb6061dcb3
--- a/SWUpdate.h	Mon May 07 19:56:00 2018 +0000
+++ b/SWUpdate.h	Sun Jul 14 01:40:36 2019 +0000
@@ -166,22 +166,22 @@
     AUTO_REBOOT     ///< Automatically reboot to activate the new firmware.
 } Reboot_T;
 
-/// Bit-Field return codes from the SoftwareUpdate API.
+/// Value return code 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, although usually there
-/// will only be a single bit set.
+/// value indicates the error.
 ///
 typedef enum {
     SWUP_OK               = 0x00,   ///< Software Update succeeded as planned.
     SWUP_SAME_VER         = 0x01,   ///< Online version is the same as the installed version.
     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_VER         = 0x40,   ///< HTTP get returned an error while trying to fetch the version file.
-    SWUP_NO_SPACE         = 0x80,   ///< No space on file system for new version.
+    SWUP_OLD_STUCK        = 0x03,   ///< Old file could not be removed.
+    SWUP_VER_STUCK        = 0x04,   ///< Old version number could not be updated.
+    SWUP_VWRITE_FAILED    = 0x05,   ///< Can't open for write the version tracking file.
+    SWUP_INTEGRITY_FAILED = 0x06,   ///< Integrity check of downloaded file failed.
+    SWUP_HTTP_VER         = 0x07,   ///< HTTP get returned an error while trying to fetch the version file.
+    SWUP_NO_SPACE         = 0x08,   ///< No space on file system for new version.
+    SWUP_NO_FILE          = 0x09,   ///< Specified file on the server does not exist
 } SWUpdate_T;
 
 
@@ -237,7 +237,7 @@
 /// @param[in] r is the result code to translate into a message
 /// @returns a pointer to a text string of the message
 ///
-const char * SoftwareUpdateGetHTTPErrorMsg(HTTPResult r);
+const char * SoftwareUpdateGetHTTPErrorMsg(SWUpdate_T r);
 
 /// Get the installed software version number.
 ///