ATMEGA 2561 losing first page of flash

  • 1
  • 2
  • Page 1 of 2
mc-electronic
Benutzer
Avatar
Gender: n/a
Location: Sauerland NRW
Posts: 372
Registered: 03 / 2008
Subject:

ATMEGA 2561 losing first page of flash

 · 
Posted: 01.09.2013 - 12:24  ·  #1
Hi all,

I am using ATMega 2561 processors in my data loggers. So far, I was happy with the devices. However, in the series of devices, that were delivered last year to me, I have encounterd the problem, that after a power off / power on sequence the data loggers do not start up anymore.

I searched and found, that the first page ( = 256 bytes) of flash memory is overwritten by $FF, i.e. the page is erased. So, the first 256 bytes of the program are missing..

I have absolutely NO idea what the reason for this is. I can reproduce it on one device by switching in off and on again for five to ten times - then all of a sudden the first page is erased.

Any ideas for the reason of this phenomen? Can I do something to prevent it?

Thanks for any help, Michael
mc-electronic
Benutzer
Avatar
Gender: n/a
Location: Sauerland NRW
Posts: 372
Registered: 03 / 2008
Subject:

Re: ATMEGA 2561 losing first page of flash

 · 
Posted: 01.09.2013 - 15:52  ·  #2
I think, I could locate the source of the problem. My systems use self-programming routines for the program flash, so if something erratic happens in the program, there is the chance, that the Flash-Write routines get invoked. That could explain the erasing of the first page.

So I did some testing and found out, that only Optimized (Merlin Optimizer) programs show this behaviour. I used older versions of the optimizer (I have not all of them, but some) and found, that the problem starts with Optimizer Version 3.2.1.19. If I use Version 3.2.1.17, I have no problem. (3.2.1.18 I do not have)

I will contact Merlin directly to get further.

Michael
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: ATMEGA 2561 losing first page of flash

 · 
Posted: 01.09.2013 - 16:15  ·  #3
Hello Michael,

it would be helpful if you compare these two types of ASM files generated by the
two different Optimiser versions. Maybe this is not a real problem of the Opti but
the operation speed of the two program versions may differ heavily in some parts.

rolf
mc-electronic
Benutzer
Avatar
Gender: n/a
Location: Sauerland NRW
Posts: 372
Registered: 03 / 2008
Subject:

Re: ATMEGA 2561 losing first page of flash

 · 
Posted: 01.09.2013 - 16:33  ·  #4
Hello Rolf,

a good thought. It seems to happen with some loggers more often, than with others (I have 2 devices showing the problem, others didn't so far). And the problem only happens during the Hardware initialization process at the beginning. The hardware is not always the same, depending on the LCD and the SD-Card, both using SPI. I will extend some of the mDelay calls at the beginnig to see, if I get rid of the problem.

And also: 3.2.1.19 saves 1 k more than the "old" Version 3.2.1.17 (which is OK), so maybe it is faster (or something is missing ;-))

Have a nice sunday, Michael
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: ATMEGA 2561 losing first page of flash

 · 
Posted: 01.09.2013 - 17:40  ·  #5
Hello Michael,

if there is a startup problem maybe SUTx and BODLEVELx can help.

rolf
mc-electronic
Benutzer
Avatar
Gender: n/a
Location: Sauerland NRW
Posts: 372
Registered: 03 / 2008
Subject:

Re: ATMEGA 2561 losing first page of flash

 · 
Posted: 01.09.2013 - 18:18  ·  #6
Hi Rolf,

SUT1 and BodLevel0 and BodLevel2 Fuses are set, thus activating the Brown Out at 4,3 V. I hope, you approve....
I had tested tested these settings with a lot of power losses, flicker tests, surges etc. The EMC Test GmbH in Kamp Lintford applied some stress to the loggers, but they survived - glad to say that. But you are right, when it comes to initializing hardware, timing matters are important. I will do the tests tomorrow morning, and check, if just the speed increase of the optimizer is the reason.

Michael
mc-electronic
Benutzer
Avatar
Gender: n/a
Location: Sauerland NRW
Posts: 372
Registered: 03 / 2008
Subject:

Re: ATMEGA 2561 losing first page of flash

 · 
Posted: 02.09.2013 - 07:41  ·  #7
Hello Rolf,

you were right, it is not an Optimizer error. Finally I solved the problem: I inserted a mDelay(300) before initializing the Ports, the ADC registers, the ACSR and the Soft I2C of the ATMega. It is the second command after a power up now. That seems to solve the problem. Small thing, big issue.

But why the first Flash Page of the µP got erased, that is still a mystery to me. Quite a rough behaviour - and strange, that the little delay keeps the optimized programs from doing it.

Anyway, I am glad, that the problem is gone.

Thank you; Michael
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1373
Registered: 03 / 2005
Subject:

Re: ATMEGA 2561 losing first page of flash

 · 
Posted: 02.09.2013 - 10:10  ·  #8
Hi Michael.

I am curious myself also. Please send me your asm/dsm files so that I can investigate and see if I can do something to prevent other users experiencing this. Did you base your boot loader on the standard samples provided with the compiler?
  • 1
  • 2
  • Page 1 of 2
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   135   149 · Page-Gen-Time: 0.022009s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI