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?