0
\$\begingroup\$

I bought a used old pcb that contains an atmega 16L processor, however I suspect that one output pin is damaged, so I want to replace the chip. However the firmware is not available online, so I now want to read the firmware from the chip.

To do that, I unsoldered the chip from the pcb and put it into an 40 pin avr to ISP adapter which I connected to an arduino uno running arduino isp. I then tried to read the firmware using avrdude with the following command:

>>>: avrdude.exe -c avrisp -p m16 -P COM4 -b 19200 -F -U flash:r:"firmware.hex":i 
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x000000 (retrying)
avrdude: device signature = 0x000000 (retrying)
avrdude: device signature = 0x000000
avrdude error: Yikes!  Invalid device signature.
avrdude warning: expected signature for ATmega16 is 1E 94 03

avrdude: processing -U flash:r:firmware.hex:i
avrdude: reading flash memory ...
Reading | ################################################## | 100% 9.96s
avrdude: writing output file firmware.hex

avrdude done.  Thank you.

However if I open the file, it reads all zeros from 0x0 until 0x3fe0 where it ends.

:20000000<20 times 00>E0
…
:203FE000<20 times 00>C1
:00000001FF

I then thought something is wrong, so I tried another chip, writing to it and then reading it again and verifying it, but that all works.

I then tried to read the lock bits, but unfortunately I get the following error:

>>>: avrdude.exe -c avrisp -p m16 -P COM4 -b 19200 -F -U lock:r:-:h 
FEHLER: cannot read savebytes / lockbytes

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x000000 (retrying)
avrdude: device signature = 0x000000 (retrying)
avrdude: device signature = 0x000000
avrdude error: Yikes!  Invalid device signature.
avrdude warning: expected signature for ATmega16 is 1E 94 03

avrdude: processing -U lock:r:-:h
avrdude: reading lock memory ...
avrdude: writing output file <stdout>

avrdude done.  Thank you.

But why can I read the flash, but not the save/lockbytes (works for a brand new controller), and is there any reason why I only get zeros from the atmega16L processor? Does this mean there is no program on it, or could that mean that there is a read protection? But shouldn’t that throw an error?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ The device signature is also reading back as 0x000000. Suggests there is something wrong with the MISO line. \$\endgroup\$ Feb 23 at 19:59
  • \$\begingroup\$ @TomCarpenter Thank you for your tip, but unfortunately I have connected the chip the same way as a brand new chip that works without any error. So does this mean the chip is broken? Or can a locked chip also return 0x0 as signature? \$\endgroup\$
    – wolflu
    Feb 25 at 7:21

1 Answer 1

2
\$\begingroup\$

The chip is either broken or locked out (or not connected properly) and doesn't respond to any commands from the programmer. As you can see in the logs, avrdude already fails to identify the chip because it can't even read the device signature. Since the chip doesn't respond at all, you get zeros. It doesn't actually read the flash.

If you're sure that the chip is locked (instead of broken), you might be able to use one of the high-voltage programming modes (HVSP or HVPP) to get it to respond.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you for your answer. Good to know that a successful read (avrdudes progress bar was going from 0% to 100%) does not mean it reads successful. And regarding broken and locked, is there any way to figure that out? As I said, I bought the chip on a PCB and I’m not sure in what state the chip is. \$\endgroup\$
    – wolflu
    Feb 25 at 7:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.