Atmega8 bootloader via AVR Studio and mkii

Hello, I got some Atmega8 chips that i would like to use on standalone projects. I followed this tutorial to burn the bootloader with AVR Studio and an Arduino UNO board http://www.arduino.cc/playground/Learning/Burn168 It said OK to everything, went pretty fast, but I couldn't use it. I am trying to follow this tutorial now : http://todbot.com/blog/2009/05/26/minimal-arduino-with-atmega8/ When I try to program the chip, just reading signature ( which worked when it was fresh ) AVR Studio writes 'Entering programming mode ... FAILED!' with an error message asking to verify everything. I see 0x00 0x00 0x00 next to 'read signature' I'm a bit lost, did I break the chip ? Thank you Philippe

PS : I put another ATMEGA8 - 16PU in the UNO board

Setting mode and device parameters.. OK! Entering programming mode.. OK! Reading signature .. 0x1E, 0x93, 0x07 .. OK! Leaving programming mode.. OK!

Flash:HEX file ( Files\arduino-0022\hardware\arduino\bootloaders\atmega8\ATmegaBOOT.hex )

Verify :((

Setting mode and device parameters.. OK! Entering programming mode.. OK! Reading FLASH .. OK! WARNING: FLASH byte address 0x1C00 is 0xFF (should be 0x12).. FAILED! Leaving programming mode.. OK!

I'm not going further as I don't know what I'm doing wrong :((

Do you have crystal + capacitors connected to the target (the ATmega8)?

The ATmega8 is plugged into Arduino UNO, it was not on breadboard.

Anyway what would you suggest as best practice to do this ? I have very small projects, like a camera remote I would like to run in standalone, so I bought a few ATTiny and Atmega chips, the AVRISP mkii, installed AVR studio etc ... but google will find thousands of ways for doing this, on breadboard, mugging the chip on Arduino board, use isp programmers ... it's kind of a nightmare for new users. It looks even worse when you have an UNO, as you see lot of warnings that it won't work with optiboot, etc ... Thank you

I suggest you use avrdude from a command-shell so you can better control what is happening. I also suggest working with either of the ATmega8 processors you described in the original post; the processors that do not seem to be working correctly.

First, make certain you can run avrdude from a command-shell. Open a command-shell and type “avrdude” and press Enter. Something similar to this should be displayed…

C:\ >avrdude
Usage: avrdude [options]
Options:
  -p <partno>                Required. Specify AVR device.
  -b <baudrate>              Override RS-232 baud rate.
  -B <bitclock>              Specify JTAG/STK500v2 bit clock period (us).
  -C <config-file>           Specify location of configuration file.
  -c <programmer>            Specify programmer type.
  -D                         Disable auto erase for flash memory
  -i <delay>                 ISP Clock Delay [in microseconds]
  -P <port>                  Specify connection port.
  -F                         Override invalid signature check.
  -e                         Perform a chip erase.
  -O                         Perform RC oscillator calibration (see AVR053).
  -U <memtype>:r|w|v:<filename>[:format]
                             Memory operation specification.
                             Multiple -U options are allowed, each request
                             is performed in the order specified.
  -n                         Do not write anything to the device.
  -V                         Do not verify.
  -u                         Disable safemode, default when running from a script.
  -s                         Silent safemode operation, will not ask you if
                             fuses should be changed back.
  -t                         Enter terminal mode.
  -E <exitspec>[,<exitspec>] List programmer exit specifications.
  -x <extended_param>        Pass <extended_param> to programmer.
  -y                         Count # erase cycles in EEPROM.
  -Y <number>                Initialize erase cycle # in EEPROM.
  -v                         Verbose output. -v -v for more.
  -q                         Quell progress output. -q -q for less.
  -?                         Display this usage.

avrdude version 5.10, URL: <http://savannah.nongnu.org/projects/avrdude/>

Did that work?

Yes, i installed Crosspack for AVR dev on my Mac, in Terminal :

Usage: avrdude [options]
Options:
-p Required. Specify AVR device.
-b Override RS-232 baud rate.
-B Specify JTAG/STK500v2 bit clock period (us).
-C Specify location of configuration file.
-c Specify programmer type.
-D Disable auto erase for flash memory
-i ISP Clock Delay [in microseconds]
-P Specify connection port.
-F Override invalid signature check.
-e Perform a chip erase.
-O Perform RC oscillator calibration (see AVR053).
-U :r|w|v:[:format]
Memory operation specification.
Multiple -U options are allowed, each request
is performed in the order specified.
-n Do not write anything to the device.
-V Do not verify.
-u Disable safemode, default when running from a script.
-s Silent safemode operation, will not ask you if
fuses should be changed back.
-t Enter terminal mode.
-E [,] List programmer exit specifications.
-x <extended_param> Pass <extended_param> to programmer.
-y Count # erase cycles in EEPROM.
-Y Initialize erase cycle # in EEPROM.
-v Verbose output. -v -v for more.
-q Quell progress output. -q -q for less.
-? Display this usage.

avrdude version 5.8cvs, URL: http://savannah.nongnu.org/projects/avrdude/

Excellent. The next step is to construct a set of arguments that query the target (the ATmega8) for basic information. For example, this is how I query an ATtiny85 processor using a Pololu AVR Programmer…

avrdude -v -v -v -pattiny85 -cavrispv2 -P\.\COM8

You need to use “atmega8” for the part and I believe “avrispmkII” for the programmer. You will have to determine the correct value for the port (the “\.\COM8” in my example). Something similar to this…

avrdude -v -v -v -patmega8 -cavrispmkII -Pyourportgoeshere

I'm using dos command prompt on PC which has avrdude 5.10 It is giving me an timeout message, not sure what the right port is, I went to Device manager but didn't see the AVRISP anywhere. It is connected via USB :roll_eyes:

Oh i see it in Jungo, but no idea how to get its address :(

I read in this resource http://www.ladyada.net/learn/avr/avrdude.html -P usb or just ommit -P if usb, but same result : stk500_2_ReceiveMessage(): timeout

Whew, what a long journey, finaly getting some results. I uninstalled avr studio, reinstalled winavr, removed the jungo driver, installed the atmel driver from winavr/utils/libusb/bin Now when typing the command I receive a bunch of infos, and it detects the ATMEGA8 ;)) It gives some errors at the end however.

Here below screenshots from DOS win :

https://picasaweb.google.com/lh/photo/tWwi8s5Mn2s4J__WX5BRBObcuCOFlv5LhEJP-bL9y9M?feat=directlink https://picasaweb.google.com/lh/photo/YBtR1z19ZTPQITHKjXwfCObcuCOFlv5LhEJP-bL9y9M?feat=directlink

I got my first chip bootloaded and running a sketch. I setup the chip on a breadboard ( http://itp.nyu.edu/physcomp/Tutorials/ArduinoBreadboard ) Then I used Arduino IDE to burn a bootloader via AVRISPmkii Then I used Arduino IDE to upload sketch to the empty UNO board, from which I used RX+TX to program the Atmega8 ;) However, it didn't work with the chip I had problems with in first instance, is there a way to recover it ? Thank you

I uninstalled avr studio, reinstalled winavr, removed the jungo driver

Ugh. I had forgotten about the annoying Jungo driver and avrdude not playing well together. Sorry about that.

It sounds like you have gotten past this problem... http://arduino.cc/forum/index.php/topic,58229.msg418836.html#msg418836 Is that true?

However, it didn't work with the chip I had problems with in first instance, is there a way to recover it ?

Maybe. You need to determine the fuse-bit settings. If everything is working correctly, running the simple avrdude command I showed earlier outputs something like this at the end...

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f
avrdude: safemode read 1, lfuse value: ff
avrdude: safemode read 2, lfuse value: ff
avrdude: safemode read 3, lfuse value: ff
avrdude: safemode: lfuse reads as FF
avrdude: safemode read 1, hfuse value: d7
avrdude: safemode read 2, hfuse value: d7
avrdude: safemode read 3, hfuse value: d7
avrdude: safemode: hfuse reads as D7
avrdude: safemode read 1, efuse value: 4
avrdude: safemode read 2, efuse value: 4
avrdude: safemode read 3, efuse value: 4
avrdude: safemode: efuse reads as 4

avrdude: safemode read 1, lfuse value: ff
avrdude: safemode read 2, lfuse value: ff
avrdude: safemode read 3, lfuse value: ff
avrdude: safemode: lfuse reads as FF
avrdude: safemode read 1, hfuse value: d7
avrdude: safemode read 2, hfuse value: d7
avrdude: safemode read 3, hfuse value: d7
avrdude: safemode: hfuse reads as D7
avrdude: safemode read 1, efuse value: 4
avrdude: safemode read 2, efuse value: 4
avrdude: safemode read 3, efuse value: 4
avrdude: safemode: efuse reads as 4
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

Yes, Jungo driver problem is the past now :)) very easy to switch for avrdude or avr studio now, by changing the mkii driver in Windows device manager, it takes a few seconds. I hope to write a little illustrated tutorial about this annoying issue.

