Pages: 1 [2] 3   Go Down
Author Topic: Using Arduino Uno instead of FTDI cable to program 1284p w/ Optiboot  (Read 6907 times)
0 Members and 1 Guest are viewing this topic.
California
Offline Offline
God Member
*****
Karma: 14
Posts: 629
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged


Global Moderator
Melbourne, Australia
Offline Offline
Brattain Member
*****
Karma: 511
Posts: 19356
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

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

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Global Moderator
Melbourne, Australia
Offline Offline
Brattain Member
*****
Karma: 511
Posts: 19356
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Poland
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

Code:
// for SDFat library see: http://code.google.com/p/beta-lib/downloads/list
#include <SdFat.h>
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:
Code:
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]
Logged

Global Moderator
Melbourne, Australia
Offline Offline
Brattain Member
*****
Karma: 511
Posts: 19356
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

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

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Global Moderator
Melbourne, Australia
Offline Offline
Brattain Member
*****
Karma: 511
Posts: 19356
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
... variable ‘atmega168_optiboot’ must be const in order to be put into read-only section  ...

Try adding the word "const" before the hex images in the .h files. eg, change:

Code:
byte PROGMEM ATmegaBOOT_168_atmega1280_hex [] = {

to:

Code:
const byte PROGMEM ATmegaBOOT_168_atmega1280_hex [] = {
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

California
Offline Offline
God Member
*****
Karma: 14
Posts: 629
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Hi Nick,

It has the stk_500_paged_write error in the middle of uploading a large sketch (Show Info modified for a Mega).  Blink uploads fine.  This problem seems to be around serial pocket programmers(USBasp) and Arduino as ISP.  

The only 1284p bootloader that uploads consistently with Aduino as ISP is WestfW's Optiboot for UART1.  I can somehow get Original Might 1284 (16MHz) to work as well.  cyclegadget has no problem with Atmega Board Programmer and an Arduino and the 1284p SMD/CrossRoads Board.  AVRISP MkII have no trouble at all.

It is quite the enigma wrapped in bacon.  I am going to build an *exact* half-board minimal-duino from your tutorial to see if there is something else causing trouble.

Even with this hic up, Atmega Board Programmer is a very clever sketch, great for my 328's!

Logged


Poland
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
... variable ‘atmega168_optiboot’ must be const in order to be put into read-only section  ...

Try adding the word "const" before the hex images in the .h files. eg, change:

Code:
byte PROGMEM ATmegaBOOT_168_atmega1280_hex [] = {

to:

Code:
const byte PROGMEM ATmegaBOOT_168_atmega1280_hex [] = {

I've already tried it before. It only makes the errors like this:
Code:
Atmega_Board_Programmer.cpp:223:3: error: invalid conversion from ‘const byte* {aka const unsigned char*}’ to ‘byte* {aka unsigned char*}’ [-fpermissive]
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]
Logged

Global Moderator
Melbourne, Australia
Offline Offline
Brattain Member
*****
Karma: 511
Posts: 19356
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You must be using a different toolchain to what I am. Try moving the word PROGMEM around a bit, eg.

Code:
byte ATmegaBOOT_168_atmega1280_hex [] PROGMEM = {
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Global Moderator
Melbourne, Australia
Offline Offline
Brattain Member
*****
Karma: 511
Posts: 19356
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It has the stk_500_paged_write error in the middle of uploading a large sketch (Show Info modified for a Mega).  Blink uploads fine.  This problem seems to be around serial pocket programmers(USBasp) and Arduino as ISP.  

Does my bootloader uploader upload a bootloader OK? If so, then after that are you saying the (new) bootloader fails to upload a large sketch? That sounds then like the hex codes for the bootloader might be wrong. If we replace them with the bootloader that works (like WestFW's one) then things should be OK.
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

California
Offline Offline
God Member
*****
Karma: 14
Posts: 629
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Does my bootloader uploader upload a bootloader OK? If so, then after that are you saying the (new) bootloader fails to upload a large sketch? That sounds then like the hex codes for the bootloader might be wrong. If we replace them with the bootloader that works (like WestFW's one) then things should be OK.

Correct.  I have an incredibly stupid question.  With the Atmega Board Programmer, the 1284p h file (bootloader is 1024 in size) is ~4kB, while the 1280 h file is ~24kB (4096 in size), is there any reason for this?  I see the 2560 h file doubles the 1280 h file size.

It really would be nice if someone could build out a 1284p on a breadboard and burn a standard optiboot or optiboot mighty 1284p with the current ABP software and with an arduino.  Then upload through FTDI (or even a aduino serial) the ABP program and report the results.  And, if that works, pull the hex out of that chip and post here or compare to the current ABP?

The optiboot atmega1284 UART1 is good to have as a stopgap, but it really would be nice to have things a little more standardized when working from anything Arduino.
Logged


Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

I had exactly the same problem: 1284p with FTDI serial converter. The bootloader was written correctly,
"blink" could be flashed but any larger sketch failed with a "protocol error" at various points of the upload
process ranging from 5% to 60%. (Previously I used the "Original Mighty 8 MHz" bootloader which was slow but usable. Ken Shirriff's IRremote- ibrary, however, insists on 16 MHz so I had to change to that bootloader version.)

I spend hours and fouled around with every parameter I could find: cabling, crystal, capacitors, voltage, software - nothing helped.

The UART1 bootloader solved the problem at the very first attempt...

Great - thanks!

Make it available to the general public!
Logged

California
Offline Offline
God Member
*****
Karma: 14
Posts: 629
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I spend hours and fouled around with every parameter I could find: cabling, crystal, capacitors, voltage, software - nothing helped.

The UART1 bootloader solved the problem at the very first attempt...

Great - thanks!

Make it available to the general public!

Another "fix" is to use a resonator instead of the more precise crystal.  Apparently, there is a Atmel problem with UART0 on just the 1284P-PU packages, not the -AU.  With the resonator and lfuse = 0xF7, all the other bootloaders should work.
Logged


Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

But, unfortunately, the UART1 pins are also interrupt pins. But I think I won't need to use more than one in my project.

The interrupt problem is even worse: No matter which interrupt I use, attachInterrupt defaults always to INT0 on pin 16/D10 - which is now used for RX1 on UART1. So in fact one only of the three interrupt lines is usable.
Logged

Global Moderator
Melbourne, Australia
Offline Offline
Brattain Member
*****
Karma: 511
Posts: 19356
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The interrupt problem is even worse: No matter which interrupt I use, attachInterrupt defaults always to INT0 on pin 16/D10 - which is now used for RX1 on UART1. So in fact one only of the three interrupt lines is usable.

This assertion is backed up by what code?
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Pages: 1 [2] 3   Go Up
Jump to: