ATmega1284p burning using arduino as ISP

Hello everyone! I am an arduino user since the NG boards back in the day. Though it's my first time on the forum. I need some help getting arduino as isp working with brand new Atmega1284p chips. Here's the scenario - I have the following things available to me - 1. Arduino Nano's - around 2-3 2. Arduino Mega 2560 3. arduino Uno 4. Arduino Duemilanove 5. If i dig around I might be able to find arduino pro and NG

Normally I use AVR ISP mk II with AVR's but Unfortunately my device was in my bag when it got stolen a month or so back. I cannot get another one anytime soon (Ive placed an order for one, will take at least a week to reach, most probably more) due to my location. Anyways I was trying to get Arduino ISP to work with my 1284p's ... I tried burning some blink codes (AVR) to it via AVRDUDESS, couldn't get it to work. Always had stk_500 errors. I tried adding a resistor between RST and +5 (150 ohm) but that didn't work. Tried with a cap between RST and GND, that didn't work. I ensured that the heartbeat delay was 20 ms. Is there something I'm missing out? I can get this device https://www.sparkfun.com/products/9825 if it can solve the problem fast. Also is there any chances that although I'm getting stk500 errors the new chip's fuses have been set and i've been locked out. Really appreciate any help, Regards

You might read this page, this scheme works for 1284P chips as well as for 328 chips, you just need to select the proper board in the IDE and burn the ArduinoISP sketch into your host board - UNO is easy to use. http://arduino.cc/en/Tutorial/ArduinoISP

Hey, thanks for the quick reply... I've read through the page already, I used to burn atmega328p and atmega168 chips using this method before, but i've only used it for that before this. If you have a new atmega1284p, can you directly program it in a 16Mhz crystal + caps setup directly without programming fuses first, at lets say a slower speed? Thanks in advance

I did it using raw unprogrammed 1284 chips. People use maniacbug's bootloader, note there are some errors in the Bobuino variant files, https://github.com/maniacbug/mighty-1284p

You also need to change the low-fuse setting for best reliability, see comment here about 1284, http://arduino.cc/forum/index.php/topic,154867.0.html

Thanks for the reply…
I’ll try the solution and report back as soon as I’m home…
Btw what arduino do you recommend to use as an isp… I can use any of the above ones as they are available to me, also what change to I have to make in order to avoid the auto-reset problem… (resistor vs cap)…
Thanks in advance

I've had pretty good luck with not having to use a cap to prevent the board running ArduinoISP from being overwritten when you start to program thru it. It seems the current bootloaders are pretty good about gracefully erroring out and not hanging up when they get an error simply because they detected serial data flowing that wasn't intended for them. By using different baud rates, you guarantee an error preventing the ArduinoISP board from accidentally being overwritten when you're trying to program another board. I use optiboot and set the baud to 115200 which doesn't match what my Uno boards run at, so even though they reset, they don't get overwritten unless I want them to. The down side is that if I accidentally forget to do the Upload Using Programmer, it will overwrite the ArduinoISP board. It's really going to be a hit or miss proposition, you'll just have to try and see what happens. You can't hurt anything that I know of.

I think the wire to ground trick is just so you can use the on-board USB to serial chip to talk to the breadboard chip that you are burning. ArduinoISP certainly won't be able to help with anything while the processor is held in reset. ;)

Hello everyone... Finally got something to work. I was able to :upload via programmer" in the IDE using duemilanove as isp (for some reasone didn't work with uno)... Anyone know what settings are configured for the mighty1284p using optiboot for avrdude? that's the device i selected in tools -> boards. Also there's a slight problem still there... The chip seems to run very slow a delay(1000); takes much much longer than 1 second ( more like 16 seconds - possible some divide error on clock fuses? or it's running on internal clock?). I uploaded the program without external oscillators on a breadboard and am running the program with the oscillator (on a board i made)...

If you have a new atmega1284p, can you directly program it in a 16Mhz crystal + caps setup directly

I uploaded the program without external oscillators on a breadboard and am running the program with the oscillator (on a board i made)...

Earlier you "implied" you were using caps on the xtal, and now you're not? You need the caps both for burning the bootloader and also sketches.

Sounds like a mismatch between what the bootloader and fuses think is your oscillator. It also sounds like you are running on the internal 1MHz oscillator (8MHz internal RC oscillator divided by 8). Your bootloader is compiled with baud information and fuse information from its Makefile. To make things confusing, your boards.txt (where the board selection entries come from) file has these things in it as well. Your CPU frequency is also included in both of these places. This all has to jive or it will not work right.

Here are some entries added to my boards.txt to program an atmega328p on a breadboard with various oscillator options:

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=arduino
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=arduino:standard

MWB16MHz.name=ATmega328 on a breadboard (16 MHz external clock)

MWB16MHz.upload.protocol=arduino
MWB16MHz.upload.maximum_size=32256
MWB16MHz.upload.speed=115200
###MWB16MHz.upload.using=arduino:arduinoisp       Uncomment this and comment the upload.protocol line to switch back arduinoisp

