firmware update from USB stick, does not work properly. If someone can get it work, please inform me.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "FirmwareUpdater.h"
00003 
00004 FirmwareUpdater  fwup("firmware", "firmware", true);
00005 // There are 2 files for the firmware.
00006 //  1. firmware.txt : firmware version file.
00007 //  2. firmware.bin : firmware binary file.
00008 Serial pc(USBTX, USBRX); // tx, rx
00009 
00010 
00011 DigitalOut myled(LED1);
00012 
00013 int main() {
00014     printf("execute update\r ");
00015     if (fwup.exist() == 0) {
00016         printf("Found a new firmware.\n\r");
00017         if (fwup.execute() == 0) {
00018             printf("Update succeed.\n\r");
00019             printf("Resetting this system...\n\n\n\n\n\r");
00020             fwup.reset();
00021         } else {
00022             printf("Update failed!\n\r");
00023         }
00024     }
00025     while (1) {
00026         myled = 1;
00027         wait(0.2);
00028         myled = 0;
00029         wait(0.2);
00030     }
00031 }