Arduino ATmega1284p bootloader

Hi,

I ordered the 1284p a few days ago and I would now burn a bootloader to chip. I only have the Arduino Mega 2560 and the Arduino UNO. Is there any good tutorial how to do that? I read a lot about this but nothing really helps...

Thank you very much!

PS: Sorry for my bad english :wink:

:slight_smile:

Another good one is Nick's programmer:

It is very fast. What kind of clock are you going to use (Crystal, Resonator or Internal)?

Sorry for the late reply, it took some time to get all the components...

Thank you for the latest link. i was able to flash a bootloader to my 1284p. Now I want to upload some code but it fails.

Here is a picture where you can see my setup:

I bought a cheap FTDI programmer but it should do the work. I get this error: avrdude: stk500_getsync(): not in sync: resp=0x00

I selected the Mighty 1284p, 16MHz using Optiboot as board and Arduino as ISP as programmer.

Thank you very much for your help!

What programmer you select is not revelant in the normal uploading the IDE uses. What you have to do is make sure you select the proper com port number for the FTDI uses in the tools menu. Fix that first and then if it still doesn't work you may have rec and tx wires reversed on the FTDI to 1284p chips, reverse them and try again.

Lefty

Thank youf or your reply.

I swap RX and TX, now I get this error messages:

avrdude: stk500_program_enable(): protocol error, expect=0x14, resp=0x50
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

Com Port should not be the problem, I have only one (the FTDI). the FTDI is blinking, when I upload a sketch, so this looks right.

You need some decoupling caps on the VCC/AVCC pins.
You also need to connect FTDI's input pin CTS to Gnd so it knows the chips is waiting for data.

EDIT: Sorry, I see from your picture that it looks like you have DTR and a cap connected for auto reset. It might still be worth trying the manual reset way though to rule reset issues out.

You might have had it round the correct way to start but have you got auto reset wired correctly for your FTDI?

If no auto reset then you'll have to manually reset the 1284P at the right point in the compile/upload process. Have a reset switch wired, or a jumper ready on the RST pin to touch to GND. When you see the compiler finished and the IDE showing 'Compiled xxxxx blah blah blah' then count 'One, Two' and reset the 1284P. It's just a matter of getting the timing right.

When you reset the bootloader starts first and waits to see it any new code is being sent to the MCU. If it has transfer on the UART pins then it facilitates a write of the code into the Flash space. If there is no communication after a short time the it hands over to the currently installed sketch to run.

So, when sending the new sketch via your FTDI you have to reset so that the bootloader becomes active to accept the upload. One normal boards there is an auto reset circuit that the IDE can control, via the FTDI, to initiate the reset at the right time.

CrossRoads:
You need some decoupling caps on the VCC/AVCC pins.
You also need to connect FTDI's input pin CTS to Gnd so it knows the chips is waiting for data.

Why do you say that is a requirement? I note that on a Duemilanove schematic the FTDI CTS pin just goes to a floating pad. I think only if the arduino IDE requested to the PC FTDI USB software driver to use hardware handshaking would you have to deal with the CTS pin on the FTDI chip.

Lefty

I connect it because the Promini has the CTS pin grounded.
The FTDI Basic connects the CTS header pin to the FTDI CTS pin.

So, used or not, that’s the way I connect it, and I never have problems with USB/Serial interfacing.

CrossRoads:
I connect it because the Promini has the CTS pin grounded.
The FTDI Basic connects the CTS header pin to the FTDI CTS pin.

So, used or not, that's the way I connect it, and I never have problems with USB/Serial interfacing.

Grounding it will not cause a problem, but it is not a requirement, it will work equally well unconnected, that was my only point.

Lefty

Yes, thats right, I have caps on both sides (0,1µF). On my FTDI there os GND, CTS, VCC TXD RXD and DTR. I thought DTR is the auto reset pin so I connected DTR to Pin 9 with a 0,1µF cap.

This is my FTDI programmer: http://www.ebay.de/itm/230820610037?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649#ht_500wt_1414

Again, thanks a lot for your help!

Is there anyone who have an idea what is wrong?

