I am a big fan of the Arduino environment because of its simplicity, ease of use, and user community. I like to use it for many of my projects so this means I must design around the Atmel ATmega MCUs to be compatible with the IDE. When you get a new commercial Arduino development board, a bootloader is already programmed on the chip. This bootloader enables the IDE to download code over the serial port on the device rather than through the SPI interface. When you click the Download Code button on the IDE, the ATmega is briefly reset, and the bootloader code runs looking for indication that new code needs to be programmed. The IDE then sends the new code to the UART on the ATmega from a serial port on the computer, usually via a USB-to-TTL converter.
If you are making your own Arduino-compatible hardware and you don’t purchase already-programmed chips, then you will need to program the chips with an Arduino serial bootloader first to be able to use the standard IDE. There are various ways of doing so and they are well documented (for the most part). The Arduino software installation comes with bootloader code ready to be programmed onto your target device. The bootloader code has different flavors to match the different variants in ATmega chips, such as flash size and crystal frequencies. I personally use the Arduino as ISP method to program the bootloader because I can use it with my existing Arduino board and not have to purchase a stand-alone AVR programmer.
I have an older Arduino Diecimila which I use as my programmer and I put the new chips on a breadboard which is on an Adafruit Proto Shield. I have the necessary pins wired up from the shield headers to the breadboard and also included the necessary crystal and reset resistor (see here: burning the bootloader). This setup works pretty well and lets me quickly and easily swap out the chip to be programmed. It’s not as easy as this, but I already had all the necessary hardware.
I recently ran into a couple issues trying to use this Arduino as ISP method while programming the bootloader on chips for my ColorNode project. First, I kept getting a “not in sync” error when it tried to run the bootloader process. After digging around, I found this site which suggested installing ~ 110Ω worth of resistance between the programmer’s Reset line (Arduino board header closest to power jack) and +5V. The method is also discussed and explained here. Basically, when the IDE connects to download the bootloader code via the Arduino board programmed as the AVR programmer, that board get’s reset due to the way the auto-reset circuitry works. Pulling the Reset line to +5V with a much lower resistance prevents this from happening and screwing up the bootloader programming process.
Once I resolved that issue I was able to successfully program the bootloader onto some ATmega328P chips (I chose the regular Duemilanove /w ATmega 328 as the board). I had also purchased up some ATmega328 (non-P) chips because they were cheaper and readily available from DigiKey. The main difference is the process technology where the P indicates their PicoPower technology and is best suited for low-power applications. Since I’m not running off batteries in my application, it doesn’t really matter. The code is compatible with either device and the Arduino IDE doesn’t differentiate between the two when doing the serial programming.
When I attempted to use the above process to program the bootloader on the ATmega328 chips, I ran into my second issue. When I ran the bootloader process I got an “Expected signature for ATMEGA328P is 1E 95 0F” error. Although the two chips are nearly identical and, from the code space aspect are identical, they have different part identification signatures. These signatures need to match those setup in the ISP configuration, specifically the avrdude.conf file. Page 302 in the full datasheet shows that the ATmega328 has a device signature of 0x1E 0×95 0×14 while the signature for the ATmega328P is 0x1E 0×95 0x0F. I found this posting on the arduino forums that talks about it more. Once I changed that setting the bootloader programmed correctly and both the P and non-P versions were able to be serially programmed with the IDE using the standard process.
I did that, i backed up the conf file and replaced the signature 0x0F with the 0×14
But now got the errors after a while
“Yikes! Invalid device signature.”
hi ! I had the same problem as you, which solved by browsing internet. and is as follow:
a) add a configuration item for the 328, and add it to the avrdude file. something like:
#————————————————————
# ATmega328 (non-picopower)
#————————————————————
part
id = “m328″;
desc = “ATMEGA328″;
has_debugwire = yes;
flash_instr = 0xB6, 0×01, 0×11;
eeprom_instr = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0×00,
0xBE, 0×01, 0xB6, 0×01, 0xBC, 0×00, 0xBB, 0xBF,
0×99, 0xF9, 0xBB, 0xAF;
stk500_devcode = 0×86;
# avr910_devcode = 0x;
signature = 0x1e 0×95 0×14;
pagel = 0xd7;
bs2 = 0xc2;
chip_erase_delay = 9000;
pgm_enable = “1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1″,
“x x x x x x x x x x x x x x x x”;
chip_erase = “1 0 1 0 1 1 0 0 1 0 0 x x x x x”,
“x x x x x x x x x x x x x x x x”;
timeout = 200;
stabdelay = 100;
cmdexedelay = 25;
synchloops = 32;
bytedelay = 0;
pollindex = 3;
pollvalue = 0×53;
predelay = 1;
postdelay = 1;
pollmethod = 1;
pp_controlstack =
0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
0×66, 0×76, 0×67, 0×77, 0x6A, 0x7A, 0x6B, 0x7B,
0xBE, 0xFD, 0×00, 0×01, 0×00, 0×00, 0×00, 0×00;
hventerstabdelay = 100;
progmodedelay = 0;
latchcycles = 5;
togglevtg = 1;
poweroffdelay = 15;
resetdelayms = 1;
resetdelayus = 0;
hvleavestabdelay = 15;
resetdelay = 15;
chiperasepulsewidth = 0;
chiperasepolltimeout = 10;
programfusepulsewidth = 0;
programfusepolltimeout = 5;
programlockpulsewidth = 0;
programlockpolltimeout = 5;
memory “eeprom”
paged = no;
page_size = 4;
size = 1024;
min_write_delay = 3600;
max_write_delay = 3600;
readback_p1 = 0xff;
readback_p2 = 0xff;
read = ” 1 0 1 0 0 0 0 0″,
” 0 0 0 x x x a9 a8″,
” a7 a6 a5 a4 a3 a2 a1 a0″,
” o o o o o o o o”;
write = ” 1 1 0 0 0 0 0 0″,
” 0 0 0 x x x a9 a8″,
” a7 a6 a5 a4 a3 a2 a1 a0″,
” i i i i i i i i”;
loadpage_lo = ” 1 1 0 0 0 0 0 1″,
” 0 0 0 0 0 0 0 0″,
” 0 0 0 0 0 0 a1 a0″,
” i i i i i i i i”;
writepage = ” 1 1 0 0 0 0 1 0″,
” 0 0 x x x x a9 a8″,
” a7 a6 a5 a4 a3 a2 0 0″,
” x x x x x x x x”;
mode = 0×41;
delay = 20;
blocksize = 4;
readsize = 256;
;
memory “flash”
paged = yes;
size = 32768;
page_size = 128;
num_pages = 256;
min_write_delay = 4500;
max_write_delay = 4500;
readback_p1 = 0xff;
readback_p2 = 0xff;
read_lo = ” 0 0 1 0 0 0 0 0″,
” 0 0 a13 a12 a11 a10 a9 a8″,
” a7 a6 a5 a4 a3 a2 a1 a0″,
” o o o o o o o o”;
read_hi = ” 0 0 1 0 1 0 0 0″,
” 0 0 a13 a12 a11 a10 a9 a8″,
” a7 a6 a5 a4 a3 a2 a1 a0″,
” o o o o o o o o”;
loadpage_lo = ” 0 1 0 0 0 0 0 0″,
” 0 0 0 x x x x x”,
” x x a5 a4 a3 a2 a1 a0″,
” i i i i i i i i”;
loadpage_hi = ” 0 1 0 0 1 0 0 0″,
” 0 0 0 x x x x x”,
” x x a5 a4 a3 a2 a1 a0″,
” i i i i i i i i”;
writepage = ” 0 1 0 0 1 1 0 0″,
” 0 0 a13 a12 a11 a10 a9 a8″,
” a7 a6 x x x x x x”,
” x x x x x x x x”;
mode = 0×41;
delay = 6;
blocksize = 128;
readsize = 256;
;
memory “lfuse”
size = 1;
min_write_delay = 4500;
max_write_delay = 4500;
read = “0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0″,
“x x x x x x x x o o o o o o o o”;
write = “1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0″,
“x x x x x x x x i i i i i i i i”;
;
memory “hfuse”
size = 1;
min_write_delay = 4500;
max_write_delay = 4500;
read = “0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0″,
“x x x x x x x x o o o o o o o o”;
write = “1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0″,
“x x x x x x x x i i i i i i i i”;
;
memory “efuse”
size = 1;
min_write_delay = 4500;
max_write_delay = 4500;
read = “0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0″,
“x x x x x x x x x x x x x o o o”;
write = “1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0″,
“x x x x x x x x x x x x x i i i”;
;
memory “lock”
size = 1;
min_write_delay = 4500;
max_write_delay = 4500;
read = “0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0″,
“x x x x x x x x x x o o o o o o”;
write = “1 0 1 0 1 1 0 0 1 1 1 x x x x x”,
“x x x x x x x x 1 1 i i i i i i”;
;
memory “calibration”
size = 1;
read = “0 0 1 1 1 0 0 0 0 0 0 x x x x x”,
“0 0 0 0 0 0 0 0 o o o o o o o o”;
;
memory “signature”
size = 3;
read = “0 0 1 1 0 0 0 0 0 0 0 x x x x x”,
“x x x x x x a1 a0 o o o o o o o o”;
;
;
b) create a new definition for the 328 processors in your home/arduino/hardware file. Simply copy under it
boards.txt, the cores directory and the bootloaders you have under hardware in the arduino binaries.
c) modify the boards,txt to create a new entry having atmega328 board. the trick is you say the avr you use an 328 chip, but to the compiler you use a 328p ( inf not you’ll get compiler errors )
# atmega328-pu (non-picopower)
atmega328npp.name=Arduino Duemilanove w/ ATmega328 (non-picopower)
atmega328drd.upload.protocol=arduino
atmega328drd.upload.maximum_size=30720
atmega328drd.upload.speed=57600
atmega328drd.bootloader.low_fuses=0xFF
atmega328drd.bootloader.high_fuses=0xDA
atmega328drd.bootloader.extended_fuses=0×05
atmega328drd.bootloader.path=atmega
atmega328drd.bootloader.file=ATmegaBOOT_168_atmega328.hex
atmega328drd.bootloader.unlock_bits=0x3F
atmega328drd.bootloader.lock_bits=0x0F
atmega328drd.build.mcu=atmega328p <—- watch this
atmega328drd.build.f_cpu=16000000L
atmega328drd.build.core=arduino
atmega328drd.build.variant=standard
you can get the full story here:http://computerpr0n.com/2012/03/burning-arduino-bootrom-on-an-atmega328-pu/
This worked nicely for me. I also made entries for Atmega32 and the attiny line, for arduino 1.x with very good results
sir,my program show an error for gsm header file,shall i get header file with out error
pls help me