Need Help with TQFP-44 version of 1284P bootloader

Hi everyone,

I decided to implement a 'Arduino-compatible' board using the TQFP-44 version of the 1284P-AU Atmel CPU. The pinouts are identical to the Bahbots controller, but I am having no luck getting the bootloader uploaded. The only difference between the Bahbots implementation and mine is the clockspeed, i.e. my chip runs at 16MHz, vs. 18.432MHz for the Bahbot. I modified the boards.txt file as follows: 16MHz


I also tried the stk500V2 bootloader that came as part of Mark Sproul's excellent archive. No joy there either. I wonder if enough changed between version 20 of the Arduino software and the current 22 revision that I am using now for that to break something?

Anyhow, my symptoms are pretty simple: I fire up the Arduino IDE to burn the bootloader. The USBTiny upload seems to work fine - the SCK-activity light blinks merrily away. Then it turn steady (on) before turning off and the Arduino ide reports the following error:

avrdude: verification error, first mismatch at byte 0x1e000
         0x0c != 0xff
avrdude: verification error; content mismatch

So what could I be doing wrong?

Oh, and I should mention that the board also has a 328P microcontroller on it. This little guy is designed to communicate via newsoftserial with the bigger Atmel processor. The only other connection between the chips is a shared reset connection. Other than that, they are completely separate. What I do notice though is that as the Bootloader for the 1284P is uploaded, the sck-activity light for the 328P stops blinking. That said, I doubt this is the issue since I was able to upload the bootloader for the 328P just fine.

