Is there a way to change the date on a .bin file from within a program, reset the mbed and run a different program?

01 Apr 2010

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

02 Apr 2010

Nobody??  I'd think this would be handy for everyone...  It'd also be handy in my multi-mbed network for redundancy.... If one mbed dies, another mbed can change the bin file, reboot and take the place of the dead mbed...(considering most of them have nearly the same hardware tied to them).. 

I can't imagine it'd be too difficult..  Can someone point me maybe in the right direction to read up on the filesystem details in regards to changing file attributes, etc.?

02 Apr 2010

Thanks Andrew, but I was thinking more without the intervention of a computer... More programmatically from the mbed.

08 Apr 2010

Can nobody help with this?  As it turns out, this is pretty important to my work...  I would greatly appreciate some input... If not, then I'll press on.. =(  sniff.. sniff..

08 Apr 2010 . Edited: 08 Apr 2010

 

struct stat atr;

stat("/local/binary.bin",&atr);

 

stat command is part of stdc lib i think, look into that. I think your problem will being tricking the magic chip to re-write the bin into the cpu

08 Apr 2010

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

08 Apr 2010

Thanks, Jason and Simon!

Simon, that's certainly a direct approach!  That has me thinking now, since I'd like to jump back to the original at some point....  It'd be really nice to have rename or copy.. ;)  Thanks for the input..  I'm sure I'll figure something out.

I will certainly look into something along the lines of maybe a 'touch' routine, etc...

18 Apr 2010

HI Mike, thanks for the reply... !

My first concern would be the lifespan of the flash memory with so many read/write cycles...  But the idea sounds reasonable, and I don't see why that wouldn't work.. 

 

Thanks a bunch, I'm going to try some experiments.. This definitely gets me thinking...

-Mark

26 Jul 2010

Hi Mark,

Do you have this "switching bin file" method working?

 

I'd like to have user upgrade the "bin" file via USB connection. So it also involves writing a new bin file, delete the current bin file, and m_reset().

 

Any experience you can share? Thanks.

 

 

 

 

26 Jul 2010

Port the coreutils touch program =P

(I just looked at the source. Probably wouldn't look as bad if it wasn't 11pm)

17 May 2012

/media/uploads/HARGOVAN/screenshot_-_17_05_2012_-_17_29_56.png there is very simple way to change date and time of file,Just go to http://www.febooti.com and download free file tweek porgramme ,in stall it ,there after go to any folder including mbed usb stick . u can select any file by Rt clicking for property and u will get optipon to modify last modified or created date you can select any past or future date and make any file latest... MBED will load it

09 Jun 2012

Can one open the bin file for Binary Random Read/Write access, seak to the first byte, read that byte, and seak again and write the same byte with the same value, resulting in the file time stamp being updated?