Bootloader for a 1284P @ 16MHz - problems :-(

I've just bought 10 of these as the 328p didn't have enough IO ports.

So if I hook up the 1284p on a bread board (for the moment) with the 6 pin programming header and hook up the USBtinyISP will this work and where do I get the bootloader? Will I need to use AVRDUDE?

Sorry but I have no experience of this and with you getting it working I am hoping to pick your brains !

:grin:

Can you program a sketch to the AVR chip using the 6 pin header? If so how?

To program the chip using the 6 pin header you'll need an Atmel AVRISP mkII programmer. This connects between your computers USB port and the 6 pin header. You will also need AVR Studio, a free download from the Atmel website.

The initial programming of the chip must be done at the slowest speed! You'll see what this means after you download the software and try it out.

You can put a "sketch" onto the CPU with this programmer, but then there will be no bootloader and you'll have to do it this way each time.

skyjumper:
To program the chip using the 6 pin header you'll need an Atmel AVRISP mkII programmer. This connects between your computers USB port and the 6 pin header. You will also need AVR Studio, a feww download from the Atmel website.

The initial programming of the chip must be done at the slowest speed! You'll see what this means after you download the software and try it out.

You can put a "sketch" onto the CPU with this programmer, but then there will be no bootloader and you'll have to do it this way each time.

Thanks.

I have one of the 1284p chips set up on a breadboard with the RST held high with a 10K resistor, a 20MHz crystal between pins 12&13 with those pins going to 0V through 22nF caps, pin 10&30 to 5v, pin 11&31 to 0V plus the 6 connections for the ICSP going to 0V,5V plus pins 6,7,8 & 9.

I have now bought an AVRISP mk II

I have downloaded the AVR studio software

I have a HEX file which is supposed to be for the 1284p @ 20MHz

I have spent all day trying to sort this out but nothing!

Is there by any chance a step by step guide ?? I am really tearing my hair out now.

I have also downloaded the files from http://aka47.adsl24.co.uk/serendipity/index.php?/pages/Min644pWarez.html and updated my Arduino installation. The 1284p appears in the list of available board but if I try to connect the setup via either the AVRISP mk II or ISPtinyUSB I get the error message "avrdude: AVR Part "atmega1284p" not found."

PLEASE can you help me!

I have to run out in a few but since I know what its like to pull my hair out on this issue, I'll send some quick comments, then I can help in more detail later.

There are two different things at issue here. First, forget about AVRDUDE for now. That can only work once you successfully have a boot loader installed.

Next, forget about Arduino cores for the 1284p. You're not up to that yet.

Let's first get things to a state where the Atmel programer can communicate with yor chip.

Conenct the Atmel programmer to the breadboard. Make sure the wires are going to the right pins. Keep in mind that on the programmer, the red stripe marks the side of the connector with pin 1. You'll need to dig around to find which pin goes where. The Arduino Uno schematic is a good reference.

Start AvrStudio. I don't have it in front of me but there is a menu option that says something like "AVR Programming" or "Program AVR" or something liek that. Select that, and a window pops up. First select the chip, 1284P. Then use the slider control to set the communication speed all the way to the elft, the slowest speed.

Next, try to read the device ID. If you get an error that says something like "unable to communicate with the processor" or whatever, then most likely the processor is not runnign right or something is not hooked up right. Disconnect the Atmel programmer from the breadboard and try to read the dfevice ID, and you'll get the very same error.

If you can't get it to work, try it with an Uno or some other known good Arduino with the 6 pin header. Make sure you're able to communicate with the Uno (or whatever) by reading its device ID, locks and fuses.

Let me know how you make out.

lso, remember that the Atmel programmer can not power your device! You need to power it using its power jack or another USB cable. Make sure the device on your breadboard is powered.

Also, you didn;t mention any caps on your crystal. Check out the Uno schematic and make sure your support circuitry is correct on your breadboard.

In fact, forget the breadboard and start with a known working Arduino.

skyjumper:
lso, remember that the Atmel programmer can not power your device! You need to power it using its power jack or another USB cable. Make sure the device on your breadboard is powered.

Also, you didn;t mention any caps on your crystal. Check out the Uno schematic and make sure your support circuitry is correct on your breadboard.

In fact, forget the breadboard and start with a known working Arduino.

No, sorry my post was quite long I did, there are 2 x 22nF caps on pins 12&13 with them going to GND. I also have a 328p sat there on the breadboard next to it :slight_smile: They were so much easier to bootload!!

Will power the device, didn't realise it couldn't take it's power from the programmer.

Yes I will try first of all to use a known working device. I will stick a fresh new 328p in one of the Deomilanove boards and get that going with the AVR studio.

I'm surprised that there is no official support for the 1284p in the IDE as it is the best DIL socketed chip in the range (that I could see) and most of us don't have the equipment to be making boards with 2560s and the like on them!!

Again, I really do appreciate your taking the time to help me out!

forget about AVRDUDE for now. That can only work once you successfully have a boot loader installed.

That's not strictly true. AVRDUDE is a general purpose communications interface that talks to a variety of programmers and bootloaders, including the AVRISP Mk2.

OTOH, I think I agree with the general idea that you should get AVRStudio talking to the 1284 as a first step...

On the gripping hand, if avrdude doesn't recognize 1284p as a known chip, it won't do so AFTER you have a bootloader installed, either. You probably need to either get a newer version of AVRDUDE (many of which are buggy when it comes to talking to Arduino-like boards), or at least modify the device file to include info about the 1284p.

You did read the AVRISP MkII user guide, right? It looks like a pretty step-to-step guide starting in the section titled "Frontend Software"...

westfw, thanks for your input. I have read pages of stuff but after 17 hours yesterday my head was like cabbage. I had not realised that you must supply the breadboard with a 5V supply as I thought that it took the power from the programmer. Skyjumper mentioned this and I have just got out of bed and down to the work shop. Within 5 minutes I have the PC running AVR studio and now talking to my 1284p on the breadboard.......

Skyjumper, inspirational :slight_smile: Yes it was the lack of a 5V line that was doing it. AVR studio is talking to the 1284p as we speak.

I will now carry on and try to flash it was a bootloader etc. Will now decide which bootloader is best. The main challenge then will be getting it working fully with the IDE.

Well I've copied the hex file to the PC and tried to upload it.

The software reads the device, the fuses etc
It says "Eraseing device... OK"

But the fails to write the hex saying communications timeout....... that is where I am at the moment.

Hmmmm.... It was just timing out due to the VERY slow speed I was using.

First 1284p now flashed :slight_smile:

Now to get the IDE working with it.

Also can I use a quicker speed or should I use the slow speed to begin with and then speed up?

can I use a quicker speed

You should be able to use a quicker speed as soon as you have reprogrammed the fuses to use your 20MHz crystal instead of the default internal 1MHz clock...

westfw:

can I use a quicker speed

You should be able to use a quicker speed as soon as you have reprogrammed the fuses to use your 20MHz crystal instead of the default internal 1MHz clock...

its working at 32.65 KHz..... I increased the speed upwards and it failer to verify at 250KHz. Now it will not verify at 32KHz but still reads the chip info

Replaced the crystal and caps just in case. It will program and verify at 250 Khz but no more.

Could it be the fuse settings?

Setting the fuses at low_fuses=0xF7, high_fuses=0xD8 & extended_fuses=0xFD allowed me to program the 1284p at 4MHz and with the warning that the ISP clock frequency must be lower than 1/4 of the frequency the device is operating at leads me to think that the bread board is all correct.

Now it is the problem of trying to get the IDE to work.

I have a new STK500_v2 directory which has the entry for a 1284p as above but when you create a simple sketch like "blink" avrdude fails with the following:

Binary sketch size: 1168 bytes (of a 126976 byte maximum)
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega1284p -cstk500v2 -P/dev/cu.usbserial-A900aeDN -b115200 -D -Uflash:w:/var/folders/TV/TVIbXQREG6GdFXOVaACCOE+++TI/-Tmp-/build8524607269580543963.tmp/Blink.cpp.hex:i 

avrdude: Version 5.4-arduino, compiled on Oct  9 2007 at 11:20:31
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         System wide configuration file is "/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/darren/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

avrdude: AVR Part "atmega1284p" not found.

Valid parts are:
  m6450 = ATMEGA6450      [/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf:11538]
  m3250 = ATMEGA3250      [/Applications/A.......................

Now I did download and thought I had installed version 5.9 of avrdude so will look at that now.

EDIT: Just checked and if I type avrdude into terminal it comes up with version 5.10!

From my copy of avrdude.conf, here is how it wants to see the part id and desc names:

#------------------------------------------------------------

ATmega1284P

#------------------------------------------------------------

similar to ATmega164p

part
id = "m1284p";
desc = "ATMEGA1284P";

retrolefty:
From my copy of avrdude.conf, here is how it wants to see the part id and desc names:

#------------------------------------------------------------

ATmega1284P

#------------------------------------------------------------

similar to ATmega164p

part
id = "m1284p";
desc = "ATMEGA1284P";

Do you have a copy of the whole section, please?

This is what I got changing the 664p's section with the bits I know are different (with the changes):

#------------------------------------------------------------
# ATmega1284P
#------------------------------------------------------------

# similar to ATmega164p

part
    id               = "m1284p";					/* changed from m664p */
    desc             = "ATMEGA1284P"; 					/* changed from ATMEGA664P */
    has_jtag         = yes;
#   stk500_devcode   = 0x82; # no STK500v1 support
#   avr910_devcode   = 0x?;  # try the ATmega16 one:^
    avr910_devcode   = 0x74;
    signature        = 0x1e 0x97 0x05;					/* changed from 0x1e 0x96 0x09 */
    pagel            = 0xd7;
    bs2              = 0xa0;
    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		= 0x53;
    predelay		= 1;
    postdelay		= 1;
    pollmethod		= 0;

    pp_controlstack     =
        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02;
    hventerstabdelay    = 100;
    progmodedelay       = 0;
    latchcycles         = 6;
    togglevtg           = 0;
    poweroffdelay       = 0;
    resetdelayms        = 0;
    resetdelayus        = 0;
    hvleavestabdelay    = 15;
    chiperasepulsewidth = 0;
    chiperasepolltimeout = 10;
    programfusepulsewidth = 0;
    programfusepolltimeout = 5;
    programlockpulsewidth = 0;
    programlockpolltimeout = 5;

    idr                 = 0x31;
    spmcr               = 0x57;
    allowfullpagebitstream = no;

    memory "eeprom"
        paged           = no; /* leave this "no" */
        page_size       = 8;  /* for parallel programming */
        size            = 4096;                                       /* changed from 2048 */
        min_write_delay = 9000;
        max_write_delay = 9000;
        readback_p1     = 0xff;
        readback_p2     = 0xff;
	read            = "  1   0   1   0      0   0   0   0",
                          "  0   0   x   x    a11 a10  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   x   x    a11 a10  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  a2  a1  a0",
			  "  i   i   i   i      i   i   i   i";

	writepage	= "  1   1   0   0      0   0   1   0",
			  "  0   0   x   x    a11 a10  a9  a8",
			  " a7  a6  a5  a4     a3   0   0   0",
			  "  x   x   x   x      x   x   x   x";

	mode		= 0x41;
	delay		= 10;
	blocksize	= 128;
	readsize	= 256;
      ;

    memory "flash"
        paged           = yes;
        size            = 131072;					/* changed from 65536 */
        page_size       = 256;
        num_pages       = 512;                                  /* changed from 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",
                          "a15 a14 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",
                          "a15 a14 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   x   x      x   x   x   x",
                          "  x  a6  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   x   x      x   x   x   x",
                          "  x  a6  a5  a4     a3  a2  a1  a0",
                          "  i   i   i   i      i   i   i   i";

        writepage       = "  0   1   0   0      1   1   0   0",
                          "a15 a14 a13 a12    a11 a10  a9  a8",
                          " a7   x   x   x      x   x   x   x",
                          "  x   x   x   x      x   x   x   x";

	mode		= 0x21;
	delay		= 6;
	blocksize	= 256;
	readsize	= 256;
      ;

    memory "lock"
        size            = 1;
        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";
        min_write_delay = 9000;
        max_write_delay = 9000;
      ;

    memory "lfuse"
        size            = 1;
        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";
        min_write_delay = 9000;
        max_write_delay = 9000;
      ;

    memory "hfuse"
        size            = 1;
        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";
        min_write_delay = 9000;
        max_write_delay = 9000;
      ;

    memory "efuse"
        size            = 1;

        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  o o o o  o 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  1 1 1 1  1 i i i";
        min_write_delay = 9000;
        max_write_delay = 9000;
      ;

    memory "signature"
        size            = 3;
        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
      ;

    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";
        ;
  ;

Do you have a copy of the whole section, please?

#------------------------------------------------------------

ATmega1284P

#------------------------------------------------------------

similar to ATmega164p

part
id = "m1284p";
desc = "ATMEGA1284P";
has_jtag = yes;
stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one
avr910_devcode = 0x74;
signature = 0x1e 0x97 0x05;
pagel = 0xd7;
bs2 = 0xa0;
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 = 0x53;
predelay = 1;
postdelay = 1;
pollmethod = 1;

pp_controlstack =
0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02;
hventerstabdelay = 100;
progmodedelay = 0;
latchcycles = 6;
togglevtg = 1;
poweroffdelay = 15;
resetdelayms = 1;
resetdelayus = 0;
hvleavestabdelay = 15;
chiperasepulsewidth = 0;
chiperasepolltimeout = 10;
programfusepulsewidth = 0;
programfusepolltimeout = 5;
programlockpulsewidth = 0;
programlockpolltimeout = 5;

idr = 0x31;
spmcr = 0x57;
allowfullpagebitstream = no;

memory "eeprom"
paged = no; /* leave this "no" /
page_size = 8; /
for parallel programming */
size = 4096;
min_write_delay = 9000;
max_write_delay = 9000;
readback_p1 = 0xff;
readback_p2 = 0xff;
read = " 1 0 1 0 0 0 0 0",
" 0 0 x x a11 a10 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 x x a11 a10 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 a2 a1 a0",
" i i i i i i i i";

writepage = " 1 1 0 0 0 0 1 0",
" 0 0 x x a11 a10 a9 a8",
" a7 a6 a5 a4 a3 0 0 0",
" x x x x x x x x";

mode = 0x41;
delay = 10;
blocksize = 128;
readsize = 256;
;

memory "flash"
paged = yes;
size = 131072;
page_size = 256;
num_pages = 512;
min_write_delay = 4500;
max_write_delay = 4500;
readback_p1 = 0xff;
readback_p2 = 0xff;
read_lo = " 0 0 1 0 0 0 0 0",
"a15 a14 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",
"a15 a14 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 x x x x x x",
" x a6 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 x x x x x x",
" x a6 a5 a4 a3 a2 a1 a0",
" i i i i i i i i";

writepage = " 0 1 0 0 1 1 0 0",
"a15 a14 a13 a12 a11 a10 a9 a8",
" a7 x x x x x x x",
" x x x x x x x x";

mode = 0x41;
delay = 10;
blocksize = 256;
readsize = 256;
;

memory "lock"
size = 1;
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";
min_write_delay = 9000;
max_write_delay = 9000;
;

memory "lfuse"
size = 1;
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";
min_write_delay = 9000;
max_write_delay = 9000;
;

memory "hfuse"
size = 1;
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";
min_write_delay = 9000;
max_write_delay = 9000;
;

memory "efuse"
size = 1;

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 o o o o o 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 1 1 1 1 1 i i i";
min_write_delay = 9000;
max_write_delay = 9000;
;

memory "signature"
size = 3;
read = "0 0 1 1 0 0 0 0 x x x x x x x x",
"x x x x x x a1 a0 o o o o o o o o";
;

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";
;
;

WOW - IT WORKS !!!!!!

With the above changes the Arduino will upload a sketch to the 1284p and it works. My 1284p is now blinking away happily.........

Right now I need to do a detailed list of everything that needs to be done and will post it (with reference to the fabulous help I have received from everyone!)

I have not tested it beyond the blink sketch but getting that working was very helpful.

retrolefty:

Do you have a copy of the whole section, please?

#------------------------------------------------------------

ATmega1284P

#------------------------------------------------------------

similar to ATmega164p

Thanks RetroLefty, that matches the one I just worked out so happy with that.