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.