Writing to AVR signature bytes?

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a Mega16 on which I have somehow managed to erase all of the signature bytes to FF. It happened when I ran a program which had been assembled for the RAM layout of a different chip. Oddly, the program appeared partly to run (a 1-second LED flash based on Timer 1 was working), but next time I tried to program it, the signature bytes read out as FF FF FF.

I can make it program by forcing the programming utility to think it is a Mega16, but ideally I'd like to be able to restore the signature so that the chip works normally. I assume there is some way of writing to signature bytes, since it seems I did it accidentally, so does anyone know of any undocumented commands (preferably serial mode or self-programming, as I don't have a parallel programmer) which will allow me to write back the correct signature bytes?

Last Edited: Sun. Dec 10, 2017 - 06:00 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Funny, I didn't even know you could change device signature. So it works, still can be reprogrammed (and verified?), but the signature is messed up?

The Dark Boxes are coming.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

svofski wrote:
Funny, I didn't even know you could change device signature. So it works, still can be reprogrammed (and verified?), but the signature is messed up?

That's right. It seems to function OK in all other ways (though I haven't run any feature-rich programs in it yet).

The sig bytes seem to form part of a little extra bank of flash or EEPROM, typically 32 or 64 bytes (it varies between chip types). Either that, or it is mask programmed and I have blown it irreversibly - but that would seem rather odd to happen using no voltages over 5V in a circuit which seems to work correctly in other ways.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm sure there are some "undocumented commands" as you said, but till today I found none :-) for AVR. Anyway, interesting thing...

Real men don't use backups, they post their stuff on a public ftp server and let the rest of the world make copies.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The signature bytes are known only to the In-System Programming routines, Serial and Parrallel, which are not visable to the user program. On at least one chip I used, the 2313 I think, they even got it wrong, but it didn't matter. At one time, I asked Atmel what the signature bytes were for some chip. There first response, before digging up a list, was "So what? It is a arbritrary value which you don't need for any reason"

Laurence Boyd II

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Laurence Boyd II wrote:
The signature bytes are known only to the In-System Programming routines, Serial and Parrallel, which are not visable to the user program. On at least one chip I used, the 2313 I think, they even got it wrong, but it didn't matter. At one time, I asked Atmel what the signature bytes were for some chip. There first response, before digging up a list, was "So what? It is a arbritrary value which you don't need for any reason"

Well yes, I read them when programming in serial mode. My programming utility compares them to a table to decide what mode of programming to use, and to verify that it is the right sort of chip for the code compiled. I can force it to assume a particular chip type regardless of sig bytes read, but then I lose the self-checking ability.

Slightly more concerning is that the calibration value for the internal RC oscillator is held in the signature byte area, so my chip will presumably calibrate the oscillator at FF, which may well be too fast for reliable EEPROM writing. I assume this calibration byte is written post-manufacture, which suggests that the whole signature area is likely to be writable - and probably eraseable, which is what I appear to have done.

I suspect there are undocumented codes in the serial programming system which can write to these bytes, but rather than try codes at random (and risk damaging something else), I wondered whether anyone here already knew what they were.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I bet that besides the signature bytes, all the OSCCAL bytes have been erased, as well...
It has happened to me, too.

Giorgos.

I hope for nothing; I fear nothing; I am free. (Nikos Kazantzakis)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The STK500 interface program has a means of reading the factory OSC calibration. For my mega 8 the 1Mhz value is B2, so FF might not be so bad

Laurence Boyd II

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Giorgos_K wrote:
I bet that besides the signature bytes, all the OSCCAL bytes have been erased, as well...
It has happened to me. too.

The Mega16 has a 0x40-byte signature area, and this has all been erased to FF. The OSCCAL byte is the most-significant half of the first word of the sig area, with the identifying sig bytes in the least-significant halves of words 0-2. Some chips have non-FF values in other bytes of the sig area, but I haven't figured out what any of these mean.

Since the only thing that happened between programming correctly and losing sig bytes was that I ran a program compiled for the wrong address space, I assume something that program did managed to erase the sig area. This suggests it's either related to normal EEPROM writes, or possibly self-programming (though I would have thought it was difficult to get into self-programming mode accidentally).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Laurence Boyd II wrote:
The STK500 interface program has a means of reading the factory OSC calibration. For my mega 8 the 1Mhz value is B2, so FF might not be so bad

The table in the data sheet suggests that FF may well be above the range for reliable EEPROM or flash writes, though in practice I would probably get away with it. This chip isn't going to get used for anything more than breadboarding now anyway.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi can you tell me how i can read the signature byte

thanks 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

karimi4511 wrote:

Hi can you tell me how i can read the signature byte

 

With your programmer or within a program?

 

The latter is answered in the datasheet.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

Topic locked