Go Down

Topic: Bootloader for a 1284P @ 16MHz - problems :-( (Read 6105 times) previous topic - next topic

skyjumper

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?





Graynomad

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

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

skyjumper

#2
May 13, 2011, 07:24 am Last Edit: May 13, 2011, 07:28 am by skyjumper Reason: 1
Wow, he posts alot, I'll search more carefully.

Here are the errors I get:

Code: [Select]
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]

skyjumper

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:

Code: [Select]
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.


Graynomad

Rob Gray aka the GRAYnomad www.robgray.com

skyjumper

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:

Code: [Select]

.
.
.

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.



Graynomad

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

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

skyjumper


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 :-(

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.


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.

skyjumper


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.

Quote

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?


skyjumper

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?

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.

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.

skyjumper


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.

Quote

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?




skyjumper

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 :-(

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


Code: [Select]
# 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


skyjumper

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


Go Up