MWB16MHz.bootloader.low_fuses=0xFF
MWB16MHz.bootloader.high_fuses=0xDE
MWB16MHz.bootloader.extended_fuses=0x05
MWB16MHz.bootloader.path=arduino:optiboot
MWB16MHz.bootloader.file=optiboot_atmega328__16MHz.hex
MWB16MHz.bootloader.unlock_bits=0x3F
MWB16MHz.bootloader.lock_bits=0x0F

MWB16MHz.build.mcu=atmega328p
MWB16MHz.build.f_cpu=16000000L
MWB16MHz.build.core=arduino:arduino
MWB16MHz.build.variant=arduino:standard

MWB20MHz.name=ATmega328 on a breadboard (20 MHz external clock)

MWB20MHz.upload.protocol=arduino
MWB20MHz.upload.maximum_size=32256
MWB20MHz.upload.speed=115200
###MWB20MHz.upload.using=arduino:arduinoisp       Uncomment this and comment the upload.protocol line to switch back arduinoisp

MWB20MHz.bootloader.low_fuses=0xF7
MWB20MHz.bootloader.high_fuses=0xDE
MWB20MHz.bootloader.extended_fuses=0x05
MWB20MHz.bootloader.path=arduino:optiboot
MWB20MHz.bootloader.file=optiboot_atmega328__20MHz.hex
MWB20MHz.bootloader.unlock_bits=0x3F
MWB20MHz.bootloader.lock_bits=0x0F

MWB20MHz.build.mcu=atmega328p
MWB20MHz.build.f_cpu=20000000L
MWB20MHz.build.core=arduino:arduino
MWB20MHz.build.variant=arduino:standard

Here is the stuff I added to the optiboot Makefile to build the two bootloaders I needed for 16Mhz and 20Mhz crystals:

# lines added by MWB for testing ATMega328P @ 16MHZ
#
atmega328_16MHz:    TARGET = atmega328__16MHz
atmega328_16MHz:    MCU_TARGET = atmega328p
atmega328_16MHz:    CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
atmega328_16MHz:    AVR_FREQ = 16000000L
atmega328_16MHz:    LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
atmega328_16MHz:    $(PROGRAM)_atmega328__16MHz.hex
atmega328_16MHz:    $(PROGRAM)_atmega328__16MHz.lst
atmega328_16MHz_isp:    atmega328_20MHz
atmega328_16MHz_isp:    TARGET = atmega328__16MHz
atmega328_16MHz_isp:    MCU_TARGET = atmega328p
# 512 byte boot, SPIEN
atmega328_16MHz_isp:    HFUSE = D6
# Low power xtal (16 MHz) 16KCK/14CK+65ms
atmega328_16MHz_isp:    LFUSE = FF
# 2.7V brownout
atmega328_16MHz_isp:    EFUSE = 05
atmega328_16MHz_isp:    isp
#
# lines added by MWB for testing ATMega328P @ 20MHZ
#
atmega328_20MHz:    TARGET = atmega328__20MHz
atmega328_20MHz:    MCU_TARGET = atmega328p
atmega328_20MHz:    CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
atmega328_20MHz:    AVR_FREQ = 20000000L
atmega328_20MHz:    LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
atmega328_20MHz:    $(PROGRAM)_atmega328__20MHz.hex
atmega328_20MHz:    $(PROGRAM)_atmega328__20MHz.lst
atmega328_20MHz_isp:    atmega328_20MHz
atmega328_20MHz_isp:    TARGET = atmega328__20MHz
atmega328_20MHz_isp:    MCU_TARGET = atmega328p
# 512 byte boot, SPIEN
atmega328_20MHz_isp:    HFUSE = D6
# Low power xtal (20 MHz) 16KCK/14CK+65ms
atmega328_20MHz_isp:    LFUSE = F7
# 2.7V brownout
atmega328_20MHz_isp:    EFUSE = 05
atmega328_20MHz_isp:    isp

I used a different bootloader that was premade for the 8MHz internal oscillator version, that's why nothing is in the Makefile for it.

I have my new boards.txt file located in a folder named breadboard, under the hardware folder. It is separate from the one that is distributed, but it merges the two when you start the IDE.

oric_dan:

If you have a new atmega1284p, can you directly program it in a 16Mhz crystal + caps setup directly

I uploaded the program without external oscillators on a breadboard and am running the program with the oscillator (on a board i made)...

Earlier you "implied" you were using caps on the xtal, and now you're not? You need the caps both for burning the bootloader and also sketches.

Earlier I was burning with the caps and xtal but it was not working, as soon as I took it off my "generic" board, and onto a breadboard, I was able to program it. Now I burned the mighty bootloader with optiboot and the timing issue got fixed. I am now able to program both directly on the board and off it. During this time I was testing all the circuitry with an arduino nano in between. (I've made an FTDI header to match that of arduino nano).

I really appreciate everyone's help on this matter. Thanks for being an awesome community and keep up the good work!

Earlier I was burning with the caps and xtal but it was not working

The std maniacbug bootloaders are expecting you to use the 16 Mhz xtal and caps. Plus every other bootloader in creation has "specific" requirements as to xtal frequency, external xtal or internal oscillator, etc. You have to match these up. Read the boards.txt files.