Hi Mark,
One way to show it can be done is just to remove the running file. Assuming you have two binaries, of which "first.bin" is the newest one containing the following:
#include "mbed.h"
DigitalOut myled(LED1);
LocalFileSystem local("local");
extern "C" void mbed_reset();
int main() {
for(int i=0; i<10; i++) {
myled = !myled;
wait(0.25);
}
remove("/local/FIRST.BIN");
mbed_reset();
}
This should run, then delete itself, then perform a reset so the next binary runs.
We don't support rename() or copy(), but you could possibly make your own using read/write to give you more flexibility (e.g. extensions that are .mkx or something, copied to .bin). Embedded filesystems are a bid adhoc beyond fopen/fwrite, so we only defined the lowest common denominator (as there is no operating system like linux). Perhaps this is an opportunity for specifying some more posix-like additional functions for manipulating files, but for now I think fudging files is your best bet.
Simon
I'm wondering... I recall reading that the mbed determines which .bin file to run on startup based on whichever has the most recent date. Is there a way to have several .bin files, the mbed boots from the latest one, and somewhere in the program if needed the running program select another .bin file from the local filesystem and change it's date so it is the most recent and then reset the mbed to boot from the alternate .bin file? This could be useful for many reasons and I can't see any reason other than my limited experience with the mbed that it shouldn't work...
Any input would be great!
-mark