And thank you for the avrdude suggestion, this is what made me find out the conflict between libusb and jungo, after that it went all very easy using Arduino ide to burn the bootloader, and upload a sketch.

My next lesson is to program a chip without a bootloader, I have a few attiny13 I would like to use.

About the hardware setup, can all the chips work with a 16mhz crystal ? I understand you can configure them for using their internal oscillator, I just don't know what difference it makes, sorry for lack of knowledge.

For my weirdo chip, I didn't get the message you are displaying, rather the error mentioned in this screenshot : https://picasaweb.google.com/lh/photo/YBtR1z19ZTPQITHKjXwfCObcuCOFlv5LhEJP-bL9y9M?feat=directlink I am trying to find a way to erase the chip, I think I saw such options in avr studio, I will give it a try.

pimousse: And thank you for the avrdude suggestion, this is what made me find out the conflict between libusb and jungo, after that it went all very easy using Arduino ide to burn the bootloader, and upload a sketch.

Glad to know you are making progress!

My next lesson is to program a chip without a bootloader, I have a few attiny13 I would like to use.

I've had a great deal of success programming ATtiny85, ATtiny84, and ATtiny2313 processors without a bootloader.

About the hardware setup, can all the chips work with a 16mhz crystal?

All the processors I've used are able to work with an external 16 MHz crystal.