Are you sure that USBTiny supports chips with more than 64k of program memory? It's an easy thing to get wrong.
(I don't know how old that discussion is WRT current product...)


I also tried the Bahbots bootloader and cores on a 1284. The bootloader installed correctly and programs would compile, but uploads would halt without an error message. My best results use a mix of brewtroller's bootloader/cores and Arduino-0022 cores. The procedure can be found in the last post of this thread. I've got no idea how this would affect your pin definitions, since my application was for a Sanguino.


You guys are the best. First of all, I stopped pulling the few of my remaining hairs out. With the help of the link you provided, I was able to confirm that the TinyISP cannot write a bootloader for any device with over 64kB of Flash memory. Even better, I was able to convince Adafruit to prominently mention on the TinyISP web store page that such devices are not supported so others don't follow in my footsteps.

In the meantime, I am waiting for the AVRII programmer from Atmel... I hope that the cores that Mark Sproul put together will work... I also made sure to download Arduino 23, and then I replaced the AVR section with the latest version of WinAVR. So now I should be ready for my shipment from Digikey... Thank you again, I really appreciate the help.

It should be relatively easy possible to modify ArduinoISP to support 128K parts.

Hello westfw,

I'm currently working on some improvements to the ArduinoISP sketch. But, I don't have any 128K parts available for testing. And, I don't know what changes are necessary to support 128K parts. So...

Do you know if the STK500v1 protocol supports 128K parts?

Are you certain the ArduinoISP sketch does not currently support 128K parts? I vaguely recall folks using the ArduinoISP sketch to burn a bootloader onto an Arduino Mega.

Do you know if the STK500v1 protocol supports 128K parts?

I think it should. It only uses two bytes of "address", but it's a word address.

Are you certain the ArduinoISP sketch does not currently support 128K parts?

Hmm. I thought I was, but perhaps not. I thought I recalled the address being immediately multipled by two and stored as a byte address in an "int", but I don't see it now (there is 2*address in the eeprom code, but...)
There is suspicious code in current_page():

int current_page(int addr) {
  if (param.pagesize == 32) return here & 0xFFFFFFF0;
  if (param.pagesize == 64) return here & 0xFFFFFFE0;
  if (param.pagesize == 128) return here & 0xFFFFFFC0;
  if (param.pagesize == 256) return here & 0xFFFFFF80;
  return here;

("here" is the address, and it's an int, and those aren't 16bit constants. But it looks like it is still using word addresses, so it may be OK.)

It's (way past) bedtime so tomorrow I'll search the forum and look over the code. Thanks.

FWIW, Ms. Fried appears to think that there are hardware and software issues that prevent her tinyISP from burning a bootloader onto any chip with more than 64kB of flash.

Since I am clueless as to the why, I cannot comment intelligently but I was surprised to read that others had gotten the tinyISP to burn programs (but not bootloaders) onto the affected chips. It makes me wonder if the issue is addressing-related - i.e the bootloader sits on a part of the flash that is 'out of reach' for the tinyISP, an error one would encounter also if one were to burn a program bigger than 64kB onto the chip.

I should also mention that I received a gift certificate this AM from adafruit for my troubles, which was a very sweet gesture. What would be really nifty is if team Adafruit found a way to upgrade their firmware to allow a tinyUSB to address the devices that are currently out of its reach.

Does anyone know if the AVR MkII programmer from Atmel is going to be 'clear' of this issue or is there another programmer I should be looking at? The Atmel pages suggest 100% compatibility... I'll report back once I get it. Many, many thanks again.

.... so I reinstalled the Arduino environment to make sure it was pristine, added winavr, so the 1284P is supported (avrdude -p? lists it). I got the AVRISP MKII fully installed including the right USB drivers. However, I lack a avrdude.conf file entry that I can trust.

In the past, I used a conf file entry for the sanguino project (which uses the dip version of the chip, not the TQFP version I am using). That doesn't seem to work. So I wonder whether anyone has a conf file that includes an entry for the 1284P, especially if it's a TQFP version. For example, the Bahbot would be one logical entry since it uses the same chip.

I suppose I could learn to use avrdude to upload the bootloader, but I would prefer the convenience of the Arduino IDE, if possible. Many thanks for any help, Constantin

Check with Skyjumper, he has tqfp version of 1284 working grandly.

I use the DIP version, this programmer downloads bootloaders into it ok.

ATMega8A based.

Thank you, I appreciate it!

The AVR ISP mkII allegedly also supports the 1284P natively. However, the programmer you reference is not only less expensive, it's smaller too! So much to learn...

Crossroads, you posted the following 1284P config file... would it work on the TQFP version of the chip or are they not pin compatible? The reason I ask is that the TQFP version of the chip has 44 pins, while the DIP version only has 40. As best as I can tell, it's not that the TQFP version has more inputs, just more VCC and GND pins. However, the added pins will impact the pin assignment, I imagine.

So if skyjumper doesn't respond, would a combination of the Brewtroller 644 arduino.conf and the below do the trick? That is, use the pin assignments from the 644 file but the other inputs from what you posted?

# ATmega1284P

# similar to ATmega164p

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

OK, for the benefit of anyone else following in my footsteps, I found success via the Brewtroller version of the Arduino IDE. Not only do the guys there do a great job of integrating it all, it even works!

I was able to get bootloaders onto both chips without error messages. Serial communications eludes me for the time being, I will retry that later. In the meantime, I am using the AVR ISP mkII to program both chips (with success!) For example, the blink program works.

The only remaining trouble I ran into was pin labeling. I thought I had a good idea of how the digital pins were distributed until I tried to run the blink program on the 1284P... and got nothing. Further digging over at the sanguino web site led me to a schematic showing the pins and also explained why I had to blink on pin 7 to make my SCK activity light go on/off.

My hat off to the folk over at Brewtroller regarding their project. If I ever get into beer brewing, that is a nifty controller to do all the heavy lifting. Thanks again everyone for your help!

Lastly, I hope that the folk at the Arduino project can get around to including more of the AVR chips out there via Mark Sprouls amazing library and the work over at Brewtroller, etc. This set doesn't have to be part of the default library, make it an add-on if you want to minimize the feature-set for the masses (and hence reduce potential confusion) while also offering those that want to use non-standard AVRs an easy way to get going.

Yes, I think it would work.