r55boy:
Sorry if this is just confusing things... ;-(
It is. You may be able to keep it all straight. I cannot. I suggest committing to one processor and one goal. Do not add more processors to the mix until you get something that works. Do not flip between a bootloader and ISP; pick one. (ISP is a better choice for a low power project).
Right mate - sorry. I have made a discovery - and its REALLY basic.
I put a fresh bootloader onto chip using Optiloader.
I load the BLINK sketch (using UNO 16MHz std board) - all fine
I hit load again to load the sketch a second time - fails.
Some of the logs attached from avrdude (had to chop it to get it under 9500 bytes to post). So basically after a load a sketch to my chip, it wont take any more sketches, until i reburn the bootloader using optiloader.
Binary sketch size: 1018 bytes (of a 32256 byte maximum)
C:\arduino-0022\hardware/tools/avr/bin/avrdude -CC:\arduino-0022\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P\\.\COM5 -b115200 -D -Uflash:w:C:\Users\Sean\AppData\Local\Temp\build4803119672540980343.tmp\Blink.cpp.hex:i
avrdude: Version 5.4-arduino, compiled on Oct 11 2007 at 19:12:32
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
System wide configuration file is "C:\arduino-0022\hardware/tools/avr/etc/avrdude.conf"
Using Port : \\.\COM5
Using Programmer : stk500v1
Overriding Baud Rate : 115200
avrdude: ser_open(): setting dtr
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Recv:
avrdude: Recv:
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 :
avrdude: verifying ...
avrdude: 1018 bytes of flash verified
avrdude: Send: Q [51] [20]
avrdude: Recv:
avrdude: Recv:
avrdude done. Thank you.
##############
Then i press UPLOAD again:
Binary sketch size: 1018 bytes (of a 32256 byte maximum)
C:\arduino-0022\hardware/tools/avr/bin/avrdude -CC:\arduino-0022\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P\\.\COM5 -b115200 -D -Uflash:w:C:\Users\Sean\AppData\Local\Temp\build6732692812831451024.tmp\Blink.cpp.hex:i
avrdude: Version 5.4-arduino, compiled on Oct 11 2007 at 19:12:32
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
System wide configuration file is "C:\arduino-0022\hardware/tools/avr/etc/avrdude.conf"
Using Port : \\.\COM5
Using Programmer : stk500v1
Overriding Baud Rate : 115200
avrdude: ser_open(): setting dtr
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: Send: Q [51] [20]
avrdude: Recv:
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51
avrdude done. Thank you.
You know these chips ship with internal clock set up as 8 MHz / 8 = 1 MHz?
Just saying, if you want 1 MHz then why bother with external clock at all unless you want precise?
And I wonder, from what I see on the pin map if you don't use external crystal then all 8 PORTB pins should be open for use?
I put a fresh bootloader onto chip using Optiloader.
Using the latest version of OptiLoader?
I load the BLINK sketch (using UNO 16MHz std board) - all fine
Just so I'm clear... You upload OptiLoader to your Uno, run OptiLoader to install a bootloader to a processor on a breadboard, move the breadboard processor to your Uno for testing. Correct?
I hit load again to load the sketch a second time - fails.
That indicates the lock-bits were not correctly set.
lemming - thx for the link - will spend some time digesting that.
Coding - i think u are bang on - i think i have screwed up the lock fuse - i changed the code in optiloader to get it to set my fuses after programming to my desired values - in the code below I changed the 0x2f,0,0,0,0 to 0x2f, Lowfuse, Highfuse, Efuse, 0.
I strongly suspect that this is not correct and need to find how to do this, for now i will set it back to 0x2f,0,0,0,0 and try again when i get home...
I am used to using "upload sketch" but dont want bootloader specifically for sure - more than happy and hoping to use your suggestion provided previously. I was only looking at bootloaders as i was trying to change fuse settings to set up the CKDIV8 and Brownout disable. Wow - it seems like weeks ago i set out to achieve something seemingly so simple!! :~
Been working this problem some more and i think the problem is baud rate.
Remember that optiloader works to my target board, but burning bootloader from within the Arduino environment doesnt, and neither does using your atmega328Pbb boards.txt file boards.
The error is:-
Binary sketch size: 1042 bytes (of a 32768 byte maximum)
C:\arduino-0022\hardware/tools/avr/bin/avrdude -CC:\arduino-0022\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P\\.\COM5 -b9600 -Uflash:w:C:\Users\Sean\AppData\Local\Temp\build5032370817224311009.tmp\Blink.cpp.hex:i
avrdude: Version 5.4-arduino, compiled on Oct 11 2007 at 19:12:32
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
System wide configuration file is "C:\arduino-0022\hardware/tools/avr/etc/avrdude.conf"
Using Port : \\.\COM5
Using Programmer : stk500v1
Overriding Baud Rate : 9600
avrdude: ser_open(): setting dtr
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Recv:
avrdude: stk500_getsync(): not in sync: resp=0xff
avrdude: Send: Q [51] [20]
avrdude: Recv:
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0xff
avrdude done. Thank you.
So - i tried the command line, and get the same problem until i switch to baudrate of 19200. then it works:
This is definitely it! I intercepted the command being generated and updated the baud rate in there from 9600 to 19200, see below, and IT WORKED!!! So how to i make the IDE use a baud rate of 19200 when generating these command lines?
Coding - with these change to boards.txt i get error "avrdude: Can't find programmer id "arduino".
i have uploaded ArduinoISP to my programmer board and have it hooked up to the target on a breadboard.
My problem is just now that the Arduino environment seems to be setting the avrdude -b parameter to 9600 when it should be 19200 and i cant see why. when i manually invoke avrdude and use -b 19200 it works.
Guys any idea here? All seems correct, and Coding Badly has this working, but no joy for me. I've been tearing my hair out for a month now, and certainly know so much more about boards.txt etc etc, but fail with the baud rate that it insists on using, despite me telling it otherwise. Arghhhh!