5
\$\begingroup\$

I'm trying to set the fuses on an ATMega16U4 with avrdude. The first problem I encountered is that avrdude version 5.11.1 does not seem to support ATMega16U4. Someone mentioned on avrfreaks that you should just copy the ATMega32U4 block on avrdude.conf and change the signature, description and memory sizes to fit the ATMega16U4 and thats what I did, here is my avrdude.conf: http://paste.dy.fi/SQP

This seems to work but I'm not 100% convinced.

The actual problem is that avrdude is unable to set the fuses (I'm using my buspirate as the ISP programmer):

avrdude -c buspirate -p m16u4 -P /dev/ttyUSB0 -U lfuse:w:0xe2:m -U > hfuse:w:0xd8:m -U efuse:w:0xf8:m

Detecting BusPirate... **
** Bus Pirate v3a ** Firmware v5.10 (r559) Bootloader v4.4 ** DEVID:0x0447 REVID:0x3046 (24FJ64GA002 B8) ** http://dangerousprototypes.com ** BusPirate: using BINARY mode avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9488 avrdude: reading input file "0xe2" avrdude: writing lfuse (1 bytes):

Writing | | 0% 0.00s >***failed;
Writing | ################################################## | 100% 0.07s

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

Reading | ################################################## | 100% 0.00s

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

avrdude: safemode: lfuse changed! Was e2, and is now 5e Would you like this fuse to be changed back? [y/n] y

It seems to be able to read the microcontroller just fine, reads the correct signature and reads the correct (default) fuses but fails to change them.

Here is a more detailed avrdude printout with -vvv: http://paste.dy.fi/JA6

I'm using a 12MHz crystal with 22p ceramics and I have a 4.7kohm pull-up resistor on the reset.

Does anybody have any idea why it is not working? I've gone through the connections with a multimeter etc. several times and they are all ok. I also doubt that reading the device would even work if the connections had a problem. The ATMega is brand new, never used, never programmed (so the lock fuses are not set) etc.

\$\endgroup\$
  • \$\begingroup\$ I am now QUITE sure the problem lies in the avrdude.conf. A friend of mine ran in to the same problem. \$\endgroup\$ – Dago Aug 9 '12 at 18:28
6
\$\begingroup\$

SOLVED IT! For some reason the AVR ships with the lock bits enabled!? According to the datasheet this is how it is specified. Erasing the chip disables the lock bits and enabled me to program the fuses.

\$\endgroup\$
  • \$\begingroup\$ Dago, How do you erase the chip? \$\endgroup\$ – sanotronics Apr 30 '15 at 16:40
  • \$\begingroup\$ How did you do that? \$\endgroup\$ – barej May 29 '15 at 23:08
  • \$\begingroup\$ I figured out that if you program with with something first before setting the fuses will do the job. Doesn't matter what hex you use to program, just flash it with anything \$\endgroup\$ – Hans Aug 10 '16 at 2:15
  • \$\begingroup\$ I have the same issue with attiny85. Current efuse value is 0x62. I have no idea about how it happened. I tried erasing and uploading different hex. But everything end up with 'verification error' \$\endgroup\$ – Sanu - Open Maker Mar 13 '17 at 13:46

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.