Using Arduino Uno instead of FTDI cable to program 1284p w/ Optiboot

Hello there,
I've bought an ATmega1284p, set it up on a breadboard(Maniacbug's Mighty 1284p setup) and successfully programmed Optiboot into it, using ArduinoISP. As my Uno(the first version, not R2 nor R3) is the only device with USB-TTL serial I have, I tried to use it to upload sketches to the 1284p. I tried to remove the ATmega328p from Uno and then connecting Rx, Tx, and Reset to 1284p - it didn't work. I also tried it without removing the ATmega328p, but connecting Uno's reset to GND and manually resetting the 1284p - no success. I always get a message from avrdude that the programmer is not responding(not out of sync). When I reset the 1284p, a LED connected to pin 1 blinks, so the bootloader is there. Original Mighty 1284p bootloader doesn't want to work either. I also tried to upload sketches via ArduinoISP, without bootloader, and it works fine. Even sketches using hardware Serial work fine, using Arduino Uno as USB-TTL serial. I'm using Arduino IDE 1.0.1 on Debian Wheezy amd64.
I'm not sure if this is issue of Arduino Uno(and buying a FTDI cable would help) or the ATmega1284p. Has anybody ever tried to use Arduino Uno with Mega8u2 to upload sketches to standalone ATmega or Arduino without USB?

PS Sorry for mistakes in language, if any. English is not my native language.

Remove the ATMega328p. Connect TX from the arduino to TX of the ATmega1284, and RX from the arduino to RX of Atmega1284. Then connect the reset pins together.

There is no reason why this shouldn't work, so I am guessing that you got the TX and RX reversed.

I've checked if the Rx and Tx pins are not reversed, and they are OK. I think this is not the problem, because sketch using Serial, uploaded with ArduinoISP, using "Upload with Programmer" works.
Here's an image showing how it's all connected. The switch on the left was used previously to reset the 1284p and in the photo it's unconnected. Three LEDs on the right were connected to Arduino when I was using it as an ISP.

When I try to upload sketches using serial, the TX and RX LEDs flash two or three times, and after two-three seconds i get "avrdude: stk500_recv(): programmer is not responding" in Arduino IDE.

Could you go to File->Preferences and check the box labeled upload next to "Show Verbose Output during:". Then try uploading again and post what it says.

Here it is:

/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega1284p -carduino -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/build5095698683208589081.tmp/Blink.cpp.hex:i 

avrdude: Version 5.11.1, compiled on Oct 18 2011 at 21:41:15
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/usr/share/arduino/hardware/tools/avrdude.conf"
         User configuration file is "/home/szymon/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 
         AVR Part                      : ATMEGA1284P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    10   128    0 no       4096    8      0  9000  9000 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash         65    10   256    0 yes    131072  256    512  4500  4500 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
avrdude: Send: A [41] . [80]   [20] 
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

Well, I've recompiled Optiboot to use 9600 baud rate and burned it into 1284p. I can upload Blink sketch without problems using serial to the 1284p, and it blinks fine, but uploading anything that is bigger is never successful. It stops in random place when uploading and I get that from avrdude:

avrdude: Recv: b [62] 

avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x62
avrdude: Send: V [56] @ [40] . [00] . [00] . [0c]   [20] 
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

When you compile optiboot with a 16MHz crystal it switches in a software based UART if the BAUD rate is <57600 baud. I found that optiboots software version is not very reliable (works for small programs, but not larger ones), so you may want to compile it for 57600.
Alternatively, if that fails, I can send you my current version of optiboot.c which has a much improved software UART routine (written mainly for the tiny84, but should work with others). That would allow you to run at the lower Baud rate.

Well, it couldn't upload even Blink at 57600 baud rate. Could you send the file, please?

Ah, the "paged_write" fun that nobody else has a problem with :wink:

This seems to be an issue when low voltage serial programmers try to put Optiboot on. You should be able to eventually get "Blink" onto the 1284p, but any larger sketches will fail.

Try bootloading the "Orginal Mighty 1284" onto the chip and then try to upload any sketch on it. It might fail.

If you bootload/sketch upload this one on the 1284p UART1 (as opposed to UART0) it seems to work well.
http://code.google.com/p/optiboot/downloads/detail?name=optiboot_atmega1284p-u1.hex&can=2&q=
Just replace the "U1" optiboot in the folder of the Mighty1284 Optiboot and burn bootloader.

The history is here: http://arduino.cc/forum/index.php/topic,80483.465.html

Have you tried NickGammon's writeup for '1284s?

Go a little past halfway down the page.
Covers installing a bootloader and downloading a sketch.

CrossRoads:
Have you tried NickGammon's writeup for '1284s?

Gammon Forum : Electronics : Microprocessors : How to make an Arduino-compatible minimal board

Go a little past halfway down the page.
Covers installing a bootloader and downloading a sketch.

Question CrossRoads... Have you tried this Gammon setup with an Uno?

I have not. I use Atmel AVR ISP MKii.

