Browse Source

Merge in the MCUdude platforms. Don't do baudcheck, and don't warn
about moderate baud errors, if PRODUCTION is set. (this reduces
clutter in the output and should make things a bit quicker.
developers are supposed to check all the warnings prior to setting
PRODUCTION)

WestfW 6 years ago
parent
commit
b263cada08

+ 13 - 1
optiboot/bootloaders/optiboot/Makefile

@@ -149,8 +149,11 @@ SIZE           = $(GCCROOT)avr-size
 #
 #
 
 
 ifdef PRODUCTION
 ifdef PRODUCTION
+ifneq ($(PRODUCTION),0)
 VERSION_CMD = -DPRODUCTION=1
 VERSION_CMD = -DPRODUCTION=1
 endif
 endif
+dummy = FORCE
+endif
 
 
 HELPTEXT += "Option CUSTOM_VERSION=nn     - set a customer version number\n"
 HELPTEXT += "Option CUSTOM_VERSION=nn     - set a customer version number\n"
 ifdef CUSTOM_VERSION
 ifdef CUSTOM_VERSION
@@ -592,7 +595,13 @@ include Makefile.1284
 include Makefile.custom
 include Makefile.custom
 include Makefile.2560
 include Makefile.2560
 include Makefile.tiny
 include Makefile.tiny
+include Makefile.MCUdude
 
 
+ifndef PRODUCTION
+BAUDCHECK= baudcheck
+else
+BAUDCHECK=
+endif
 
 
 #---------------------------------------------------------------------------
 #---------------------------------------------------------------------------
 #
 #
@@ -613,13 +622,16 @@ isp-stk500: $(PROGRAM)_$(TARGET).hex
 	$(STK500-1)
 	$(STK500-1)
 	$(STK500-2)
 	$(STK500-2)
 
 
-%.elf: $(OBJ) baudcheck $(dummy)
+%.elf: $(OBJ) $(BAUDCHECK) $(dummy)
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
 	$(SIZE) $@
 	$(SIZE) $@
 
 
 clean:
 clean:
 	rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex *.tmp.sh
 	rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex *.tmp.sh
 
 
+clean_asm:
+	rm -rf *.lst
+
 %.lst: %.elf
 %.lst: %.elf
 	$(OBJDUMP) -h -S $< > $@
 	$(OBJDUMP) -h -S $< > $@
 
 

+ 302 - 0
optiboot/bootloaders/optiboot/Makefile.MCUdude

