Browse Source

Add support for ATmega1284, including sketches larger than 64k
See http://code.google.com/p/optiboot/issues/detail?id=51

Bill Westfield 13 years ago
parent
commit
af07bb219a

+ 19 - 0
optiboot/bootloaders/optiboot/Makefile

@@ -236,6 +236,25 @@ atmega328_isp: LFUSE = FF
 atmega328_isp: EFUSE = 05
 atmega328_isp: isp
 
+atmega1284: TARGET = atmega1284p
+atmega1284: MCU_TARGET = atmega1284p
+atmega1284: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
+atmega1284: AVR_FREQ = 16000000L
+atmega1284: LDSECTIONS  = -Wl,--section-start=.text=0x1fc00
+atmega1284: $(PROGRAM)_atmega1284p.hex
+atmega1284: $(PROGRAM)_atmega1284p.lst
+
+atmega1284_isp: atmega1284
+atmega1284_isp: TARGET = atmega1284p
+atmega1284_isp: MCU_TARGET = atmega1284p
+# 1024 byte boot
+atmega1284_isp: HFUSE = DE
+# Low power xtal (16MHz) 16KCK/14CK+65ms
+atmega1284_isp: LFUSE = FF
+# 2.7V brownout
+atmega1284_isp: EFUSE = FD
+atmega1284_isp: isp
+
 # Sanguino has a minimum boot size of 1024 bytes, so enable extra functions
 #
 sanguino: TARGET = atmega644p

+ 11 - 2
optiboot/bootloaders/optiboot/optiboot.c

@@ -132,6 +132,11 @@
 /**********************************************************/
 /* Edit History:					  */
 /*							  */
+/* Jan 2012:                                              */
+/* 4.4 WestfW and Maniacbug:  Add m1284 support.  This    */
+/*             does not change the 328 binary, so the     */
+/*             version number didn't change either. (?)   */
+/* June 2011:                                             */
 /* 4.4 WestfW: remove automatic soft_uart detect (didn't  */
 /*             know what it was doing or why.)  Added a   */
 /*             check of the calculated BRG value instead. */
@@ -257,6 +262,9 @@ void appStart() __attribute__ ((naked));
 #elif defined (__AVR_ATmega644P__)
 #define RAMSTART (0x100)
 #define NRWWSTART (0xE000)
+#elif defined (__AVR_ATmega1284P__)
+#define RAMSTART (0x100)
+#define NRWWSTART (0xF000)
 #elif defined(__AVR_ATtiny84__)
 #define RAMSTART (0x100)
 #define NRWWSTART (0x0000)
@@ -482,7 +490,8 @@ int main(void) {
         putch(ch);
       } while (--length);
 #else
-#ifdef __AVR_ATmega1280__
+#ifdef RAMPZ
+// Since RAMPZ should already be set, we need to use EPLM directly.
 //      do putch(pgm_read_byte_near(address++));
 //      while (--length);
       do {
@@ -615,7 +624,7 @@ uint8_t getch(void) {
 }
 
 #ifdef SOFT_UART
-// AVR350 equation: #define UART_B_VALUE (((F_CPU/BAUD_RATE)-23)/6)
+// AVR305 equation: #define UART_B_VALUE (((F_CPU/BAUD_RATE)-23)/6)
 // Adding 3 to numerator simulates nearest rounding for more accurate baud rates
 #define UART_B_VALUE (((F_CPU/BAUD_RATE)-20)/6)
 #if UART_B_VALUE > 255

+ 1 - 1
optiboot/bootloaders/optiboot/optiboot_atmega1280.lst

@@ -399,7 +399,7 @@ int main(void) {
    1fd5a:	39 d0       	rcall	.+114    	; 0x1fdce <verifySpace>
    1fd5c:	e6 01       	movw	r28, r12
    1fd5e:	0e 2d       	mov	r16, r14
-#ifdef __AVR_ATmega1280__
+// Since RAMPZ should already be set, we need to use EPLM directly.
 //      do putch(pgm_read_byte_near(address++));
 //      while (--length);
       do {

+ 1 - 1
optiboot/bootloaders/optiboot/pin_defs.h

@@ -44,7 +44,7 @@
 #endif
 
 /* Sanguino support */
-#if defined(__AVR_ATmega644P__)
+#if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
 /* Onboard LED is connected to pin PB0 on Sanguino */ 
 #define LED_DDR     DDRB
 #define LED_PORT    PORTB