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:
16:de99e872fc9d
Parent:
15:49cc43dcbbf6
Child:
17:1d318666246c
--- a/SWUpdate.cpp	Sat Jun 28 19:46:46 2014 +0000
+++ b/SWUpdate.cpp	Sat Jul 05 16:06:55 2014 +0000
@@ -133,11 +133,14 @@
     char fqurl[SW_MAX_URL];    // fully qualified url
     char verfn[SW_MAX_FQFN];     // local version file
     char fwfn[SW_MAX_FQFN];
+    char nameroot[7];
     uint16_t result = SWUP_OK;    // starting out quite optimistic, for all the things that can go wrong
     char buf[50];           // long enough for 3 comma separated numbers...
         
     INFO("SoftwareUpdate(%s,%s)", url, name);
-    snprintf(verfn, SW_MAX_FQFN, "/local/%s.ver", name);
+    strncpy(nameroot, name, 6);
+    nameroot[6] = '\0';
+    snprintf(verfn, SW_MAX_FQFN, "/local/%s.ver", nameroot);
 
     /* Read installed version string */
     int inst_ver = -1;
@@ -164,14 +167,14 @@
             INFO("          file size: %d", fsize);
             if (inst_ver != latest_ver) {
                 INFO("  Downloading firmware ver %d ...", latest_ver);
-                sprintf(fwfn, "/local/%s%02d.BIN", name, latest_ver);
+                sprintf(fwfn, "/local/%s%02d.BIN", nameroot, (latest_ver % 100));
                 snprintf(fqurl, 150, "%s/%s.bin", url, name);
         
                 HTTPFile latest(fwfn);
                 r = http.get(fqurl, &latest);
                 if (r == HTTP_OK) {
                     if (PassesIntegrityCheck(fwfn, cksum, fsize)) {
-                        if (!RemoveOtherBinFiles(name, latest_ver)) {
+                        if (!RemoveOtherBinFiles(nameroot, latest_ver)) {
                             ERR("  *** Failed to remove old version(s). ***");
                             result |= SWUP_OLD_STUCK;
                         }
@@ -209,7 +212,7 @@
             }
         }
     } else {
-        WARN("Failed to download online firmware version number.");
+        WARN("Failed to download online firmware version number. r= %d", r);
         result |= SWUP_HTTP_ERR;
     }
     return (SWUpdate_T)result;