@@ -0,0 +1,302 @@
+/*
+ * These are the CPU targets from Hans "MCUdude"
+ * MightyCore, MegaCore, MiniCore, and MajorCore
+ *  https://github.com/MCUdude
+ *
+ * This file has basic CPU defintions, while many possible combinations
+ * of AVR_FREQ, BAUD_RATE, and UART are built by a shell script.
+ */
+
+#ATmega16/A
+atmega16: TARGET = atmega16
+atmega16: MCU_TARGET = atmega16
+atmega16: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega16: AVR_FREQ ?= 16000000L
+atmega16: LDSECTIONS = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe
+atmega16: $(PROGRAM)_atmega16_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega16: $(PROGRAM)_atmega16_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+atmega16a: atmega16
+
+#ATmega64/A
+atmega64: TARGET = atmega64
+atmega64: MCU_TARGET = atmega64
+atmega64: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT $(UART_CMD)
+atmega64: AVR_FREQ ?= 16000000L
+atmega64: LDSECTIONS = -Wl,--section-start=.text=0xfc00 -Wl,--section-start=.version=0xfffe
+atmega64: $(PROGRAM)_atmega64_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega64: $(PROGRAM)_atmega64_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+atmega64a: atmega64
+
+#ATmega88P/PA
+atmega88p: TARGET = atmega88p
+atmega88p: MCU_TARGET = atmega88p
+atmega88p: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega88p: AVR_FREQ ?= 16000000L 
+atmega88p: LDSECTIONS = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe -Wl,--gc-sections -Wl,--undefined=optiboot_version
+atmega88p: $(PROGRAM)_atmega88p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega88p: $(PROGRAM)_atmega88p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+atmega88pa: atmega88p
+
+#ATmega8PB
+atmega88pb: TARGET = atmega88pb
+atmega88pb: MCU_TARGET = atmega88pb
+atmega88pb: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega88pb: AVR_FREQ ?= 16000000L
+atmega88pb: LDSECTIONS = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe -Wl,--gc-sections -Wl,--undefined=optiboot_version
+atmega88pb: $(PROGRAM)_atmega88pb_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega88pb: $(PROGRAM)_atmega88pb_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+
+#ATmega128/A
+atmega128: TARGET = atmega128
+atmega128: MCU_TARGET = atmega128
+atmega128: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT $(UART_CMD)
+atmega128: AVR_FREQ ?= 16000000L
+atmega128: LDSECTIONS = -Wl,--section-start=.text=0x1fc00 -Wl,--section-start=.version=0x1fffe
+atmega128: $(PROGRAM)_atmega128_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega128: $(PROGRAM)_atmega128_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+atmega128a: atmega128
+
+#ATmega162
+atmega162: TARGET = atmega162
+atmega162: MCU_TARGET = atmega162
+atmega162: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega162: AVR_FREQ ?= 16000000L
+atmega162: LDSECTIONS = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe
+atmega162: $(PROGRAM)_atmega162_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega162: $(PROGRAM)_atmega162_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+
+#ATmega164/A
+atmega164a: TARGET = atmega164a
+atmega164a: MCU_TARGET = atmega164a
+atmega164a: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega164a: AVR_FREQ ?= 16000000L
+atmega164a: LDSECTIONS = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe
+atmega164a: $(PROGRAM)_atmega164a_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega164a: $(PROGRAM)_atmega164a_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+atmega164: atmega164a
+
+#ATmega164P/PA
+atmega164p: TARGET = atmega164p
+atmega164p: MCU_TARGET = atmega164p
+atmega164p: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega164p: AVR_FREQ ?= 16000000L
+atmega164p: LDSECTIONS = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe
+atmega164p: $(PROGRAM)_atmega164p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega164p: $(PROGRAM)_atmega164p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+atmega164pa: atmega164p
+
+#ATmega168/A
+atmega168: TARGET = atmega168
+atmega168: MCU_TARGET = atmega168
+atmega168: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega168: AVR_FREQ ?= 16000000L 
+atmega168: LDSECTIONS = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe
+atmega168: $(PROGRAM)_atmega168_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega168: $(PROGRAM)_atmega168_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+atmega168a: atmega168
+
+#ATmega168P/PA
+atmega168p: TARGET = atmega168p
+atmega168p: MCU_TARGET = atmega168p
+atmega168p: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega168p: AVR_FREQ ?= 16000000L 
+atmega168p: LDSECTIONS = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe
+atmega168p: $(PROGRAM)_atmega168p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega168p: $(PROGRAM)_atmega168p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+atmega168pa: atmega168p
+
+#ATmega168PB
+atmega168pb: TARGET = atmega168pb
+atmega168pb: MCU_TARGET = atmega168pb
+atmega168pb: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega168pb: AVR_FREQ ?= 16000000L 
+atmega168pb: LDSECTIONS = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe
+atmega168pb: $(PROGRAM)_atmega168pb_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega168pb: $(PROGRAM)_atmega168pb_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+
+#ATmega169/A
+atmega169: TARGET = atmega169
+atmega169: MCU_TARGET = atmega169
+atmega169: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega169: AVR_FREQ ?= 16000000L
+atmega169: LDSECTIONS = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe
+atmega169: $(PROGRAM)_atmega169_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega169: $(PROGRAM)_atmega169_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+atmega169a: atmega169
+
+#ATmega169P/PA
+atmega169p: TARGET = atmega169p
+atmega169p: MCU_TARGET = atmega169p
+atmega169p: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega169p: AVR_FREQ ?= 16000000L
+atmega169p: LDSECTIONS = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe
+atmega169p: $(PROGRAM)_atmega169p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega169p: $(PROGRAM)_atmega169p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+atmega169pa: atmega169
+
+#ATmega324A
+atmega324a: TARGET = atmega324a
+atmega324a: MCU_TARGET = atmega324a
+atmega324a: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega324a: AVR_FREQ ?= 16000000L
+atmega324a: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
+atmega324a: $(PROGRAM)_atmega324a_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega324a: $(PROGRAM)_atmega324a_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+atmega324: atmega324a
+
+#ATmega324P
+atmega324p: TARGET = atmega324p
+atmega324p: MCU_TARGET = atmega324p
+atmega324p: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega324p: AVR_FREQ ?= 16000000L
+atmega324p: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
+atmega324p: $(PROGRAM)_atmega324p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega324p: $(PROGRAM)_atmega324p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+
+#ATmega324PA
+atmega324pa: TARGET = atmega324pa
+atmega324pa: MCU_TARGET = atmega324pa
+atmega324pa: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega324pa: AVR_FREQ ?= 16000000L
+atmega324pa: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
+atmega324pa: $(PROGRAM)_atmega324pa_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega324pa: $(PROGRAM)_atmega324pa_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+
+#ATmega324PB
+atmega324pb: TARGET = atmega324pb
+atmega324pb: MCU_TARGET = atmega324pb
+atmega324pb: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega324pb: AVR_FREQ ?= 16000000L
+atmega324pb: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
+atmega324pb: $(PROGRAM)_atmega324pb_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega324pb: $(PROGRAM)_atmega324pb_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+
+#ATmega328PB
+atmega328pb: TARGET = atmega328pb
+atmega328pb: MCU_TARGET = atmega328pb
+atmega328pb: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega328pb: AVR_FREQ ?= 16000000L
+atmega328pb: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
+atmega328pb: $(PROGRAM)_atmega328pb_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega328pb: $(PROGRAM)_atmega328pb_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+
+#ATmega329/A
+atmega329: TARGET = atmega329
+atmega329: MCU_TARGET = atmega329
+atmega329: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega329: AVR_FREQ ?= 16000000L
+atmega329: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
+atmega329: $(PROGRAM)_atmega329_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega329: $(PROGRAM)_atmega329_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+atmega329a: atmega329
+
+#ATmega329P/PA
+atmega329p: TARGET = atmega329p
+atmega329p: MCU_TARGET = atmega329p
+atmega329p: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega329p: AVR_FREQ ?= 16000000L
+atmega329p: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
+atmega329p: $(PROGRAM)_atmega329p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega329p: $(PROGRAM)_atmega329p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+atmega329pa: atmega329p
+
+#ATmega640
+atmega640: TARGET = atmega640
+atmega640: MCU_TARGET = atmega640
+atmega640: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT $(UART_CMD)
+atmega640: AVR_FREQ ?= 16000000L
+atmega640: LDSECTIONS = -Wl,--section-start=.text=0xfc00 -Wl,--section-start=.version=0xfffe
+atmega640: $(PROGRAM)_atmega640_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega640: $(PROGRAM)_atmega640_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+
+#ATmega649
+atmega649: TARGET = atmega649
+atmega649: MCU_TARGET = atmega649
+atmega649: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT $(UART_CMD)
+atmega649: AVR_FREQ ?= 16000000L
+atmega649: LDSECTIONS = -Wl,--section-start=.text=0xfc00 -Wl,--section-start=.version=0xfffe
+atmega649: $(PROGRAM)_atmega649_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega649: $(PROGRAM)_atmega649_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+
+#ATmega649P
+atmega649p: TARGET = atmega649p
+atmega649p: MCU_TARGET = atmega649p
+atmega649p: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT $(UART_CMD)
+atmega649p: AVR_FREQ ?= 16000000L
+atmega649p: LDSECTIONS = -Wl,--section-start=.text=0xfc00 -Wl,--section-start=.version=0xfffe
+atmega649p: $(PROGRAM)_atmega649p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega649p: $(PROGRAM)_atmega649p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+
+#ATmega1281
+atmega1281: TARGET = atmega1281
+atmega1281: MCU_TARGET = atmega1281
+atmega1281: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT $(UART_CMD)
+atmega1281: AVR_FREQ ?= 16000000L
+atmega1281: LDSECTIONS = -Wl,--section-start=.text=0x1fc00 -Wl,--section-start=.version=0x1fffe
+atmega1281: $(PROGRAM)_atmega1281_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega1281: $(PROGRAM)_atmega1281_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+
+#ATmega2561
+atmega2561: TARGET = atmega2561
+atmega2561: MCU_TARGET = atmega2561
+atmega2561: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT $(UART_CMD)
+atmega2561: AVR_FREQ ?= 16000000L
+atmega2561: LDSECTIONS = -Wl,--section-start=.text=0x3fc00 -Wl,--section-start=.version=0x3fffe
+atmega2561: $(PROGRAM)_atmega2561_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega2561: $(PROGRAM)_atmega2561_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+
+#ATmega3290
+atmega3290: TARGET = atmega3290
+atmega3290: MCU_TARGET = atmega3290
+atmega3290: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega3290: AVR_FREQ ?= 16000000L
+atmega3290: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
+atmega3290: $(PROGRAM)_atmega3290_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega3290: $(PROGRAM)_atmega3290_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+
+#ATmega3290P/PA
+atmega3290p: TARGET = atmega3290p
+atmega3290p: MCU_TARGET = atmega3290p
+atmega3290p: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega3290p: AVR_FREQ ?= 16000000L
+atmega3290p: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
+atmega3290p: $(PROGRAM)_atmega3290p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega3290p: $(PROGRAM)_atmega3290p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+atmega3290pa: atmega3290p
+
+#ATmega6490
+atmega6490: TARGET = atmega6490
+atmega6490: MCU_TARGET = atmega6490
+atmega6490: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT $(UART_CMD)
+atmega6490: AVR_FREQ ?= 16000000L
+atmega6490: LDSECTIONS = -Wl,--section-start=.text=0xfc00 -Wl,--section-start=.version=0xfffe
+atmega6490: $(PROGRAM)_atmega6490_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega6490: $(PROGRAM)_atmega6490_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+
+#ATmega6490P
+atmega6490p: TARGET = atmega6490p
+atmega6490p: MCU_TARGET = atmega6490p
+atmega6490p: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT $(UART_CMD)
+atmega6490p: AVR_FREQ ?= 16000000L
+atmega6490p: LDSECTIONS = -Wl,--section-start=.text=0xfc00 -Wl,--section-start=.version=0xfffe
+atmega6490p: $(PROGRAM)_atmega6490p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega6490p: $(PROGRAM)_atmega6490p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+
+#ATmega8515
+atmega8515: TARGET = atmega8515
+atmega8515: MCU_TARGET = atmega8515
+atmega8515: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega8515: AVR_FREQ ?= 16000000L
+atmega8515: LDSECTIONS = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe
+atmega8515: $(PROGRAM)_atmega8515_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega8515: $(PROGRAM)_atmega8515_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+
+#ATmega8535
+atmega8535: TARGET := atmega8535
+atmega8535: MCU_TARGET = atmega8535
+atmega8535: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
+atmega8535: AVR_FREQ ?= 16000000L
+atmega8535: LDSECTIONS = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe
+atmega8535: $(PROGRAM)_atmega8535_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).hex
+atmega8535: $(PROGRAM)_atmega8535_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst
+

