Installing the NerdKit Bootloader

This is a continuation of some of my more popular posts on the NK site.   I had added this post to the NerdKit library section and since I don’t know if the library will return or not, I want to be sure it remains available.



As of late, I’ve noticed a lot of interest in the programming of the bootloader onto either a new or existing micro-controller.  This post is to provide a brief instruction to those venturing into this.

Programming a bootloader on a micro-controller requires additional hardware that was not provided with your NerdKit.

First and foremost, programming a bootloader requires a different type of programmer.  While there are other methods to install a bootloader, for this instruction, I am going to focus on the ISP programmer.  An ISP (or In System Programmer) is a device that connects to the SPI port of your micro-controller to program it via a serial protocol.  There are several of these devices readily available on the internet, or if you are adventurous, you can attempt to build your own from scratch.

Some common ISP programmers include:

  1. DAPA – Direct Access Parallel Adapter.  This is a somewhat outdated homebrew programming method.  To use this type of programmer, you MUST have a TRUE parallel port in your computer, not a USB to parallel adapter.  The schematic for this can be found several places on the web.
  2. DASA – Direct Access Serial Adapter.  This is the serial variation of the DAPA programmer.  It is also a homebrew programmer that requires a TRUE serial port in your computer, not a USB to serial adapter.  This schematic too can be found several places on the web.
  3. USB – ISP Programmer.  There are several variations of these available.  Many commercial types even some directly from Atmel.  Some of these would be the Atmel Dragon, USBASP, AVR MKII, USBTinyISP, etc…

There are others including the popular STK500 dev kit from Atmel, and some other buffered parallel port programmers that can be used.  The type you use isn’t terribly important.  I currently use a programmer I purchased in kit form on ebay.  It has the USBASP firmware on it.

Here is a photo of the programmer I use.  You may be able to find one on ebay, or from the designers WEBSITE.

NOTE: If you use purchase one of these programmers, be sure to specify the USBASP firmware.  There have been problems with the AVRISP MkII emulator firmware especially in Win Vista and 7.  I also have the USBASP Firmware in my programmer and can be of more help if we share common programmer hardware should you have a problem.

PHOTO
PHOTO

Once you have your programmer, you need to keep a couple of things in mind.  Some programmers will supply power to your circuit for programming, some require the circuit to have power.  The programmer I am using is capable of supplying the power.  As a result, I do not use the power regulator or battery when programming.

OK, let’s get started.

To program the bootloader you will need to build your breadboard very similar to how the initial setup in the guide describes.  If your programmer supplies power, you can leave the regulator portion off the board.  The main difference is that you MUST replace the jumper wire at pin1 with a resistor (I use 10k).

Note: If you use the programmer I have, the programmer will supply power if the 5v/3.3v jumper is installed.  If you use your own power, you MUST remove that jumper.

This Photo illustrates the basic setup.

PHOTO

Here I have added a small circuit board I made that breaks out the MOSI, MISO, SCK, and Reset pins from the programming cable to my breadboard.  You can purchase similar breakout boards on e-bay, or just attach wires into the ribbon cable connector to the proper places on your breadboard.

PHOTO

This photo shows the connections to the micro-controller.

PHOTO

And Programmer…

PHOTO

If you go your own route, the pin-out for the connector is this.

This is the header pinout on a board.

PHOTO

And this would be the view of the 10 pin female connector on the cable itself.

connector

Once all your connections are made, you are ready to start loading the bootloader.


Edit 1/16/2012

If you are using the USBASP like I have, you will need to have the low speed jumper installed when programming the bootloader.  This is especially important when installing to a new chip.


The NK team kindly has done most all of the work here for you in providing you with a compiled source to upload and a list of all the fuse settings.  The main thing here is to make sure to use the proper bootloader for the chip you are programming.  The ATMEGA168 and ATMEGA328P are different and used different fuse settings and bootloader file.

The chip I am using in my example is the ATMEGA328P.

In your code folder you downloaded from the member area, you will find 2 folders for bootloaders. They are called “bootloader168” and bootloader328P)

The first thing you need to do is look at the makefile.

The default makefile uses a DAPA programmer.  You must change this to the type of programmer you have prior to attempting to load the files.

In my case, I changed the dapa in the 1st line to usbasp so mine reads like this.

AVRDUDEFLAGS=-c usbasp -pm328p

