AVR Butterfly Part 2: Setting the BOOTRST Fuse with ISP Cable

11 07 2009

With a little more research I decided to hack together an ISP programming cable using a computer parallel port to toggle the BOOTRST (Select Reset Vector) fuse on my AVR Butterfly, rather than send it to someone to fix it or back to Mouser. Schematic shown below,

direct_ave_parallel_access_cableNOTE: the 1K resistor going from pin 11 of the DB25 to the MISO is too high of resistance. When I tried to use this cable with AVRdude I got the following error,

avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

I just removed that MISO resistor entirely and got it working correctly. A lower value might be good to avoid accidentally damaging your LPT port; some schematics said 300 ohms. If you still get the above error without the resistor, check all your wires. Also, be careful and DO NOT plug in and turn on the AVR when the computer is off. This will possibly damage your LPT port from what I’ve read.

To get my male DB25 I cut off an end from an old printer cable, which also works well because it is shielded. The plans on the Internet recommended you keep the cable below 70cm in length to avoid interference problems. I forgot how many wires are in these things… If I ever make a bomb, I shall construct it with DB25 connectors.

“Cut the orange wire!”

“but.. WHICH ONE?!”

DSCN0801As far as I can tell there is no standard for the wire colors inside,  so you just have to strip each one and test it with a meter. If you’re following along with this, I hope you have a good pair of wire strippers. Either that, or I’ve found for this small of wire you can put an old tip on your soldering iron, crank the heat up all the way, and then just let it sit on the bit of exposed wire on the end. The insulation should peel enough to test it with a meter easily.

AVRdude is a command line utility that can easily toggle the fuse bits using this cable and the butterfly, and it comes with WinAVR. There is a great tutorial for how to set fuse bits here. The following is just a quick summary.

First, read the current configuration of the high fuse byte.

avrdude -c dapa -p m169 -U hfuse:r:hfuse.txt:b

This will create a file called hfuse.txt containing something like,

0b10011001

The #1 (last, LSB) bit of the high fuse byte is the BOOTRST bit which needs to be programmed to activate the bootloader.  In Atmel jargon, a bit is “programmed” if it is 0 and not programmed if it is 1. In my case, flipping (programming) the last bit will result in 0b10011000, or 0x98 hex. To write that to the fuse byte,

avrdude -c dapa -p m169 -U hfuse:w:0x98:m

Success! Going back to AVR Studio and writing a simple program to blink some LEDs in a Cylon eye pattern to the AVR worked fine.

DSCN0804RISE MY CYLON BRETHREN! Er.. maybe I’ve been sniffing the solder fumes a bit much.

Advertisements

Actions

Information

6 responses

21 09 2009
David

This works great ! Thank you very much for your effort in developing a simple workaround. I just got 20 Butterflies deliverd (for educational purposes) and all of them had this Fuse Bit problem. Thanks to your solution they are all programmable via RS232 now. You should ask to get paid by atmel !

24 10 2009
Stefan

Thankyou _so_ much. I’m new to the whole AVRdealy, and this was really frustrating. Thanks to your guide I now can get into the bootloader =) cheers!

13 12 2009
Martins

Best tutorial ever! I was looking for something like this all night and finally found! Thank you! Now all works perfect!

19 12 2009
internet connection speeds

Looks like I’m gonna have to read up some more, but this is a pretty good spring board.

5 01 2010
Jitkasem

I found some interesting resource for AVR and Arduino at this site

29 01 2010
Phrank916

I just used these instructions and a usbtiny programmer to fix my defective Butterfly which I had also ordered from Mouser. I used the same commands above simply changing dapa to usbtiny. Thanks PherricOxide!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: