by mike31416 » Fri Jan 18, 2013 6:49 am
Hello,
The AVRDUDE option -y will use the last 4 bytes of the EEPROM to track the number of times a new sketch is uploaded. The -Y option lets you set the initial value of the tracking counter. Perhaps you can use the -y option in conjunction with another EEPROM value to detect that an upload has been performed (save the tracking value in another location and compare the two on application startup).
The AVRDUDE option -e will erase both the flash and EEPROM. Note, there is a bit in hfuse that will disable the EEPROM erase while using this option. I believe the default is set to allow the EEPROM erase.
Be aware that there is a finite number of times you can reprogram EEPROM. The atmega168 allows 10,000 flash and 100,000 EEPROM erases. Might seem to be a lot, but if your code goes wild it can wear it out.
Mike