Practical library series : Firmware updater
.
Languages
日本語版はこちら: 実用ライブラリシリーズ:ファームウェアアップデーター
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.
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.
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
FirmwareUpdater fwup("http://mbed.org/media/uploads/shintamainjp/", "firm", true);
Description
- 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 test program
#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
FAQ
Why it use a version information text file? Use the binary suffix!
The library 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 mbed.org server.
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. 2. There is no time stamp. 3. mbed interface controller check the binary name and the time stamp. It means 'The firmware updater should change a binary name.'.
Why the name 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. Press the "Browse" button on the dialog. Press "Upload file" button on the File browser. Select your target file.
Limits
- Please do not use this for a high reliability system.
- The library sequence have some critical timings.
1 comment
You need to log in to post a comment
When I try your example program, I get an error
Error: Cannot open source input file "TCPSocketConnection.h"
When I add the Socket library manually, I get a lot of new errors...
Thus this example still work or are the httpcleint libraries changes sinds it was published?