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

Hi All...

Does anyone have an Arduino bootloader for an ATMega1284P clocking at 16MHz they would be willing to share?

I have tried building one and tried one I found, but so far no joy. I installed it using AVR Studio and an AVRISP MKii programmer. I think I did the install right. AVR Studio can read the chip, its fuses and lock bits. I can change the fuses and after I upload the hex file I'm told the verification was good.

When I try to use the Arduino IDE to upload a sketch, I get errors that indicate they are not communicating. I'm not there now but one error indicated a sync fault of some type, so perhaps the boot loader was built for the wrong clock speed? Of perhaps a baud rate mismatch?

Have a search for user "wanago", I'm pretty sure he got one working and posted about it.


Rob

Wow, he posts alot, I'll search more carefully.

Here are the errors I get:

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

         System wide configuration file is "C:\Users\jim\Desktop\arduino-0022\hardware/tools/avr/etc/avrdude.conf"

         Using Port            : \\.\COM3
         Using Programmer      : stk500v2
         Overriding Baud Rate  : 57600
avrdude: ser_open(): setting dtr
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
avrdude: Recv: 
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
avrdude: Recv: 
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]

Apparently some people managed to get this working:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1273415167/45

I downloaded the bootloader provided in that thread, which was compiled for 16 MHz, which is what I need. I then tried to use AVR Studio to upload it to the chip. I would use the IDE, but apparently it uses a different driver than AVR Studio and the two are mutually exclusive. So, I opened up AVR Studio, went to "AVR Programming" and set the lock bits, set the fuses, uploaded the hex file, then reset the lock bits.

I have no idea if it loaded properly or not.

I also created a boards.txt entry as explained.

I still get this:

Binary sketch size: 1222 bytes (of a 131072 byte maximum)
C:\Users\jim\Desktop\arduino-0022\hardware/tools/avr/bin/avrdude -CC:\Users\jim\Desktop\arduino-0022\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega1284p -cstk500v2 -P\\.\COM3 -b115200 -D -Uflash:w:C:\Users\jim\AppData\Local\Temp\build7097107564340213921.tmp\Blink.cpp.hex:i 

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

         System wide configuration file is "C:\Users\jim\Desktop\arduino-0022\hardware/tools/avr/etc/avrdude.conf"

         Using Port            : \\.\COM3
         Using Programmer      : stk500v2
         Overriding Baud Rate  : 115200
avrdude: ser_open(): setting dtr
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14] 
avrdude: Recv: 
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]

I suppose the next step is to uninstall AVR Studio and see if I can program the bootloader with the IDE.

I thinl my avrdude is cirrent enough as I don't get an error saying that the atmega1284p is not found.

Have a look at this thread


Rob

Hi Rob and thanks, I had seen that but didn't see anything particularly helpful. I do use his cores.

I did find a boot loader in hex compiled for the 1284P at 16MHz, and by using a computer without the AVR Studio software, and by tweaking board.txt and avrdude.conf I was able to get it to upload to the board, I think.

Now, when I try to upload a sketch I get a verification error that seems to indicate the sketch is makign it to the board but not actually being written:

.
.
.

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x0c != 0xff
avrdude: verification error; content mismatch
avrdude: Send: Q [51]   [20] 
avrdude: Recv: 
avrdude: Recv: 

avrdude done.  Thank you.

That sounds like the error James was getting on that thread, apparently though the loader still worked despite the error.


Rob

Graynomad:
That sounds like the error James was getting on that thread, apparently though the loader still worked despite the error.

True it does, but in my case, the sketches do not run :frowning:

I am wondering if one of the lock bits got set, I am trying to check that now. Since the verification fails ont eh very first byte, that's an implication that the hex file never got written to the flash.

Does the bootloader blink as it should after a reset?
Can you combine the bootloader hex file with a compiled sketch (blink, for example), and upload the combined hex file via ISP?
That would enable you to verify that the bootloader is running and passing control to the sketch correctly.

tim7:
Does the bootloader blink as it should after a reset?
Can you combine the bootloader hex file with a compiled sketch (blink, for example), and upload the combined hex file via ISP?
That would enable you to verify that the bootloader is running and passing control to the sketch correctly.

Well I'm not certain that it should. This is a custom board and it works with a 644P chip from a Sanguino that came with a bootloader. I'll put that chip back in and watch for the blink. This one does not blink. If I erase the chip I get no communication, if I upload this bootloader the chip takes the HEX file then the verification fails.

I am able to erase the chip and upload some Arduino compiled HEX files that run, but most don't. The Streaming example runs, but blink does not. This is directly from the AVG Studio using he AVRISP.

Can you combine the bootloader hex file with a compiled sketch (blink, for example), and upload the combined hex file via ISP?

Hm, I don't know, can I? Is a hex file binary data? How do i do that, maybe cat on a unix system?

Maybe I'm not installing the boot loader correctly. Does it have to go into a particular part of the flash? Could there be a corresponding entry in avrdude.conf that is wrong?

