Option to include sketch in flash?

westfw:
The idea has usefulness that is somewhat inversely proportional to how likely it is to work.

It works really well for small sketches like BLINK, but who cares? As your sketch gets bigger and more complicated, it would be more useful, but it's less likely to work :frowning:

It would work for much more complicated sketches than just Blink. It either works or it doesn't, and you can discover that at the time you compile your sketch so you can adjust your development style accordingly. I think some folks would use this all the time when possible, and some folks would never use it.

westfw:
Saving a copy of the source doesn't get rid of the need for reasonable discipline in version control.

Sure it does. Obviously if there are intermediate versions that I care about, then it is up to me to archive them responsibly - this is true of any content I create. But with Arduino, most of the time I only care about the code that is on the board right now. In fact, I can't think of a single time that I've needed an arbitrary intermediate version of a sketch, but I can think of dozens of times that I've had to go back and make sure I picked up development from the right version of a sketch.

To provide a more concrete example: I make haunted house animatronics, and I use lots of Arduinos to run servos, pneumatics, lights, etc. The sketches are pretty straight forward sequencing (wait for a PIR sensor to fire, cycle through a fixed sequence and then reset). Each prop is hand made and slightly unique. Also, each year, the exact needs of the haunted house may be slightly different (might want to tweak the timing).

So, when I am setting up a prop that needs tweaking, I have to count on my notes to make sure I'm not loading the wrong firmware. I'd much rather plug in my laptop (or any random laptop for that matter), extract/tweak/upload - done. No chance that I picked the wrong firmware, and I really don't care about the timings that the haunted house 3 years ago used.

I agree that from a computer science purist perspective it is a sloppy approach, but in this real-world situation it would absolutely save me time and reduce mistakes.

westfw:
If you have 16k of source with no other markings (like version numbers), and are trying to figure out what it does compared to other source for the same sketch that is 6 months newer (or older), you're probably ... in trouble.

I'm not suggesting that. I simply suggesting putting the current source with the executable. It isn't intended to help you compare versions, or determine history. It is just intended to keep the source and the product together in one place.

Version control is always a good idea. But having a copy of the source on the device that you are 100% sure matches the code on the device eliminates all variables and mitigates bad version control practices, hard drive failures, etc. It also works if you give the project to a friend and they want to continue hacking on it.

westfw:
I wonder if some intermediate level of information stored in flash would be nearly as useful? Sketch name and date, perhaps (+ username + computername + ip address? Gotta make those arduino chips traceable in case someone uses them for evil purposes.)

That would be fantastic, and I'd support getting that info into the flash 100% of the time. I'd also love to see the IDE include integrated version control, even if it is just something trivial and linear. But all that aside, I still don't see why putting the source code into flash would ever be a bad thing if it fits.

Cheers,

  • Dean