Wednesday, March 28, 2012

Atmega 328 non p adventure

A few weeks ago I ordered a pair of Atmega328 non P version to use in my Arduino projects. Since I am curious took the challenge of changing the bootloader on the chip. Went online, read a lot of tutorials and success stories about the desired task. All seems so easy that I took on the challenge without hesitation.
Started by openning the ArduinoISP (commenting the include of the pins.h library file) and downloading to the board. Connected the chip and... "no bacon". Try and try again and no bacon. A few nights and a lot of hours latter finally got it working and my steps to success are listed bellow

Short steps.
1. Loaded a VirtualBox Windows XP machine after reading in some forums about a situation with Ubuntu 11.X where the kernel may cause the burning process to fail. (Couldn't explain but since tried everything else..)
2. Loaded the Arduino 1.0 tool set in the WinXP machine.
3. Modify the Arduino ISP baud rate to 9600 and commented the "pins" include at the beginning (will not compile with it).
4. Edited 3 files in the arduino directory tree (boards.txt and avrdude.conf and programers.txt). Change the signature of the Atmega328p chip in avrdude.conf my recommendation as I founded by someone else post. Just open the file copy all Atmega328p and change the name Atmega328p to atmega328 and change the chip signature. Also open boards.txt and copy paste the ArduinoUno settings to Arduino328UnoNonP rename the uno. To uno328. And the chip type from atmega328p to atmega328. Edit programers.txt and change the baud rate of the ArduinoISP to 9600
5. Close and open the ArduinoISP and select the new ArduinoUno328 we just created from the menu.
6. Select ArduinoISP as the programer. Put a capacitor between reset and ground. The exact value was taken from the official arduino web site. This prevents the arduino from reset. 
7. Select burn bootloader
8. Wait for it to finish, that should be all.

Files are not here since this post was from my phone. But should be updated latter with more details and files for easy reproduce.
The Ubuntu problem I had may not be an Ubuntu issue but I tried and tried till changed to a virtual machine with XP. Still I will continue trying to make it work with in Ubuntu without the virtual XP. I had a version of avrdude compiled myself with the Arduino1.0 also downloaded not installed from ubuntu repository. Maybe all my stupidity was the cause, who knows. Important thing is that it is working now like new!!

The Atmega328 non P is a possibility and can be found for less than $3 in or in other web sites for a little more preloaded with the Arduino bootloader.