Old flash data not purged upon sketch upload?

Nothing urgent or critical here...

I dug out an old board with an Atmel 168. I used it 8 years ago for a big project, 4 years ago for a different project, and more recently to start introducing my son to Arduino's and coding. It has always functioned fine and I have no issues with it. I seem to recall this is not a genuine Arduino Diecimila but a Freeduino that I soldered together.

Today for experimentation I yanked the 168 chip and dumped its contents with an external programmer. I was surprised to see that the flash still currently contains recognizable text from my original project, secondary project, and "Hello, World!" from its most recent use.

I always imagined that the flash was wiped prior to upload but I guess just changing necessary bits reduces write cycle wear and tear. I suppose for my purposes it doesn't matter if old data is left in flash but I was curious if this is standard procedure?

Much appreciated.

I always imagined that the flash was wiped prior to upload but I guess just changing necessary bits reduces write cycle wear and tear. I suppose for my purposes it doesn't matter if old data is left in flash but I was curious if this is standard procedure?

It depends on how you program the Arduino. If you program it using an ICSP programmer you will always overwrite the complete flash but if you upload using the serial interface and the bootloader you will write only to the size of the sketch uploaded. If an older sketch was bigger it will stay in the flash memory. You can change this behavior by modifying the bootloader but in average you will get longer upload times.

Yeah, I figured it was something along those lines. It makes sense, I was just a bit surprised to see remnants of projects past kicking around. Brought back some memories.

:slight_smile:

Also, sorry if I put this in the wrong forum area. I may have misunderstood the title programming (coding) as programming (writing data).