This Lazy Old Geek is also an Arduino Geek. If you are an Arduino Geek, one of the common microcontrollers used by Arduinos is the Atmega328 chip. In order to use Arduino software, the Atmega must have bootloader software on it.
Okay, so I bought some blank Atmega328-PU chips from Mouser.com.
TIP: If you want to make your life simpler, order the Atmega328P-PU chips instead of the Atmega328-PU chips.
I didn’t realize there was a difference. As far as I can tell, the Atmega328P-PU has lower power but it also has a different device signature which is important to Arduino users. As of November 2011, the Atmega328-PU is cheaper by about $1.
Problem: So there are hundreds of articles on installing bootloader on the Atmega328. I built one using another Arduino to program the chip. I built one using the USB-BUB to program the chip. I built one using a parallel port to program the chip. Well, even after a week of troubleshooting and searching the Internet, none of them worked. So I gave up. I am usually a very persistent hacker but I’m getting old so I gave up.
Solution?: Well, about a month later I saw another bootloader from Ladyada.net:
Well, this one looked a lot like most of the others I’d built. But it was from AdaFruit which has some of the best tutorials (accurate, complete, well documented) I’ve seen for the Arduino and it had different code. So I hacked up the hardware (See picture) using a RBBB Arduino and loaded the software. And guess what. It still didn’t work.
Well, I looked at the code and saw that it was set up to use the Serial Terminal. So I opened up the Serial Terminal and ran the program again.
This is the error message I got. (See picture)
After a lot of fooling around with Bootloaders I thought that this was not the correct signature that most software was looking for.
Signature: So what is a signature? Well, it turns out it is a specific code hard wired into the chip to identify it. Now all of the bootloader software seemed to be looking for 0x950F and not 9514 or 0x9514.
GeekSpeak: This is like ROM code that cannot be changed. By the way when you see programming code written starting with ‘0x’ that means it is a hexadecimal number. I won’t go into details but hexadecimal numbers go from 0 to 15 instead of 0 to 10.
Signature: So it turns out the bootloader software I’ve seen were based on the 0x950F signature which is the signature for the Atmega328P-PU chip. Being in electronics for 40 years, I usually ignored letters after the number. They are usually just revisions. This is basically true but in this case, the change also affects bootloading.
GeekSpeak: The PU refers to the packaging in this case PDIP which will fit into the 28 pin narrow IC socket preferred by most hobbyists.
Step 1: My Programmer
Solution: Well, I did get it to work with my breadboard setup with some software changes discussed later but I wanted a more permanent setup. I did have a protoshield like the one used in the AdaFruit writeup but I wanted to save mine for future projects so I decided to build my own shield.
PCB I used a hunk of the following:
5* Breadboard Bread Board Prototype 432 Points 5*7cm
28 pin IC socket
2 1.2K resistors
1 red LED
1 green LED
Male header pins
About $0.25 Taydaelectronics.com
I had all of the above on hand but the total cost was about $1.
Step 2: Assembly
Problem: These PCBs have solder pads on only one side. I decided to put the pads on the bottom so the IC socket could be soldered in. The problem is the header pins going into Arduino go on the bottom couldn’t be easily soldered.
Solution: Well I decided to hot glue the headers to the PCB.
Problem: The standard prototype PCBs have 0.1” spacing between holes. This is standard for most electronics components. As many Arduino Geeks know, the original Arduinos had three connectors spaced correctly on 1/10 centers but the fourth connector was offset slightly. What this means is that Arduino shields cannot be easily made on standard prototype PCBs.
Solution: Hobbyists/Instructablers have come up with solutions for this. Most involve bending header pins to fit. Well, my header pins are a little short to bend so I decided to go a different route. For the one connector that was offset, I marked the location on the protoboard. Then I used a Dremel-clone to cut a slot there for the connector. I wonder if a laser engraver could cut this slot.
Hot-glue procedure: I wanted to use an Arduino (clone) to get the pins lined up and make the gluing easier. But I’m a messy hot gluer so I took some male header strip and inserted it part way into the female headers. (See picture)
Then I took a strip of transparent tape and pinched it in between the male and female header. (See picture). It’s hard to see the tape but the reflections are an indicator.
Then I folded the tape over onto the female headers. (See picture)
Then I did the same for the other side.
Next put the correctly sized male headers 2 eights and 2 sixs into the protoboard where you want them and push the headers onto the Arduino.
Next I hot-glued the header strips to the protoboard.
After it cools, you can carefully pull the headers out maybe with a knife or small screwdriver. The tape helps keep the glue from sticking to the female headers. Now it can be removed.
Next you can carefully hot glue the insides of the male header pins to the protoboard for strength.
Step 3: Wiring
Install the LEDs resistors and pushbutton where you want them.
NOTE: The LEDs aren’t essential but helps to show that it’s working correctly. The pushbutton starts the bootloading process.
Wire it up per the attached schematic. I used some 30AWG wire as it will slip through the protoboard holes and is easy to work with.
NOTE: One connector isn’t wired at all but helps align and stabilize the shield.
Step 4: Sketches
The first zip file contains the sketch that is from the original LadyAda tutorial. The second is one I modified for the Atmega328 chip.
Load the whole subdirectory into your Arduino software for the ones you need.
So I put the protoboard on my Arduino and loaded one of the scripts into it and pushed the button.
Problem: Well of course, it didn’t work. The program seemed to be in a continous loop of bootloading.
Solution: After some troubleshooting, I’d found that I’d wired the pushbutton incorrectly. As many know, these pushbuttons have four pins and two on each side are wired together. I know that and knew it when I was wiring it up but I still managed to wire it wrong. Once I fixed this, it worked fine.
Disadvantage: So the disadvantage of this method is that I have to load the correct sketch for the particular Atmega chip I am trying to program. Now, it would be more elegant to re-write the sketch to automatically detect which chip is attached and program accordingly. Well, I am Lazy and a lot of this code is written in C++ rather the easier Arduino so I decided not to mess with it. I don’t plan on having to bootload very many chips anyway.
Conclusions: Searching the Internet, it looks like a lot of Arduinoites have had this problem. I hope this Instructable reaches some of them. I’m guessing there’s a lot of C++ programmers who can/have come up with a fix for the standard Arduino software. If you know of any, please comment. But this fix works for me.