ATmega8L-PU bootloader

Hi.
First of all, I wanted to say that im new to burning bootladers and using standalone microcontrollers. I've read tons of posts and tutorials, but nothing helps.

I just got my ATmega8L-PU and I wanted to turn it to a standalone microcontroller on a breadboard. I followed those posts:

http://todbot.com/blog/2009/05/26/minimal-arduino-with-atmega8/

The problem is that I get everytime this error:

processing.app.debug.RunnerException
	at processing.app.debug.BasicUploader.burnBootloader(BasicUploader.java:288)
	at processing.app.Editor$47.run(Editor.java:2524)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

I tried different connections to ATmega8 and still nothing.

If I pick board "Arduino NG or older" i just get error that it can't connect to it.

avrdude: stk500_getsync(): not in sync: resp=0xff

I'm using Arduino UNO and 1.5.2 IDE

Any help for a newbie?

Thanks!

volt123:
I'm using Arduino UNO and 1.5.2 IDE

Any help for a newbie?

Thanks!

I would try with the Arduino IDE 1.0.5.
I recently used the Mega 2560 board as ISP and the Arduino IDE 1.0.5 (avrdude) to burn the bootloader onto an ATmega8 (USBasp based on ATmega8).

That was a good idea. At least I get a different error:

avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

What is it, should I override it?

volt123:
That was a good idea. At least I get a different error:

avrdude: Yikes!  Invalid device signature.

Double check connections and try again, or use -F to override
        this check.




What is it, should I override it?

Did you use Arduino IDE or Terminal > avrdude?

I used the Terminal:

avrdude -c arduino -P /dev/cu.usbmodem411 -b19200 -p m8 -v -U flash:w:20130212_mega8_usbisp.hex:a -U lfuse:w:0xef:m -U hfuse:w:0xc9

I used IDE.

avrdude -c arduino -P /dev/cu.usbmodem411 -b19200 -p m8 -v -U flash:w:20130212_mega8_usbisp.hex:a -U lfuse:w:0xef:m -U hfuse:w:0xc9

What should I modify in this code if I want it to work with ATmega8? Hex file, and fuses only, and where I can get them?

volt123:
I used IDE.

avrdude -c arduino -P /dev/cu.usbmodem411 -b19200 -p m8 -v -U flash:w:20130212_mega8_usbisp.hex:a -U lfuse:w:0xef:m -U hfuse:w:0xc9

What should I modify in this code if I want it to work with ATmega8? Hex file, and fuses only, and where I can get them?

You will find these parameters e.g. on a MAC in /Applications/Arduino.app > Package Contents ... (boards.txt) or some experts here can post the exact values you need.

flurin:
You will find these parameters e.g. on a MAC in /Applications/Arduino.app > Package Contents … (boards.txt) or some experts here can post the exact values you need.

And what about the settings like -c; -p; etc? I’m kinda afraid to play with this kind of commands…

… just type avrdude to get help:

$ 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.11.1, URL: <http://savannah.nongnu.org/projects/avrdude/>

Manual:

I think Ill wait for my usbasp and when I will have enough money to break an atmega, Ill try this. :slight_smile:

Ok, I got my USBasp but i still get this error:

C:\Users\Volt\Desktop\avrdude-4.4.0\windows>C:\Users\Volt\Desktop\avrdude\avrdud
e.exe avrdude -p m8 -c usbasp -F

avrdude.exe: error: programm enable: target doesn't answer. 1
avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude.exe: Device signature = 0x000000
avrdude.exe: Yikes!  Invalid device signature.
avrdude.exe: Expected signature for ATMEGA8 is 1E 93 07

avrdude.exe: safemode: Fuses OK

avrdude.exe done.  Thank you.

Am I stll connecting something wrong or there is a problem with ATmega?

It seems to me that the PC correctly detects the USBasp but the connection to the ATmega8 is wrong.

Ok I got it. The problem was the connection. My little silly breadboard probably has problems with those little pins.

I've connected USBasp directly to arduino using this http://www.instructables.com/files/deriv/FDK/4II1/HH2VXVNZ/FDK4II1HH2VXVNZ.LARGE.jpg pinouts and now AVRDUDE reads the ATmega.

This time the problem is the bootloader. When I set up in arduino IDE and press Burn Bootloader I get this error:

avrdude: verification error, first mismatch at byte 0x0000
         0xff != 0x00
avrdude: verification error; content mismatch

@edit

