Electrical – Can’t write lock bits on ATMega328p-pu

atmega328pavrdude

I'm trying to set the lock bits on my ATMega328p-pu, using an Arduino UNO as an ISP.

this is what happens:

>avrdude -c arduino -p m328p -P COM4 -b 19200 -U lock:w:0xFC:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "0xFC"
avrdude: writing lock (1 bytes):

Writing |                                                    | 0% 0.00s ***failed;
Writing | ################################################## | 100% 0.16s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0xFC:
avrdude: load data lock data from input file 0xFC:
avrdude: input file 0xFC contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x0c != 0xfc
avrdude: verification error; content mismatch

avrdude: safemode: Fuses OK (E:FD, H:DA, L:FF)

avrdude done.  Thank you.

I'm very new to using avrdude and have no clue how to proceed with debugging this issue.

EDIT: I've tried using another chip, but exactly the same response.

Best Answer

To use the Arduino as ISP you should specify avrisp as the programmer:

avrdude -c avrisp -p m328p -P COM4 -b 19200 -U lock:w:0xFC:m

See eg the Sparkfun tutorial on Arduino as ISP.

I can't confirm it right now but I believe the arduino programmer uses the serial protocol of the Arduino bootloader, though I thought that was essentially STK500, so I don't know why that is needed as a separate option. Maybe it is just a subset of STK500 that is implemented in the bootloader.

Related Topic