Arduino sketch dissappears - bootloader still works fine - what's happening?

Hi fellows,

currently I've figured out a really, really strange behavior.

I designed a custom ArduinoMega board.
Then I flashed the bootloader by ISP and connected this board to my computer with an ArduinoUno board without AtMega238 (just removed the controller to use the serial converter only).

So far everything works fine.
Programming worked like a charm.
But now one of the users has a microcontroller that was flashed empty.
Bootloader still works and after dumping the memory I've seen this:

:1000000071C0000081C000007FC000007DC0000002
:100010007BC0000079C0000077C0000075C0000000
:1000200073C0000071C000006FC000006DC0000010
:100030006BC0000069C0000067C0000065C0000020
:1000400063C0000061C000005FC000FFFFFFFFFF52
:10005000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFB0
:10006000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA0
:10007000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF90
:10008000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF80
:10009000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF70
:1000A000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF60
:1000B000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF50
:1000C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF40
:1000D000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF30
:1000E000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF20
:1000F000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF10
:10010000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
:10011000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEF
:10012000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDF
:10013000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFCF
:10014000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBF
:10015000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAF
:10016000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9F
:10017000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8F
:10018000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7F
:10019000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6F
:1001A000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5F
:1001B000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4F
:1001C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3F
:1001D000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF2F
:1001E000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1F
:1001F000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0F
:10020000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE

...and so on...

So I wonder how this could happen.
If this happened a single time, I wouldn't wonder - just an user mistake, flashing an empty sketch.
But it happened twice, with two of my circuits.
And one of them absolutely didn't get in contact with an computer after being installed.

So what could cause this behavior?

I just have seen the hex-dump of one of the machines yet. But the second one didn't get in contact with any computer since it has been set-up properly.

Is there anything that can clear my sketch by hardware?
Or any known strange behavior of the arduinobootloader to clear a sketch without using a computer?

Are you sure the sketch was uploaded successfully to that unit? Was it previously tested? That's very strange.

Yes, it was. I testet all units and all connected sensors - outout was shown on the connected display.

On google+ some guys mentiones it could be any oscillating part on my self layouted PCB.
So I have to see what's going to happen on an oscilloscope.

Didn't have such behaviors till now - so I'm not exactly sure where to start fishing.

Well, maybe it would help to show the layout and schematic. Did you do bypassing correctly?

Using ground pours liberally helps. One of the dirty truths of electronics is capacitive coupling, which means a high impedance node can couple with other nearby signals. Again pour the ground everywhere possible to reduce the coupling. I'll link to my latest board to show the idea (though it may have some brain farts, I should have the first one in reflow in a day or so).

The problem was while turning on the motor there was a voltage-drop on RST-line. The Arduino-bootloader interpreted it as "watch out, new software incoming".

Then the PWM of the motor did the trick. Overwriting the whole sketch :smiley:

I cut the connection between the boost converter (which is needed for the motor voltage) and my puffer capacitor which now keeps the whole microcontroller on a continual high level.
Problem solved :wink: