My butterfly is sick

Go To Last Post
17 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was happily programming my butterfly and all of a sudden I get this message Address: 0x000, Expected: 0x940c, Received: 0x100

I have it hooked to the serial port and am using AVRstudio4...
I can still read and program the eeprom but when I try to write
the flash I always get the above message... I even tried loading
the original butterfly code back in..it erases and then starts to program
but again stops with the same message as above.

Any ideas what might be wrong? I am sure I have not reprogrammed the atmega169 more than maybe 100 times...could it have pooped out after so few writes??

The program that was last loaded before this started is still in there and still runs perfectly...I just can't overwrite it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think there is a Looooooonnnggg thread about this error.

Use search

One is here
https://www.avrfreaks.net/index.p...

But if you search on 0x940c , several other will pop up

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Golly!
this looks like a problem that many are having...
I am going to solder a set of isp pins onto this thing
and try using my stk500 to resurrect this butterfly.

If it is a problem with the serial port programming of the
butterfly I guess I can just program it with the stk500
until I am finished playing with the code in Smileys neat book..
This butterfly is really cool but is also a pain in the u kno what...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You prob. need to resurrect it with the stk500 , Remember to set the board power on the stk500 to 3..3v , from within AvrStudio.

As i read the above thread , it might be a "Weak" battery (low voltage) causing the error , or fiddeling with the joystick while downloading.

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Gwen,

You didn't by chance use rechargeable batteries did you?

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Smiley :)

Nope, no batteries, I mounted my butterfly to the same board that holds
my stk500 and a solderless breadboard...I used an lm317 and a WallMart
WallWart to make a 3.25v power supply for it.

I am going to solder a set of pins onto the butterfly this evening and try using
the stk500 to program the atmega169...say a prayer for me....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I soldered isp pins onto the butterfly and hooked it up to the stk500
I had to erase the chip to change the lockbits to Application Protection
Mode 1 (No lock on SPM and LPM in Application Section)

