How to wipe the arduino memory every time it boots up

Hi guys,
I just wrote a simple blink Led program to blink an led. However I observe that it is stored every time I boot back(which is exactly what it is supposed to do). Is there any way to clear the memory every time it boots.(Pressing the reset switch does not appear to do the trick)

I'm going to have to ask "Why do you want to do this?"

The answer to your question is "yes", but you'd have to modify the bootloader, and it would adversely affect the lifetime of your processor' program memory.

Usually you would want the code to stay on the board, otherwise as soon as you finish uploding and plug the arduino in somewhere else it would be empty, not too practical
you could perhaps make it seem like it forgot the progamm by using eeprom and checking how many ttimes its been reset since upload and after so many times stop everything

Simple answer, "No".
Longer answer, "Not without a computer, or another IC acting to tell the bootloader to erase the chip"

Extended answer, "The flash memory of the atmega chip has a limited number of program cycles (about 100000). If you erase the flash every time you turn the arduino on, you will just rapily wear out the flash, ultimately making the board useless whilst not actually achieving anything at all."

Why?


Rob

Why rob?

To get money, of course!

AWOL:
Why rob?

To get money, of course!

If being a Moderator let's one get away with posting puns this bad, that alone is almost worth all the extra responsibility. :wink:

Puns are the rare moments of joy, punctuating the grind of beating off spammers and moving mis-posts.
Besides, you don't have to be a mod to post puns.

Okay everyone. The why is a really difficult question to answer , I just felt like knowing if this is possible . So the most appropriate answer to that would be I was curious :P. Apart from that there is no real use. :slight_smile:
How do we erase the memory of the flash using the IDE? Or is this possible only if we upload a new program or can I do it manually also.

How do we erase the memory of the flash using the IDE?

Only by uploading a new sketch. Could be a do-nothing sketch like:

void setup() {}
void loop() {}

Okay Thanks!

Or using AVRDude. From a command line type AVRDude and look at the command list that it print out.

D:\Arduino\arduino-1.0.1\hardware\tools\avr\bin> ar

d - delete file(s) from the archive
m[ab] - move file(s) in the archive
p - print file(s) found in the archive
q[f] - quick append file(s) to the archive
r[ab][f] - replace existing or insert new file(s) into the archive
s - act as ranlib
t - display contents of archive
x[o] - extract file(s) from the archive
command specific modifiers:
[a] - put file(s) after [member-name]
__ - put file(s) before [member-name] (same as )__
[D] - use zero for timestamps and uids/gids
[N] - use instance [count] of name
[f] - truncate inserted file names
[P] - use full path names when matching
[o] - preserve original dates
- only replace files that are newer than current archive contents
generic modifiers:

```c
[u]*[u]          - do not warn if the library had to be created
[s]          - create an archive index (cf. ranlib)
[S]          - do not build a symbol table
[T]          - make a thin archive
[v]          - be verbose
[V]          - display the version number
@      - read options from
–target=BFDNAME - specify the target object format as BFDNAME

Sp I am guessing the command is ar -d. Is that right?[/u][/u]
[u]__
```*__[/u]

no. ar and avrdude are completely separate programs.

./avrdude -p atmega328p -C ./avrdude.conf -c arduino -b 115200 -P /dev/ttyACM0 -e

in the hardware/tools directory should erase the chip.

Of course, replace /dev/ttyACM0 by whatever com port the arduino is on.

Fierce:
Okay everyone. The why is a really difficult question to answer , I just felt like knowing if this is possible . So the most appropriate answer to that would be I was curious :P. Apart from that there is no real use. :slight_smile:
How do we erase the memory of the flash using the IDE? Or is this possible only if we upload a new program or can I do it manually also.

So you erase the flash and the Arduino does nothing.
Plus you've used up one of your many but finite number of flash loads for 'nothing'.
Are you sure it's the flash you want to clear?

If you want no one to be able to read your code then see about setting lock bits.

Apart from that there is no real use.

We are up to reply #14 for something that is not useful. Ah well.

EFTPOS (dunno what its called overseas) have a self destruct mechanism if the cover is opened. I believe it works by keeping the crypto in volatile kept alive by a battery backup. If the cover is opened the power to the volitile is lost = dead unit.

Okay. thanks for the response everyone!

The arduino bootloader does NOT support the "erase chip" command.
It can only overwrite with something else.