Now, just to make sure we start of fresh, it’s a good idea to do a chip erase.  This will make sure the lock bits are cleared and any existing bootloader/program is cleared off the chip.  (It will also test the setup.

To do this simply type this from your command line.

avrdude -c usbasp -p m328p -e

(substitute your programmer and micro in the proper spots as needed)

If your setup is good, you should see this response.

C:\Users\Rick\Desktop\Code\BOOTLO~2>avrdude -c usbasp -p m328p -e
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.02s
avrdude: Device signature = 0x1e950f
avrdude: erasing chip
avrdude: safemode: Fuses OK
avrdude done.  Thank you.

If you did, your setup is good, and you are ready to proceed to programming.

After you’ve done the erase, you need to set the fuse bits in the micro to configure it.

This is done by navigating into your bootloader folder and typeing:

make fuses

If this was successful, you should see a bunch of lines scroll on your screen as each fuse is programmed.  Make sure each section verifies.  For the 328P I’m programming, this is what the response is from make.

C:\Users\Rick\Desktop\Code\BOOTLO~2>make fuses
avrdude -c usbasp -pm328p -U lock:w:0x2f:m
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.02s
avrdude: Device signature = 0x1e950f
avrdude: reading input file "0x2f"
avrdude: writing lock (1 bytes):
Writing | ################################################## | 100% 0.00s
avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x2f:
avrdude: load data lock data from input file 0x2f:
avrdude: input file 0x2f contains 1 bytes
avrdude: reading on-chip lock data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: safemode: Fuses OK
avrdude done.  Thank you.
avrdude -c usbasp -pm328p -U efuse:w:0x05:m
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.03s
avrdude: Device signature = 0x1e950f
avrdude: reading input file "0x05"
avrdude: writing efuse (1 bytes):
Writing | ################################################## | 100% 0.00s
avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x05:
avrdude: load data efuse data from input file 0x05:
avrdude: input file 0x05 contains 1 bytes
avrdude: reading on-chip efuse data:
Reading | ################################################## | 100% 0.02s
avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: safemode: Fuses OK
avrdude done.  Thank you.
avrdude -c usbasp -pm328p -U hfuse:w:0xd2:m
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.03s
avrdude: Device signature = 0x1e950f
avrdude: reading input file "0xd2"
avrdude: writing hfuse (1 bytes):
Writing | ################################################## | 100% 0.02s
avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xd2:
avrdude: load data hfuse data from input file 0xd2:
avrdude: input file 0xd2 contains 1 bytes
avrdude: reading on-chip hfuse data:
Reading | ################################################## | 100% 0.02s
avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: safemode: Fuses OK
avrdude done.  Thank you.
avrdude -c usbasp -pm328p -U lfuse:w:0xf7:m
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.02s
avrdude: Device signature = 0x1e950f
avrdude: reading input file "0xf7"
avrdude: writing lfuse (1 bytes):
Writing | ################################################## | 100% 0.02s
avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xf7:
avrdude: load data lfuse data from input file 0xf7:
avrdude: input file 0xf7 contains 1 bytes
avrdude: reading on-chip lfuse data:
Reading | ################################################## | 100% 0.02s
avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: safemode: Fuses OK
avrdude done.  Thank you.

After this is done, you are ready to send the bootloader to the chip.  This can be done by typeing:

make install

Once you’ve done this, you should get the following response from make.

C:\Users\Rick\Desktop\Code\BOOTLO~2>make install
avrdude -c usbasp -pm328p -U flash:w:foodloader.hex:a
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.02s
avrdude: Device signature = 0x1e950f
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "foodloader.hex"
avrdude: input file foodloader.hex auto detected as Intel Hex
avrdude: writing flash (31756 bytes):
Writing | ################################################## | 100% 15.62s
avrdude: 31756 bytes of flash written
avrdude: verifying flash memory against foodloader.hex:
avrdude: load data flash data from input file foodloader.hex:
avrdude: input file foodloader.hex auto detected as Intel Hex
avrdude: input file foodloader.hex contains 31756 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 9.38s
avrdude: verifying ...
avrdude: 31756 bytes of flash verified
avrdude: safemode: Fuses OK
avrdude done.  Thank you.

If you made it to this point,

Congratulations!

You just installed your bootloader.  You should now be able to connect the micro-controller as shown in your guide and use it to upload your programs via the NK programming cable.

Rick

This entry was posted in News. Bookmark the permalink.

2 Responses to Installing the NerdKit Bootloader

  1. Noter says:

    I sure wish I had kept a backup of the items I put in the nerdkits library but I keyed them directly into their site never figuring they were such flakes … C’est la vie !

    • Rick_S says:

      Welcome Paul,

      Most of what I had put in the NK library was from other posts I had made on the forum, so I was able to get a lot of it back. I know there in conversation at the NK forum about your NK ISP loader. I looked at the wayback machine page and it looks like your NK ISP page is missing there as well. A good chunk of the library is there though if you haven’t checked it out.

Leave a Reply

Your email address will not be published. Required fields are marked *