[solved] AVRDUDE - Atmega8 - reading back fuses was unreliable

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

Hey there,
This is my 1st Forum Post on AVRFREAKS.

 

I'm using AS7. and I really enjoyed using its External Tools section.

 

As you can see, here I have 4 commands and the picture clearly shows the task of each one:

 

AS7-External Tools

 

The UNO ones work well and I'm totally cheerful about it. 😎

The problem is about the Atmega8 ones.

using the 2nd command, I've uploaded ArduinoISP Sketch to Arduino-UNO to convert it to an ISP Programmer.
then using the 3rd command, I tried to upload a simple Blink program to Atmega8A.

Actually, It worked well and the LED started to Blink.
but there's just a Warning/Error message in AVRDUDE's log which worries me:

avrdude.exe: safemode: Sorry, reading back fuses was unreliable. I have given up and exited programming mode

NOTE1: I've attached the avrdude log file, if you need it in full.
NOTE2: I've tried reducing the baudrate. I guess "recommending this solution again" won't help.

 

Thank You in Advance for taking the time to solve my problem. 🙏

 


Appendix:

Here is the argument for the 3rd command:

//AVRDUDE.EXE

//To use Calibrated Internal RC Oscillator
//keep CKOPT unprogrammed to use Internal Oscillator
// CKSEL3:0 = 0x4 -> 8MHz

//Write Fuse LowByte
-U lfuse:w:0xE4:m

//Write Fuse High Byte
-U hfuse:w:0xd9:m

//Execute Chip Erase
-e

//Enable Verbose Output
-v

//Specify the MCU
-p m8

//Specify the programmer
-c arduino

//Specify the Device's Port which the programmer is attached to
-P COM6

//Specify the baudrate
-b 19200

//Disable Auto Erase for Flash
-D

//Write HEX file on Flash
-U flash:w:"$(ProjectDir)Debug\$(TargetName).hex":i

//Specify the Config file
-C "C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf"

 

Attachment(s): 

This topic has a solution.

I'm just trying to learn how to be an Embedded Systems Developer. ¯\_(ツ)_/¯

Last Edited: Tue. Mar 24, 2020 - 01:15 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, maybe there is as problem with the chip, where did you get them from?

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

Long ago, I bought it from a local electronics store. And I've been working with it until now.

Actually, It wasn't long before I got to know AVRDUDE and how it functions. (just some few days!)
The point is that the chip is working and I don't understand the exact meaning of that avrdude's error/warning message.

 

I hadn't noticed the following message in the log file:

 

avrdude.exe: Device signature = 0x1e9307 (probably m8)
avrdude.exe: safemode: lfuse reads as E4
avrdude.exe: safemode: hfuse reads as D9
avrdude.exe: safemode: Fuse reading not support by programmer. Safemode disabled.

I cannot understand it! Arduino supports Reading Fuses or Not? 
If No, why it has read them?
If Yes, what does this message mean?

 

Here I increased the verbose level from 1 to 4.
now, I can see that AVRDUDE is trying to read efuse too.
while there's not such a fuse byte inside ATmega8A!!!

Can it be the source for my problem?

avrdude.exe: safemode read 3, hfuse value: d9
avrdude.exe: safemode: hfuse reads as D9
avrdude.exe: safemode read 1, efuse value: ff
avrdude.exe: safemode read 2, efuse value: d9
avrdude.exe: safemode: Sorry, reading back fuses was unreliable. I have given up and exited programming mode
avrdude.exe: Send: Q [51]   [20] 
avrdude.exe: Recv: . [14] 
avrdude.exe: Recv: . [10] 

avrdude.exe done.  Thank you.

 

I'm just trying to learn how to be an Embedded Systems Developer. ¯\_(ツ)_/¯

Last Edited: Wed. Mar 18, 2020 - 05:54 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Yeah, but why would avrdude try to read efuse, that doesn't exist? The avrdude.conf file specifies the available fuses, the entry for m8 only has hfuse and lfuse.

Unless your avrdude.conf file is different for some reason?

 

#------------------------------------------------------------
# ATmega8
#------------------------------------------------------------