I understand you can configure them for using their internal oscillator, I just don't know what difference it makes, sorry for lack of knowledge.

You can. The internal oscillator is nice for power-saving applications or applications where you need the extra two I/O pins. The downside is the accuracy. From the factory, the oscillator is calibrated to ±10%. It's fairly easy to calibrate it to ±1% (or better if the voltage and ambient temperature are fairly stable).

For my weirdo chip, I didn't get the message you are displaying, rather the error mentioned in this screenshot : https://picasaweb.google.com/lh/photo/YBtR1z19ZTPQITHKjXwfCObcuCOFlv5LhEJP-bL9y9M?feat=directlink I am trying to find a way to erase the chip, I think I saw such options in avr studio, I will give it a try.

Sounds good. If I think of anything to try, I'll let you know.

When you followed this tutorial...

http://www.arduino.cc/playground/Learning/Burn168

...did you use 0xCA for the high fuse or the low fuse?

I used this tutorial once with the Atmega8, which i cannot read the signature now :((

For the other chips I used Arduino IDE to burn bootloader.

I used this tutorial once with the Atmega8

The instructions had you set the fuses. Do you remember if you used 0xCA or 0xFF for the high fuse? The instructions are not clear which is which.

Honestly, because it was the first time, I am sure I did exactly as it is described, word for word, nothing fancy, especialy at this level. I don't know for you, but I think on my side the mistake was using the UNO to burn the bootloader, I think it was not using the crystal or something like that from what I read. I was suggested to try to use an external clock at 1Mh to communicate back with my device. I'm sorry if I'm not very helpful. Regards,

pimousse: Honestly, because it was the first time, I am sure I did exactly as it is described, word for word, nothing fancy, especialy at this level.

But that's the problem. The tutorial does not indicate which value goes to which place. Even if you follow the instructions precisely, you have a fifty-fifty chance of making a mistake.

I'm sorry if I'm not very helpful.

No need for you to apologize!

I was suggested to try to use an external clock at 1Mh to communicate back with my device.

That is (sort of) worth trying. Not the "external clock" part but the lower frequency part.

If the fuse bytes are swapped, the the clock is set to "Ext Crystal/Resonator Low Freq". The datasheet mentions a "32.768kHz watch crystal" when the clock is set to that value. I assume that means that you would connect a watch crystal on the XTAL pins (with capacitors). You will also have to lower the frequency of your programmer.