Go Down

Topic: Is the whole program uploaded even if only one byte changed? (Read 1 time) previous topic - next topic

guix

Hello :)

I'm not sure where to post this question...

I am wondering if when I upload a program in which I did only small changes compared to the previous version of that program (changing for example byte a = 2 to byte a = 3), will the whole program be uploaded or just the changes?

My real question is, will uploading a program "damage" every memory cells it uses, even if only one memory cell was required to be changed? Considering "memory supports at least 10,000 writes or upload cycles"... I'm already at 2000+ uploads I think, and I haven't even done 10% of the code for my project, just testing things...

billroy

The whole program is uploaded every time.  The flash has 10x the wear endurance of the EEPROM that you quoted, so it is not a practical problem.

Not to worry. 

-br

Jack Christensen


The whole program is uploaded every time.  The flash has 10x the wear endurance of the EEPROM that you quoted, so it is not a practical problem.


Actually the other way 'round. Still seems like a lot though. From the ATmegaXX8 datasheet:

Quote
Features
• High Performance, Low Power Atmel®AVR® 8-Bit Microcontroller Family
• Advanced RISC Architecture
- 131 Powerful Instructions - Most Single Clock Cycle Execution
- 32 x 8 General Purpose Working Registers
- Fully Static Operation
- Up to 20 MIPS Throughput at 20MHz
- On-chip 2-cycle Multiplier
• High Endurance Non-volatile Memory Segments
- 4/8/16/32KBytes of In-System Self-Programmable Flash program memory
- 256/512/512/1KBytes EEPROM
- 512/1K/1K/2KBytes Internal SRAM
- Write/Erase Cycles: 10,000 Flash/100,000 EEPROM
- Data retention: 20 years at 85?C/100 years at 25?C(1)
- Optional Boot Code Section with Independent Lock Bits
In-System Programming by On-chip Boot Program
True Read-While-Write Operation
- Programming Lock for Software Security
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

billroy

Oops - sorry, you're right.  My mistake.

Still never been a practical problem here and I have a very old '328.

-br

Jack Christensen


Still never been a practical problem here and I have a very old '328.


Agree. If and when it does wear out, it's only a few dollars investment.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

guix

Well you are right, I use a Mega 2560 so can't replace chip (at least not easily) but (sainsmart's) Mega 2560 is like 15$ these days. But still, isn't it possible for the "uploader" (avrdude?) to "download" the current program that is on the chip, compare with the to-be-uploaded and if only few bytes changed only upload those bytes? Is it theorically possible and if yes, why it hasn't been made? It would greatly increase the lifetime of that flash memory right?

billroy

1. Small changes in the source code cause bigger changes in the executable.  Think about it: if you insert an instruction without changing anything else, everything after it is moved later in memory.

2. The flash memory is organized into pages anyway (see table 27-11 on page 299 of the '328 data sheet) which means you're writing large sectors for a 1-byte change.

3. To solve what real-world problem?

-br

PeterH


I'm already at 2000+ uploads I think, and I haven't even done 10% of the code for my project, just testing things...


Is this an exaggeration? I can't imagine how a project small enough to fit on an Arduino could require 2000 attempts to get 10% of it working. Are you uploading the code when you meant to just verify it, or something? You'd have to be uploading every five minutes for weeks on end to reach that sort of number of uploads.
I only provide help via the forum - please do not contact me for private consultancy.

guix

Well, I have an Arduino since approx 7 months, uploading on average 10 times a day... (that's how it works when you want to explorate and learn) so that's how I calculated those 2000+. Maybe you don't realize, but it goes quick.

Robin2

Divide the cost of a new Arduino by the number of hours you will have been programming before it wears out. If you do about 15 minutes of programming for every upload that works out at 2,500 hours before you use up the 10,000 uploads. £25 / 2,500 = 1p per hour. Not very expensive compared with your time.

...R

Grumpy_Mike

Quote
Is it theorically possible

yes
Quote
and if yes, why it hasn't been made?

because it is not a problem and it would take so much memory space in the boot loader that it would restrict the maximum program size.
But suppose you added one byte at the start of the memory then everything else gets shuffled down making all the code needing moving. So just changing one line in C might result in one more or less actual machine code instructions and that would shuffle everything.

Quote
It would greatly increase the lifetime of that flash memory right?

Yes, but to what end? Practically it is not a problem.

PeterH


Well, I have an Arduino since approx 7 months, uploading on average 10 times a day... (that's how it works when you want to explorate and learn) so that's how I calculated those 2000+. Maybe you don't realize, but it goes quick.


Bearing in mind that when the flash life runs out the failure symptoms are that the memory becomes 'leaky' and will eventually encounter bit errors if you leave it for long enough, if you keep using your arduino rather than leaving it for months and years without being reprogrammed, it is likely you will be able to massively exceed the specified life without encountering any errors. And, if it does encounter any errors you can resolve them by reloading your sketch. And if you get fed up with that it's only a couple of bucks to replace the chip, although I suppose by the time you reach that point these chips will be obsolete and will have been replaced by something with the same form factor but a million times more powerful.
I only provide help via the forum - please do not contact me for private consultancy.

guix

OK, I will stop worrying about memory lifetime then :)

Go Up