part
    id               = "m8";
    desc             = "ATmega8";
    stk500_devcode   = 0x70;
    avr910_devcode   = 0x76;
    signature        = 0x1e 0x93 0x07;
    pagel            = 0xd7;
    bs2              = 0xc2;
    chip_erase_delay = 10000;
    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
                       "x x x x  x x x x    x x x x  x x x x";

    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
                       "x x x x  x x x x    x x x x  x x x x";

    timeout		= 200;
    stabdelay		= 100;
    cmdexedelay		= 25;
    synchloops		= 32;
    bytedelay		= 0;
    pollindex		= 3;
    pollvalue		= 0x53;
    predelay		= 1;
    postdelay		= 1;
    pollmethod		= 0;

    pp_controlstack     =
	0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
	0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
	0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
	0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
    hventerstabdelay    = 100;
    progmodedelay       = 0;
    latchcycles         = 5;
    togglevtg           = 1;
    poweroffdelay       = 15;
    resetdelayms        = 2;
    resetdelayus        = 0;
    hvleavestabdelay    = 15;
    resetdelay          = 15;
    chiperasepulsewidth = 0;
    chiperasepolltimeout = 10;
    programfusepulsewidth = 0;
    programfusepolltimeout = 5;
    programlockpulsewidth = 0;
    programlockpolltimeout = 5;

    memory "eeprom"
        size            = 512;
        page_size       = 4;
        min_write_delay = 9000;
        max_write_delay = 9000;
        readback_p1     = 0xff;
        readback_p2     = 0xff;
	read            = "  1   0   1   0      0   0   0   0",
                          "  0   0   x   x      x   x   x  a8",
                          " a7  a6  a5  a4     a3  a2  a1  a0",
                          "  o   o   o   o      o   o   o   o";

	write           = "  1   1   0   0      0   0   0   0",
                          "  0   0   x   x      x   x   x  a8",
                          " a7  a6  a5  a4     a3  a2  a1  a0", 
                          "  i   i   i   i      i   i   i   i";

	mode		= 0x04;
	delay		= 20;
	blocksize	= 128;
	readsize	= 256;
      ;
    memory "flash"
        paged           = yes;
        size            = 8192;
        page_size       = 64;
        num_pages       = 128;
        min_write_delay = 4500;
        max_write_delay = 4500;
        readback_p1     = 0xff;
        readback_p2     = 0x00;
        read_lo         = "  0   0   1   0    0   0   0   0",
                          "  0   0   0   0  a11 a10  a9  a8",
                          " a7  a6  a5  a4   a3  a2  a1  a0",
                          "  o   o   o   o    o   o   o   o";

        read_hi         = "  0   0   1   0    1   0   0   0",
                          "  0   0   0   0  a11 a10  a9  a8",
                          " a7  a6  a5  a4   a3  a2  a1  a0",
                          "  o   o   o   o    o   o   o   o";

        loadpage_lo     = "  0   1   0   0      0   0   0   0",
                          "  0   0   0   0      x   x   x   x",
                          "  x   x   x  a4     a3  a2  a1  a0",
                          "  i   i   i   i      i   i   i   i";

        loadpage_hi     = "  0   1   0   0      1   0   0   0",
                          "  0   0   0   0      x   x   x   x",
                          "  x   x   x  a4     a3  a2  a1  a0",
                          "  i   i   i   i      i   i   i   i";

        writepage       = "  0   1   0   0      1   1   0   0",
                          "  0   0   0   0    a11 a10  a9  a8",
                          " a7  a6  a5   x      x   x   x   x",
                          "  x   x   x   x      x   x   x   x";

	mode		= 0x21;
	delay		= 10;
	blocksize	= 64;
	readsize	= 256;
      ;

    memory "lfuse"
        size            = 1;
        min_write_delay = 2000;
        max_write_delay = 2000;
        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
                          "x x x x  x x x x   o o o o  o o o o";

        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
                          "x x x x  x x x x   i i i i  i i i i";
      ;

    memory "hfuse"
        size            = 1;
        min_write_delay = 2000;
        max_write_delay = 2000;
        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
                          "x x x x  x x x x   o o o o  o o o o";

        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
                          "x x x x  x x x x   i i i i  i i i i";
      ;

    memory "lock"
        size            = 1;
        min_write_delay = 2000;
        max_write_delay = 2000;
        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
                          "x x x x  x x x x   x x o o  o o o o";

        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
                          "x x x x  x x x x   1 1 i i  i i i i";
      ;

    memory "calibration"
        size            = 4;
        read            = "0  0  1  1   1  0  0  0   0  0  x  x   x  x  x  x",
                          "0  0  0  0   0  0 a1 a0   o  o  o  o   o  o  o  o";
      ;

    memory "signature"
        size            = 3;
        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
      ;
  ;

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks to you, Now I know the root of the problem!

 

I compared the Atmega8 config part of "avrdude.conf" of Arduino with your config file via Diffchecker.com.

and here is the difference:

diffchecker result 01

I checked the github.com issue: Write bootloader - problem on ATmega8

 

And here is their solution for their problem with Arduino IDE:

github comment 01 


Solution for my own problem:

Delete their Solution!!! ¯\_(ツ)_/¯

  1. Copy and Paste the "avrdude.conf" in a new location.
  2. Delete the efuse part.
  3. Use the new file as your config file.

And here is the result: 🙂

Reading | ################################################## | 100% 0.14s

avrdude.exe: verifying ...
avrdude.exe: 146 bytes of flash verified

avrdude.exe: safemode: lfuse reads as E4
avrdude.exe: safemode: hfuse reads as D9
avrdude.exe: safemode: Fuses OK (E:FF, H:D9, L:E4)

avrdude.exe done.  Thank you.

 

I'm just trying to learn how to be an Embedded Systems Developer. ¯\_(ツ)_/¯

Last Edited: Tue. Mar 24, 2020 - 12:37 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
/Write Fuse LowByte
-U lfuse:w:0xE4:m

//Write Fuse High Byte
-U hfuse:w:0xd9:m

 

If "via arduino" means using the bootloader, you can't set any fuses that way, and you probably shouldn't try...

 

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

westfw wrote:

If "via arduino" means using the bootloader, you can't set any fuses that way, and you probably shouldn't try...

 

Of course not! I'm using Arduino as an ISP.
I was using "avrdude.conf" of Arduino IDE and that caused a problem. and It's solved now.

 

Here is how I've used Arduino as ISP:

 

Commands in order:

  1. UNO - Convert to an ISP
  2. Amega8 - Program via Arduino - Internal 8MHz

 

ArduinoISP-myCircuit

I'm just trying to learn how to be an Embedded Systems Developer. ¯\_(ツ)_/¯

Last Edited: Tue. Mar 24, 2020 - 06:59 PM