SzymekRak:
Hello there,
I've bought an ATmega1284p, set it up on a breadboard(Maniacbug's Mighty 1284p setup) and successfully programmed Optiboot into it, using ArduinoISP. As my Uno(the first version, not R2 nor R3) is the only device with USB-TTL serial I have, I tried to use it to upload sketches to the 1284p. I tried to remove the ATmega328p from Uno and then connecting Rx, Tx, and Reset to 1284p - it didn't work. I also tried it without removing the ATmega328p, but connecting Uno's reset to GND and manually resetting the 1284p - no success. I always get a message from avrdude that the programmer is not responding(not out of sync). When I reset the 1284p, a LED connected to pin 1 blinks, so the bootloader is there. Original Mighty 1284p bootloader doesn't want to work either. I also tried to upload sketches via ArduinoISP, without bootloader, and it works fine. Even sketches using hardware Serial work fine, using Arduino Uno as USB-TTL serial. I'm using Arduino IDE 1.0.1 on Debian Wheezy amd64.
I'm not sure if this is issue of Arduino Uno(and buying a FTDI cable would help) or the ATmega1284p. Has anybody ever tried to use Arduino Uno with Mega8u2 to upload sketches to standalone ATmega or Arduino without USB?

PS Sorry for mistakes in language, if any. English is not my native language.

I feel like I'm the expert at this type of problem with the 1284p =P!! Try my solution and if it doesn't work i'll try to help you in some other way.

http://arduino.cc/forum/index.php/topic,80483.465.html See Post : #473

The Original Mighty 1284p bootloader doesn't work and Nick Gammon's sketch doesn't want to compile on Arduino IDE 1.0.1.

The UART1 solution seems to work fine with 115200 baud rate. Thanks! But, unfortunately, the UART1 pins are also interrupt pins. But I think I won't need to use more than one in my project.

Nick Gammon's sketch doesn't want to compile on Arduino IDE 1.0.1.

Did you put all the files into the same folder, Atmega_Board_Programmer?
I did and then opened Atmega_Board_Programmer.ino, compiled just fine.

CrossRoads:

Nick Gammon's sketch doesn't want to compile on Arduino IDE 1.0.1.

Did you put all the files into the same folder, Atmega_Board_Programmer?
I did and then opened Atmega_Board_Programmer.ino, compiled just fine.

I have used the Atmega Board Programmer and it is nice, and it appears to install the 1284p well enough, but again, uploading a sketch ~25kB fails with the paged_write error. Blink uploads fine. I have also tried pulling the hex out of another hex file and putting in, same problem.

The Atmega328 works flawlessly. The 25kB sketch uploads perfectly.

SzymekRak:
The Original Mighty 1284p bootloader doesn't work and Nick Gammon's sketch doesn't want to compile on Arduino IDE 1.0.1.

Please post your error messages. Possibly you didn't install the SDFat library. There is a comment near the top of the sketch about that:

// for SDFat library see: http://code.google.com/p/beta-lib/downloads/list
#include <SdFat.h>

spcomputing:
I have used the Atmega Board Programmer and it is nice, and it appears to install the 1284p well enough, but again, uploading a sketch ~25kB fails with the paged_write error. Blink uploads fine. I have also tried pulling the hex out of another hex file and putting in, same problem.

The Atmega328 works flawlessly. The 25kB sketch uploads perfectly.

What gives the paged write error? The bootloader? My sketch? Please clarify and post any messages you get.

I have SDFat installed. I didn't try to compile the sd card hex uploader, but Atmega_Board_Programmer and here are the error messages:

In file included from Atmega_Board_Programmer.cpp:121:0:
bootloader_atmega168.h:3:34: error: variable ‘atmega168_optiboot’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
In file included from Atmega_Board_Programmer.cpp:122:0:
bootloader_atmega328.h:3:34: error: variable ‘atmega328_optiboot’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
In file included from Atmega_Board_Programmer.cpp:123:0:
bootloader_atmega2560_v2.h:3:29: error: variable ‘atmega2560_v2’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
In file included from Atmega_Board_Programmer.cpp:124:0:
bootloader_atmega1284.h:5:40: error: variable ‘optiboot_atmega1284p_hex’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
In file included from Atmega_Board_Programmer.cpp:125:0:
bootloader_lilypad328.h:5:53: error: variable ‘ATmegaBOOT_168_atmega328_pro_8MHz_hex’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
In file included from Atmega_Board_Programmer.cpp:126:0:
bootloader_atmega1280.h:5:45: error: variable ‘ATmegaBOOT_168_atmega1280_hex’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp:223:3: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
Atmega_Board_Programmer.cpp: In function ‘byte writeFlash(long unsigned int, byte)’:
Atmega_Board_Programmer.cpp:262:3: warning: no return statement in function returning non-void [-Wreturn-type]
Atmega_Board_Programmer.cpp: In function ‘void showHex(byte, boolean, boolean)’:
Atmega_Board_Programmer.cpp:270:71: warning: narrowing conversion of ‘((((int)(b >> 4)) & 255) | 48)’ from ‘int’ to ‘char’ inside { } is ill-formed in C++11 [-Wnarrowing]
Atmega_Board_Programmer.cpp:270:71: warning: narrowing conversion of ‘((((int)b) & 15) | 48)’ from ‘int’ to ‘char’ inside { } is ill-formed in C++11 [-Wnarrowing]
Atmega_Board_Programmer.cpp: In function ‘void writeBootloader()’:
Atmega_Board_Programmer.cpp:415:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
Atmega_Board_Programmer.cpp:438:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
Atmega_Board_Programmer.cpp:354:8: warning: unused variable ‘lFuse’ [-Wunused-variable]
Atmega_Board_Programmer.cpp: In function ‘void getSignature()’:
Atmega_Board_Programmer.cpp:526:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

I just re-tested on Arduino 1.0.1 and got this result:

Binary sketch size: 22,932 bytes (of a 32,256 byte maximum)

This is on OS/X. Also compiled OK on Windows XP.