Go Down

Topic: ATMega1284P, 8MHz, 57600 bootloader, no joy (Read 950 times) previous topic - next topic

Steph

I am building a project around the ATMega1284P, and it's running at 8MHz due to the voltage being 3.3v (it's battery powered). I can communicate at 57600 during 'normal' use, but I can't get the bootloader to work at that speed.

I am using the bootloader from the Sanguino project, modified & recompiled for the 1284p at 8MHz and 57600 baud. When I compile it for 19200 baud everything works, but when I compile it for 57600 baud, I can't upload sketches from the IDE - it looks like the ATMega is not responding at all at that speed.

Is it possible to use a 57600 baud bootloader on an 8MHz chip? I figured if I can use 57600 baud within a sketch that it ought to be ok in the bootloader too.

Should I look into a different bootloader?

My environment is Mac OS X 10.6.8, Arduino IDE 1.0.1, using Sparkfun's Pocket Programmer (USBTiny clone) and an FTDI adaptor. Everything is known to be working, I have  used all the hardware and software on other Arduinos and other projects without any problem.

Thank you!

wanderson

I had a similiar problem with the Mightohm core files.  For me the optiboot bootloader did not work for uploading files, but the original version did.  I logged the issue, but so far no results.
New true random number library available at: http://code.google.com/p/avr-hardware-random-number-generation/

Current version 1.0.1

Steph

I didn't try Optiboot. I briefly looked at it, but the original one looked easier to figure out, plus I had the Sanguino example to start from.

I think I've got it figured out - I looked at the Sparkfun Pro Mini board settings for 8MHz with a '328, as they were using 57600 baud and I know that works as I've used those boards in other projects.

Anyhow, the trick seemed to be that they were using the 'double speed' option in the baud rate, so I copied what they were doing for the '328 and tried it on the '1284p and it worked.

In the makefile, my cflags are set to:
Code: [Select]
CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=57600 -DDOUBLE_SPEED

and in the ATmegaBOOT_168.c source file, In the section for initializing the UART(s) I changed the __AVR_ATmega1284P__ section to this:
Code: [Select]
#ifdef DOUBLE_SPEED
UCSR0A = (1<<U2X0); //Double speed mode USART0
UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*8L)-1);
UBRR0H = (F_CPU/(BAUD_RATE*8L)-1) >> 8;
#else
UCSR0A = 0x00;
UBRR0L = (uint8_t)(F_CPU/(BAUD_RATE*16L)-1);
UBRR0H = (F_CPU/(BAUD_RATE*16L)-1) >> 8;
#endif
UCSR0C = 0x06;
UCSR0B = _BV(TXEN0)|_BV(RXEN0);


The only thing that I've omitted is there was originally settings for both UART0 and UART1 and I'm only using UART0 so I've dropped the stuff for UART1 in the above code.

57600 is nice and snappy, compared to 19200. :)

spcomputing


I had a similiar problem with the Mightohm core files.  For me the optiboot bootloader did not work for uploading files, but the original version did.  I logged the issue, but so far no results.


Same with me.  I think it might be the same problem that optiboot had with the Duemilanove and UART comms.  My blueboard UNOs and MEGAs yes, but my projects will be the original bootloaders.

Go Up