If you're using the Adaboot bootloader, then it should flash 4 times on startup, followed by another sequence of flashes to show the version number.

HEX files are ascii text, so can be combined in a text editor. Just delete the EOF marker of the first file :00000001FF, and then past the second file below.

tim7:
If you're using the Adaboot bootloader, then it should flash 4 times on startup, followed by another sequence of flashes to show the version number.

No I'm not, I'm using one that was posted on the forum here:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1273415167/30

I put the working 644P chip back in and when I start it, it does not blink at all. So that tells me that this board is not going to blink with the stock boot loader.

HEX files are ascii text, so can be combined in a text editor. Just delete the EOF marker of the first file :00000001FF, and then past the second file below.

I tried that, no joy.

I also tried to blow away the boot loader on my 644P chip, which worked. I then uploaded a blink hex file that blinked a LED on pin 31, that worked fine. I then verified that there was no bootloader by trying to upl;oad a sketch from the IDE and it failed as expected. I then burned the 644P bootloader back into the chip and was able to successfully and normally upload that same blink sketch through the IDE.

I can also program that blink HEX file into the 1284P chip with AVRStudio and have it run.

So this tells me that the bootloader I am using probably has issues.

I ran accross the ADA Bootloader, but I thought it was only for smaller chips? Can I make it work with a 1284P?

Problem resolved. The attached code and makefile needed a change to the LDSECTION macro to support the 1284P. Then, the HEX file built by the current avr-gcc was too big to fit into the boot block, so lots of size optomozations on the compiler were needed to trim it down. Hopefully future versions of gcc won't grow it anymore.

More hopefully, this post will save someone else the few days of hair pulling I just experienced :frowning:

-- OOPS, too big for one post. Here is the make file, hopefully the code will fit into the next post.

# Makefile for ATmegaBOOT
# E.Lins, 18.7.2005
# $Id$
# Modified by JWA 2011-05-14 to support ATMega1284P
#

# program name should not be changed...
PROGRAM    = ATmegaBOOT_1284P

# enter the target CPU frequency
AVR_FREQ   = 16000000L

MCU_TARGET = atmega1284p

# JWA
# NOTE: The ATMega644P and the ATMega1284P require different values for
# LDSECTION
# For the 644P uncomment this line:
# LDSECTION  = --section-start=.text=0xF800
#
# for the 1284P uncomment this line:
LDSECTION  = --section-start=.text=0x1F800

OBJ        = $(PROGRAM).o

# JWA
# The newer avr-gcc makes bigger code, too big to fit into the boot block.
# if you get the following error, 
# ld.exe: address 0x200d0 of ATmegaBOOT_1284P.elf section .text is not within region text
# This just means your built code is too big to fit intot he boot block. To reduce the size,
# comment out
# OPTIMIZE   = -O2
#
# and instead use:
OPTIMIZE   = -Os -funsigned-char -funsigned-bitfields -fno-inline-small-functions

DEFS       = 
LIBS       = 

CC         = avr-gcc

# Override is only needed by avr-lib build system.

override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
override LDFLAGS       = -Wl,$(LDSECTION)
#override LDFLAGS       = -Wl,-Map,$(PROGRAM).map,$(LDSECTION)

OBJCOPY        = avr-objcopy
OBJDUMP        = avr-objdump

all: CFLAGS += '-DMAX_TIME_COUNT=8000000L>>1' -DADABOOT
all: $(PROGRAM).hex

$(PROGRAM).hex: $(PROGRAM).elf
	$(OBJCOPY) -j .text -j .data -O ihex $< $@
	
$(PROGRAM).elf: $(OBJ)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
	
$(OBJ): ATmegaBOOT.c
	avr-gcc $(CFLAGS) $(LDFLAGS) -c -g -O2 -Wall -mmcu=$(MCU_TARGET) ATmegaBOOT.c -o $(PROGRAM).o

%.lst: %.elf
	$(OBJDUMP) -h -S $< > $@

%.srec: %.elf
	$(OBJCOPY) -j .text -j .data -O srec $< $@

%.bin: %.elf
	$(OBJCOPY) -j .text -j .data -O binary $< $@

clean:
	rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex

Nope, the code didn't fit. I'll post it on a web page somewhere and procide a lnk.

Thanks skyjumper, that may save people (me included) a lot of hair tearing.


Rob

1.check the fuses as well (these work with mine):

atmega1284.bootloader.low_fuses=0xFF
atmega1284.bootloader.high_fuses=0xDC
atmega1284.bootloader.extended_fuses=0xFD

see:
http://www.engbedded.com/fusecalc

mind: the boot flash section size shall be 1024 WORDS and boot start address =$fC00

when using LDSECTION = --section-start=.text=0x1F800 (as $1F800 = 2x $FC00)

  1. do not use high baudrates, start with 19200 when troubleshooting the bootloader. Btw, did you set the baudrate properly? (it can be done in the .c or or in makefile, check it pls)..

  2. adjust the baudrate in boards.txt accordingly, choose the proper board then :stuck_out_tongue_closed_eyes:

P.

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!