Avrdude: why no safemode prompt or fuse recovery?

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When I program a fuse with Avrdude, which is apparently in "safemode", I get no prompt to confirm the fuse change, nor does Avrdude try to recover the original fuse value. I get the same result in Terminal mode (option -t). I also tried the options "-u" (Disable safemode) and "-s" (Disable safemode prompting); they seem to have no effect in this regard, although "-u" does prevent safemode pre/post-fuse reporting.

 

The Avrdude manual indicates that I should get a prompt and do the recovery by default. 

 

Does anyone know why safemode does not appear to be working although it seems to be enabled?

 

Here is my command (change Extended fuse value from 0xFD to 0xFF in this case):

C:\Workspace\Projects\AVR\ArduinoISP>avrdude -v -patmega328p -cstk500v1 -PCOM33 -b115200 -Uefuse:w:0xff:m

avrdude: Version 6.3, compiled on Feb 17 2016 at 09:25:53
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files\avr-gcc-8.2.0-x86-mingw\bin\avrdude.conf"

         Using Port                    : COM33
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as FD
avrdude: reading input file "0xff"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.02s

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

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

avrdude: verifying ...
avrdude: 1 bytes of efuse verified

avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as FF
avrdude: safemode: Fuses OK (E:FF, H:DA, L:FF)

avrdude done.  Thank you.

 

The conf file does not disable safemode:

...

# Turn off safemode by default
#default_safemode  = no;

...

 

Last Edited: Tue. Sep 8, 2020 - 08:26 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Safemode only prompts you if an >>uncommanded<< change in fuses is detected.  You asked for efuse to be changed to 0xFF, and that appears to have been successful, so no prompt.  Likewise, hfuses doesn't appear to have changed between the read at the beginning of the programming session and the sanity check at the end of the programming session, so no prompt.

 

What are you expecting?

 

-s      Disable safemode prompting.  When safemode discovers that one or more fuse bits have unintentionally changed, it will
        prompt for confirmation regarding whether or not it should attempt to recover the fuse bit(s).  Specifying this flag dis‐
        ables the prompt and assumes that the fuse bit(s) should be recovered without asking for confirmation first.

 

The curious bit is that lfuse appears not to have been read at the start or finish (although it is in fact reported at the end).

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What are you expecting?

I am not exactly sure what to expect, but I forgot to mention that avrdude is working very well, and that I am just beginning to learn to use it.

Safemode only prompts you if an >>uncommanded<< change in fuses is detected.  You asked for efuse to be changed to 0xFF, and that appears to have been successful, so no prompt.

It would be reasonable for avrdude to program a fuse without prompting for confirmation just after it has been given the "-U efuse:w:0xff:m" programming command option ("intentional"?), but the "-u" option description (underlined parts) seems to explicitly state otherwise:

-u

Disables the default behaviour of reading out the fuses three times before programming,
then verifying at the end of programming that the fuses have not
changed. If you want to change fuses you will need to specify this option, as
avrdude will see the fuses have changed (even though you wanted to) and will
change them back for your "safety". This option was designed to prevent cases
of fuse bits magically changing (usually called safemode).

...

My interpretation is that "even though [I] wanted to" change the fuses (i.e. "-U efuse:w:0xff:m") "[I] need to specify [the -u] option", otherwise safemode will "change them back". With that in mind, I was surprised to see that it changed the fuse and did not prompt for confirmation without either the "-u" or "-s" option.

 

I feel like I might be looking too hard and missing something obvious, but I am still very happy with how useful avrdude is.

The curious bit is that lfuse appears not to have been read at the start or finish (although it is in fact reported at the end).

I noticed that as well, and later discovered it is a known issue (bug #47718). However, lfuse is reported as one might expect in at least version 6.3-20190619, which I found after my original post; I think I got with my latest Arduino IDE update.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

flubberlab wrote:

My interpretation is that "even though [I] wanted to" change the fuses (i.e. "-U efuse:w:0xff:m") "[I] need to specify [the -u] option", otherwise safemode will "change them back". With that in mind, I was surprised to see that it changed the fuse and did not prompt for confirmation without either the "-u" or "-s" option.

Not an unreasonable interpretation.  However, (at least the current version of) avrdude doesn't work that way.

 

flubberlab wrote:
I noticed that as well, and later discovered it is a known issue (bug #47718).
You appear to have stumbled upon more than one ;-)

 

It's not perfect.  Most recently, I found that although the feature has been removed since 6.0.1, the usage message still refers to the '-y' and '-Y' options:

https://www.avrfreaks.net/comment/2941751#comment-2941751

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]