Storing text file program in Arduino's EEPROM

Hi

It happens quite often that I upload a code to my Arduino, and after a wile I don't remember what program is it running.

Isn't there a way to get back the text program uploaded in an Arduino ?

I guess, the answer is no.

But isn't it possible to upload the text file in the same time uploading the compiled code, then retrieve the text file to see what it was ? Of course, the texte file would take some space whitch wouldn't be available for the compiled code.

Or maybe, automatically only upload a version and then be able to get back the right text file in a specific space on the working developing computer hard drive.

For example, when uploading to Arduino, it would upload a small name and version program name in the same time uploading the code.

Then, we could connect back the Arduino to the computerwith and with the Arduino IDE, get back , or link the text file program with the rightname and version.

This would be very helpful.

Hope my explanation are clear.

Like this:

#include <EEPROM.h>

char myFile[] =__FILE__;

void setup() 

{
  EEPROM.put(0,myFile);
  Serial.begin(9600);
  Serial.println(EEPROM.get(0, myFile));
}

void loop() 
{

}

Delta_G:
With GIT, I always have every version of every program I've written without needing to save a bunch of different versions. I can always go back to any version I've ever had before. It's a bitch to learn to use, but with Eclipse it's all built in and sort-of a little bit more user friendly.

hary,

There are GUI interfaces that integrate into the gui file managers for Windows as well as linux that make using git very easy to use. While the GUI can't do nearly everything that can be done from the commandline, it will do pretty much all that is needed, especially for small projects.

I use rabbitvcs on linux.

The nice thing about having git integrated into the gui file manager is that when you explore around, all the files have little icons on them indicating if the file has been changed, and you can click on a file and see how it was changed from the previous commit.

For revision information I use the output of:
git describe --dirty
and save it into a define in a version header file that can be used if desired.

That gives a string description that includes the most recent tag as well as a hash which can pinpoint the state of the code being used.

In the bigger picture, I think the most important thing a s/w person can do is to start using source control and git is what I'd recommend.
In my view source control is a necessity and part of being mature about programming.
I've been using source control all the way back to the early days with SCCS - which is very primitive in comparison to something like git.
Source control is much important than trying to keep a copy of source code in the part since that quickly becomes not possible and you could simply re-load the part from scratch after building everything in just a minute or two at most.
And using extra directories to hold various versions is also not recommended as it quickly gets out of hand.

Having your code in source control is extremely valuable and using one of the git GUIs that integrates into the gui shell/file-manager makes it really simple to use.
It becomes vital if more than one person is working on the code.
Also, if you use a tool like git you can go get a free account on sites like bitbucket or github and then push updates to it so that if your disk ever dies, you can quickly restore everything from the git repository.
bitbucket allows free private repositories if you don't want others to be able to see/get it.

--- bill

It happens quite often that I upload a code to my Arduino, and after a wile I don't remember what program is it running.

The below is pretty simple and should get the job done.

void setup() {
  Serial.begin(9600);
  Serial.println("serial delimit test 1.0"); // so I can keep track of what is loaded
}

zoomkat:
The below is pretty simple and should get the job done.

void setup() {

Serial.begin(9600);
 Serial.println("serial delimit test 1.0"); // so I can keep track of what is loaded
}

That is not reliable particularly for inter-revision tracking, because if using something that primitive, there is no guarantee that the string is always updated. And then how often do you update it? especially during your development?
In order to have something ALWAYS be meaningful it has to be automated. Otherwise what good is to have something that may or may not be accurate?
My opinion is that you would be far better off including a date and time string that is filled in by the compiler at compile time than depending on a manually maintained version information.
At least that way you know the date/time of when the module was built.

DATE is the local date as a const string
TIME is the local time as a const string

So this will print when the module was compiled.
(which may not be the same as the build date, if there are multiple modules and the module that prints this was not re-compiled)

Serial.println(__DATE__ " " __TIME__);

Another thing that could be done if you are really wanting to know what is stored in the flash, is to write a simple script that uses avrdude to read in the flash contents in binary and then use the "strings" command on that image and pipe its output to "grep" to look for your particular version string information.

But by far the best thing is to automatically create a string that tied into your source control so at any point in time in the future you can go back to the source code that was used to create that image.

--- bill

Delta_G:
Most of my big projects have a header that just defines one #define called GIT_HASH that I set to the GIT hash of the current version. Then somewhere at the beginning of my code it either prints that to serial or there is some back-door button sequence that will display it on an LCD or something.

That's pretty nice. Perhaps it might even be possible to something like ssh randomart, although for arduino projects it's probably more trouble than it's worth.

Best solution is probably simply:

Serial.println(F(__FILE__ " " __DATE__ " " __TIME__));

That is not reliable particularly for inter-revision tracking, because if using something that primitive, there is no guarantee that the string is always updated. And then how often do you update it? especially during your development?

It is only as reliable as the developer. If the developer can't keep a simple string updated, what are his chances of having the EEPROM updated? As usual, YMMV.

zoomkat:
It is only as reliable as the developer. If the developer can't keep a simple string updated, what are his chances of having the EEPROM updated? As usual, YMMV.

Delta_G:
With the little batch script I wrote it does it all by itself and is no trouble at all.

But therein lies the problem. Scripting is easy on *nix operating systems, but I'm guessing that the vast majority of Arduino users are using Windows rather than a more advanced OS.
Windows was not designed for s/w development so it doesn't come with command line tools.
So getting *nix type shell scripts to run on Windows machines is a challenge especially since they will often tend to use and depend on other command line tools that simply don't come with Windows.
And I think it is getting more difficult for Arduino users on Windows since I think the IDE is going to or has already stopped including the binutils with the Windows IDE package.
At least when the binutils were included, you could fire up a shell and have access to many other commandline tools that make stuff like this pretty simple. Now, in order to do that will require installing MinGW.

Yes, you can do quite a bit with Windows command/cmd .bat files but it is no substitute for having a real shell and a full suite of command line tools.

Windows was not designed for s/w development so it doesn't come with command line tools

Cygwin is useful.

AWOL:
Cygwin is useful.

It is. It is pretty much the same functionality and purpose as MinGW.
I've used them both for development when I had to, but still not as good as the real thing....

bperrybap:
Windows was not designed for s/w development so it doesn't come with command line tools.

I don't think it was even designed.

aarg:
I don't think it was even designed.

:slight_smile: so true...