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.

The library compare versions between binary on a server and local file system on mbed.
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.

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
#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.
}
FirmwareUpdater http://mbed.org/users/shintamainjp/libraries/FirmwareUpdater/latest/docs/classFirmwareUpdater.html
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.
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 mbed.
The interfaces
The interfaces are very simple.
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.
It's for mbed.org! :)
You can use it.
This is from a specification of LocalFileSystem for mbed.
The specification of LocalFileSystem
It means 'The firmware updater should change a binary name.'.
Please see another FAQ.
Please see another FAQ.
Select "Add new notebook page" on your home.

Press the "Browse" button on the dialog.

Press "Upload file" button on the File browser.

Select your target file.

Please do not use this for a high reliability system.
The library sequence have some critical timings.
No tags
|
5 comments
Please login to post comments.
Is there any fallback if the new binary is faulty?