avrdude-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avrdude-dev] Patch for "Safemode" Support


From: Colin O'Flynn
Subject: [avrdude-dev] Patch for "Safemode" Support
Date: Wed, 5 Jan 2005 20:15:01 -0400
User-agent: KMail/1.7.1

Hello,

I have created a patch against CVS that implements  "safemode".

It stemmed from a dead AVR I had happen to me, and figuring out that probably 
a databyte got corrupted which resulted in the lock-bits changing to disable 
the external RESET pin on my AtMega. Since there are no error detection bits 
on the AVR's programming protocol, it is possible to have changed the fuse 
bits and not know it. However - as long as you don't exit programming mode 
the fuse bits don't become active.

You can see the thread at 
http://www.avrfreaks.net/phpBB2/viewtopic.php?t=25596 - which includes Erik's 
comments which are pretty much the reason I actually made the patch ;-)


Erik summed up the idea as this:

"- Before the start of every program, read the fuse settings and store.
- Program flash / eeprom
- Read the fuse settings again and compare to previously stored settings.
- If different, reprogram fuse settings with previously stored settings.
- Exit programming mode. "

Which is what this patch does. The -s option enables safemode, which right now 
prevents you from changing the fuse bits *at all*. 

If you want to see this patch in action do the following:

connect to an AVR in terminal mode with your fav device, with safemode enabled
(ie: avrdude -s -c stk500 -P /dev/ttyS0 -p m128 -t)

Now change the fuse bytes - as many as you want. When you exit safemode it 
will detect the fuse bits changed because of a "mysterious force", and change 
them back. 

It will try many times if the first time doesn't work - you can use the 
verbose output for more information (-v option). If you want to see what it 
would look like with an AVR that goes dead half-way through, enter terminal 
mode again. This time don't change any fuse bits - just pull the cable that 
connects to the AVR (for STK500 just pull the 6-pin connector) and quit 
terminal mode. It will read the fuse bits as 0xff and try 10 times to 
reprogram them.

I tried to keep the same programming style as the rest of the file as well in 
the patch, but let me know of places where I can do stuff better.

Regards,

 -Colin

Attachment: safemode_20050401.patch.gz
Description: GNU Zip compressed data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]