Avrprogrammer v2.1 under linux

I’m able to program fuses and firmware under windows then the same board with linux. However, when I try to do the same starting with linux with a fresh board (i.e. with a mcu which has never had it’s fuses programmed) then I get “Initial SPI command failed.”. Unless I preprogram the fuses first on a Windows machine, then I can program on a Linux machine.

This is the command I’m using:
#program fuses
avrdude -v -patmega2560 -cavrispv2 -P/dev/ttyACM1 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xD8:m -Ulfuse:w:0xFF:m -B 5

#flash firmware
avrdude -v -patmega2560 -cavrispv2 -P/dev/ttyACM1 -Uflash:w:firmware.bin:r -e -B 0.1

Obviously it’s the fuse setting that is failing under Linux, because when I use -B 3 to burn the FW then it works under Linux, but after fuse burning on a Windows machine then 0.1 works. This tells me that the MCU is still running under it’s default factory setting.

Why is the fuse setting failing under Linux (even though it says successful) but not under Windows. It’s almost like the fuses aren’t taking hold when programming on a Linux machine.

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/user/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM1
         Using Programmer              : avrispv2
         Setting bit clk period        : 20.0
         AVR Part                      : ATmega2560
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         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    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
           flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 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 : STK500V2
         Description     : Atmel AVR ISP V2
         Programmer Model: STK500
         Hardware Version: 15
         Firmware Version Master : 2.10
         Topcard         : Unknown
         Vtarget         : 4.8 V
         SCK period      : 22.2 us
         Varef           : 0.0 V
         Oscillator      : Off

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: safemode: lfuse reads as 62
avrdude: safemode: hfuse reads as 99
avrdude: safemode: efuse reads as FF
avrdude: erasing chip
avrdude: reading input file "0x3F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.01s

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

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

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

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

avrdude done.  Thank you.

Hello.

I’m sorry you are having trouble programming your boards. Please connect the programmer to one of your boards that you believe to have incorrectly-programmed fuses, and then run the following commands on the Linux machine and post the full output from each of them. We expect the first command to fail, and then the next two commands should help us get more details about what went wrong.

avrdude -v -cstk500v2 -P/dev/ttyACM1 -patmega2560 -B0.5 -Uflash:w:firmware.bin:r
pavr2cmd --status
avrdude -v -cstk500v2 -PCOM6 -patmega32u4 -B5 -Uefuse:r:-:h -Uhfuse:r:-:h -Ulfuse:r:-:h

Please make sure you run the commands in the order shown above. The second command uses the Pololu USB AVR Programmer v2 Command-line Utility (which you can download from the “Installing Linux Software” section of the Pololu USB AVR Programmer v2 User’s Guide) to get details about what went wrong with the first command.

–David

Hello David,
I figured it out. The standard avrdude 6.3-20171130+svn1429-2, from the Ubuntu 22 repository will not set fuses at all!!. I compiled my own 7.3 and that fixed it.
We can mark this as solved.

1 Like