FirmwareUpdater

Overview

Network features on mbed is great. So there are so many mbed application in our world.

Sometime I need to update these mbed application firmware.

So I implemented a firmware update class.

You can update mbed if you put on a new firmware with version text file automatically.

It's really easy to update mbed in the distance.

http://mbed.org/media/uploads/shintamainjp/firmwareupdaterimage.jpg

The library compare versions between binary on a server and local file system on mbed.

How to use it?

mbed side

Download your firmware. (e.g.: firm.bin) http://mbed.org/media/uploads/shintamainjp/firm.bin

Make the version text file for the firmware. (e.g.: firm.txt) http://mbed.org/media/uploads/shintamainjp/firm.txt

10

You can check the sequences if logging option enabled.

http://mbed.org/media/uploads/shintamainjp/firmwareupdatermbedside.jpg

Server side

Put on a new firmware on HTTP server. (e.g.: firm.bin) http://mbed.org/media/uploads/shintamainjp/firm.bin

Put on the version text file for the firmware (e.g.: firm.txt) http://mbed.org/media/uploads/shintamainjp/firm.txt

25

Setup the library on your application

#include "mbed.h"
#include "FirmwareUpdater.h"
#include "EthernetNetIf.h"

EthernetNetIf eth;
FirmwareUpdater fwup("http://mbed.org/media/uploads/shintamainjp/", "firm", true); 

// There are 2 files for the firmware.
//  1. firm.txt : firmware version file.
//  2. firm.bin : firmware binary file.

void check_newfirm() {
    if (fwup.exist() == 0) {
        printf("Found a new firmware.\n");
        if (fwup.execute() == 0) {
            printf("Update succeed.\n");
            printf("Resetting this system...\n\n\n\n\n");
            fwup.reset();
        } else {
            printf("Update failed!\n");
        }
    }
}

int main(void) {
  
    eth.setup();
 
    check_newfirm();

    // Your application is here.   
}

The library

FirmwareUpdater http://mbed.org/users/shintamainjp/libraries/FirmwareUpdater/latest/docs/classFirmwareUpdater.html

Description

exist()

Compare version files between on a server and on a mbed.

Return 0 if a version on a server higher than a version on a mbed.

execute()

Download a new firmware binary file to a temporary file.

Download a new firmware version text file to a temporary file.

Copy these new files to .bin and .txt.

reset()

Reset mbed.

The interfaces

The interfaces are very simple.

FAQ

Why it use a version information text file? Use the binary suffix!

The library need to check a version on a mbed and a server.

If there are so many versions it spent so much time.

So it use a simple version text file.

Why the extension of a version information text file is '.txt'?

It's for mbed.org! :)

You can use it.

Why it add a version suffix to a binary?

This is from a specification of LocalFileSystem for mbed.

The specification of LocalFileSystem

  1. File name: '8+3' rules.
  1. There is no time stamp.
  1. mbed interface controller check the binary name and the time stamp.

It means 'The firmware updater should change a binary name.'.

Why the name for FirmwareUpdater length is up to 8?

Please see another FAQ.

Why the library cleanup all .bin?

Please see another FAQ.

Where is the my storage on mbed.org?

Select "Add new notebook page" on your home.

http://mbed.org/media/uploads/shintamainjp/_scaled_fwup_step1.png

Press the "Browse" button on the dialog.

http://mbed.org/media/uploads/shintamainjp/_scaled_fwup_step2.png

Press "Upload file" button on the File browser.

http://mbed.org/media/uploads/shintamainjp/_scaled_fwup_step3.png

Select your target file.

http://mbed.org/media/uploads/shintamainjp/_scaled_fwup_step4.png

Limits

Please do not use this for a high reliability system.

The library sequence have some critical timings.


All wikipages