BUB II && ATMega644P - Some Help Please?

Making your program work.
The Hermit
Posts: 3
Joined: Sat Jul 20, 2013 5:12 pm

BUB II && ATMega644P - Some Help Please?

Post by The Hermit »

Paul;

Hoping to get some assistance in using the BUB II to program the ATMega644P, both of which I purchased from you a month or two ago. I'm finally getting around to putting some components on a development board and have not had any luck programming the 644P.

As provided with the "blink" program, the AVR seems to be operating normally when powered up.

The BUB II likewise appears to be functional, I did use it to successfully program an ATMega328P-PU with the "blink" program, so I know it is capable of resetting an AVR and communicating with it.

While trying to program the 644P, I see the LED on pin 13 stop blinking for a bit, indicating that the BUB II is actuating the reset pin of the processor, but no transfer of data seems to be taking place. A copy-and-paste from my Arduino 1.0.4 IDE is as follows:

Code: Select all

Binary sketch size: 1,140 bytes (of a 63,488 byte maximum)
C:\Program Files\arduino-1.0.4\hardware/tools/avr/bin/avrdude -CC:\Program Files\arduino-1.0.4\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega644p -cstk500v1 -P\\.\COM7 -b57600 -D -Uflash:w:C:\Users\AppData\Local\Temp\build5181601075636667321.tmp\Blink.cpp.hex:i 

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\arduino-1.0.4\hardware/tools/avr/etc/avrdude.conf"

         Using Port                    : \\.\COM7
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 57600
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.
Here's the hardware setup:

Code: Select all

BUB II		ATMega644P
GND		   AVR ground
CTS		   AVR ground
VCC		   AVR +5
TX		    Pin 14 (RXD)
RX		    Pin 15 (TXD)
I've also tried the BUB II and 644P in Arduino 0022 with the following results:

Code: Select all

Binary sketch size: 1074 bytes (of a 63488 byte maximum)
C:\Program Files\arduino-0022\hardware/tools/avr/bin/avrdude -CC:\Program Files\arduino-0022\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega644p -cstk500v1 -P\\.\COM7 -b57600 -D -Uflash:w:C:\Users\AppData\Local\Temp\build1881022248408480352.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:\Program Files\arduino-0022\hardware/tools/avr/etc/avrdude.conf"

         Using Port            : \\.\COM7
         Using Programmer      : stk500v1
         Overriding Baud Rate  : 57600
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.
Is there something I'm missing here? I've read up on several web pages about workarounds for sync errors, and tried a few, but none helped.

Please advise, I had very high hopes for the future of this AVR, as it is an integral part of a project I'm building.

[edit] I swear, my browser does some strange stuff with online forms. Deleted some superfluous chaff from the copy-paste [/edit]

The Hermit
Posts: 3
Joined: Sat Jul 20, 2013 5:12 pm

Re: BUB II && ATMega644P - Some Help Please?

Post by The Hermit »

OK, I have a partial answer, but the solution is somewhat bulky:

I decided to have a go at using the command line invocation of avrdude. After reading on the Sanguino.cc site that this AVR won't connect except at serial rates of 38400, I modified the command line to reflect this rate ( -b38400). One of the workarounds I had tried previously was to hold the reset pin low until avrdude was running. These two changes together returned some response from the AVR, but still didn't load the "blink" program, returning at the end of the session "Yikes! Invalid device signature".

Next up I used the -F switch to force the upload. Success! my modified blink program went in and ran!

Here's the command line:

Code: Select all

c:\>C:\Progra~1\arduino-1.0.4\hardware/tools/avr/bin/avrdude -CC:\Progra~1\ardui
no-1.0.4\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega644p -cstk500v1
 -P\\.\COM7 -b38400 -D -F -Uflash:w:C:\Users\AppData\Local\Temp\build85513152524
98230966.tmp\Blink.cpp.hex:i
I can edit one or the other of the Arduino config files to change the serial rate, but I don't know how to force the upload except by command line.

Also somewhat puzzling that I have to manually reset the AVR to make the upload work. Perhaps there's a config setting to make the reset pulse time more synchronised?

I feel I'm on the right track, but don't want to waste a bunch more time trying to get the Arduino IDE to upload if it's a lost cause. Command line works, but is a bit more troublesome to pull off than clicking the "upload" button in the IDE.

Any helpful comments? Files I can edit to make this more automatic (without hosing things when using other AVR's)? Am I the only one who's run into this issue?

oz
Site Admin
Posts: 542
Joined: Mon May 12, 2008 4:19 pm

Re: BUB II && ATMega644P - Some Help Please?

Post by oz »

The Hermit,

You installed all the Sanguino libraries in Arduino, correct?
From what I remember the last time I used Sanguino chip I had no problems with the upload. I do think that what we are providing on the chip is the Duemilanove bootloader though and not optiboot. Let me check on that tomorrow and maybe I can do some experiments to confirm.

I'm flat out on too many other projects to get to it tonight - I was travelling on the weekend.

You can get some further information out of boards.txt in your Arduino folder as to the proper settings. You did modify boards.txt, right?

Paul

The Hermit
Posts: 3
Joined: Sat Jul 20, 2013 5:12 pm

Re: BUB II && ATMega644P - Some Help Please?

Post by The Hermit »

Thanks for getting back to me.

Edit boards.txt? No, I must have missed that instruction.

I have two boards.txt, one in arduino-1.0.4/hardware/arduino/ and one in arduino-1.0.4/hardware/sanguino/ (yes, I did install the libraries).

Tried copy-pasting the contents of the sanguino/boards.txt into the ardunio/boards.txt without a change in the behaviour.

Edited sanguino/boards.txt to change the serial baud rate to 38400 and now get the "Yikes! Invalid device signature" message, which is progress, but not enough to rectify the upload failure.

Don't knock yourself out finding an answer until you have a comfortable amount of spare time. I was able to load my project sketch into the 644P from the command line and it runs just fine. I can busy myself with building the hardware portion of the project while you find an answer (if there is one). Being able to upload from inside Arduino IDE is a convenience, not a necessity.

Also, I was not able to get interrupt INT2 to work in my sketch. Had to change it over to INT0, which works fine with no other changes. Maybe a problem caused by forcing the upload? Not a big problem. Actually made me think of a better way to lay out the circuit board.

Post Reply