I then loaded the gcc port of the butterfly code (from Smiley's CD) into the
butterfly and the butterfly was set back to its original state and seems to
work as it did when I first unpacked it.

But I have tried everything and I cannot get the butterfly to communicate
via the 3 pin rs232 hookup :( ..I even tried loading in the original butterfly
code from Atmel's website...still no rs232 communication..

I was having no problems with the rs232 before this happened and was
regularly programming the butterfly with the serial connection...so something
has happened to the usart on the butterfly I guess.

I am going to leave the stk500 connected to the butterfly as shown in the
jpg below...at least I can load code into it and get it to run..but it's a pain that
I cannot use the serial port to communicate anymore as I still had a few
experiments to run that needed the serial port :(

I conclude that the butterfly is very cool but is not suitable as a dev board
for a begginer that does not also own a programmer like the stk500...because
if or when the lockbits mess up they will be left with a butterfly they cannot
program anymore. It would be better to spend 80$ on the stk500 and use it
as a dev board or to make up a kit consisting of something like

-a solderless breadboard
-a couple of atmega 48/88/168 chips w/bootloader preloaded
-a max232 chip
-and various small parts and cables to carry out simple experiments.
Such a kit would cost less than 20$ if you shop well.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I once had the same symptoms on a (Mega32 i think .... it was)
I had enabled (or forgotten to disable the Jtag fuse) , now Jtag owned the pins that were also used for RS-232

You might want to check the fuses , and the datasheet for the M169 , it just might be ....... :-)

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Bingo 600
Maybe there is still hope then..
I will check on that and let you know :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ohh btw

As it is a bootloader , in order to activate it on boot , you have to enable the BOOTRST FUSE , and make room for the bootloader

This should be a working fuse setting
http://www.siwawi.arubi.uni-kl.d...

What i would expect is that you will have to load the bootloader only via the stk500
And then let the bootloader do the "loading of the rest"

The avr bootloader is here (description):
http://www.siwawi.arubi.uni-kl.d...

The hexfile is here:
http://www.siwawi.arubi.uni-kl.d...

This is the guy who made the GCC-Port , and i guess that Smiley also got his version from here.
http://www.siwawi.arubi.uni-kl.d...

Did you only try the bootloader for testing the RS-232 ??
If you load the gcc-port (butterfly app) via the stk500 i'd say it would erase the bootloader ,as part of the loading.

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And the obvious, resolder all the joints for the RS232 on the Butterfly and your connector... yah never know.

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think maybe the boot code is not loading in..or it is not running..

I seem to remember that I used to have to push the joystick upward
to get the original butterfly code to start running?? Now it just starts
up when power is applied.

I simply loaded in the gcc port of the butterfly code using my stk500
is there something I am missing here? does simply moving the code
to the atmega169 somehow miss storing or enabling the boot code?

I have the lockbits set correctly I think and also the fuses.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@Gwen
I dont think it matters here , but sometimes it matters to remove the ISP Plug from the target after programming.

1: Do the fuses as described in my prev. post
2: Then load the bootcode (link in my prev post).
3: Then if the Bootloader works , load the Butterfly app via the Bootloader.

If that doesn't work then do as Smiley suggests.
And write a test app , that uses the RS-232 , and load that via the STK-500.
If you still have no RS-232 ..... (something has gone wrong).

Ohh and i suppose you have made sure that your pc's commport works , it does if it's the same you use for the STK-500.

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Gwen,

Have you had it hooked up to a terminal program and turned on the Butterfly while holding the joystick pressed to the center so that you will see the stream of '? ? ? ? ...'? Also did you try to use the name download function?

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

YES!!!
It's working again :)

Here is what it took...

-Hook the butterfly up to the stk500 as shown in jpg above
-erase the chip
-get this file...it is the latest gcc port of the boot section code only..it is
a <5kb file..the large 40kb-ish file will not work!
http://www.siwawi.arubi.uni-kl.d...
look in the bin folder for the hex file.
-load the file into the butterfly
-set the fuses like so..make sure these and ONLY these are checked.
Brown-out detection disabled
JTAG Interface Enabled
Boot Flash section size=1024 words boot start address = $1c00
Boot Reset vector Enabled (default address = $0000)
Int RC Osc: Startup time 6 CK +65ms
-Now make sure these and only these Lockbits are checked
Mode1: No Memory Lock features enabled
Application Protection mode1 no lock on SPM and LPM in Application Section
Boot Loader Protection Mode 2 SPM prohibited in Boot Loader Section

After following the above steps my serial bootloading works again on the
butterfly.. I did not re-load the entire original butterfly code as I am no longer
interested in running that...but I have loaded in some of my own programs
and they load and run just fine as before...I see no reason why the original
butterfly application code won't also load and run fine if that is what is desired.

This problem where the lockbit is somehow setting on its own and locking
out the ability to load new code into the application section via the usart port
is a real problem. If a newbie has only a butterfly and is programming it with
the serial connection and this happens s/he will have to either buy an stk500
to reset the butterfly or find someone else who has one and is willing to reset
it for them. Maybe some kind soul/s would be willing to accept zapped
butterflies by mail and return them to hapless users with the lockbits reset?
I'd do it myself but my dad would skin me alive if I gave out our actual address
to people on the internet..that's rule#1 here for me :-/

hmmmmm...maybe Atmel would do this? seems fair since it is a glitch in
the butterfly...and it seems to me that some of the most important people
to Atmel would be newbies who are trying to learn how to program AVRs
using the butterfly as a dev kit...good customer service to these eager learners will mean future sales :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are no bootloader-functions in the application code. If you flash the application using the STK the first step in the programming procedure "chip erase" by default. So if the bootloader has been in the flash before it will be erased after flashing an application the bootloader function (indicated by "joystick up") is lost and all locks get reseted.
Main reason for the problem could be a new version of the preinstalled bootloader which may offer "lock-bit-set-functions" and/or locks set in the factory. The old bootloader version (and my gcc-port of the old version at www.siwawi...) does not include lock functions and the older Butterflys I have all came without locks set. The readout $0x0100 instead of 0x940c indicates that a application read lock is enabled since then an AVR just sends a number sequence (0x00, 0x01, 0x02) instead of the real data stored in the flash (0x940c is the typical "reset jump" at adress 0 in binaries made with gcc for an ATmega169).
A STK is not needed to reset the the locks and reinsall the bootloader. For one-time use the method descibed in http://bluebat.dnsalias.org/howt... is ok. At least current limiters or even better voltage deviders should be added to the adpater to reduce the voltages to a "Butterfly level".

Martin Thomas

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi mjthomas :)

So you are the guy that wrote the gcc port of the butterfly code huh...cool!
Thanks very much for taking the time to do that...that code is very useful and
it's great to be able to look at the source and learn from it.

I will have to try making that simple lpt port connection to the isp pins on
the butterfly and see if it works with avrdude.