Part 3/3:
Here is the step by step sequence of my activities, so please follow along. I tried to be as detailed as possible.
I try to run the AVRdude command shown at:
https://www.sparkfun.com/products/9825, which is:
avrdude -c usbtiny -B 1 -patmega328 -U flash:w:main.hex
However, avrdude replies that "atmega328" not found.
So, I change to:
avrdude -c usbtinty -B 1 -pm328p -U flash:w:main.hex
However, I get...initialization failed, rc=-1
I read that this may be due to a high baud rate, so I change to:
avrdude -c usbtiny -B 32 -pm328p -U flash:w:main.hex
Now, avrdude is reporting the same thing that Arduino IDE boot load did, i.e.:
avrdude: Device signature = 0x737373
avrdude: Expected signature for ATMEGA328P is 1E 95 0F
So, I follow the same logic as before to change avrdude's expected signature and go to C:\WinAVR-20100110\bin\avrdude.conf and edit the following section to change the signature that Arduino AVRdude uses for the check, as below.
#------------------------------------------------------------
# ATmega328P
#------------------------------------------------------------
part
id = "m328p";
desc = "ATMEGA328P";
has_debugwire = yes;
flash_instr = 0xB6, 0x01, 0x11;
eeprom_instr = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
0x99, 0xF9, 0xBB, 0xAF;
stk500_devcode = 0x86;
# avr910_devcode = 0x;
# signature = 0x1e 0x95 0x0F;
signature = 0x73 0x73 0x73;
pagel = 0xd7;
bs2 = 0xc2;
Now, when I run,
avrdude -c usbtiny -B 32 -pm328p -U flash:w:main.hex
I get:
avrdude: Device signature = 0x737373
avrdude: NOTE: FLASH memory has not been specified, an erase cycle will be performed.
To disable this feature, specify the -D option.
So I do this and command:
avrdude -c usbtiny -B 32 -pm328p -D -U flash:w:main.hex
Now avrdude complains that "main.hex" No such file or exists, and it is in Safemode with questions:
lfuse was 73, now ff, change back?
lfuse was 7b, now ff, change back?
lfuse was 3, now 7, change back?
I say no to each, as yes causes things to hang up.
I find a copy of "optiboot_atmega328.hex" and use it instead.
Now I command,
avrdude -c usbtiny -B 32 -pm328p -D -U flash:w:optiboot_atmega328.hex
Awsome...things start to Write and read, but still to Device signature 0x737373
and the resulting message for the process is:
C:\>avrdude -c usbtiny -B 32 -pm328p -D -U flash:w:optiboot_atmega328.hex
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.04s
avrdude: Device signature = 0x737373
avrdude: reading input file "optiboot_atmega328.hex"
avrdude: input file optiboot_atmega328.hex auto detected as Intel Hex
avrdude: writing flash (32768 bytes):
Writing | ################################################## | 100% 46.03s
avrdude: 32768 bytes of flash written
avrdude: verifying flash memory against optiboot_atmega328.hex:
avrdude: load data flash data from input file optiboot_atmega328.hex:
avrdude: input file optiboot_atmega328.hex auto detected as Intel Hex
avrdude: input file optiboot_atmega328.hex contains 32768 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 43.63s
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
0xff != 0x00
avrdude: verification error; content mismatch
avrdude: safemode: lfuse changed! Was 73, and is now 0
Would you like this fuse to be changed back? [y/n] n
avrdude: safemode: hfuse changed! Was 7b, and is now 0
Would you like this fuse to be changed back? [y/n] n
avrdude: safemode: efuse changed! Was 3, and is now 0
Would you like this fuse to be changed back? [y/n] n
avrdude: safemode: Fuses OK
avrdude done. Thank you.
All looked good, except the verification process, AND it does not look like the fuses were set properly, AND I still have this annoying Device signature issue.
In the end, even though this occurs, I guess this is why I cannot load a Blink sketch through Arduino IDE, as I get the following error in Arduino IDE trying to upload the sketch...
avrdude: Version 5.11, compiled on Sep 2 2011 at 19:38:36
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "C:\Program Files (x86)\arduino-1.0\hardware/tools/avr/etc/avrdude.conf"
Using Port : \\.\COM4
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Recv:
avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude done. Thank you.
Sorry for the long winded explanation, but I wanted all the details out there for whomever can help me here.
Otherwise, I just go and spend the extra $1 for a pre-boot loaded chip and succumb to failure as a boot loader.
Thanks for any advice and help.