+ 202 - 0
optiboot/bootloaders/optiboot/makeall.mcudude.sh

@@ -0,0 +1,202 @@
+#!/bin/bash
+set -e
+
+##################################################################################################
+## Created by MCUdude for compiling Optiboot flash from source                                  ##
+## https://github.com/MCUdude/optiboot_flash                                                    ##
+##                                                                                              ##
+## Execute ./makeall to build all variants of this bootloader.                                  ##
+## Run $ chmod +x if this file isn't executable.                                                ##
+##                                                                                              ##
+## This is the file contains all all make procedures for all microcontrollers. You can modify   ##
+## the mcu_and_params array if you want to add, remove or edit any of the settings. You can     ##
+## also modify the clock_and_baud array if you need other F_CPUs or baudrates.                  ##
+##                                                                                              ##
+## The table below shows the available precompiled bootloaders for the corresponding            ##
+## clock frequencies and baud rates.                                                            ##
+##                                                                                              ##
+## |             | 1000000 | 500000 | 250000 | 230400 | 115200 | 57600 | 38400 | 19200 | 9600 | ##
+## |-------------|---------|--------|--------|--------|--------|-------|-------|-------|------| ##
+## | 20 MHz      |         |  X     |  X     |        |  X     |       |       |  X    |      | ##
+## | 18.4320 MHz |         |        |        |  X     |  X     |  X    |  X    |  X    |  X   | ##
+## | 16 MHz      |  X      |  X     |  X     |        |  X     |       |  X    |  X    |  X   | ##
+## | 14.7456 MHz |         |        |        |  X     |  X     |  X    |  X    |  X    |  X   | ## 
+## | 12 MHz      |         |  X     |  X     |        |        |  X    |       |  X    |  X   | ##
+## | 11.0592 MHz |         |        |        |  X     |  X     |  X    |  X    |  X    |  X   | ## 
+## | 8 MHz       |  X      |  X     |  X     |        |  X     |  X    |  X    |  X    |  X   | ##
+## | 7.3728 MHz  |         |        |        |  X     |  X     |  X    |  X    |  X    |  X   | ## 
+## | 4 MHz       |         |  X     |  X     |        |        |       |       |  X    |  X   | ##
+## | 3.6864 MHz  |         |        |        |  X     |  X     |  X    |  X    |  X    |  X   | ## 
+## | 2 MHz       |         |        |  X     |        |        |       |       |  X    |  X   | ##
+## | 1.8432 MHz  |         |        |        |  X     |  X     |  X    |  X    |  X    |  X   | ## 
+## | 1 MHz       |         |        |        |        |        |       |       |       |  X   | ## 
+##                                                                                              ##
+##################################################################################################
+
+declare -a mcu_and_params=(
+"atmega8"     "LED=B5 LED_START_FLASHES=2 UART=0"
+"atmega16"    "LED=B0 LED_START_FLASHES=2 UART=0"
+"atmega32"    "LED=B0 LED_START_FLASHES=2 UART=0"
+"atmega64"    "LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1"
+"atmega64"    "LED=B5 LED_START_FLASHES=2 UART=1 BIGBOOT=1"
+"atmega88"    "LED=B5 LED_START_FLASHES=2 UART=0"
+"atmega88p"   "LED=B5 LED_START_FLASHES=2 UART=0"
+"atmega88pb"  "LED=B5 LED_START_FLASHES=2 UART=0"
+"atmega128"   "LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1"
+"atmega128"   "LED=B5 LED_START_FLASHES=2 UART=1 BIGBOOT=1"
+"atmega162"   "LED=B0 LED_START_FLASHES=0 UART=0"
+"atmega162"   "LED=B0 LED_START_FLASHES=0 UART=1"
+"atmega164a"  "LED=B0 LED_START_FLASHES=2 UART=0"
+"atmega164a"  "LED=B0 LED_START_FLASHES=2 UART=1"
+"atmega164p"  "LED=B0 LED_START_FLASHES=2 UART=0"
+"atmega164p"  "LED=B0 LED_START_FLASHES=2 UART=1"
+"atmega168"   "LED=B5 LED_START_FLASHES=2 UART=0"
+"atmega168p"  "LED=B5 LED_START_FLASHES=2 UART=0"
+"atmega168pb" "LED=B5 LED_START_FLASHES=2 UART=0"
+"atmega169"   "LED=B5 LED_START_FLASHES=2 UART=0"
+"atmega169p"  "LED=B5 LED_START_FLASHES=2 UART=0"
+"atmega324a"  "LED=B0 LED_START_FLASHES=2 UART=0"
+"atmega324a"  "LED=B0 LED_START_FLASHES=2 UART=1"
+"atmega324p"  "LED=B0 LED_START_FLASHES=2 UART=0"
+"atmega324p"  "LED=B0 LED_START_FLASHES=2 UART=1"
+"atmega324pa" "LED=B0 LED_START_FLASHES=2 UART=0"
+"atmega324pa" "LED=B0 LED_START_FLASHES=2 UART=1"
+"atmega324pb" "LED=B0 LED_START_FLASHES=2 UART=0"
+"atmega324pb" "LED=B0 LED_START_FLASHES=2 UART=1"
+"atmega324pb" "LED=B0 LED_START_FLASHES=2 UART=2"
+"atmega328"   "LED=B5 LED_START_FLASHES=2 UART=0"
+# "atmega328p"  "LED=B5 LED_START_FLASHES=2 UART=0"
+"atmega328pb" "LED=B5 LED_START_FLASHES=2 UART=0"
+"atmega328pb" "LED=B5 LED_START_FLASHES=2 UART=1"
+"atmega329"   "LED=B5 LED_START_FLASHES=2 UART=0"
+"atmega329p"  "LED=B5 LED_START_FLASHES=2 UART=0"
+"atmega640"   "LED=B7 LED_START_FLASHES=2 UART=0 BIGBOOT=1"
+"atmega640"   "LED=B7 LED_START_FLASHES=2 UART=1 BIGBOOT=1"
+"atmega640"   "LED=B7 LED_START_FLASHES=2 UART=2 BIGBOOT=1"
+"atmega640"   "LED=B7 LED_START_FLASHES=2 UART=3 BIGBOOT=1"
+# "atmega644"   "LED=B0 LED_START_FLASHES=2 UART=0 BIGBOOT=1"
+# "atmega644"   "LED=B0 LED_START_FLASHES=2 UART=1 BIGBOOT=1"
+"atmega644p"  "LED=B0 LED_START_FLASHES=2 UART=0 BIGBOOT=1"
+"atmega644p"  "LED=B0 LED_START_FLASHES=2 UART=1 BIGBOOT=1"
+"atmega649"   "LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1"
+"atmega649p"  "LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1"
+"atmega1280"  "LED=B7 LED_START_FLASHES=2 UART=0 BIGBOOT=1"
+"atmega1280"  "LED=B7 LED_START_FLASHES=2 UART=1 BIGBOOT=1"
+"atmega1280"  "LED=B7 LED_START_FLASHES=2 UART=2 BIGBOOT=1"
+"atmega1280"  "LED=B7 LED_START_FLASHES=2 UART=3 BIGBOOT=1"
+"atmega1281"  "LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1"
+"atmega1281"  "LED=B5 LED_START_FLASHES=2 UART=1 BIGBOOT=1"
+"atmega1284"  "LED=B0 LED_START_FLASHES=2 UART=0 BIGBOOT=1"
+"atmega1284"  "LED=B0 LED_START_FLASHES=2 UART=1 BIGBOOT=1"
+"atmega1284p" "LED=B0 LED_START_FLASHES=2 UART=0 BIGBOOT=1"
+"atmega1284p" "LED=B0 LED_START_FLASHES=2 UART=1 BIGBOOT=1"
+"atmega2560"  "LED=B7 LED_START_FLASHES=2 UART=0 BIGBOOT=1"
+"atmega2560"  "LED=B7 LED_START_FLASHES=2 UART=1 BIGBOOT=1"
+"atmega2560"  "LED=B7 LED_START_FLASHES=2 UART=2 BIGBOOT=1"
+"atmega2560"  "LED=B7 LED_START_FLASHES=2 UART=3 BIGBOOT=1"
+"atmega2561"  "LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1"
+"atmega2561"  "LED=B5 LED_START_FLASHES=2 UART=1 BIGBOOT=1"
+"atmega3290"  "LED=B5 LED_START_FLASHES=2 UART=0"
+"atmega3290p" "LED=B5 LED_START_FLASHES=2 UART=0"
+"atmega6490"  "LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1"
+"atmega6490p" "LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1"
+"atmega8515"  "LED=B0 LED_START_FLASHES=2 UART=0"
+"atmega8535"  "LED=B0 LED_START_FLASHES=2 UART=0"
+)
+
+declare -a clock_and_baud=(
+# "20000000L" "500000"
+# "20000000L" "250000"
+"20000000L" "115200"
+# "20000000L" "19200"
+# "18432000L" "230400"
+# "18432000L" "115200"
+# "18432000L" "57600"
+# "18432000L" "38400"
+# "18432000L" "19200"
+# "18432000L" "9600"
+# "16000000L" "1000000"
+# "16000000L" "500000"
+# "16000000L" "250000"
+"16000000L" "115200"
+# "16000000L" "38400"
+# "16000000L" "19200"
+# "16000000L" "9600"
+# "14745600L" "230400"
+# "14745600L" "115200"
+# "14745600L" "57600"
+# "14745600L" "38400"
+# "14745600L" "19200"
+# "14745600L" "9600"
+# "12000000L" "500000"
+# "12000000L" "250000"
+"12000000L" "57600"
+# "12000000L" "19200"
+# "12000000L" "9600"
+# "11059200L" "230400"
+# "11059200L" "115200"
+# "11059200L" "57600"
+# "11059200L" "38400"
+# "11059200L" "19200"
+# "11059200L" "9600"
+# "8000000L" "1000000" 
+# "8000000L" "500000" 
+# "8000000L" "250000" 
+# "8000000L" "115200" 
+"8000000L" "57600"
+# "8000000L" "38400"
+# "8000000L" "19200"
+# "8000000L" "9600"
+# "7372800L" "230400"
+# "7372800L" "115200"
+# "7372800L" "57600"
+# "7372800L" "38400"
+# "7372800L" "19200"
+# "7372800L" "9600"
+# "4000000L" "500000"
+# "4000000L" "250000"
+# "4000000L" "19200"
+# "4000000L" "9600"
+# "3686400L" "230400"
+# "3686400L" "115200"
+# "3686400L" "57600"
+# "3686400L" "38400"
+# "3686400L" "19200"
+# "3686400L" "9600"
+# "2000000L" "250000"
+# "2000000L" "19200"
+# "2000000L" "9600"
+# "1843200L" "230400"
+# "1843200L" "115200"
+# "1843200L" "57600"
+# "1843200L" "38400"
+# "1843200L" "19200"
+# "1843200L" "9600"
+# "1000000L" "9600"
+)
+
+
+# Start out by deleting all previous generated files
+echo -e "\x1B[7m\n\nDeleting all previous generated files \x1B[0m"
+#make clean_all
+make clean
+
+# Loop through all MCUs and parameters
+for((i=0; i < ${#mcu_and_params[@]}; i+=2));
+do
+  # Loop through all clock speeds and baud rated
+  for((j=0; j < ${#clock_and_baud[@]}; j+=2));
+  do
+     # Count how many builds that have been ran
+     COUNTER=$(($COUNTER + 1))
+     echo -e "\x1B[7m\n\n$COUNTER of $((${#mcu_and_params[@]} * ${#clock_and_baud[@]} / 4))"
+     # Print out current build info
+     echo -e " ${mcu_and_params[$i]} AVR_FREQ=${clock_and_baud[$j]} BAUD_RATE=${clock_and_baud[$j+1]} ${mcu_and_params[$i+1]} \x1B[0m"
+     # Build
+     make ${mcu_and_params[$i]} AVR_FREQ=${clock_and_baud[$j]} BAUD_RATE=${clock_and_baud[$j+1]} ${mcu_and_params[$i+1]}
+  done
+done
+
+# Finish up by removing all *.lst files
+echo -e "\x1B[7m\n\nDeleting all generated *.lst files \x1B[0m"
+make clean_asm

+ 36 - 13
optiboot/bootloaders/optiboot/optiboot.c

@@ -339,14 +339,14 @@ typedef union {
   #define BAUD_ERROR (( 100*(BAUD_RATE - BAUD_ACTUAL) ) / BAUD_RATE)
   #define BAUD_ERROR (( 100*(BAUD_RATE - BAUD_ACTUAL) ) / BAUD_RATE)
   #if BAUD_ERROR >= 5
   #if BAUD_ERROR >= 5
     #error BAUD_RATE off by greater than -5%
     #error BAUD_RATE off by greater than -5%
-  #elif BAUD_ERROR >= 2
+  #elif BAUD_ERROR >= 2  && !defined(PRODUCTION)
     #warning BAUD_RATE off by greater than -2%
     #warning BAUD_RATE off by greater than -2%
   #endif
   #endif
 #else
 #else
   #define BAUD_ERROR (( 100*(BAUD_ACTUAL - BAUD_RATE) ) / BAUD_RATE)
   #define BAUD_ERROR (( 100*(BAUD_ACTUAL - BAUD_RATE) ) / BAUD_RATE)
   #if BAUD_ERROR >= 5
   #if BAUD_ERROR >= 5
     #error BAUD_RATE off by greater than 5%
     #error BAUD_RATE off by greater than 5%
-  #elif BAUD_ERROR >= 2
+  #elif BAUD_ERROR >= 2  && !defined(PRODUCTION)
     #warning BAUD_RATE off by greater than 2%
     #warning BAUD_RATE off by greater than 2%
   #endif
   #endif
 #endif
 #endif
@@ -511,7 +511,11 @@ int main(void) {
   // If not, uncomment the following instructions:
   // If not, uncomment the following instructions:
   // cli();
   // cli();
   asm volatile ("clr __zero_reg__");
   asm volatile ("clr __zero_reg__");
-#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega16__)
+
+#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega8515__) ||		\
+    defined(__AVR_ATmega8535__) || defined (__AVR_ATmega16__) || 	\
+    defined (__AVR_ATmega32__) || defined (__AVR_ATmega64__)  ||	\
+    defined (__AVR_ATmega128__) || defined (__AVR_ATmega162__)
   SP=RAMEND;  // This is done by hardware reset
   SP=RAMEND;  // This is done by hardware reset
 #endif
 #endif
 
 
@@ -522,10 +526,12 @@ int main(void) {
    * Code by MarkG55
    * Code by MarkG55
    * see discusion in https://github.com/Optiboot/optiboot/issues/97
    * see discusion in https://github.com/Optiboot/optiboot/issues/97
    */
    */
-#if !defined(__AVR_ATmega16__)
-  ch = MCUSR;
-#else
+#if defined(__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) ||	\
+    defined(__AVR_ATmega16__)   || defined(__AVR_ATmega162__) ||	\
+    defined (__AVR_ATmega128__)
   ch = MCUCSR;
   ch = MCUCSR;
+#else
+  ch = MCUSR;
 #endif
 #endif
   // Skip all logic and run bootloader if MCUSR is cleared (application request)
   // Skip all logic and run bootloader if MCUSR is cleared (application request)
   if (ch != 0) {
   if (ch != 0) {
@@ -549,10 +555,13 @@ int main(void) {
 	       * '&' operation is skipped to spare few bytes as bits in MCUSR
 	       * '&' operation is skipped to spare few bytes as bits in MCUSR
 	       * can only be cleared.
 	       * can only be cleared.
 	       */
 	       */
-#if !defined(__AVR_ATmega16__)
-	      MCUSR = ~(_BV(WDRF));  
+#if defined(__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) ||	\
+    defined(__AVR_ATmega16__)   || defined(__AVR_ATmega162__) ||	\
+    defined(__AVR_ATmega128__)
+               // Fix missing definitions in avr-libc
+	      MCUCSR = ~(_BV(WDRF));
 #else
 #else
-	      MCUCSR = ~(_BV(WDRF));  
+	      MCUSR = ~(_BV(WDRF));
 #endif
 #endif
 	  }
 	  }
 	  appStart(ch);
 	  appStart(ch);
@@ -565,7 +574,9 @@ int main(void) {
 #endif
 #endif
 
 
 #ifndef SOFT_UART
 #ifndef SOFT_UART
-#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega16__)
+#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega8515__) ||		\
+    defined (__AVR_ATmega8535__) || defined (__AVR_ATmega16__) ||	\
+    defined (__AVR_ATmega32__)
 #ifndef SINGLESPEED
 #ifndef SINGLESPEED
   UCSRA = _BV(U2X); //Double speed mode USART
   UCSRA = _BV(U2X); //Double speed mode USART
 #endif
 #endif
@@ -700,6 +711,9 @@ int main(void) {
  * AVR with 4-byte ISR Vectors and "jmp"
  * AVR with 4-byte ISR Vectors and "jmp"
  * WARNING: this works only up to 128KB flash!
  * WARNING: this works only up to 128KB flash!
  */
  */
+#if FLASHEND > (128*1024)
+#error "Can't use VIRTUAL_BOOT_PARTITION with more than 128k of Flash"
+#endif
       if (address.word == 0) {
       if (address.word == 0) {
 	// This is the reset vector page. We need to live-patch the
 	// This is the reset vector page. We need to live-patch the
 	// code so the bootloader runs first.
 	// code so the bootloader runs first.
@@ -824,7 +838,10 @@ uint8_t getch(void) {
   uint8_t ch;
   uint8_t ch;
 
 
 #ifdef LED_DATA_FLASH
 #ifdef LED_DATA_FLASH
-#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega16__)
+#if defined(__AVR_ATmega8__)    || defined(__AVR_ATmega8515__) ||	\
+    defined(__AVR_ATmega8535__) || defined(__AVR_ATmega16__)   ||	\
+    defined(__AVR_ATmega162__)  || defined(__AVR_ATmega32__)   ||	\
+    defined(__AVR_ATmega64__)   || defined(__AVR_ATmega128__)
   LED_PORT ^= _BV(LED);
   LED_PORT ^= _BV(LED);
 #else
 #else
   LED_PIN |= _BV(LED);
   LED_PIN |= _BV(LED);
@@ -875,7 +892,10 @@ uint8_t getch(void) {
 #endif
 #endif
 
 
 #ifdef LED_DATA_FLASH
 #ifdef LED_DATA_FLASH
-#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega16__)
+#if defined(__AVR_ATmega8__)    || defined(__AVR_ATmega8515__) ||	\
+    defined(__AVR_ATmega8535__) || defined(__AVR_ATmega16__)   ||	\
+    defined(__AVR_ATmega162__)  || defined(__AVR_ATmega32__)   ||	\
+    defined(__AVR_ATmega64__)   || defined(__AVR_ATmega128__)
   LED_PORT ^= _BV(LED);
   LED_PORT ^= _BV(LED);
 #else
 #else
   LED_PIN |= _BV(LED);
   LED_PIN |= _BV(LED);
@@ -924,7 +944,10 @@ void flash_led(uint8_t count) {
     TCNT1 = -(F_CPU/(1024*16));
     TCNT1 = -(F_CPU/(1024*16));
     TIFR1 = _BV(TOV1);
     TIFR1 = _BV(TOV1);
     while(!(TIFR1 & _BV(TOV1)));
     while(!(TIFR1 & _BV(TOV1)));
-#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__) || defined (__AVR_ATmega16__)
+#if defined(__AVR_ATmega8__)    || defined(__AVR_ATmega8515__) ||	\
+    defined(__AVR_ATmega8535__) || defined(__AVR_ATmega16__)   ||	\
+    defined(__AVR_ATmega162__)  || defined(__AVR_ATmega32__)   ||	\
+    defined(__AVR_ATmega64__)   || defined(__AVR_ATmega128__)
     LED_PORT ^= _BV(LED);
     LED_PORT ^= _BV(LED);
 #else
 #else
     LED_PIN |= _BV(LED);
     LED_PIN |= _BV(LED);

+ 327 - 6
optiboot/bootloaders/optiboot/pin_defs.h

@@ -116,16 +116,169 @@
 
 
 /*------------------------------------------------------------------------ */
 /*------------------------------------------------------------------------ */
 /* Sanguino support (and other 40pin DIP cpus) */
 /* Sanguino support (and other 40pin DIP cpus) */
-#if    defined(__AVR_ATmega644P__)	\
-    || defined(__AVR_ATmega1284P__)	\
-    || defined(__AVR_ATmega32__)	\
-    || defined (__AVR_ATmega16__)
 /*------------------------------------------------------------------------ */
 /*------------------------------------------------------------------------ */
-/* Onboard LED is connected to pin PB0 on Sanguino */ 
+/*------------------------------------------------------------------------ */
+#if defined(__AVR_ATmega8515__) || defined(__AVR_ATmega162__) 
+/*------------------------------------------------------------------------ */
+#if !defined(LED)
+#define LED         B0
+#endif
+
+/* Fix register names */
+#if defined(__AVR_ATmega8515__)
+#define UCSR0A  UCSRA
+#define UDR0    UDR
+#define UDRE0   UDRE
+#define RXC0    RXC
+#define FE0     FE
+#endif
+#define TIFR1   TIFR
+#define WDTCSR  WDTCR
+
+/* Ports for soft UART */
+#ifdef SOFT_UART
+#define UART_PORT   PORTD
+#define UART_PIN    PIND
+#define UART_DDR    DDRD
+#define UART_TX_BIT 1
+#define UART_RX_BIT 0
+#endif
+#endif
+
+#if    defined(__AVR_ATmega8535__)		\
+    || defined(__AVR_ATmega16__)		\
+    || defined(__AVR_ATmega32__)		\
+    || defined(__AVR_ATmega164A__)		\
+    || defined(__AVR_ATmega164P__)		\
+    || defined(__AVR_ATmega324A__)		\
+    || defined(__AVR_ATmega324P__)		\
+    || defined(__AVR_ATmega324PA__)		\
+    || defined(__AVR_ATmega644__)		\
+    || defined(__AVR_ATmega644P__)		\
+    || defined(__AVR_ATmega1284__)		\
+    || defined(__AVR_ATmega1284P__)
+/*------------------------------------------------------------------------ */
 #if !defined(LED)
 #if !defined(LED)
 #define LED         B0
 #define LED         B0
 #endif
 #endif
 
 
+#if     defined(__AVR_ATmega8535__)	\
+    ||  defined(__AVR_ATmega16__)	\
+    ||  defined(__AVR_ATmega32__)
+/* Fix register names */
+#define UCSR0A  UCSRA
+#define UDR0    UDR
+#define UDRE0   UDRE
+#define RXC0    RXC
+#define FE0     FE
+#define TIFR1   TIFR
+#define WDTCSR  WDTCR
+#endif
+#if defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__)
+#define WDCE        WDTOE
+#endif
+
+/* Ports for soft UART */
+#ifdef SOFT_UART
+#define UART_PORT   PORTD
+#define UART_PIN    PIND
+#define UART_DDR    DDRD
+#define UART_TX_BIT 1
+#define UART_RX_BIT 0
+#endif
+#endif
+
+
+/*------------------------------------------------------------------------ */
+#if defined(__AVR_ATmega324PB__)
+/*------------------------------------------------------------------------ */
+
+#if !defined(LED)
+#define LED         B0
+#endif
+
+/* Fix missing register names */
+#define MPCM0   MPCM
+#define U2X0    U2X
+#define UPE0    UPE
+#define DOR0    DOR
+#define FE0     FE
+#define UDRE0   UDRE
+#define TXC0    TXC
+#define RXC0    RXC
+
+#define TXB80   TXB8
+#define RXB80   RXB8
+#define UCSZ02  UCSZ2
+#define TXEN0   TXEN
+#define RXEN0   RXEN
+#define UDRIE0  UDRIE
+#define TXCIE0  TXCIE
+#define RXCIE0  RXCIE
+
+#define UCPOL0  UCPOL
+#define UCSZ00  UCSZ0
+#define UCSZ01  UCSZ1
+#define USBS0   USBS
+#define UPM00   UPM0
+#define UPM01   UPM1
+#define UMSEL00 UMSEL0
+#define UMSEL01 UMSEL1
+
+#define MPCM1   MPCM
+#define U2X1    U2X
+#define UPE1    UPE
+#define DOR1    DOR
+#define FE1     FE
+#define UDRE1   UDRE
+#define TXC1    TXC
+#define RXC1    RXC
+
+#define TXB81   TXB8
+#define RXB81   RXB8
+#define UCSZ12  UCSZ2
+#define TXEN1   TXEN
+#define RXEN1   RXEN
+#define UDRIE1  UDRIE
+#define TXCIE1  TXCIE
+#define RXCIE1  RXCIE
+
+#define UCPOL1  UCPOL
+#define UCSZ10  UCSZ0
+#define UCSZ11  UCSZ1
+#define USBS1   USBS
+#define UPM10   UPM0
+#define UPM11   UPM1
+#define UMSEL10 UMSEL0
+#define UMSEL11 UMSEL1
+
+#define MPCM2   MPCM
+#define U2X2    U2X
+#define UPE2    UPE
+#define DOR2    DOR
+#define FE2     FE
+#define UDRE2   UDRE
+#define TXC2    TXC
+#define RXC2    RXC
+
+#define TXB82   TXB8
+#define RXB82   RXB8
+#define UCSZ22  UCSZ2
+#define TXEN2   TXEN
+#define RXEN2   RXEN
+#define UDRIE2  UDRIE
+#define TXCIE2  TXCIE
+#define RXCIE2  RXCIE
+
+#define UCPOL2  UCPOL
+#define UCSZ20  UCSZ0
+#define UCSZ21  UCSZ1
+#define USBS2   USBS
+#define UPM20   UPM0
+#define UPM21   UPM1
+#define UMSEL20 UMSEL0
+#define UMSEL21 UMSEL1
+
 /* Ports for soft UART */
 /* Ports for soft UART */
 #ifdef SOFT_UART
 #ifdef SOFT_UART
 #define UART_PORT   PORTD
 #define UART_PORT   PORTD
@@ -136,9 +289,32 @@
 #endif
 #endif
 #endif
 #endif
 
 
+/*------------------------------------------------------------------------ */
+#if defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__)
+/*------------------------------------------------------------------------ */
+#if !defined(LED)
+#define LED         B5
+#endif
+
+#define TIFR1 TIFR
+#define WDTCSR WDTCR
+//#define MCUSR MCUCSR
+//#define SPMCR SPMCSR
+
+/* Ports for soft UART */
+#ifdef SOFT_UART
+#define UART_PORT   PORTE
+#define UART_PIN    PINE
+#define UART_DDR    DDRE
+#define UART_TX_BIT 1
+#define UART_RX_BIT 0
+#endif
+#endif
+
 /*------------------------------------------------------------------------ */
 /*------------------------------------------------------------------------ */
 /* Mega support */
 /* Mega support */
-#if    defined(__AVR_ATmega1280__)	\
+#if    defined(__AVR_ATmega640__)	\
+    || defined(__AVR_ATmega1280__)	\
     || defined(__AVR_ATmega2560__)
     || defined(__AVR_ATmega2560__)
 /*------------------------------------------------------------------------ */
 /*------------------------------------------------------------------------ */
 /* Onboard LED is connected to pin PB7 on Arduino Mega */ 
 /* Onboard LED is connected to pin PB7 on Arduino Mega */ 
@@ -156,6 +332,151 @@
 #endif
 #endif
 #endif
 #endif
 
 
+/*------------------------------------------------------------------------ */
+#if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
+/*------------------------------------------------------------------------ */
+#if !defined(LED)
+#define LED         B5
+#endif
+
+/* Ports for soft UART */
+#ifdef SOFT_UART
+#define UART_PORT   PORTE
+#define UART_PIN    PINE
+#define UART_DDR    DDRE
+#define UART_TX_BIT 1
+#define UART_RX_BIT 0
+#endif
+#endif
+
+
+/*------------------------------------------------------------------------ */
+#if defined(__AVR_ATmega169__) 
+/*------------------------------------------------------------------------ */
+#if !defined(LED)
+#define LED         B5
+#endif
+
+/* Fix register names */
+#define UCSR0A UCSRA
+#define UCSR0B UCSRB
+#define UCSR0C UCSRC
+#define UBRR0L UBRRL
+#define UDR0 UDR
+#define UDRE0 UDRE
+#define RXC0 RXC
+#define FE0 FE
+#define WDTCSR WDTCR
+#define U2X0 U2X
+#define RXEN0 RXEN
+#define TXEN0 TXEN
+#define UCSZ00 UCSZ0
+#define UCSZ01 UCSZ1
+
+/* Ports for soft UART */
+#ifdef SOFT_UART
+#define UART_PORT   PORTE
+#define UART_PIN    PINE
+#define UART_DDR    DDRE
+#define UART_TX_BIT 1
+#define UART_RX_BIT 0
+#endif
+#endif
+
+/*------------------------------------------------------------------------ */
+#if defined(__AVR_ATmega169P__) || defined(__AVR_ATmega329__) || defined(__AVR_ATmega329P__) \
+|| defined(__AVR_ATmega3290__) || defined(__AVR_ATmega3290P__) || defined(__AVR_ATmega649__) \
+|| defined(__AVR_ATmega649P__) || defined(__AVR_ATmega6490__) || defined(__AVR_ATmega6490P__)
+/*------------------------------------------------------------------------ */
+#if !defined(LED)
+#define LED         B5
+#endif
+
+/* Fix register names */
+#define WDTCSR WDTCR
+
+/* Ports for soft UART */
+#ifdef SOFT_UART
+#define UART_PORT   PORTE
+#define UART_PIN    PINE
+#define UART_DDR    DDRE
+#define UART_TX_BIT 1
+#define UART_RX_BIT 0
+#endif
+#endif
+/*------------------------------------------------------------------------ */
+#if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
+/*------------------------------------------------------------------------ */
+#if !defined(LED)
+#define LED         B5
+#endif
+
+/* Ports for soft UART */
+#ifdef SOFT_UART
+#define UART_PORT   PORTE
+#define UART_PIN    PINE
+#define UART_DDR    DDRE
+#define UART_TX_BIT 1
+#define UART_RX_BIT 0
+#endif
+#endif
+
+
+/*------------------------------------------------------------------------ */
+#if defined(__AVR_ATmega169__) 
+/*------------------------------------------------------------------------ */
+#if !defined(LED)
+#define LED         B5
+#endif
+
+/* Fix register names */
+#define UCSR0A UCSRA
+#define UCSR0B UCSRB
+#define UCSR0C UCSRC
+#define UBRR0L UBRRL
+#define UDR0 UDR
+#define UDRE0 UDRE
+#define RXC0 RXC
+#define FE0 FE
+#define WDTCSR WDTCR
+#define U2X0 U2X
+#define RXEN0 RXEN
+#define TXEN0 TXEN
+#define UCSZ00 UCSZ0
+#define UCSZ01 UCSZ1
+
+/* Ports for soft UART */
+#ifdef SOFT_UART
+#define UART_PORT   PORTE
+#define UART_PIN    PINE
+#define UART_DDR    DDRE
+#define UART_TX_BIT 1
+#define UART_RX_BIT 0
+#endif
+#endif
+
+/*------------------------------------------------------------------------ */
+#if defined(__AVR_ATmega169P__) || defined(__AVR_ATmega329__) || defined(__AVR_ATmega329P__) \
+|| defined(__AVR_ATmega3290__) || defined(__AVR_ATmega3290P__) || defined(__AVR_ATmega649__) \
+|| defined(__AVR_ATmega649P__) || defined(__AVR_ATmega6490__) || defined(__AVR_ATmega6490P__)
+/*------------------------------------------------------------------------ */
+#if !defined(LED)
+#define LED         B5
+#endif
+
+/* Fix register names */
+#define WDTCSR WDTCR
+
+/* Ports for soft UART */
+#ifdef SOFT_UART
+#define UART_PORT   PORTE
+#define UART_PIN    PINE
+#define UART_DDR    DDRE
+#define UART_TX_BIT 1
+#define UART_RX_BIT 0
+#endif
+#endif
+
 /*------------------------------------------------------------------------ */
 /*------------------------------------------------------------------------ */
 #if defined(__AVR_ATtiny1634__)
 #if defined(__AVR_ATtiny1634__)
 /*------------------------------------------------------------------------ */
 /*------------------------------------------------------------------------ */