php-freak:
Yes, thats right, I have caps on both sides (0,1µF). On my FTDI there os GND, CTS, VCC TXD RXD and DTR. I thought DTR is the auto reset pin so I connected DTR to Pin 9 with a 0,1µF cap.

This is my FTDI programmer: http://www.ebay.de/itm/230820610037?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649#ht_500wt_1414

Again, thanks a lot for your help!

First you can use either RTS or DTR as the arduino IDE/AVRDUDE pulses both signals to generate the auto-reset pulse. The oldest auto-resetting arduino boards used RTS, all the newer ones use DTR, but for legacy backwards compatibility the IDE pulses both RTS and DTR signals.
Second, what do you mean by "I have caps on both sides (0,1µF)" ? if the DTR (or RTS) signal has to pass through two series .1ufd caps to get to the reset pin on the avr chip then that is an effective capacitance of .05ufd and may be too small a value to allow the pulse to generate the reset. If that is the case remove one of the two series connected .1ufd caps from the circuit.

Lefty

Thank you for the info, I didn't know that RTS and DTR works.

I made a better picture with a higher resoultion and some description: 2,8MB Picture

I have two caps between VCC and GND (AVCC and GND). And there is one cap between Pin 9 (Reset) and DTR. I checked TX and RX, at first it was correct then I swap them so it wasn't correct anymore so know it is the right way but the error message is the same: avrdude: stk500_getsync(): not in sync: resp=0x00

The programmer is set for 5V?

You didn't say how you were able to install the bootloader.
I install it via the the IDE, Tools:Burn Bootloader.
This ensures that the fuses are all set correctly for 16 MHz crytsal operation.
I download sketches after that.
If the fuses are not set correctly, the data rate for serial downloads will be mismatched and the download will not work.

I selected the Mighty 1284p, 16MHz using Optiboot as board and Arduino as ISP as programmer.

This is wrong for downloading general sketches, it's only used to download the ISP sketch into
the 1284P to use it to program other chips.

Secondly, as Bob asked, how did you burn the bootloader into the 1284P chip in the first place?
Are you sure that went correctly?

Thirdly, your FTDI cable looks like a knockoff of the FTDI friend. It may or may not "in
fact" be using DTR, rather than RTS. If it's actually using RTS you need to go to the
Control Panel device manager for the COMPORT and select "set RTS on close".

Fourthly, it looks like in your 2.8MB picture you have TX and RX wired wrong. The TX
and RX labels on the FTDI Friend and regular FTDI cables specify the signal flow with
respect to the cable, not the Arduino. So, the wires have to be swapped between the
2 devices. BTW, I always insert 1K series-Rs in the RX,TX lines in case I hook them
up backwards.

The other thing is I use the FTDI Friend and FTDI cables most of the time, and have
never tied CTS to anything.

Thanks for the great answers!

I changed the setting in the device manager, just in case to test it. I used this tutorial: Gammon Forum : Electronics : Microprocessors : How to make an Arduino-compatible minimal board and the Serial Monitor said that it was successful. That do I have to choose to download a general sketch?

Yes it is a cheap FTDI version, on the ebay page they said it uses DTR. Thanks for the information that I have to swap TX and RX. Is connection via the cap to the reset pin right for DTR?

For a general sketch, you just go to your sketchbook or the IDE "File > Examples",
and choose something other than ArduinoISP.

I think your reset pin wiring is ok. All you need is a 0.1 uF cap from FTDI DTR to the
1284P reset pin, plus a 10K pullup to 5V on the reset pin. Simple.

I am still curious [Bob too], as to how you burned the bootloader into the 1284P in the
first place. ???

Yes I am, how was the bootloader set up?

I use an Atmel AVR ISP MKii. I use the IDE to burn the bootloader first to make the fuses are set correctly.
The times I forgot to that, I spend a frustrating 1/2 figuring what is going on, eventually figuring out the clock is really slow, and then finally remembering to do the bootloader for the fuses. Getting better about that.

I then use File: Upload Using Programmer with the MKii if I don't need the bootloader, or I connect up an FTDI Basic for downloading sketch via serial interface.

I don't use the Optiboot 16 MHz tho, I always use Bobuino so Serial is at D0/D1, SPI is D10-11-12-13, and I2C is A4/A5 of D18/D19, just like on a '328 board. I like a little consistency.