Ok, I've changed some fuses, turned off the SLOW mode on USBasp and arduino IDE showed that the bootloader is burnt.

But I still can't upload to it:

avrdude: stk500_getsync(): not in sync: resp=0x00

@edit2

Ok... Few times playing with fuses, failing at uploading hex files, more burnt bootloaders... and it works!

It's like one of the rules : It works and I have no idea why... Who cares.

After cutting myself because of this atmega its time for beer.

Thanks guys for help!
Cheers!

volt123:
...
It's like one of the rules : It works and I have no idea why... Who cares.

You can use avrdude with -v (verbose) to find out why it works (this may be useful for other forum members)

As an example for the ATmega 2560:

$ avrdude -c usbasp -p m2560 -P usb -b 115200 -v

avrdude: Version 5.11.1, compiled on Jul 26 2013 at 11:40:23
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/opt/local/etc/avrdude.conf"
         User configuration file is "/Users/username/.avrduderc"

         Using Port                    : usb
         Using Programmer              : usbasp
         Overriding Baud Rate          : 115200
         AVR Part                      : ATMEGA2560
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         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                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
           flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9801
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D8
avrdude: safemode: efuse reads as FD

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D8
avrdude: safemode: efuse reads as FD
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

I’ve noticed another problem… The ATmega8 works when it is placed on arduino but it doesn’t work as a standalone microcontroller - image attached. Any ideas why? Maybe Arduino IDE sets ATmega to use external crystal and thats why it doesn’t work after taking out from arduino?

For those of you still playing with the bootloader, this is what I did:

1st - take out your atmega328 or other one from arduino (I have Arduino UNO Rev.3) and place in the ATmega8,
2nd - connect your USBasp using this pinout pic http://www.instructables.com/files/deriv/FDK/4II1/HH2VXVNZ/FDK4II1HH2VXVNZ.MEDIUM.jpg
3rd - Get this file .hex file http://forum.arduino.cc/index.php?topic=116404.msg878668#msg878668 and put it to your arduino IDE folder i.e. arduino-1.0.5/hardware/arduino/bootloaders/optiboot.
4th - Edit boards.txt file i.e. arduino-1.0.5/hardware/arduino/boards.txt and add the lines from post above.
4th - Pick from boards ‘ATmega8 Optiboot (8MHz internal OSC)’ in Arduino IDE. The new ATmega8 is set to 1MHz so you need to set your USBasp on SLOW mode and press Burn Bootloader in Arduino IDE. You will wait a couple of sec. and probably get an error that it can’t communicate with ATmega. It’s ok, now disable the SLOW mode in USBasp and try burning the bootloader again - it should work now.
5th - You have a working standalone ATmega8 with adruinos bootloader running on 8MHz internal crystal.

Log:

C:\Users\Volt\Desktop\avrdude>avrdude -p m8 -c usbasp -v

avrdude: Version 5.11.1, compiled on Jul  5 2013 at 20:28:28
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

Compiled special for http://forum.atnel.pl (v5.11.1)


         System wide configuration file is "C:\Users\Volt\Desktop\avrdude\avrdud
e.conf"

         Using Port                    : lpt1
         Using Programmer              : usbasp
         AVR Part                      : ATMEGA8
         Chip Erase delay              : 10000 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                 :

                                  Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           eeprom         4    20   128    0 no        512    0      0  9000  90
00 0xff 0xff
           flash         33    10    64    0 yes      8192   64    128  4500  45
00 0xff 0x00
           lfuse          0     0     0    0 no          1    0      0  2000  20
00 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  2000  20
00 0x00 0x00
           lock           0     0     0    0 no          1    0      0  2000  20
00 0x00 0x00
           calibration    0     0     0    0 no          4    0      0     0
 0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0
 0 0x00 0x00

         Programmer Type : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9307
avrdude: safemode: lfuse reads as DF
avrdude: safemode: hfuse reads as CA

avrdude: safemode: lfuse reads as DF
avrdude: safemode: hfuse reads as CA
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

Compiled special for http://forum.atnel.pl (v5.11.1)

Maybe Arduino IDE sets ATmega to use external crystal and thats why it doesn't work after taking out from arduino?

Yes, exactly...

Succses! I used this bootloader Serial does not work with internal 8Mhz oscillator [SOLVED] - #9 by perhof - Installation & Troubleshooting - Arduino Forum and it works perfectly. :slight_smile:

Thanks guys for everything!
Cheers!