NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » Bootloader install

February 13, 2010
by NS
NS's Avatar

Is there any tutorial available on how to install bootloader on AtMega168. I have STK500 and AVRISPmkii. I would like to be able to use just NerdKit USB to serial cable.

February 14, 2010
by Frozenlock
Frozenlock's Avatar

If you're able to connect to your MCU, it should not be difficult at all.

The foodloader.hex is already compiled for the Atmega168. All you have to do is to upload it and set the fuses. I think the info is located in fuses_mike.txt. However, you can use one of the many fuses calculator available on the web if needed. Fuses calculator

I did the upload and the fuses setting with the software eXtreme Burner AVR for my Atmega325.

Hope it helps!


February 14, 2010
by Phrank916
Phrank916's Avatar


I remember you talking about putting the foodloader on a 325 from a different thread I believe...I'm interested to know if you needed any modification to do that. I'm sure the Makefile required a few minor changes, but what about the foodloader? I'm thinking I want to get ahold of one of the 40PIN ATmega32 to play with soon, and I wondered what it would take to put the NK bootloader on that. After that, I'll have to graduate up to one of the ATmega128A1s on this breakout, heheheh.


February 14, 2010
by Frozenlock
Frozenlock's Avatar


You need to change some few things in the the mcu model and the pin you want to use as the programming flag.

The has priority on the first few lines of the makefile, but you still need to add some new information if the mcu you want isn't already in there. For example, I added:

else ifeq ($(MCU),atmega325)
# atmega325 with 1024 words bootloader:
# bootloader section starts at 0x3c00 (word-address) == 0x7800 (byte-address)
# atmega325 with 512 words bootloader:
# bootloader section starts at 0x3e00 (word-address) == 0x7c00 (byte-address)

You can find these in the datasheet of your mcu.

Finally, you need to add the required information in the config.h.

        #elif defined(__AVR_ATmega325__)
/* {{{ */
#define _ATMEGA325

#define _TXEN_UART0 TXEN0
#define _RXEN_UART0 RXEN0
#define _UCSZ0_UART0 UCSZ00
#define _UCSZ1_UART0 UCSZ01
#define _UDR_UART0 UDR0
#define _UDRE_UART0 UDRE0
#define _RXC_UART0 RXC0
#define _IVREG MCUCR
#define _TIFR_TIMER1 TIFR1

/* see datasheet! */
#define _SIG_BYTE_1 0x1e
#define _SIG_BYTE_2 0x95
#define _SIG_BYTE_3 0x0D

/* see avrdude configuration */
#define _AVR910_DEVCODE 0x74

Chances are that the first part will be exactly the same as almost all the other MCU. Try a simple copy paste. After that you check in the datasheet for the signature byte and in the avrdude configuration for the devcode.

I think that's it. Don't forget to set your fuses, otherwise the bootloader will only work once and you'll have to upload it again.

Oh, and don't wire it backward, like I did!


February 15, 2010
by Rick_S
Rick_S's Avatar

Ted, that link at Sparkfun is for an ATXmega128 - different processor altogether. If you want to get into the 128meg AVR, you might want to look for a mega128. Futurlec has a 128 dev board I have used off and on. It's great in that all ports are run out to headers you can find it HERE. There are vendors on ebay that sell these from time to time as well.

If you are handy with IDC cables, you can make up cables that have the connector on one end then strip and tin the wires on the other to plug into a breadboard. I do that often when working (PLAYING) ;) with these.

Now I haven't tried to load a bootlader on this but it has a built in serial level converter with 2 on board hardware serial uarts. I'm sure it could be done.

BTW, Frozenlock, great writeup on setting up foodloader!


February 15, 2010
by Phrank916
Phrank916's Avatar

Yeah I realized it was a different chip, my comment was jokingly eluding to that particular one being the next upgrade in logical succession. heheh, i.e. after the 168 then the 328 then the 40 pin 325 ... THEN the 100 pin 128!! I did leave out the "x" though in the name of the chip, my bad!


Post a Reply

Please log in to post a reply.

Did you know that multiple microcontrollers can communicate with each other? Learn more...