0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Nope, exactly the same response from avrdude \$\endgroup\$ – Owen Tourlamain Aug 7 '16 at 21:17
0
\$\begingroup\$

I managed to find the answer: turns out whoever I bought this chip from (and the other chip) had set the bootloader lock on and, since my command was trying to set the bootloader lock off, the command was failing.

Avrdude reports that the lock is read back as 0x0C, which is my command (0xFC) minus the already set lock bits (0x0), so I had to change my command to: -U lock:w:0x0C:m

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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