diff --git a/optiboot/bootloaders/optiboot/Makefile b/optiboot/bootloaders/optiboot/Makefile index cc3e4ba..8bec291 100644 --- a/optiboot/bootloaders/optiboot/Makefile +++ b/optiboot/bootloaders/optiboot/Makefile @@ -60,7 +60,7 @@ export # defaults MCU_TARGET = atmega168 -LDSECTIONS = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe +LDSECTIONS = -Wl,-Tlink_optiboot.ld # Build environments # Start of some ugly makefile-isms to allow optiboot to be built @@ -349,8 +349,6 @@ virboot8: TARGET = atmega8 virboot8: MCU_TARGET = atmega8 virboot8: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' '-Dsave_vect_num=EE_RDY_vect_num' virboot8: AVR_FREQ ?= 16000000L -# Start address of 1D80 allows for size up to 640 bytes, app up to 7552 -virboot8: LDSECTIONS = -Wl,--section-start=.text=0x1d80 -Wl,--section-start=.version=0x1ffe virboot8: $(PROGRAM)_virboot8.hex ifndef PRODUCTION virboot8: $(PROGRAM)_virboot8.lst @@ -362,7 +360,6 @@ virboot328: TARGET = atmega328 virboot328: MCU_TARGET = atmega328p virboot328: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' virboot328: AVR_FREQ ?= 16000000L -virboot328: LDSECTIONS = -Wl,--section-start=.text=0x7d80 -Wl,--section-start=.version=0x7ffe virboot328: $(PROGRAM)_virboot328.hex ifndef PRODUCTION virboot328: $(PROGRAM)_virboot328.lst @@ -403,11 +400,6 @@ atmega8: TARGET = atmega8 atmega8: MCU_TARGET = atmega8 atmega8: CFLAGS += $(COMMON_OPTIONS) atmega8: AVR_FREQ ?= 16000000L -ifndef BIGBOOT -atmega8: LDSECTIONS = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe -Wl,--gc-sections -Wl,--undefined=optiboot_version -else -atmega8: LDSECTIONS = -Wl,--section-start=.text=0x1c00 -Wl,--section-start=.version=0x1ffe -Wl,--gc-sections -Wl,--undefined=optiboot_version -endif atmega8: $(PROGRAM)_atmega8.hex ifndef PRODUCTION atmega8: $(PROGRAM)_atmega8.lst @@ -432,11 +424,6 @@ atmega168: TARGET = atmega168 atmega168: MCU_TARGET = atmega168 atmega168: CFLAGS += $(COMMON_OPTIONS) atmega168: AVR_FREQ ?= 16000000L -ifndef BIGBOOT -atmega168: LDSECTIONS = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe -else -atmega168: LDSECTIONS = -Wl,--section-start=.text=0x3c00 -Wl,--section-start=.version=0x3ffe -endif atmega168: $(PROGRAM)_atmega168.hex ifndef PRODUCTION atmega168: $(PROGRAM)_atmega168.lst @@ -462,12 +449,6 @@ atmega328: TARGET = atmega328 atmega328: MCU_TARGET = atmega328p atmega328: CFLAGS += $(COMMON_OPTIONS) atmega328: AVR_FREQ ?= 16000000L -ifndef BIGBOOT -atmega328: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe -else -# bigboot version is 1k long; starts earlier -atmega328: LDSECTIONS = -Wl,--section-start=.text=0x7c00 -Wl,--section-start=.version=0x7ffe -endif atmega328: $(PROGRAM)_atmega328.hex ifndef PRODUCTION atmega328: $(PROGRAM)_atmega328.lst @@ -494,7 +475,6 @@ atmega328_isp: isp atmega1280: MCU_TARGET = atmega1280 atmega1280: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT $(UART_CMD) atmega1280: AVR_FREQ ?= 16000000L -atmega1280: LDSECTIONS = -Wl,--section-start=.text=0x1fc00 -Wl,--section-start=.version=0x1fffe atmega1280: $(PROGRAM)_atmega1280.hex ifndef PRODUCTION atmega1280: $(PROGRAM)_atmega1280.lst diff --git a/optiboot/bootloaders/optiboot/Makefile.1284 b/optiboot/bootloaders/optiboot/Makefile.1284 index 78de8e6..5ac63ae 100644 --- a/optiboot/bootloaders/optiboot/Makefile.1284 +++ b/optiboot/bootloaders/optiboot/Makefile.1284 @@ -12,7 +12,6 @@ atmega644p: TARGET = atmega644p atmega644p: MCU_TARGET = atmega644p atmega644p: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT atmega644p: AVR_FREQ ?= 16000000L -atmega644p: LDSECTIONS = -Wl,--section-start=.text=0xfc00 -Wl,--section-start=.version=0xfffe atmega644p: CFLAGS += $(UART_CMD) atmega644p: $(PROGRAM)_atmega644p.hex ifndef PRODUCTION @@ -24,7 +23,6 @@ atmega1284: TARGET = atmega1284p atmega1284: MCU_TARGET = atmega1284p atmega1284: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT atmega1284: AVR_FREQ ?= 16000000L -atmega1284: LDSECTIONS = -Wl,--section-start=.text=0x1fc00 -Wl,--section-start=.version=0x1fffe atmega1284: CFLAGS += $(UART_CMD) atmega1284: $(PROGRAM)_atmega1284p.hex ifndef PRODUCTION diff --git a/optiboot/bootloaders/optiboot/Makefile.2560 b/optiboot/bootloaders/optiboot/Makefile.2560 index bd6d518..2ab370e 100644 --- a/optiboot/bootloaders/optiboot/Makefile.2560 +++ b/optiboot/bootloaders/optiboot/Makefile.2560 @@ -12,7 +12,6 @@ atmega2560: TARGET = atmega2560 atmega2560: MCU_TARGET = atmega2560 atmega2560: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT atmega2560: AVR_FREQ ?= 16000000L -atmega2560: LDSECTIONS = -Wl,--section-start=.text=0x3fc00 -Wl,--section-start=.version=0x3fffe atmega2560: CFLAGS += $(UART_CMD) atmega2560: $(PROGRAM)_atmega2560.hex ifndef PRODUCTION diff --git a/optiboot/bootloaders/optiboot/Makefile.extras b/optiboot/bootloaders/optiboot/Makefile.extras index 35de4b0..ab10385 100644 --- a/optiboot/bootloaders/optiboot/Makefile.extras +++ b/optiboot/bootloaders/optiboot/Makefile.extras @@ -19,7 +19,6 @@ atmega88: TARGET = atmega88 atmega88: MCU_TARGET = atmega88 atmega88: CFLAGS += $(COMMON_OPTIONS) atmega88: AVR_FREQ ?= 16000000L -atmega88: LDSECTIONS = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe -Wl,--gc-sections -Wl,--undefined=optiboot_version atmega88: $(PROGRAM)_atmega88.hex atmega88: $(PROGRAM)_atmega88.lst @@ -82,7 +81,6 @@ atmega32: TARGET = atmega32 atmega32: MCU_TARGET = atmega32 atmega32: CFLAGS += $(COMMON_OPTIONS) atmega32: AVR_FREQ ?= 11059200L -atmega32: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe atmega32: $(PROGRAM)_atmega32.hex atmega32: $(PROGRAM)_atmega32.lst @@ -100,7 +98,6 @@ HELPTEXT += "target atmega128rfa1 - ATmega128RFA1 (100pin, 128k)\n" atmega128rfa1: MCU_TARGET = atmega128rfa1 atmega128rfa1: CFLAGS += $(COMMON_OPTIONS) -DBIGBOOT $(UART_CMD) atmega128rfa1: AVR_FREQ ?= 16000000L -atmega128rfa1: LDSECTIONS = -Wl,--section-start=.text=0x1fc00 -Wl,--section-start=.version=0x1fffe atmega128rfa1: $(PROGRAM)_atmega128rfa1.hex ifndef PRODUCTION atmega128rfa1: $(PROGRAM)_atmega128rfa1.lst diff --git a/optiboot/bootloaders/optiboot/Makefile.mcudude b/optiboot/bootloaders/optiboot/Makefile.mcudude index a0f10c3..8457a08 100644 --- a/optiboot/bootloaders/optiboot/Makefile.mcudude +++ b/optiboot/bootloaders/optiboot/Makefile.mcudude @@ -25,7 +25,6 @@ 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 ifndef PRODUCTION atmega16: $(PROGRAM)_atmega16_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -37,7 +36,6 @@ 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 ifndef PRODUCTION atmega64: $(PROGRAM)_atmega64_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -49,7 +47,6 @@ 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 ifndef PRODUCTION atmega88p: $(PROGRAM)_atmega88p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -61,7 +58,6 @@ 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 ifndef PRODUCTION atmega88pb: $(PROGRAM)_atmega88pb_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -72,7 +68,6 @@ 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 ifndef PRODUCTION atmega128: $(PROGRAM)_atmega128_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -84,7 +79,6 @@ 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 ifndef PRODUCTION atmega162: $(PROGRAM)_atmega162_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -95,7 +89,6 @@ 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 ifndef PRODUCTION atmega164a: $(PROGRAM)_atmega164a_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -107,7 +100,6 @@ 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 ifndef PRODUCTION atmega164p: $(PROGRAM)_atmega164p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -119,7 +111,6 @@ atmega164pa: atmega164p #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 #ifndef PRODUCTION #atmega168: $(PROGRAM)_atmega168_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -131,7 +122,6 @@ 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 ifndef PRODUCTION atmega168p: $(PROGRAM)_atmega168p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -143,7 +133,6 @@ 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 ifndef PRODUCTION atmega168pb: $(PROGRAM)_atmega168pb_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -154,7 +143,6 @@ 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 ifndef PRODUCTION atmega169: $(PROGRAM)_atmega169_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -166,7 +154,6 @@ 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 ifndef PRODUCTION atmega169p: $(PROGRAM)_atmega169p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -178,7 +165,6 @@ 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 ifndef PRODUCTION atmega324a: $(PROGRAM)_atmega324a_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -190,7 +176,6 @@ 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 ifndef PRODUCTION atmega324p: $(PROGRAM)_atmega324p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -201,7 +186,6 @@ 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 ifndef PRODUCTION atmega324pa: $(PROGRAM)_atmega324pa_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -212,7 +196,6 @@ 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 ifndef PRODUCTION atmega324pb: $(PROGRAM)_atmega324pb_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -223,7 +206,6 @@ 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 ifndef PRODUCTION atmega328pb: $(PROGRAM)_atmega328pb_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -234,7 +216,6 @@ 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 ifndef PRODUCTION atmega329: $(PROGRAM)_atmega329_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -246,7 +227,6 @@ 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 ifndef PRODUCTION atmega329p: $(PROGRAM)_atmega329p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -258,7 +238,6 @@ 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 ifndef PRODUCTION atmega640: $(PROGRAM)_atmega640_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -269,7 +248,6 @@ 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 ifndef PRODUCTION atmega649: $(PROGRAM)_atmega649_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -280,7 +258,6 @@ 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 ifndef PRODUCTION atmega649p: $(PROGRAM)_atmega649p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -291,7 +268,6 @@ 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 ifndef PRODUCTION atmega1281: $(PROGRAM)_atmega1281_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -302,7 +278,6 @@ 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 ifndef PRODUCTION atmega2561: $(PROGRAM)_atmega2561_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -313,7 +288,6 @@ 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 ifndef PRODUCTION atmega3290: $(PROGRAM)_atmega3290_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -324,7 +298,6 @@ 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 ifndef PRODUCTION atmega3290p: $(PROGRAM)_atmega3290p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -336,7 +309,6 @@ 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 ifndef PRODUCTION atmega6490: $(PROGRAM)_atmega6490_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -347,7 +319,6 @@ 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 ifndef PRODUCTION atmega6490p: $(PROGRAM)_atmega6490p_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -358,7 +329,6 @@ 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 ifndef PRODUCTION atmega8515: $(PROGRAM)_atmega8515_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst @@ -369,7 +339,6 @@ 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 ifndef PRODUCTION atmega8535: $(PROGRAM)_atmega8535_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ).lst diff --git a/optiboot/bootloaders/optiboot/Makefile.tiny b/optiboot/bootloaders/optiboot/Makefile.tiny index 3a5f564..1a8c463 100644 --- a/optiboot/bootloaders/optiboot/Makefile.tiny +++ b/optiboot/bootloaders/optiboot/Makefile.tiny @@ -10,7 +10,6 @@ attiny1634: MCU_TARGET = attiny1634 attiny1634: LED_CMD ?= -DLED=C0 attiny1634: CFLAGS += $(COMMON_OPTIONS) -DVIRTUAL_BOOT_PARTITION -DFOURPAGEERASE $(UART_CMD) attiny1634: AVR_FREQ ?= 8000000L -attiny1634: LDSECTIONS = -Wl,--section-start=.text=0x3d80 -Wl,--section-start=.version=0x3ffe attiny1634: $(PROGRAM)_attiny1634.hex ifndef PRODUCTION attiny1634: $(PROGRAM)_attiny1634.lst @@ -178,7 +177,6 @@ attiny841: TARGET = attiny841 attiny841: MCU_TARGET = attiny841 attiny841: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' '-DFOURPAGEERASE' $(UART_CMD) attiny841: AVR_FREQ ?= 8000000L -attiny841: LDSECTIONS = -Wl,--section-start=.text=0x1d80 -Wl,--section-start=.version=0x1ffe attiny841: $(PROGRAM)_attiny841.hex ifndef PRODUCTION attiny841: $(PROGRAM)_attiny841.lst @@ -363,21 +361,21 @@ endif #----------------------- attiny841at20noLED: - $(MAKE) attiny841 AVR_FREQ=20000000L LED_START_FLASHES=0 LDSECTIONS = -Wl,--section-start=.text=0x1dc0 -Wl,--section-start=.version=0x1ffe + $(MAKE) attiny841 AVR_FREQ=20000000L LED_START_FLASHES=0 mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_20000000L_noLED.hex ifndef PRODUCTION mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_20000000L_noLED.lst endif attiny841at16noLED: - $(MAKE) attiny841 AVR_FREQ=16000000L LED_START_FLASHES=0 LDSECTIONS = -Wl,--section-start=.text=0x1dc0 -Wl,--section-start=.version=0x1ffe + $(MAKE) attiny841 AVR_FREQ=16000000L LED_START_FLASHES=0 mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_16000000L_noLED.hex ifndef PRODUCTION mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_16000000L_noLED.lst endif attiny841at8noLED: - $(MAKE) attiny841 AVR_FREQ=8000000L BAUD_RATE=57600 LED_START_FLASHES=0 LDSECTIONS = -Wl,--section-start=.text=0x1dc0 -Wl,--section-start=.version=0x1ffe + $(MAKE) attiny841 AVR_FREQ=8000000L BAUD_RATE=57600 LED_START_FLASHES=0 mv $(PROGRAM)_attiny841.hex $(PROGRAM)_attiny841_8000000L_noLED.hex ifndef PRODUCTION mv $(PROGRAM)_attiny841.lst $(PROGRAM)_attiny841_8000000L_noLED.lst @@ -395,7 +393,6 @@ attiny441: TARGET = attiny441 attiny441: MCU_TARGET = attiny441 attiny441: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' '-DFOURPAGEERASE' $(UART_CMD) attiny441: AVR_FREQ ?= 8000000L -attiny441: LDSECTIONS = -Wl,--section-start=.text=0x0d80 -Wl,--section-start=.version=0x0ffe attiny441: $(PROGRAM)_attiny441.hex ifndef PRODUCTION attiny441: $(PROGRAM)_attiny441.lst @@ -586,21 +583,21 @@ endif #----------------------- attiny441at20noLED: - $(MAKE) attiny441 AVR_FREQ=20000000L LED_START_FLASHES=0 LDSECTIONS = -Wl,--section-start=.text=0x0dc0 -Wl,--section-start=.version=0x0ffe + $(MAKE) attiny441 AVR_FREQ=20000000L LED_START_FLASHES=0 mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_20000000L_noLED.hex ifndef PRODUCTION mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_20000000L_noLED.lst endif attiny441at16noLED: - $(MAKE) attiny441 AVR_FREQ=16000000L LED_START_FLASHES=0 LDSECTIONS = -Wl,--section-start=.text=0x0dc0 -Wl,--section-start=.version=0x0ffe + $(MAKE) attiny441 AVR_FREQ=16000000L LED_START_FLASHES=0 mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_16000000L_noLED.hex ifndef PRODUCTION mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_16000000L_noLED.lst endif attiny441at8noLED: - $(MAKE) attiny441 AVR_FREQ=8000000L BAUD_RATE=57600 LED_START_FLASHES=0 LDSECTIONS = -Wl,--section-start=.text=0x0dc0 -Wl,--section-start=.version=0x0ffe + $(MAKE) attiny441 AVR_FREQ=8000000L BAUD_RATE=57600 LED_START_FLASHES=0 mv $(PROGRAM)_attiny441.hex $(PROGRAM)_attiny441_8000000L_noLED.hex ifndef PRODUCTION mv $(PROGRAM)_attiny441.lst $(PROGRAM)_attiny441_8000000L_noLED.lst @@ -617,7 +614,6 @@ attiny828: TARGET = attiny828 attiny828: MCU_TARGET = attiny828 attiny828: CFLAGS += $(COMMON_OPTIONS) attiny828: AVR_FREQ ?= 8000000L -attiny828: LDSECTIONS = -Wl,--section-start=.text=0x1E00 -Wl,--section-start=.version=0x1ffe attiny828: $(PROGRAM)_attiny828.hex ifndef PRODUCTION attiny828: $(PROGRAM)_attiny828.lst @@ -683,7 +679,6 @@ attiny88: TARGET = attiny88 attiny88: MCU_TARGET = attiny88 attiny88: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' '-DSOFT_UART' attiny88: AVR_FREQ ?= 8000000L -attiny88: LDSECTIONS = -Wl,--section-start=.text=0x1D80 -Wl,--section-start=.version=0x1ffe attiny88: $(PROGRAM)_attiny88.hex ifndef PRODUCTION attiny88: $(PROGRAM)_attiny88.lst @@ -750,7 +745,6 @@ attiny48: TARGET = attiny48 attiny48: MCU_TARGET = attiny48 attiny48: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' '-DSOFT_UART' attiny48: AVR_FREQ ?= 8000000L -attiny48: LDSECTIONS = -Wl,--section-start=.text=0x0D80 -Wl,--section-start=.version=0x0ffe attiny48: $(PROGRAM)_attiny48.hex ifndef PRODUCTION attiny48: $(PROGRAM)_attiny48.lst @@ -817,7 +811,6 @@ attiny85: MCU_TARGET = attiny85 attiny85: LED_START_FLASHES_CMD = '-DLED_START_FLASHES=0' attiny85: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' '-DSOFT_UART' attiny85: AVR_FREQ ?= 8000000L -attiny85: LDSECTIONS = -Wl,--section-start=.text=0x1DC0 -Wl,--section-start=.version=0x1ffe attiny85: $(PROGRAM)_attiny85.hex ifndef PRODUCTION attiny85: $(PROGRAM)_attiny85.lst @@ -904,7 +897,6 @@ attiny45: MCU_TARGET = attiny45 attiny45: LED_START_FLASHES_CMD = '-DLED_START_FLASHES=0' attiny45: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' '-DSOFT_UART' attiny45: AVR_FREQ ?= 8000000L -attiny45: LDSECTIONS = -Wl,--section-start=.text=0x0DC0 -Wl,--section-start=.version=0x0ffe attiny45: $(PROGRAM)_attiny45.hex ifndef PRODUCTION attiny45: $(PROGRAM)_attiny45.lst @@ -991,7 +983,6 @@ attiny84: TARGET = attiny84 attiny84: MCU_TARGET = attiny84 attiny84: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' '-DSOFT_UART' attiny84: AVR_FREQ ?= 8000000L -attiny84: LDSECTIONS = -Wl,--section-start=.text=0x1D80 -Wl,--section-start=.version=0x1ffe attiny84: $(PROGRAM)_attiny84.hex ifndef PRODUCTION attiny84: $(PROGRAM)_attiny84.lst @@ -1078,7 +1069,6 @@ attiny44: TARGET = attiny44 attiny44: MCU_TARGET = attiny44 attiny44: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' '-DSOFT_UART' attiny44: AVR_FREQ ?= 8000000L -attiny44: LDSECTIONS = -Wl,--section-start=.text=0x0D80 -Wl,--section-start=.version=0x0ffe attiny44: $(PROGRAM)_attiny44.hex ifndef PRODUCTION attiny44: $(PROGRAM)_attiny44.lst @@ -1166,7 +1156,6 @@ attiny861: TARGET = attiny861 attiny861: MCU_TARGET = attiny861 attiny861: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' '-DSOFT_UART' attiny861: AVR_FREQ ?= 8000000L -attiny861: LDSECTIONS = -Wl,--section-start=.text=0x1D80 -Wl,--section-start=.version=0x1ffe attiny861: $(PROGRAM)_attiny861.hex ifndef PRODUCTION attiny861: $(PROGRAM)_attiny861.lst @@ -1253,7 +1242,6 @@ attiny461: TARGET = attiny461 attiny461: MCU_TARGET = attiny461 attiny461: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' '-DSOFT_UART' attiny461: AVR_FREQ ?= 8000000L -attiny461: LDSECTIONS = -Wl,--section-start=.text=0x0D80 -Wl,--section-start=.version=0x0ffe attiny461: $(PROGRAM)_attiny461.hex ifndef PRODUCTION attiny461: $(PROGRAM)_attiny461.lst @@ -1341,7 +1329,6 @@ attiny167: TARGET = attiny167 attiny167: MCU_TARGET = attiny167 attiny167: AVR_FREQ ?= 8000000L attiny167: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' -attiny167: LDSECTIONS = -Wl,--section-start=.text=0x3d80 -Wl,--section-start=.version=0x3ffe attiny167: $(PROGRAM)_attiny167.hex ifndef PRODUCTION attiny167: $(PROGRAM)_attiny167.lst @@ -1352,7 +1339,6 @@ attiny87: TARGET = attiny87 attiny87: MCU_TARGET = attiny87 attiny87: CFLAGS += $(COMMON_OPTIONS) '-DVIRTUAL_BOOT_PARTITION' attiny87: AVR_FREQ ?= 8000000L -attiny87: LDSECTIONS = -Wl,--section-start=.text=0x1d80 -Wl,--section-start=.version=0x1ffe attiny87: $(PROGRAM)_attiny87.hex ifndef PRODUCTION attiny87: $(PROGRAM)_attiny87.lst diff --git a/optiboot/bootloaders/optiboot/Makefile.usbmcus b/optiboot/bootloaders/optiboot/Makefile.usbmcus index cb497d6..7b11e9d 100644 --- a/optiboot/bootloaders/optiboot/Makefile.usbmcus +++ b/optiboot/bootloaders/optiboot/Makefile.usbmcus @@ -23,11 +23,6 @@ atmega8u2atUART: TARGET = atmega8u2 atmega8u2atUART: MCU_TARGET = atmega8u2 atmega8u2atUART: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD) atmega8u2atUART: AVR_FREQ ?= 16000000L -ifndef BIGBOOT ## standard version is 512 Bytes long; starts earlier -atmega8u2atUART: LDSECTIONS = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe -else ## bigboot version is 1024 Bytes long; starts earlier -atmega8u2atUART: LDSECTIONS = -Wl,--section-start=.text=0x1c00 -Wl,--section-start=.version=0x1ffe -endif atmega8u2atUART: $(PROGRAM)_atmega8u2_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).hex ifndef PRODUCTION atmega8u2atUART: $(PROGRAM)_atmega8u2_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).lst @@ -57,11 +52,6 @@ atmega16u2atUART: TARGET = atmega16u2 atmega16u2atUART: MCU_TARGET = atmega16u2 atmega16u2atUART: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD) atmega16u2atUART: AVR_FREQ ?= 16000000L -ifndef BIGBOOT ## standard version is 512 Bytes long; starts earlier -atmega16u2atUART: LDSECTIONS = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe -else ## bigboot version is 1024 Bytes long; starts earlier -atmega16u2atUART: LDSECTIONS = -Wl,--section-start=.text=0x3c00 -Wl,--section-start=.version=0x3ffe -endif atmega16u2atUART: $(PROGRAM)_atmega16u2_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).hex ifndef PRODUCTION atmega16u2atUART: $(PROGRAM)_atmega16u2_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).lst @@ -91,11 +81,6 @@ atmega32u2atUART: TARGET = atmega32u2 atmega32u2atUART: MCU_TARGET = atmega32u2 atmega32u2atUART: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD) atmega32u2atUART: AVR_FREQ ?= 16000000L -ifndef BIGBOOT ## standard version is 512 Bytes long; starts earlier -atmega32u2atUART: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe -else ## bigboot version is 1024 Bytes long; starts earlier -atmega32u2atUART: LDSECTIONS = -Wl,--section-start=.text=0x7c00 -Wl,--section-start=.version=0x7ffe -endif atmega32u2atUART: $(PROGRAM)_atmega32u2_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).hex ifndef PRODUCTION atmega32u2atUART: $(PROGRAM)_atmega32u2_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).lst @@ -125,11 +110,6 @@ atmega16u4atUART: TARGET = atmega16u4 atmega16u4atUART: MCU_TARGET = atmega16u4 atmega16u4atUART: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD) atmega16u4atUART: AVR_FREQ ?= 16000000L -ifndef BIGBOOT ## standard version is 512 Bytes long; starts earlier -atmega16u4atUART: LDSECTIONS = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe -else ## bigboot version is 1024 Bytes long; starts earlier -atmega16u4atUART: LDSECTIONS = -Wl,--section-start=.text=0x3c00 -Wl,--section-start=.version=0x3ffe -endif atmega16u4atUART: $(PROGRAM)_atmega16u4_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).hex ifndef PRODUCTION atmega16u4atUART: $(PROGRAM)_atmega16u4_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).lst @@ -160,11 +140,6 @@ atmega32u4atUART: TARGET = atmega32u4 atmega32u4atUART: MCU_TARGET = atmega32u4 atmega32u4atUART: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD) atmega32u4atUART: AVR_FREQ ?= 16000000L -ifndef BIGBOOT ## standard version is 512 Bytes long; starts earlier -atmega32u4atUART: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe -else ## bigboot version is 1024 Bytes long; starts earlier -atmega32u4atUART: LDSECTIONS = -Wl,--section-start=.text=0x7c00 -Wl,--section-start=.version=0x7ffe -endif atmega32u4atUART: $(PROGRAM)_atmega32u4_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).hex ifndef PRODUCTION atmega32u4atUART: $(PROGRAM)_atmega32u4_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).lst @@ -195,11 +170,6 @@ atmega32u6atUART: TARGET = atmega32u6 atmega32u6atUART: MCU_TARGET = atmega32u6 atmega32u6atUART: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD) atmega32u6atUART: AVR_FREQ ?= 16000000L -ifndef BIGBOOT ## standard version is 512 Bytes long; starts earlier -atmega32u6atUART: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe -else ## bigboot version is 1024 Bytes long; starts earlier -atmega32u6atUART: LDSECTIONS = -Wl,--section-start=.text=0x7c00 -Wl,--section-start=.version=0x7ffe -endif atmega32u6atUART: $(PROGRAM)_atmega32u6_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).hex ifndef PRODUCTION atmega32u6atUART: $(PROGRAM)_atmega32u6_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).lst @@ -229,11 +199,6 @@ at90usb646atUART: TARGET = at90usb646 at90usb646atUART: MCU_TARGET = at90usb646 at90usb646atUART: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD) at90usb646atUART: AVR_FREQ ?= 16000000L -ifndef BIGBOOT ## standard version is 512 Bytes long; starts earlier -at90usb646atUART: LDSECTIONS = -Wl,--section-start=.text=0xfc00 -Wl,--section-start=.version=0xfffe -else ## bigboot version is 1024 Bytes long; starts earlier -at90usb646atUART: LDSECTIONS = -Wl,--section-start=.text=0xf800 -Wl,--section-start=.version=0xfffe -endif at90usb646atUART: $(PROGRAM)_at90usb646_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).hex ifndef PRODUCTION at90usb646atUART: $(PROGRAM)_at90usb646_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).lst @@ -244,11 +209,7 @@ at90usb646: at90usb646_isp: at90usb646 at90usb646_isp: TARGET = at90usb646 at90usb646_isp: MCU_TARGET = at90usb646 -ifndef BIGBOOT ## standard version is 1024 Bytes long; starts earlier at90usb646_isp: HFUSE ?= DE# = 1024 byte boot, SPI (ISP!!!) enabled, JTAG disabled -else ## bigboot version is 2048 Bytes long; starts earlier -at90usb646_isp: HFUSE ?= DC# = 2048 byte boot, SPI (ISP!!!) enabled, JTAG disabled -endif at90usb646_isp: LFUSE ?= FF# = Full Swing xtal (16MHz) 16KCK/14CK+65ms at90usb646_isp: EFUSE ?= FB# = 2.6V brownout at90usb646_isp: LOCK ?= 2F# = APP protect mode 1, BL protect mode 2 @@ -263,11 +224,6 @@ at90usb647atUART: TARGET = at90usb647 at90usb647atUART: MCU_TARGET = at90usb647 at90usb647atUART: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD) at90usb647atUART: AVR_FREQ ?= 16000000L -ifndef BIGBOOT ## standard version is 1024 Bytes long; starts earlier -at90usb647atUART: LDSECTIONS = -Wl,--section-start=.text=0xfc00 -Wl,--section-start=.version=0xfffe -else ## bigboot version is 2048 Bytes long; starts earlier -at90usb647atUART: LDSECTIONS = -Wl,--section-start=.text=0xf800 -Wl,--section-start=.version=0xfffe -endif at90usb647atUART: $(PROGRAM)_at90usb647_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).hex ifndef PRODUCTION at90usb647atUART: $(PROGRAM)_at90usb647_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).lst @@ -278,11 +234,7 @@ at90usb647: at90usb647_isp: at90usb647 at90usb647_isp: TARGET = at90usb647 at90usb647_isp: MCU_TARGET = at90usb647 -ifndef BIGBOOT ## standard version is 1024 Bytes long; starts earlier at90usb647_isp: HFUSE ?= DE# = 1024 byte boot, SPI (ISP!!!) enabled, JTAG disabled -else ## bigboot version is 2048 Bytes long; starts earlier -at90usb647_isp: HFUSE ?= DC# = 2048 byte boot, SPI (ISP!!!) enabled, JTAG disabled -endif at90usb647_isp: LFUSE ?= FF# = Full Swing xtal (16MHz) 16KCK/14CK+65ms at90usb647_isp: EFUSE ?= FB# = 2.6V brownout at90usb647_isp: LOCK ?= 2F# = APP protect mode 1, BL protect mode 2 @@ -297,11 +249,6 @@ at90usb1286atUART: TARGET = at90usb1286 at90usb1286atUART: MCU_TARGET = at90usb1286 at90usb1286atUART: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD) at90usb1286atUART: AVR_FREQ ?= 16000000L -ifndef BIGBOOT ## standard version is 1024 Bytes long; starts earlier -at90usb1286atUART: LDSECTIONS = -Wl,--section-start=.text=0x1fc00 -Wl,--section-start=.version=0x1fffe -else ## bigboot version is 2048 Bytes long; starts earlier -at90usb1286atUART: LDSECTIONS = -Wl,--section-start=.text=0x1f800 -Wl,--section-start=.version=0x1fffe -endif at90usb1286atUART: $(PROGRAM)_at90usb1286_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).hex ifndef PRODUCTION at90usb1286atUART: $(PROGRAM)_at90usb1286_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).lst @@ -312,11 +259,7 @@ at90usb1286: at90usb1286_isp: at90usb1286 at90usb1286_isp: TARGET = at90usb1286 at90usb1286_isp: MCU_TARGET = at90usb1286 -ifndef BIGBOOT ## standard version is 1024 Bytes long; starts earlier at90usb1286_isp: HFUSE ?= DE# = 1024 byte boot, SPI (ISP!!!) enabled, JTAG disabled -else ## bigboot version is 2048 Bytes long; starts earlier -at90usb1286_isp: HFUSE ?= DC# = 2048 byte boot, SPI (ISP!!!) enabled, JTAG disabled -endif at90usb1286_isp: LFUSE ?= FF# = Full Swing xtal (16MHz) 16KCK/14CK+65ms at90usb1286_isp: EFUSE ?= FB# = 2.6V brownout at90usb1286_isp: LOCK ?= 2F# = APP protect mode 1, BL protect mode 2 @@ -331,11 +274,6 @@ at90usb1287atUART: TARGET = at90usb1287 at90usb1287atUART: MCU_TARGET = at90usb1287 at90usb1287atUART: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD) at90usb1287atUART: AVR_FREQ ?= 16000000L -ifndef BIGBOOT ## standard version is 1024 Bytes long; starts earlier -at90usb1287atUART: LDSECTIONS = -Wl,--section-start=.text=0x1fc00 -Wl,--section-start=.version=0x1fffe -else ## bigboot version is 2048 Bytes long; starts earlier -at90usb1287atUART: LDSECTIONS = -Wl,--section-start=.text=0x1f800 -Wl,--section-start=.version=0x1fffe -endif at90usb1287atUART: $(PROGRAM)_at90usb1287_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).hex ifndef PRODUCTION at90usb1287atUART: $(PROGRAM)_at90usb1287_UART$(UART)_$(BAUD_RATE)_$(AVR_FREQ)_BB$(BIGBOOT).lst @@ -346,11 +284,7 @@ at90usb1287: at90usb1287_isp: at90usb1287 at90usb1287_isp: TARGET = at90usb1287 at90usb1287_isp: MCU_TARGET = at90usb1287 -ifndef BIGBOOT ## standard version is 1024 Bytes long; starts earlier at90usb1287_isp: HFUSE ?= DE# = 1024 byte boot, SPI (ISP!!!) enabled, JTAG disabled -else ## bigboot version is 2048 Bytes long; starts earlier -at90usb1287_isp: HFUSE ?= DC# = 2048 byte boot, SPI (ISP!!!) enabled, JTAG disabled -endif at90usb1287_isp: LFUSE ?= FF# = Full Swing xtal (16MHz) 16KCK/14CK+65ms at90usb1287_isp: EFUSE ?= FB# = 2.6V brownout at90usb1287_isp: LOCK ?= 2F# = APP protect mode 1, BL protect mode 2 diff --git a/optiboot/bootloaders/optiboot/link_optiboot.ld b/optiboot/bootloaders/optiboot/link_optiboot.ld new file mode 100644 index 0000000..62ce421 --- /dev/null +++ b/optiboot/bootloaders/optiboot/link_optiboot.ld @@ -0,0 +1,145 @@ +/* Customized Linker script for Optiboot */ + +/* Copyright (C) 2014-2015 Free Software Foundation, Inc. + Copyright (C) 2021 by William Westfield + Copying and distribution of this script, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. +*/ + +/* + * this is based off of the default ATmega328 linker script, but it + * has been generalized (since optiboot makes little use of the standard + * chip-specific values), and also specialized to based start addresses + * of the code on symbols passed from the C program, instead of needing + * --section-start commands in the linker command line. + * (The C program does this by using asm() statements to define absolute + * symbols that the linker can see. + * The .data and .bss segments are removed, since the bootloader must not + * use them (and does its own memory management) (this has the added + * "benefit" of spitting out error messages if the code DOES try to + * use data or bss variables. + */ + +OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr") +__FUSE_REGION_LENGTH__ = DEFINED(__FUSE_REGION_LENGTH__) ? __FUSE_REGION_LENGTH__ : 1K; +/* This makes the disassembly listings prettier */ +__RAM__ = 0x800000; + +MEMORY +{ + text (rx) : ORIGIN = __BOOT_START__, LENGTH = __BOOT_SIZE__ + version (rx) : ORIGIN = __VERSION_START__, LENGTH = 2 + fuse (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__ +} + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + /* Internal text space or external memory. */ + .text : + { + *(.vectors) + KEEP(*(.vectors)) + /* For data that needs to reside in the lower 64k of progmem. */ + *(.progmem.gcc*) + /* PR 13812: Placing the trampolines here gives a better chance + that they will be in range of the code that uses them. */ + . = ALIGN(2); + *(.init0) /* Start here after reset. */ + KEEP (*(.init0)) + *(.init1) + KEEP (*(.init1)) + *(.init2) /* Clear __zero_reg__, set up stack pointer. */ + KEEP (*(.init2)) + *(.init3) + KEEP (*(.init3)) + *(.init4) /* Initialize data and BSS. */ + KEEP (*(.init4)) + *(.init5) + KEEP (*(.init5)) + *(.init6) /* C++ constructors. */ + KEEP (*(.init6)) + *(.init7) + KEEP (*(.init7)) + *(.init8) + KEEP (*(.init8)) + *(.init9) /* Call main(). */ + KEEP (*(.init9)) + *(.text) + . = ALIGN(2); + *(.text.*) + . = ALIGN(2); + *(.fini9) /* _exit() starts here. */ + KEEP (*(.fini9)) + *(.fini8) + KEEP (*(.fini8)) + *(.fini7) + KEEP (*(.fini7)) + *(.fini6) /* C++ destructors. */ + KEEP (*(.fini6)) + *(.fini5) + KEEP (*(.fini5)) + *(.fini4) + KEEP (*(.fini4)) + *(.fini3) + KEEP (*(.fini3)) + *(.fini2) + KEEP (*(.fini2)) + *(.fini1) + KEEP (*(.fini1)) + *(.fini0) /* Infinite loop after program termination. */ + KEEP (*(.fini0)) + _etext = . ; + } > text + .version __VERSION_START__ : + { + *(.version) + } > text + .fuse : + { + KEEP(*(.fuse)) + KEEP(*(.lfuse)) + KEEP(*(.hfuse)) + KEEP(*(.efuse)) + } > fuse + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .note.gnu.build-id : { *(.note.gnu.build-id) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + /* DWARF Extension. */ + .debug_macro 0 : { *(.debug_macro) } +} diff --git a/optiboot/bootloaders/optiboot/makeall.everycpu.sh b/optiboot/bootloaders/optiboot/makeall.everycpu.sh new file mode 100644 index 0000000..82b9e3f --- /dev/null +++ b/optiboot/bootloaders/optiboot/makeall.everycpu.sh @@ -0,0 +1,115 @@ +# +# Makefile to make one image for each chip that optiboot supports. +# includes Arduino, Spence Konde ATtinyCore, Hans MCUDude cores, and +# some others. +# this is mainly used to sanity check modifications, especially those +# that are expected to cause "no binary changes" (you can diff the +# resulting .hex file with a reference implementation.) +# + +make clean + +#Attinycore +make attiny841at16 +make attiny841at16ser1 +make attiny441at16 +make attiny441at16ser1 +make attiny87at16 +make attiny167at16 +make attiny1634at16 +make attiny1634at16ser1 +make attiny828at16 +make attiny88at16 +make attiny48at16 +make attiny85at16 +make attiny45at16 +make attiny84at16 +make attiny44at16 +make attiny861at16 +make attiny461at16 + +# mega +make mega2560 +make mega1280 + +# usb +make atmega8u2 LED=D5 LED_START_FLASHES=2 UART=1 +make atmega16u2 LED=D5 LED_START_FLASHES=2 UART=1 +make atmega32u2 LED=D5 LED_START_FLASHES=2 UART=1 +make atmega16u4 LED=C7 LED_START_FLASHES=0 UART=1 +make atmega32u4 LED=C7 LED_START_FLASHES=0 UART=1 +make atmega32u6 LED=C6 LED_START_FLASHES=2 UART=1 +make at90usb646 LED=C6 LED_START_FLASHES=2 UART=1 NODATE=1 BIGBOOT=1 +make at90usb647 LED=C6 LED_START_FLASHES=2 UART=1 NODATE=1 BIGBOOT=1 +make at90usb1286 LED=C6 LED_START_FLASHES=2 UART=1 NODATE=1 BIGBOOT=1 +make at90usb1287 LED=C6 LED_START_FLASHES=2 UART=1 NODATE=1 BIGBOOT=1 + +# buildable platforms of somewhat questionable support level +make lilypad +make pro8 +make pro16 +make pro20 +make atmega328_pro8 +make sanguino +make mega1280 +make luminet +make diecimila +make bobuino +make wildfirev2 +make atmega1284 +make atmega32 +make atmega168p + +# Atmel development board targets +make xplained168pb +make xplained328p +make xplained328pb + +# mcudude cores +make atmega8 LED=B5 LED_START_FLASHES=2 UART=0 +make atmega16 LED=B0 LED_START_FLASHES=2 UART=0 +make atmega32 LED=B0 LED_START_FLASHES=2 UART=0 +make atmega64 LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 +make atmega88 LED=B5 LED_START_FLASHES=2 UART=0 +make atmega88p LED=B5 LED_START_FLASHES=2 UART=0 +make atmega88pb LED=B5 LED_START_FLASHES=2 UART=0 +make atmega128 LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 +make atmega162 LED=B0 LED_START_FLASHES=0 UART=0 +make atmega164a LED=B0 LED_START_FLASHES=2 UART=0 +make atmega164p LED=B0 LED_START_FLASHES=2 UART=0 +make atmega168 LED=B5 LED_START_FLASHES=2 UART=0 +make atmega168p LED=B5 LED_START_FLASHES=2 UART=0 +make atmega168pb LED=B5 LED_START_FLASHES=2 UART=0 +make atmega169 LED=B5 LED_START_FLASHES=2 UART=0 +make atmega169p LED=B5 LED_START_FLASHES=2 UART=0 +make atmega324a LED=B0 LED_START_FLASHES=2 UART=0 +make atmega324p LED=B0 LED_START_FLASHES=2 UART=0 +make atmega324pa LED=B0 LED_START_FLASHES=2 UART=0 +make atmega324pb LED=B0 LED_START_FLASHES=2 UART=0 +make atmega328 LED=B5 LED_START_FLASHES=2 UART=0 +make atmega328pb LED=B5 LED_START_FLASHES=2 UART=0 +make atmega329 LED=B5 LED_START_FLASHES=2 UART=0 +make atmega329p LED=B5 LED_START_FLASHES=2 UART=0 +make atmega640 LED=B7 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 +make atmega644p LED=B0 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 +make atmega649 LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 +make atmega649p LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 +make atmega1280 LED=B7 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 +make atmega1281 LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 +make atmega1284 LED=B0 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 +make atmega1284p LED=B0 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 +make atmega2560 LED=B7 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 +make atmega2561 LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 +make atmega3290 LED=B5 LED_START_FLASHES=2 UART=0 +make atmega3290p LED=B5 LED_START_FLASHES=2 UART=0 +make atmega6490 LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 +make atmega6490p LED=B5 LED_START_FLASHES=2 UART=0 BIGBOOT=1 NODATE=1 +make atmega8515 LED=B0 LED_START_FLASHES=2 UART=0 +make atmega8535 LED=B0 LED_START_FLASHES=2 UART=0 + +# default generic platforms +# These need to be built AFTER the platforms, or they'll get renamed +make atmega8 +make atmega168 +make atmega328 + diff --git a/optiboot/bootloaders/optiboot/optiboot.c b/optiboot/bootloaders/optiboot/optiboot.c index cb764f7..0774d00 100644 --- a/optiboot/bootloaders/optiboot/optiboot.c +++ b/optiboot/bootloaders/optiboot/optiboot.c @@ -239,6 +239,10 @@ /**********************************************************/ /* Edit History: */ /* */ +/* Oct 2021 */ +/* 8.3 WestfW add section-start determination code to */ +/* the C source. In theory, this causes no changes */ +/* to the binary, but it's "risky", so ... bump. */ /* Aug 2019 */ /* 8.1 WestfW Fix bug in calculation of Vboot offset */ /* Sep 2018 */ @@ -328,7 +332,7 @@ /**********************************************************/ #define OPTIBOOT_MAJVER 8 -#define OPTIBOOT_MINVER 2 +#define OPTIBOOT_MINVER 3 /* * OPTIBOOT_CUSTOMVER should be defined (by the makefile) for custom edits @@ -597,6 +601,92 @@ static addr16_t buff = {(uint8_t *)(RAMSTART)}; #endif // VIRTUAL_BOOT_PARTITION +void sectionOpts() __attribute__((naked)); +void sectionOpts() { +/* + * Mysterious Magic code to allow section-start addresses to be + * specifed by the C code (which, after all, has access to CPP symbols + * like FLASHEND, and can make a "safer" guess than putting manually + * determined constants in the Makefile. This is dependent on a custom + * linker script that makes use of the __BOOT_ symbols that we define. + * Fortunately, that script can be used to link optiboot on any of its + * usual chips. + * + * with some judicious use of asm directives, we can define symbols + * that the linker will look at for positioning our segments (in + * combination with a custom linker script) based on the flash size + * defined via io.h, instead of requiring magic --section-start + * constants on the build line. + * + * This apparently needs to be inside a function in order to pass + * arguments to the asm command (even though the asm doesn't + * generate any code) But we can make sure the function (which doesn't + * actually contain any code) doesn't actually end up in the binary. + */ +#if BIGBOOT + /* + * BIGBOOT images are easy, because they're much smaller than the + * flash size that they are defined to occupy (1k) + */ + asm(" .global __BOOT_SIZE__, __BOOT_START__, __VERSION_START__\n" + " .equ __BOOT_SIZE__, 1024\n" + " .equ __BOOT_START__, (%0-1023)\n" + " .equ __VERSION_START__, (%0-1)\n" + ::"i"((uint32_t)FLASHEND)); +#else + /* + * non-BIGBOOT images try to fit in 512bytes, but don't quite fit + * on chips that don't have HW support for a boot section. We try + * to guess how big the extra bits of code are, and then round up + * to the next larger flash page boundry (which can be nearly 4 pages + * away on chips with FOURPAGEERASE) + * These numbers are determined manually by building a reference + * implementation with various options and comparing sizes. + */ +# if VIRTUAL_BOOT_PARTITION +/* VIRTUAL_BOOT_PARTITION code is about 100 bytes */ +# define VBSIZE 110 +# else +# define VBSIZE 0 +# endif +# if LED_START_FLASHES==0 +/* if LED_START_FLASHES is 0 (eg on 8pin chips), it saves some code */ +# define LEDSIZE (-30) +# else +# define LEDSIZE 0 +# endif +# if SOFT_UART +/* But not having a hardware UART costs a bit */ +# define SOFTUSIZE 16 +# else +# define SOFTUSIZE 0 +# endif + +# if FOURPAGEERASE +/* FOURPAGEERASE adds some code, and also affects how we round */ +# define ERASESIZE 8 +# define PAGSIZ_B (SPM_PAGESIZE*4) +# else +# define PAGSIZ_B (SPM_PAGESIZE) +# define ERASESIZE 0 +# endif + +/* + * Round our guess up to next page size. So 560 byte images occupy 576bytes, + * 600 byte images occupy 640 bytes, etc. Depending on chip. + * Note that SPM_PAGESIZE is already in bytes in the .h files. + */ +# define ROUNDTOPAGE(size) (((size + (PAGSIZ_B/2))/(PAGSIZ_B))*(PAGSIZ_B)) +/* use 511 here so we don't round up to the next page on normal systems. */ +# define BOOTSIZE (511+ERASESIZE+VBSIZE+SOFTUSIZE+LEDSIZE) + asm(" .global __BOOT_SIZE__, __BOOT_START__, __VERSION_START__\n" + " .equ __BOOT_SIZE__, %1\n" + " .equ __BOOT_START__, ((%0+1)-%1)\n" + " .equ __VERSION_START__, (%0-1)\n" + ::"i"((uint32_t)FLASHEND), "i"(ROUNDTOPAGE(BOOTSIZE))); +#endif +/* Wasn't that FUN! */ +} /* everything that needs to run VERY early */ void pre_main(void) { @@ -1566,7 +1656,10 @@ OPT2FLASH(SOFT_UART); OPT2FLASH(UART); #endif +#if (!defined(NODATE)) || (NODATE == 0) +// Leave out the date, useful if we want to compare binaries OPTFLASHSECT const char f_date[] = "Built:" __DATE__ ":" __TIME__; +#endif #if BIGBOOT OPT2FLASH(BIGBOOT); #endif diff --git a/optiboot/bootloaders/optiboot/optiboot_atmega1280.hex b/optiboot/bootloaders/optiboot/optiboot_atmega1280.hex index 9741b34..e7e6f2d 100644 --- a/optiboot/bootloaders/optiboot/optiboot_atmega1280.hex +++ b/optiboot/bootloaders/optiboot/optiboot_atmega1280.hex @@ -1,55 +1,54 @@ :020000021000EC -:10FC000001C022C1112484B7882369F0982F9A700B +:10FC000001C01DC1112484B7882369F0982F9A7010 :10FC1000923049F081FF02C097EF94BF282E80E018 -:10FC2000FED00C94000085E08093810082E08093F8 +:10FC2000F9D00C94000085E08093810082E08093FD :10FC3000C00088E18093C10086E08093C20080E12B -:10FC40008093C4008EE0EBD0279A86E020E33CEF5F +:10FC40008093C4008EE0E6D0279A86E020E33CEF64 :10FC500091E0309385002093840096BBB09BFECF4B :10FC60001F9AA8954091C00047FD02C0815089F7B6 -:10FC7000FF24F39455E0E52E61E1D62EC4D0813403 -:10FC8000C9F4C1D0C82FD1D0C23811F481E010C05E -:10FC9000C13869F488E00CC0843709F482C0853724 -:10FCA00009F0A2C0C2D08EE1A7D087E9A5D083E039 -:10FCB000A3D09FC0823411F484E103C0853419F4C9 -:10FCC00085E0BBD096C0853579F49DD0082F9BD0B8 -:10FCD000182F87FF03C08BB7816002C08BB78E7F60 -:10FCE0008BBF000F111F84C0863581F48CD08D34FA -:10FCF00049F489D0CBB787D0C170880FC82BCBBF50 -:10FD000081E001C083E099D080E0D2CF843609F051 -:10FD1000C3CF79D0C82FD0E0DC2FCC2774D0C82B2C -:10FD200072D0C82E5E01812C32E0932E6CD0F4018B -:10FD300081934F01F1E0AF1AB108C1F776D085E4A5 -:10FD4000C81212C0DE5F4801A12C92E0B92EAC1699 -:10FD5000BD0609F44EC0F50161915F01C4018CD06C -:10FD6000FFEF8F1A9F0AF3CF83E0F80187BFE89572 -:10FD700007B600FCFDCFA0E0B2E0F8018D919D91A7 -:10FD80000C01F7BEE8951124229732962097B1F71F -:10FD9000F801E7BEE89507B600FCFDCFD7BEE895B1 -:10FDA00028C031D0C82FD0E0DC2FCC272CD05E016A -:10FDB000A82A29D0982E39D0E801F5E49F120BC06B -:10FDC000CE0152D019D081E0A81AB1082196A11411 -:10FDD000B104B1F70EC0FE018791EF010DD0E1E053 -:10FDE000AE1AB108C1F705C0813511F488E017D00B -:10FDF0001CD080E101D042CF9091C00095FFFCCF94 -:10FE00008093C60008958091C00087FFFCCF809149 -:10FE1000C00084FD01C0A8958091C6000895E0E669 -:10FE2000F0E098E1908380830895EDDF803219F04F -:10FE300088E0F5DFFFCF84E1DFCFCF93C82FE3DF8A -:10FE4000C150E9F7CF91F1CFFC010A0167BFE895F6 -:10FE5000112407B600FCFDCF667029F0452B19F47C -:10FE600081E187BFE8950895F999FECF92BD81BDE4 -:10FE7000F89A992780B50895262FF999FECF1FBAD1 -:10FE800092BD81BD20BD0FB6F894FA9AF99A0FBEC3 -:10FE90000196089556657273696F6E3D382E310074 -:10FEA0004F505449424F4F545F435553544F4D5652 -:10FEB00045523D30004465766963653D61746D650A -:10FEC00067613132383000465F4350553D3136303E -:10FED00030303030304C00424947424F4F543D3172 -:10FEE000004275696C743A4D6179203239203230A4 -:10FEF00032303A30313A30323A343000554152548F -:10FF00003D3000424155445F524154453D31313509 -:10FF1000323030004C45443D4237004C45445F533D -:0FFF2000544152545F464C41534845533D3300C2 -:02FFFE000108F8 +:10FC7000FF24F39455E0E52E61E1D62EBFD0813408 +:10FC800049F4BCD0C82FCCD0C13809F0A6C088E058 +:10FC9000AED0AAC0823411F484E103C0853419F4D3 +:10FCA00085E0C6D0A1C0853579F4A8D0082FA6D0AC +:10FCB000182F87FF03C08BB7816002C08BB78E7F80 +:10FCC0008BBF000F111F8FC0863581F497D08D3404 +:10FCD00049F494D0CBB792D0C170880FC82BCBBF5A +:10FCE00081E001C083E0A4D080E0D2CF843609F067 +:10FCF00048C084D0C82FD0E0DC2FCC277FD0C82BC1 +:10FD00007DD0C82E5E01812C32E0932E77D0F40195 +:10FD100081934F01F1E0AF1AB108C1F781D085E4BA +:10FD2000C81212C0DE5F4801A12C92E0B92EAC16B9 +:10FD3000BD0609F459C0F50161915F01C40197D076 +:10FD4000FFEF8F1A9F0AF3CF83E0F80187BFE89592 +:10FD500007B600FCFDCFA0E0B2E0F8018D919D91C7 +:10FD60000C01F7BEE8951124229732962097B1F73F +:10FD7000F801E7BEE89507B600FCFDCFD7BEE895D1 +:10FD800033C0843719F53AD0C82FD0E0DC2FCC2708 +:10FD900035D05E01A82A32D0982E42D0E801F5E491 +:10FDA0009F120BC0CE015BD022D081E0A81AB1080F +:10FDB0002196A114B104B1F717C0FE018791EF019C +:10FDC00016D0E1E0AE1AB108C1F70EC0853739F49C +:10FDD00027D08EE10CD087E90AD083E059CF813556 +:10FDE00011F488E017D01CD080E101D047CF90916A +:10FDF000C00095FFFCCF8093C60008958091C0009D +:10FE000087FFFCCF8091C00084FD01C0A895809140 +:10FE1000C6000895E0E6F0E098E1908380830895BD +:10FE2000EDDF803219F088E0F5DFFFCF84E1DFCF2E +:10FE3000CF93C82FE3DFC150E9F7CF91F1CFFC0199 +:10FE40000A0167BFE895112407B600FCFDCF667074 +:10FE500029F0452B19F481E187BFE8950895F999B8 +:10FE6000FECF92BD81BDF89A992780B50895262FBF +:10FE7000F999FECF1FBA92BD81BD20BD0FB6F8948F +:10FE8000FA9AF99A0FBE01960895FF566572736942 +:10FE90006F6E3D382E33004465766963653D61744D +:10FEA0006D6567613132383000465F4350553D31F2 +:10FEB000363030303030304C00424947424F4F549A +:10FEC0003D31004275696C743A4E6F7620203420C3 +:10FED000323032313A31383A30333A3033005541EA +:10FEE00052543D3000424155445F524154453D31EA +:10FEF0003135323030004C45443D4237004C4544AA +:10FF00005F53544152545F464C41534845533D332F +:01FF100000F0 +:02FFFE000308F6 :040000031000FC00ED :00000001FF diff --git a/optiboot/bootloaders/optiboot/optiboot_atmega1280.lst b/optiboot/bootloaders/optiboot/optiboot_atmega1280.lst index c4932c1..6ce8058 100644 --- a/optiboot/bootloaders/optiboot/optiboot_atmega1280.lst +++ b/optiboot/bootloaders/optiboot/optiboot_atmega1280.lst @@ -3,29 +3,29 @@ optiboot_atmega1280.elf: file format elf32-avr Sections: Idx Name Size VMA LMA File off Algn - 0 .data 00000000 00800200 0001ff2f 000003c3 2**0 - CONTENTS, ALLOC, LOAD, DATA - 1 .text 0000032f 0001fc00 0001fc00 00000094 2**1 + 0 .text 00000311 0001fc00 0001fc00 00000094 2**0 CONTENTS, ALLOC, LOAD, READONLY, CODE - 2 .version 00000002 0001fffe 0001fffe 000003c3 2**0 + 1 .trampolines 00000000 0001ff12 0001ff12 000003a6 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 2 .version 00000002 0001fffe 0001fffe 000003a6 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA - 3 .comment 0000002f 00000000 00000000 000003c5 2**0 + 3 .comment 0000002f 00000000 00000000 000003a8 2**0 CONTENTS, READONLY - 4 .debug_aranges 00000030 00000000 00000000 000003f4 2**0 + 4 .debug_aranges 00000030 00000000 00000000 000003d7 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_info 000007ec 00000000 00000000 00000424 2**0 + 5 .debug_info 00000816 00000000 00000000 00000407 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_abbrev 000002c5 00000000 00000000 00000c10 2**0 + 6 .debug_abbrev 000002ea 00000000 00000000 00000c1d 2**0 CONTENTS, READONLY, DEBUGGING - 7 .debug_line 000003c7 00000000 00000000 00000ed5 2**0 + 7 .debug_line 000003cd 00000000 00000000 00000f07 2**0 CONTENTS, READONLY, DEBUGGING - 8 .debug_frame 0000009c 00000000 00000000 0000129c 2**2 + 8 .debug_frame 000000ac 00000000 00000000 000012d4 2**2 CONTENTS, READONLY, DEBUGGING - 9 .debug_str 0000028c 00000000 00000000 00001338 2**0 + 9 .debug_str 000002a2 00000000 00000000 00001380 2**0 CONTENTS, READONLY, DEBUGGING - 10 .debug_loc 00000449 00000000 00000000 000015c4 2**0 + 10 .debug_loc 00000449 00000000 00000000 00001622 2**0 CONTENTS, READONLY, DEBUGGING - 11 .debug_ranges 00000088 00000000 00000000 00001a0d 2**0 + 11 .debug_ranges 00000068 00000000 00000000 00001a6b 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: @@ -33,12 +33,12 @@ Disassembly of section .text: 0001fc00 : /* everything that needs to run VERY early */ void pre_main(void) { - // Allow convenient way of calling do_spm function - jump table, - // so entry to this function will always be here, indepedent of compilation, - // features etc + // Allow convenient way of calling do_spm function - jump table, so + // entry to this function will always be here, independent of + // compilation, features etc asm volatile ( 1fc00: 01 c0 rjmp .+2 ; 0x1fc04
- 1fc02: 22 c1 rjmp .+580 ; 0x1fe48 + 1fc02: 1d c1 rjmp .+570 ; 0x1fe3e 0001fc04
: // SP points to RAMEND @@ -46,121 +46,125 @@ void pre_main(void) { // // If not, uncomment the following instructions: // cli(); - asm volatile ("clr __zero_reg__"); + asm volatile (" clr __zero_reg__"); 1fc04: 11 24 eor r1, r1 -#if defined(__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) || \ - defined(__AVR_ATmega16__) || defined(__AVR_ATmega162__) || \ - defined (__AVR_ATmega128__) - ch = MCUCSR; -#else +# warning "START_APP_ON_EXTR is defined and NO_START_APP_ON_POR isn't" +# define APP_START_REASONS 1 /* Always start rge App. */ +# define WDRF_CLR_REASONS 0 /* Never clear WDRF */ +#endif + ch = MCUSR; 1fc06: 84 b7 in r24, 0x34 ; 52 -#endif + // Skip all logic and run bootloader if MCUSR is cleared (application request) if (ch != 0) { 1fc08: 88 23 and r24, r24 1fc0a: 69 f0 breq .+26 ; 0x1fc26 - * 2. we clear WDRF if it's set with EXTRF to avoid loops - * One problematic scenario: broken application code sets watchdog timer - * without clearing MCUSR before and triggers it quickly. But it's - * recoverable by power-on with pushed reset button. - */ - if ((ch & (_BV(WDRF) | _BV(EXTRF))) != _BV(EXTRF)) { + * One problematic scenario: broken application code sets watchdog timer + * without clearing MCUSR before and triggers it quickly. But it's + * recoverable by power-on with pushed reset button. + */ + + if (APP_START_REASONS) { 1fc0c: 98 2f mov r25, r24 1fc0e: 9a 70 andi r25, 0x0A ; 10 1fc10: 92 30 cpi r25, 0x02 ; 2 1fc12: 49 f0 breq .+18 ; 0x1fc26 - if (ch & _BV(EXTRF)) { + if (WDRF_CLR_REASONS) { 1fc14: 81 ff sbrs r24, 1 1fc16: 02 c0 rjmp .+4 ; 0x1fc1c - defined(__AVR_ATmega16__) || defined(__AVR_ATmega162__) || \ - defined(__AVR_ATmega128__) - // Fix missing definitions in avr-libc - MCUCSR = ~(_BV(WDRF)); -#else - MCUSR = ~(_BV(WDRF)); + /* + * Clear WDRF if it was most probably set by wdr in bootloader. + */ + if ((uint16_t)&MCUSR > 0x1F) { + MCUSR = ~(_BV(WDRF)); // optimize to LDI/OUT 1fc18: 97 ef ldi r25, 0xF7 ; 247 1fc1a: 94 bf out 0x34, r25 ; 52 - /* - * save the reset flags in the designated register - * This can be saved in a main program by putting code in .init0 (which - * executes before normal c init code) to save R2 to a global variable. - */ - __asm__ __volatile__ ("mov r2, %0\n" :: "r" (ch)); + /* + * save the reset flags in the designated register + * This can be saved in a main program by putting code in .init0 (which + * executes before normal c init code) to save R2 to a global variable. + */ + __asm__ __volatile__ (" mov r2, %0\n" :: "r" (ch)); 1fc1c: 28 2e mov r2, r24 - // switch off watchdog - watchdogConfig(WATCHDOG_OFF); + // switch off watchdog + watchdogConfig(WATCHDOG_OFF); 1fc1e: 80 e0 ldi r24, 0x00 ; 0 - 1fc20: fe d0 rcall .+508 ; 0x1fe1e - // Note that appstart_vec is defined so that this works with either - // real or virtual boot partitions. - __asm__ __volatile__ ( + 1fc20: f9 d0 rcall .+498 ; 0x1fe14 + // Note that appstart_vec is defined so that this works with either + // real or virtual boot partitions. + __asm__ __volatile__ ( 1fc22: 0c 94 00 00 jmp 0 ; 0x0 <__tmp_reg__> #elif defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)||defined(__AVR_ATtiny85__) - TCCR1 = 0x0E; //div 8196 - it's an 8-bit timer. + TCCR1 = 0x0E; //div 8196 - it's an 8-bit timer. #elif defined(__AVR_ATtiny43__) - #error "LED flash for Tiny43 not yet supported" +#error "LED flash for Tiny43 not yet supported" #else TCCR1B = _BV(CS12) | _BV(CS10); // div 1024 1fc26: 85 e0 ldi r24, 0x05 ; 5 - 1fc28: 80 93 81 00 sts 0x0081, r24 ; 0x800081 <__TEXT_REGION_LENGTH__+0x7e0081> + 1fc28: 80 93 81 00 sts 0x0081, r24 ; 0x800081 <__RAM__+0x81> LINBTR = (1 << LDISR) | (8 << LBT0); - LINCR = _BV(LENA) | _BV(LCMD2) | _BV(LCMD1) | _BV(LCMD0); + LINCR = _BV(LENA) | _BV(LCMD2) | _BV(LCMD1) | _BV(LCMD0); LINDAT=0; - #else - #ifndef SINGLESPEED +#else +#if (SINGLESPEED == 0) UART_SRA = _BV(U2X0); //Double speed mode USART0 1fc2c: 82 e0 ldi r24, 0x02 ; 2 - 1fc2e: 80 93 c0 00 sts 0x00C0, r24 ; 0x8000c0 <__TEXT_REGION_LENGTH__+0x7e00c0> - #endif + 1fc2e: 80 93 c0 00 sts 0x00C0, r24 ; 0x8000c0 <__RAM__+0xc0> +#endif UART_SRB = _BV(RXEN0) | _BV(TXEN0); 1fc32: 88 e1 ldi r24, 0x18 ; 24 - 1fc34: 80 93 c1 00 sts 0x00C1, r24 ; 0x8000c1 <__TEXT_REGION_LENGTH__+0x7e00c1> + 1fc34: 80 93 c1 00 sts 0x00C1, r24 ; 0x8000c1 <__RAM__+0xc1> UART_SRC = _BV(UCSZ00) | _BV(UCSZ01); 1fc38: 86 e0 ldi r24, 0x06 ; 6 - 1fc3a: 80 93 c2 00 sts 0x00C2, r24 ; 0x8000c2 <__TEXT_REGION_LENGTH__+0x7e00c2> + 1fc3a: 80 93 c2 00 sts 0x00C2, r24 ; 0x8000c2 <__RAM__+0xc2> UART_SRL = (uint8_t)BAUD_SETTING; 1fc3e: 80 e1 ldi r24, 0x10 ; 16 - 1fc40: 80 93 c4 00 sts 0x00C4, r24 ; 0x8000c4 <__TEXT_REGION_LENGTH__+0x7e00c4> - #endif // LIN_UART - #endif // mega8/etc -#endif // soft_uart + 1fc40: 80 93 c4 00 sts 0x00C4, r24 ; 0x8000c4 <__RAM__+0xc4> + RS485_PORT &= ~_BV(RS485_BIT); + #endif +#endif // Set up watchdog to trigger after desired timeout watchdogConfig(WDTPERIOD); 1fc44: 8e e0 ldi r24, 0x0E ; 14 - 1fc46: eb d0 rcall .+470 ; 0x1fe1e + 1fc46: e6 d0 rcall .+460 ; 0x1fe14 -#if (LED_START_FLASHES > 0) || defined(LED_DATA_FLASH) || defined(LED_START_ON) +#if (LED_START_FLASHES > 0) || LED_DATA_FLASH || LED_START_ON /* Set LED pin as output */ LED_DDR |= _BV(LED); 1fc48: 27 9a sbi 0x04, 7 ; 4 1fc4a: 86 e0 ldi r24, 0x06 ; 6 - TIFR = _BV(TOV1); - while(!(TIFR & _BV(TOV1))); - #elif defined(__AVR_ATtiny43__) - #error "LED flash for Tiny43 not yet supported" - #else - TCNT1 = -(F_CPU/(1024*16)); + TIFR = _BV(TOV1); + while (!(TIFR & _BV(TOV1))); +#elif defined(__AVR_ATtiny43__) +#error "LED flash for Tiny43 not yet supported" +#else + TCNT1 = -(F_CPU/(1024*16)); 1fc4c: 20 e3 ldi r18, 0x30 ; 48 1fc4e: 3c ef ldi r19, 0xFC ; 252 - TIFR1 = _BV(TOV1); + TIFR1 = _BV(TOV1); 1fc50: 91 e0 ldi r25, 0x01 ; 1 - TCNT1 = -(F_CPU/(1024*16)); - 1fc52: 30 93 85 00 sts 0x0085, r19 ; 0x800085 <__TEXT_REGION_LENGTH__+0x7e0085> - 1fc56: 20 93 84 00 sts 0x0084, r18 ; 0x800084 <__TEXT_REGION_LENGTH__+0x7e0084> - TIFR1 = _BV(TOV1); + TIFR = _BV(TOV1); + while (!(TIFR & _BV(TOV1))); +#elif defined(__AVR_ATtiny43__) +#error "LED flash for Tiny43 not yet supported" +#else + TCNT1 = -(F_CPU/(1024*16)); + 1fc52: 30 93 85 00 sts 0x0085, r19 ; 0x800085 <__RAM__+0x85> + 1fc56: 20 93 84 00 sts 0x0084, r18 ; 0x800084 <__RAM__+0x84> + TIFR1 = _BV(TOV1); 1fc5a: 96 bb out 0x16, r25 ; 22 - while(!(TIFR1 & _BV(TOV1))); + while (!(TIFR1 & _BV(TOV1))); 1fc5c: b0 9b sbis 0x16, 0 ; 22 1fc5e: fe cf rjmp .-4 ; 0x1fc5c - defined(__AVR_ATmega8535__) || defined(__AVR_ATmega16__) || \ - defined(__AVR_ATmega162__) || defined(__AVR_ATmega32__) || \ - defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - LED_PORT ^= _BV(LED); + defined(__AVR_ATmega8535__) || defined(__AVR_ATmega16__) || \ + defined(__AVR_ATmega162__) || defined(__AVR_ATmega32__) || \ + defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) + LED_PORT ^= _BV(LED); #else - LED_PIN |= _BV(LED); + LED_PIN |= _BV(LED); // Newer AVRs can toggle by writing PINx 1fc60: 1f 9a sbi 0x03, 7 ; 3 } #endif @@ -169,460 +173,624 @@ void pre_main(void) { void watchdogReset() { __asm__ __volatile__ ( 1fc62: a8 95 wdr + * by the UART hardware, avrdude sends several attempts in rather + * quick succession, some of which will be lost and cause us to + * get out of sync. So if we see any data; stop blinking. + */ +#ifndef LIN_UART if (UART_SRA & _BV(RXC0)) - 1fc64: 40 91 c0 00 lds r20, 0x00C0 ; 0x8000c0 <__TEXT_REGION_LENGTH__+0x7e00c0> + 1fc64: 40 91 c0 00 lds r20, 0x00C0 ; 0x8000c0 <__RAM__+0xc0> 1fc68: 47 fd sbrc r20, 7 1fc6a: 02 c0 rjmp .+4 ; 0x1fc70 1fc6c: 81 50 subi r24, 0x01 ; 1 +#else +// This doesn't seem to work? +// if ((UART_PIN & (1< - putch(optiboot_version & 0xFF); + + /* + * Copy data from the buffer into the flash write buffer. + */ + do { + __boot_page_fill_short((uint16_t)(void*)addrPtr, *(mybuff.wptr++)); 1fc70: ff 24 eor r15, r15 1fc72: f3 94 inc r15 - } while (len -= 2); + } while (len -= 2); - /* - * Actually Write the buffer to flash (and wait for it to finish.) - */ - __boot_page_write_short(address.word); + /* + * Actually Write the buffer to flash (and wait for it to finish.) + */ + __boot_page_write_short(address.word); 1fc74: 55 e0 ldi r21, 0x05 ; 5 1fc76: e5 2e mov r14, r21 - boot_spm_busy_wait(); + boot_spm_busy_wait(); #if defined(RWWSRE) - // Reenable read access to flash - __boot_rww_enable_short(); + // Reenable read access to flash + __boot_rww_enable_short(); 1fc78: 61 e1 ldi r22, 0x11 ; 17 +#endif + + /* Forever loop: exits by causing WDT reset */ + for (;;) { + /* get character from UART */ ch = getch(); 1fc7a: d6 2e mov r13, r22 - if(ch == STK_GET_PARAMETER) { - 1fc7c: c4 d0 rcall .+392 ; 0x1fe06 + + if (ch == STK_GET_PARAMETER) { + 1fc7c: bf d0 rcall .+382 ; 0x1fdfc unsigned char which = getch(); 1fc7e: 81 34 cpi r24, 0x41 ; 65 - 1fc80: c9 f4 brne .+50 ; 0x1fcb4 - 1fc82: c1 d0 rcall .+386 ; 0x1fe06 + 1fc80: 49 f4 brne .+18 ; 0x1fc94 + 1fc82: bc d0 rcall .+376 ; 0x1fdfc verifySpace(); 1fc84: c8 2f mov r28, r24 - 1fc86: d1 d0 rcall .+418 ; 0x1fe2a + * Send optiboot version as "SW version" + * Note that the references to memory are optimized away. + */ if (which == STK_SW_MINOR) { - 1fc88: c2 38 cpi r28, 0x82 ; 130 - 1fc8a: 11 f4 brne .+4 ; 0x1fc90 - putch(optiboot_version & 0xFF); - 1fc8c: 81 e0 ldi r24, 0x01 ; 1 - 1fc8e: 10 c0 rjmp .+32 ; 0x1fcb0 + putch(optiboot_version & 0xFF); } else if (which == STK_SW_MAJOR) { - 1fc90: c1 38 cpi r28, 0x81 ; 129 - 1fc92: 69 f4 brne .+26 ; 0x1fcae - putch(optiboot_version >> 8); - 1fc94: 88 e0 ldi r24, 0x08 ; 8 - 1fc96: 0c c0 rjmp .+24 ; 0x1fcb0 - else if(ch == STK_READ_PAGE) { - 1fc98: 84 37 cpi r24, 0x74 ; 116 - 1fc9a: 09 f4 brne .+2 ; 0x1fc9e - else if(ch == STK_READ_SIGN) { - 1fc9c: 82 c0 rjmp .+260 ; 0x1fda2 - 1fc9e: 85 37 cpi r24, 0x75 ; 117 - verifySpace(); - 1fca0: 09 f0 breq .+2 ; 0x1fca4 - putch(SIGNATURE_0); - 1fca2: a2 c0 rjmp .+324 ; 0x1fde8 - 1fca4: c2 d0 rcall .+388 ; 0x1fe2a - 1fca6: 8e e1 ldi r24, 0x1E ; 30 - putch(SIGNATURE_1); - 1fca8: a7 d0 rcall .+334 ; 0x1fdf8 - 1fcaa: 87 e9 ldi r24, 0x97 ; 151 - 1fcac: a5 d0 rcall .+330 ; 0x1fdf8 - putch(0x03); - 1fcae: 83 e0 ldi r24, 0x03 ; 3 - 1fcb0: a3 d0 rcall .+326 ; 0x1fdf8 - 1fcb2: 9f c0 rjmp .+318 ; 0x1fdf2 - else if(ch == STK_SET_DEVICE) { - 1fcb4: 82 34 cpi r24, 0x42 ; 66 - 1fcb6: 11 f4 brne .+4 ; 0x1fcbc + 1fc86: cc d0 rcall .+408 ; 0x1fe20 + 1fc88: c1 38 cpi r28, 0x81 ; 129 + 1fc8a: 09 f0 breq .+2 ; 0x1fc8e + putch(optiboot_version >> 8); + 1fc8c: a6 c0 rjmp .+332 ; 0x1fdda + 1fc8e: 88 e0 ldi r24, 0x08 ; 8 + 1fc90: ae d0 rcall .+348 ; 0x1fdee + 1fc92: aa c0 rjmp .+340 ; 0x1fde8 + * other parameters - enough to keep Avrdude happy + */ + putch(0x03); + } + } + else if (ch == STK_SET_DEVICE) { + 1fc94: 82 34 cpi r24, 0x42 ; 66 + // SET DEVICE is ignored getNch(20); - 1fcb8: 84 e1 ldi r24, 0x14 ; 20 - else if(ch == STK_SET_DEVICE_EXT) { - 1fcba: 03 c0 rjmp .+6 ; 0x1fcc2 + 1fc96: 11 f4 brne .+4 ; 0x1fc9c + 1fc98: 84 e1 ldi r24, 0x14 ; 20 + } + else if (ch == STK_SET_DEVICE_EXT) { + 1fc9a: 03 c0 rjmp .+6 ; 0x1fca2 + // SET DEVICE EXT is ignored getNch(5); - 1fcbc: 85 34 cpi r24, 0x45 ; 69 - 1fcbe: 19 f4 brne .+6 ; 0x1fcc6 - 1fcc0: 85 e0 ldi r24, 0x05 ; 5 - 1fcc2: bb d0 rcall .+374 ; 0x1fe3a - else if(ch == STK_LOAD_ADDRESS) { - 1fcc4: 96 c0 rjmp .+300 ; 0x1fdf2 - 1fcc6: 85 35 cpi r24, 0x55 ; 85 + 1fc9c: 85 34 cpi r24, 0x45 ; 69 + 1fc9e: 19 f4 brne .+6 ; 0x1fca6 + 1fca0: 85 e0 ldi r24, 0x05 ; 5 + } + else if (ch == STK_LOAD_ADDRESS) { + 1fca2: c6 d0 rcall .+396 ; 0x1fe30 + 1fca4: a1 c0 rjmp .+322 ; 0x1fde8 + // LOAD ADDRESS address.bytes[0] = getch(); - 1fcc8: 79 f4 brne .+30 ; 0x1fce8 - 1fcca: 9d d0 rcall .+314 ; 0x1fe06 - 1fccc: 08 2f mov r16, r24 + 1fca6: 85 35 cpi r24, 0x55 ; 85 + 1fca8: 79 f4 brne .+30 ; 0x1fcc8 + 1fcaa: a8 d0 rcall .+336 ; 0x1fdfc address.bytes[1] = getch(); - 1fcce: 9b d0 rcall .+310 ; 0x1fe06 - 1fcd0: 18 2f mov r17, r24 - 1fcd2: 87 ff sbrs r24, 7 + 1fcac: 08 2f mov r16, r24 + 1fcae: a6 d0 rcall .+332 ; 0x1fdfc + 1fcb0: 18 2f mov r17, r24 +#ifdef RAMPZ + // Transfer top bit to LSB in RAMPZ if (address.bytes[1] & 0x80) { - 1fcd4: 03 c0 rjmp .+6 ; 0x1fcdc + 1fcb2: 87 ff sbrs r24, 7 + 1fcb4: 03 c0 rjmp .+6 ; 0x1fcbc RAMPZ |= 0x01; - 1fcd6: 8b b7 in r24, 0x3b ; 59 - 1fcd8: 81 60 ori r24, 0x01 ; 1 + 1fcb6: 8b b7 in r24, 0x3b ; 59 + 1fcb8: 81 60 ori r24, 0x01 ; 1 + } + else { RAMPZ &= 0xFE; - 1fcda: 02 c0 rjmp .+4 ; 0x1fce0 - 1fcdc: 8b b7 in r24, 0x3b ; 59 + 1fcba: 02 c0 rjmp .+4 ; 0x1fcc0 + 1fcbc: 8b b7 in r24, 0x3b ; 59 + } +#endif address.word *= 2; // Convert from word address to byte address - 1fcde: 8e 7f andi r24, 0xFE ; 254 - 1fce0: 8b bf out 0x3b, r24 ; 59 - 1fce2: 00 0f add r16, r16 - else if(ch == STK_UNIVERSAL) { - 1fce4: 11 1f adc r17, r17 - 1fce6: 84 c0 rjmp .+264 ; 0x1fdf0 + 1fcbe: 8e 7f andi r24, 0xFE ; 254 + 1fcc0: 8b bf out 0x3b, r24 ; 59 + verifySpace(); + } + else if (ch == STK_UNIVERSAL) { + 1fcc2: 00 0f add r16, r16 + 1fcc4: 11 1f adc r17, r17 +#ifdef RAMPZ + // LOAD_EXTENDED_ADDRESS is needed in STK_UNIVERSAL for addressing more than 128kB if ( AVR_OP_LOAD_EXT_ADDR == getch() ) { - 1fce8: 86 35 cpi r24, 0x56 ; 86 - 1fcea: 81 f4 brne .+32 ; 0x1fd0c - 1fcec: 8c d0 rcall .+280 ; 0x1fe06 + 1fcc6: 8f c0 rjmp .+286 ; 0x1fde6 + 1fcc8: 86 35 cpi r24, 0x56 ; 86 + 1fcca: 81 f4 brne .+32 ; 0x1fcec + 1fccc: 97 d0 rcall .+302 ; 0x1fdfc + // get address getch(); // get '0' - 1fcee: 8d 34 cpi r24, 0x4D ; 77 - 1fcf0: 49 f4 brne .+18 ; 0x1fd04 + 1fcce: 8d 34 cpi r24, 0x4D ; 77 RAMPZ = (RAMPZ & 0x01) | ((getch() << 1) & 0xff); // get address and put it in RAMPZ - 1fcf2: 89 d0 rcall .+274 ; 0x1fe06 - 1fcf4: cb b7 in r28, 0x3b ; 59 - 1fcf6: 87 d0 rcall .+270 ; 0x1fe06 - 1fcf8: c1 70 andi r28, 0x01 ; 1 - 1fcfa: 88 0f add r24, r24 - 1fcfc: c8 2b or r28, r24 + 1fcd0: 49 f4 brne .+18 ; 0x1fce4 + 1fcd2: 94 d0 rcall .+296 ; 0x1fdfc + 1fcd4: cb b7 in r28, 0x3b ; 59 + 1fcd6: 92 d0 rcall .+292 ; 0x1fdfc + 1fcd8: c1 70 andi r28, 0x01 ; 1 + 1fcda: 88 0f add r24, r24 getNch(1); // get last '0' - 1fcfe: cb bf out 0x3b, r28 ; 59 - getNch(3); - 1fd00: 81 e0 ldi r24, 0x01 ; 1 - 1fd02: 01 c0 rjmp .+2 ; 0x1fd06 - 1fd04: 83 e0 ldi r24, 0x03 ; 3 + 1fcdc: c8 2b or r28, r24 + 1fcde: cb bf out 0x3b, r28 ; 59 + // response putch(0x00); - 1fd06: 99 d0 rcall .+306 ; 0x1fe3a - 1fd08: 80 e0 ldi r24, 0x00 ; 0 - else if(ch == STK_PROG_PAGE) { - 1fd0a: d2 cf rjmp .-92 ; 0x1fcb0 - 1fd0c: 84 36 cpi r24, 0x64 ; 100 + } + else { + // everything else is ignored + getNch(3); + 1fce0: 81 e0 ldi r24, 0x01 ; 1 + 1fce2: 01 c0 rjmp .+2 ; 0x1fce6 + putch(0x00); + 1fce4: 83 e0 ldi r24, 0x03 ; 3 + 1fce6: a4 d0 rcall .+328 ; 0x1fe30 + getNch(4); + putch(0x00); +#endif + } + /* Write memory, length is big endian and is in bytes */ + else if (ch == STK_PROG_PAGE) { + 1fce8: 80 e0 ldi r24, 0x00 ; 0 + 1fcea: d2 cf rjmp .-92 ; 0x1fc90 + 1fcec: 84 36 cpi r24, 0x64 ; 100 + // PROGRAM PAGE - we support flash programming only, not EEPROM + uint8_t desttype; + uint8_t *bufPtr; + pagelen_t savelength; + GETLENGTH(length); - 1fd0e: 09 f0 breq .+2 ; 0x1fd12 - 1fd10: c3 cf rjmp .-122 ; 0x1fc98 - 1fd12: 79 d0 rcall .+242 ; 0x1fe06 - 1fd14: c8 2f mov r28, r24 - 1fd16: d0 e0 ldi r29, 0x00 ; 0 - 1fd18: dc 2f mov r29, r28 - 1fd1a: cc 27 eor r28, r28 - 1fd1c: 74 d0 rcall .+232 ; 0x1fe06 + 1fcee: 09 f0 breq .+2 ; 0x1fcf2 + 1fcf0: 48 c0 rjmp .+144 ; 0x1fd82 + 1fcf2: 84 d0 rcall .+264 ; 0x1fdfc + 1fcf4: c8 2f mov r28, r24 + 1fcf6: d0 e0 ldi r29, 0x00 ; 0 + 1fcf8: dc 2f mov r29, r28 + 1fcfa: cc 27 eor r28, r28 + 1fcfc: 7f d0 rcall .+254 ; 0x1fdfc + savelength = length; desttype = getch(); - 1fd1e: c8 2b or r28, r24 - 1fd20: 72 d0 rcall .+228 ; 0x1fe06 - 1fd22: c8 2e mov r12, r24 + 1fcfe: c8 2b or r28, r24 + 1fd00: 7d d0 rcall .+250 ; 0x1fdfc + 1fd02: c8 2e mov r12, r24 + // PROGRAM PAGE - we support flash programming only, not EEPROM + uint8_t desttype; + uint8_t *bufPtr; + pagelen_t savelength; + GETLENGTH(length); - 1fd24: 5e 01 movw r10, r28 + 1fd04: 5e 01 movw r10, r28 + savelength = length; desttype = getch(); - 1fd26: 81 2c mov r8, r1 - 1fd28: 32 e0 ldi r19, 0x02 ; 2 - 1fd2a: 93 2e mov r9, r19 + 1fd06: 81 2c mov r8, r1 + 1fd08: 32 e0 ldi r19, 0x02 ; 2 + 1fd0a: 93 2e mov r9, r19 + + // read a page worth of contents + bufPtr = buff.bptr; do *bufPtr++ = getch(); - 1fd2c: 6c d0 rcall .+216 ; 0x1fe06 - 1fd2e: f4 01 movw r30, r8 - 1fd30: 81 93 st Z+, r24 - 1fd32: 4f 01 movw r8, r30 - 1fd34: f1 e0 ldi r31, 0x01 ; 1 + 1fd0c: 77 d0 rcall .+238 ; 0x1fdfc + 1fd0e: f4 01 movw r30, r8 + 1fd10: 81 93 st Z+, r24 + 1fd12: 4f 01 movw r8, r30 + 1fd14: f1 e0 ldi r31, 0x01 ; 1 while (--length); - 1fd36: af 1a sub r10, r31 - 1fd38: b1 08 sbc r11, r1 - 1fd3a: c1 f7 brne .-16 ; 0x1fd2c + 1fd16: af 1a sub r10, r31 + 1fd18: b1 08 sbc r11, r1 + 1fd1a: c1 f7 brne .-16 ; 0x1fd0c + 1fd1c: 81 d0 rcall .+258 ; 0x1fe20 + + // Read command terminator, start reply verifySpace(); - 1fd3c: 76 d0 rcall .+236 ; 0x1fe2a - 1fd3e: 85 e4 ldi r24, 0x45 ; 69 - switch (memtype) { - 1fd40: c8 12 cpse r12, r24 - 1fd42: 12 c0 rjmp .+36 ; 0x1fd68 - 1fd44: de 5f subi r29, 0xFE ; 254 - 1fd46: 48 01 movw r8, r16 - 1fd48: a1 2c mov r10, r1 - 1fd4a: 92 e0 ldi r25, 0x02 ; 2 - 1fd4c: b9 2e mov r11, r25 - 1fd4e: ac 16 cp r10, r28 - while(len--) { - 1fd50: bd 06 cpc r11, r29 - 1fd52: 09 f4 brne .+2 ; 0x1fd56 - 1fd54: 4e c0 rjmp .+156 ; 0x1fdf2 - 1fd56: f5 01 movw r30, r10 - eeprom_write_byte((address.bptr++), *(mybuff.bptr++)); - 1fd58: 61 91 ld r22, Z+ - 1fd5a: 5f 01 movw r10, r30 - 1fd5c: c4 01 movw r24, r8 - 1fd5e: 8c d0 rcall .+280 ; 0x1fe78 - 1fd60: ff ef ldi r31, 0xFF ; 255 - 1fd62: 8f 1a sub r8, r31 - 1fd64: 9f 0a sbc r9, r31 - 1fd66: f3 cf rjmp .-26 ; 0x1fd4e - 1fd68: 83 e0 ldi r24, 0x03 ; 3 - 1fd6a: f8 01 movw r30, r16 - __boot_page_erase_short(address.word); - 1fd6c: 87 bf out 0x37, r24 ; 55 - 1fd6e: e8 95 spm - 1fd70: 07 b6 in r0, 0x37 ; 55 - 1fd72: 00 fc sbrc r0, 0 - boot_spm_busy_wait(); - 1fd74: fd cf rjmp .-6 ; 0x1fd70 - 1fd76: a0 e0 ldi r26, 0x00 ; 0 - 1fd78: b2 e0 ldi r27, 0x02 ; 2 - 1fd7a: f8 01 movw r30, r16 - 1fd7c: 8d 91 ld r24, X+ - __boot_page_fill_short((uint16_t)(void*)addrPtr, *(mybuff.wptr++)); - 1fd7e: 9d 91 ld r25, X+ - 1fd80: 0c 01 movw r0, r24 - 1fd82: f7 be out 0x37, r15 ; 55 - 1fd84: e8 95 spm - 1fd86: 11 24 eor r1, r1 - } while (len -= 2); - 1fd88: 22 97 sbiw r28, 0x02 ; 2 - 1fd8a: 32 96 adiw r30, 0x02 ; 2 - 1fd8c: 20 97 sbiw r28, 0x00 ; 0 - __boot_page_write_short(address.word); - 1fd8e: b1 f7 brne .-20 ; 0x1fd7c - 1fd90: f8 01 movw r30, r16 - 1fd92: e7 be out 0x37, r14 ; 55 - boot_spm_busy_wait(); - 1fd94: e8 95 spm - __boot_rww_enable_short(); - 1fd96: 07 b6 in r0, 0x37 ; 55 - 1fd98: 00 fc sbrc r0, 0 - 1fd9a: fd cf rjmp .-6 ; 0x1fd96 + 1fd1e: 85 e4 ldi r24, 0x45 ; 69 + * void writebuffer(memtype, buffer, address, length) + */ +static inline void writebuffer(int8_t memtype, addr16_t mybuff, + addr16_t address, pagelen_t len) +{ + switch (memtype) { + 1fd20: c8 12 cpse r12, r24 + 1fd22: 12 c0 rjmp .+36 ; 0x1fd48 + 1fd24: de 5f subi r29, 0xFE ; 254 + 1fd26: 48 01 movw r8, r16 + 1fd28: a1 2c mov r10, r1 + 1fd2a: 92 e0 ldi r25, 0x02 ; 2 + 1fd2c: b9 2e mov r11, r25 + 1fd2e: ac 16 cp r10, r28 + case 'E': // EEPROM +#if SUPPORT_EEPROM || BIGBOOT + while (len--) { + 1fd30: bd 06 cpc r11, r29 + 1fd32: 09 f4 brne .+2 ; 0x1fd36 + 1fd34: 59 c0 rjmp .+178 ; 0x1fde8 + 1fd36: f5 01 movw r30, r10 + eeprom_write_byte((address.bptr++), *(mybuff.bptr++)); + 1fd38: 61 91 ld r22, Z+ + 1fd3a: 5f 01 movw r10, r30 + 1fd3c: c4 01 movw r24, r8 + 1fd3e: 97 d0 rcall .+302 ; 0x1fe6e + 1fd40: ff ef ldi r31, 0xFF ; 255 + 1fd42: 8f 1a sub r8, r31 + 1fd44: 9f 0a sbc r9, r31 + 1fd46: f3 cf rjmp .-26 ; 0x1fd2e + 1fd48: 83 e0 ldi r24, 0x03 ; 3 + 1fd4a: f8 01 movw r30, r16 + * and we needed the space back. + */ +#ifdef FOURPAGEERASE + if ((address.bytes[0] & ((SPM_PAGESIZE<<2)-1))==0) { +#endif + __boot_page_erase_short(address.word); + 1fd4c: 87 bf out 0x37, r24 ; 55 + 1fd4e: e8 95 spm + 1fd50: 07 b6 in r0, 0x37 ; 55 + 1fd52: 00 fc sbrc r0, 0 + boot_spm_busy_wait(); + 1fd54: fd cf rjmp .-6 ; 0x1fd50 + 1fd56: a0 e0 ldi r26, 0x00 ; 0 + 1fd58: b2 e0 ldi r27, 0x02 ; 2 + 1fd5a: f8 01 movw r30, r16 + 1fd5c: 8d 91 ld r24, X+ + 1fd5e: 9d 91 ld r25, X+ + + /* + * Copy data from the buffer into the flash write buffer. + */ + do { + __boot_page_fill_short((uint16_t)(void*)addrPtr, *(mybuff.wptr++)); + 1fd60: 0c 01 movw r0, r24 + 1fd62: f7 be out 0x37, r15 ; 55 + 1fd64: e8 95 spm + 1fd66: 11 24 eor r1, r1 + 1fd68: 22 97 sbiw r28, 0x02 ; 2 + addrPtr += 2; + } while (len -= 2); + 1fd6a: 32 96 adiw r30, 0x02 ; 2 + 1fd6c: 20 97 sbiw r28, 0x00 ; 0 + 1fd6e: b1 f7 brne .-20 ; 0x1fd5c + + /* + * Actually Write the buffer to flash (and wait for it to finish.) + */ + __boot_page_write_short(address.word); + 1fd70: f8 01 movw r30, r16 + 1fd72: e7 be out 0x37, r14 ; 55 + boot_spm_busy_wait(); + 1fd74: e8 95 spm + 1fd76: 07 b6 in r0, 0x37 ; 55 + 1fd78: 00 fc sbrc r0, 0 +#if defined(RWWSRE) + // Reenable read access to flash + __boot_rww_enable_short(); + 1fd7a: fd cf rjmp .-6 ; 0x1fd76 + 1fd7c: d7 be out 0x37, r13 ; 55 + writebuffer(desttype, buff, address, savelength); + + + } +/* Read memory block mode, length is big endian. */ + else if (ch == STK_READ_PAGE) { + 1fd7e: e8 95 spm + uint8_t desttype; GETLENGTH(length); - 1fd9c: d7 be out 0x37, r13 ; 55 - 1fd9e: e8 95 spm - 1fda0: 28 c0 rjmp .+80 ; 0x1fdf2 - 1fda2: 31 d0 rcall .+98 ; 0x1fe06 - 1fda4: c8 2f mov r28, r24 - 1fda6: d0 e0 ldi r29, 0x00 ; 0 - 1fda8: dc 2f mov r29, r28 - 1fdaa: cc 27 eor r28, r28 - 1fdac: 2c d0 rcall .+88 ; 0x1fe06 + 1fd80: 33 c0 rjmp .+102 ; 0x1fde8 + 1fd82: 84 37 cpi r24, 0x74 ; 116 + 1fd84: 19 f5 brne .+70 ; 0x1fdcc + 1fd86: 3a d0 rcall .+116 ; 0x1fdfc + 1fd88: c8 2f mov r28, r24 + 1fd8a: d0 e0 ldi r29, 0x00 ; 0 + 1fd8c: dc 2f mov r29, r28 + 1fd8e: cc 27 eor r28, r28 + 1fd90: 35 d0 rcall .+106 ; 0x1fdfc + 1fd92: 5e 01 movw r10, r28 + desttype = getch(); - 1fdae: 5e 01 movw r10, r28 - 1fdb0: a8 2a or r10, r24 - 1fdb2: 29 d0 rcall .+82 ; 0x1fe06 + 1fd94: a8 2a or r10, r24 + 1fd96: 32 d0 rcall .+100 ; 0x1fdfc + verifySpace(); - 1fdb4: 98 2e mov r9, r24 - 1fdb6: 39 d0 rcall .+114 ; 0x1fe2a - 1fdb8: e8 01 movw r28, r16 + 1fd98: 98 2e mov r9, r24 + 1fd9a: 42 d0 rcall .+132 ; 0x1fe20 + 1fd9c: e8 01 movw r28, r16 static inline void read_mem(uint8_t memtype, addr16_t address, pagelen_t length) { - uint8_t ch; + uint8_t ch; - switch (memtype) { - 1fdba: f5 e4 ldi r31, 0x45 ; 69 + switch (memtype) { + 1fd9e: f5 e4 ldi r31, 0x45 ; 69 + 1fda0: 9f 12 cpse r9, r31 -#if defined(SUPPORT_EEPROM) || defined(BIGBOOT) - case 'E': // EEPROM - do { - putch(eeprom_read_byte((address.bptr++))); - 1fdbc: 9f 12 cpse r9, r31 - 1fdbe: 0b c0 rjmp .+22 ; 0x1fdd6 - 1fdc0: ce 01 movw r24, r28 - 1fdc2: 52 d0 rcall .+164 ; 0x1fe68 - } while (--length); - 1fdc4: 19 d0 rcall .+50 ; 0x1fdf8 - 1fdc6: 81 e0 ldi r24, 0x01 ; 1 - 1fdc8: a8 1a sub r10, r24 - 1fdca: b1 08 sbc r11, r1 - 1fdcc: 21 96 adiw r28, 0x01 ; 1 - 1fdce: a1 14 cp r10, r1 - 1fdd0: b1 04 cpc r11, r1 - 1fdd2: b1 f7 brne .-20 ; 0x1fdc0 - // Since RAMPZ should already be set, we need to use EPLM directly. - // Also, we can use the autoincrement version of lpm to update "address" - // do putch(pgm_read_byte_near(address++)); - // while (--length); - // read a Flash and increment the address (may increment RAMPZ) - __asm__ ("elpm %0,Z+\n" : "=r" (ch), "=z" (address.bptr): "1" (address)); - 1fdd4: 0e c0 rjmp .+28 ; 0x1fdf2 - 1fdd6: fe 01 movw r30, r28 - 1fdd8: 87 91 elpm r24, Z+ +#if SUPPORT_EEPROM || BIGBOOT + case 'E': // EEPROM + do { + putch(eeprom_read_byte((address.bptr++))); + 1fda2: 0b c0 rjmp .+22 ; 0x1fdba + 1fda4: ce 01 movw r24, r28 + 1fda6: 5b d0 rcall .+182 ; 0x1fe5e + } while (--length); + 1fda8: 22 d0 rcall .+68 ; 0x1fdee + 1fdaa: 81 e0 ldi r24, 0x01 ; 1 + 1fdac: a8 1a sub r10, r24 + 1fdae: b1 08 sbc r11, r1 + 1fdb0: 21 96 adiw r28, 0x01 ; 1 + 1fdb2: a1 14 cp r10, r1 + // Since RAMPZ should already be set, we need to use EPLM directly. + // Also, we can use the autoincrement version of lpm to update "address" + // do putch(pgm_read_byte_near(address++)); + // while (--length); + // read a Flash and increment the address (may increment RAMPZ) + __asm__ (" elpm %0,Z+\n" : "=r" (ch), "=z" (address.bptr): "1" (address)); + 1fdb4: b1 04 cpc r11, r1 + 1fdb6: b1 f7 brne .-20 ; 0x1fda4 + 1fdb8: 17 c0 rjmp .+46 ; 0x1fde8 #else - // read a Flash byte and increment the address - __asm__ ("lpm %0,Z+\n" : "=r" (ch), "=z" (address.bptr): "1" (address)); + // read a Flash byte and increment the address + __asm__ (" lpm %0,Z+\n" : "=r" (ch), "=z" (address.bptr): "1" (address)); #endif - putch(ch); - 1fdda: ef 01 movw r28, r30 - 1fddc: 0d d0 rcall .+26 ; 0x1fdf8 - } while (--length); - 1fdde: e1 e0 ldi r30, 0x01 ; 1 - 1fde0: ae 1a sub r10, r30 - 1fde2: b1 08 sbc r11, r1 - 1fde4: c1 f7 brne .-16 ; 0x1fdd6 - 1fde6: 05 c0 rjmp .+10 ; 0x1fdf2 - else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */ - 1fde8: 81 35 cpi r24, 0x51 ; 81 - 1fdea: 11 f4 brne .+4 ; 0x1fdf0 - watchdogConfig(WATCHDOG_16MS); - 1fdec: 88 e0 ldi r24, 0x08 ; 8 - 1fdee: 17 d0 rcall .+46 ; 0x1fe1e - 1fdf0: 1c d0 rcall .+56 ; 0x1fe2a + putch(ch); + 1fdba: fe 01 movw r30, r28 + 1fdbc: 87 91 elpm r24, Z+ + } while (--length); + 1fdbe: ef 01 movw r28, r30 + 1fdc0: 16 d0 rcall .+44 ; 0x1fdee + 1fdc2: e1 e0 ldi r30, 0x01 ; 1 + 1fdc4: ae 1a sub r10, r30 + 1fdc6: b1 08 sbc r11, r1 + + read_mem(desttype, address, length); + } + +/* Get device signature bytes */ + else if (ch == STK_READ_SIGN) { + 1fdc8: c1 f7 brne .-16 ; 0x1fdba + 1fdca: 0e c0 rjmp .+28 ; 0x1fde8 + // READ SIGN - return what Avrdude wants to hear verifySpace(); - 1fdf2: 80 e1 ldi r24, 0x10 ; 16 - 1fdf4: 01 d0 rcall .+2 ; 0x1fdf8 + 1fdcc: 85 37 cpi r24, 0x75 ; 117 + 1fdce: 39 f4 brne .+14 ; 0x1fdde + putch(SIGNATURE_0); + 1fdd0: 27 d0 rcall .+78 ; 0x1fe20 + 1fdd2: 8e e1 ldi r24, 0x1E ; 30 + 1fdd4: 0c d0 rcall .+24 ; 0x1fdee + putch(SIGNATURE_1); + 1fdd6: 87 e9 ldi r24, 0x97 ; 151 + 1fdd8: 0a d0 rcall .+20 ; 0x1fdee + 1fdda: 83 e0 ldi r24, 0x03 ; 3 + putch(SIGNATURE_2); + 1fddc: 59 cf rjmp .-334 ; 0x1fc90 + 1fdde: 81 35 cpi r24, 0x51 ; 81 + } + else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */ + 1fde0: 11 f4 brne .+4 ; 0x1fde6 + 1fde2: 88 e0 ldi r24, 0x08 ; 8 + // Adaboot no-wait mod + watchdogConfig(WATCHDOG_16MS); + 1fde4: 17 d0 rcall .+46 ; 0x1fe14 + 1fde6: 1c d0 rcall .+56 ; 0x1fe20 + 1fde8: 80 e1 ldi r24, 0x10 ; 16 + verifySpace(); + } + else { + // This covers the response to commands like STK_ENTER_PROGMODE + verifySpace(); + 1fdea: 01 d0 rcall .+2 ; 0x1fdee + 1fdec: 47 cf rjmp .-370 ; 0x1fc7c + +0001fdee : + } putch(STK_OK); - 1fdf6: 42 cf rjmp .-380 ; 0x1fc7c - -0001fdf8 : - 1fdf8: 90 91 c0 00 lds r25, 0x00C0 ; 0x8000c0 <__TEXT_REGION_LENGTH__+0x7e00c0> + 1fdee: 90 91 c0 00 lds r25, 0x00C0 ; 0x8000c0 <__RAM__+0xc0> + 1fdf2: 95 ff sbrs r25, 5 } - 1fdfc: 95 ff sbrs r25, 5 - while (!(UART_SRA & _BV(UDRE0))) { /* Spin */ } - 1fdfe: fc cf rjmp .-8 ; 0x1fdf8 + 1fdf4: fc cf rjmp .-8 ; 0x1fdee +# else + RS485_PORT &= ~_BV(RS485_BIT); +# endif +#else //not RS485 + while (!(UART_SRA & _BV(UDRE0))) { /* Spin */ } UART_UDR = ch; - 1fe00: 80 93 c6 00 sts 0x00C6, r24 ; 0x8000c6 <__TEXT_REGION_LENGTH__+0x7e00c6> - 1fe04: 08 95 ret + 1fdf6: 80 93 c6 00 sts 0x00C6, r24 ; 0x8000c6 <__RAM__+0xc6> + 1fdfa: 08 95 ret -0001fe06 : - while(!(UART_SRA & _BV(RXC0))) { /* Spin */ } - 1fe06: 80 91 c0 00 lds r24, 0x00C0 ; 0x8000c0 <__TEXT_REGION_LENGTH__+0x7e00c0> - 1fe0a: 87 ff sbrs r24, 7 - 1fe0c: fc cf rjmp .-8 ; 0x1fe06 +0001fdfc : + : + "r25" + ); +#else +#ifndef LIN_UART + while (!(UART_SRA & _BV(RXC0))) { /* Spin */ } + 1fdfc: 80 91 c0 00 lds r24, 0x00C0 ; 0x8000c0 <__RAM__+0xc0> + 1fe00: 87 ff sbrs r24, 7 + 1fe02: fc cf rjmp .-8 ; 0x1fdfc if (!(UART_SRA & _BV(FE0))) { - 1fe0e: 80 91 c0 00 lds r24, 0x00C0 ; 0x8000c0 <__TEXT_REGION_LENGTH__+0x7e00c0> - 1fe12: 84 fd sbrc r24, 4 - 1fe14: 01 c0 rjmp .+2 ; 0x1fe18 + 1fe04: 80 91 c0 00 lds r24, 0x00C0 ; 0x8000c0 <__RAM__+0xc0> + 1fe08: 84 fd sbrc r24, 4 + 1fe0a: 01 c0 rjmp .+2 ; 0x1fe0e +} +#endif + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { __asm__ __volatile__ ( - 1fe16: a8 95 wdr + 1fe0c: a8 95 wdr + while (!(LINSIR & _BV(LRXOK))) { /* Spin */ } + if (!(LINSIR & _BV(LFERR))) { + watchdogReset(); /* Eventually abort if wrong speed */ + } +#endif ch = UART_UDR; - 1fe18: 80 91 c6 00 lds r24, 0x00C6 ; 0x8000c6 <__TEXT_REGION_LENGTH__+0x7e00c6> -} - 1fe1c: 08 95 ret + 1fe0e: 80 91 c6 00 lds r24, 0x00C6 ; 0x8000c6 <__RAM__+0xc6> +#if LED_DATA_FLASH + toggle_led(); +#endif -0001fe1e : + return ch; +} + 1fe12: 08 95 ret + +0001fe14 : +} + +void watchdogConfig(uint8_t x) { +#ifdef WDCE //does it have a Watchdog Change Enable? +#ifdef WDTCSR WDTCSR = _BV(WDCE) | _BV(WDE); - 1fe1e: e0 e6 ldi r30, 0x60 ; 96 - 1fe20: f0 e0 ldi r31, 0x00 ; 0 - 1fe22: 98 e1 ldi r25, 0x18 ; 24 - 1fe24: 90 83 st Z, r25 + 1fe14: e0 e6 ldi r30, 0x60 ; 96 + 1fe16: f0 e0 ldi r31, 0x00 ; 0 + 1fe18: 98 e1 ldi r25, 0x18 ; 24 + 1fe1a: 90 83 st Z, r25 +#else //then it must be one of those newfangled ones that use CCP + CCP=0xD8; //so write this magic number to CCP +#endif + +#ifdef WDTCSR WDTCSR = x; - 1fe26: 80 83 st Z, r24 - 1fe28: 08 95 ret + 1fe1c: 80 83 st Z, r24 + 1fe1e: 08 95 ret -0001fe2a : - if (getch() != CRC_EOP) { - 1fe2a: ed df rcall .-38 ; 0x1fe06 - 1fe2c: 80 32 cpi r24, 0x20 ; 32 - 1fe2e: 19 f0 breq .+6 ; 0x1fe36 - watchdogConfig(WATCHDOG_16MS); // shorten WD timeout - 1fe30: 88 e0 ldi r24, 0x08 ; 8 - 1fe32: f5 df rcall .-22 ; 0x1fe1e - 1fe34: ff cf rjmp .-2 ; 0x1fe34 - putch(STK_INSYNC); - 1fe36: 84 e1 ldi r24, 0x14 ; 20 - 1fe38: df cf rjmp .-66 ; 0x1fdf8 - -0001fe3a : -void getNch(uint8_t count) { - 1fe3a: cf 93 push r28 - 1fe3c: c8 2f mov r28, r24 +0001fe20 : do getch(); while (--count); - 1fe3e: e3 df rcall .-58 ; 0x1fe06 - 1fe40: c1 50 subi r28, 0x01 ; 1 - 1fe42: e9 f7 brne .-6 ; 0x1fe3e -} - 1fe44: cf 91 pop r28 verifySpace(); - 1fe46: f1 cf rjmp .-30 ; 0x1fe2a +} -0001fe48 : - 1fe48: fc 01 movw r30, r24 +void verifySpace() { + if (getch() != CRC_EOP) { + 1fe20: ed df rcall .-38 ; 0x1fdfc + 1fe22: 80 32 cpi r24, 0x20 ; 32 + 1fe24: 19 f0 breq .+6 ; 0x1fe2c + watchdogConfig(WATCHDOG_16MS); // shorten WD timeout + 1fe26: 88 e0 ldi r24, 0x08 ; 8 + 1fe28: f5 df rcall .-22 ; 0x1fe14 + 1fe2a: ff cf rjmp .-2 ; 0x1fe2a + while (1) // and busy-loop so that WD causes + ; // a reset and app start. + } + putch(STK_INSYNC); + 1fe2c: 84 e1 ldi r24, 0x14 ; 20 + 1fe2e: df cf rjmp .-66 ; 0x1fdee + +0001fe30 : + ::[count] "M" (UART_B_VALUE) + ); +} +#endif + +void getNch(uint8_t count) { + 1fe30: cf 93 push r28 + 1fe32: c8 2f mov r28, r24 + do getch(); while (--count); + 1fe34: e3 df rcall .-58 ; 0x1fdfc + 1fe36: c1 50 subi r28, 0x01 ; 1 + 1fe38: e9 f7 brne .-6 ; 0x1fe34 + verifySpace(); +} + 1fe3a: cf 91 pop r28 +} +#endif + +void getNch(uint8_t count) { + do getch(); while (--count); + verifySpace(); + 1fe3c: f1 cf rjmp .-30 ; 0x1fe20 + +0001fe3e : + 1fe3e: fc 01 movw r30, r24 * data=0 in WRITE */ static void do_spm(uint16_t address, uint8_t command, uint16_t data) __attribute__ ((used)); static void do_spm(uint16_t address, uint8_t command, uint16_t data) { - // Do spm stuff - asm volatile ( - 1fe4a: 0a 01 movw r0, r20 - 1fe4c: 67 bf out 0x37, r22 ; 55 - 1fe4e: e8 95 spm - 1fe50: 11 24 eor r1, r1 - 1fe52: 07 b6 in r0, 0x37 ; 55 + // Do spm stuff + asm volatile ( + 1fe40: 0a 01 movw r0, r20 + 1fe42: 67 bf out 0x37, r22 ; 55 + 1fe44: e8 95 spm + 1fe46: 11 24 eor r1, r1 + 1fe48: 07 b6 in r0, 0x37 ; 55 ); - // wait for spm to complete - // it doesn't have much sense for __BOOT_PAGE_FILL, - // but it doesn't hurt and saves some bytes on 'if' - boot_spm_busy_wait(); - 1fe54: 00 fc sbrc r0, 0 - 1fe56: fd cf rjmp .-6 ; 0x1fe52 - 1fe58: 66 70 andi r22, 0x06 ; 6 + // wait for spm to complete + // it doesn't have much sense for __BOOT_PAGE_FILL, + // but it doesn't hurt and saves some bytes on 'if' + boot_spm_busy_wait(); + 1fe4a: 00 fc sbrc r0, 0 + 1fe4c: fd cf rjmp .-6 ; 0x1fe48 + 1fe4e: 66 70 andi r22, 0x06 ; 6 #if defined(RWWSRE) - // this 'if' condition should be: (command == __BOOT_PAGE_WRITE || command == __BOOT_PAGE_ERASE)... - // but it's tweaked a little assuming that in every command we are interested in here, there - // must be also SELFPRGEN set. If we skip checking this bit, we save here 4B - if ((command & (_BV(PGWRT)|_BV(PGERS))) && (data == 0) ) { - 1fe5a: 29 f0 breq .+10 ; 0x1fe66 - 1fe5c: 45 2b or r20, r21 - 1fe5e: 19 f4 brne .+6 ; 0x1fe66 - 1fe60: 81 e1 ldi r24, 0x11 ; 17 - // Reenable read access to flash - __boot_rww_enable_short(); - 1fe62: 87 bf out 0x37, r24 ; 55 - 1fe64: e8 95 spm - 1fe66: 08 95 ret + // this 'if' condition should be: (command == __BOOT_PAGE_WRITE || command == __BOOT_PAGE_ERASE)... + // but it's tweaked a little assuming that in every command we are interested in here, there + // must be also SELFPRGEN set. If we skip checking this bit, we save here 4B + if ((command & (_BV(PGWRT)|_BV(PGERS))) && (data == 0) ) { + 1fe50: 29 f0 breq .+10 ; 0x1fe5c + 1fe52: 45 2b or r20, r21 + 1fe54: 19 f4 brne .+6 ; 0x1fe5c + 1fe56: 81 e1 ldi r24, 0x11 ; 17 + // Reenable read access to flash + __boot_rww_enable_short(); + 1fe58: 87 bf out 0x37, r24 ; 55 + 1fe5a: e8 95 spm + 1fe5c: 08 95 ret -0001fe68 : - 1fe68: f9 99 sbic 0x1f, 1 ; 31 - 1fe6a: fe cf rjmp .-4 ; 0x1fe68 - 1fe6c: 92 bd out 0x22, r25 ; 34 - 1fe6e: 81 bd out 0x21, r24 ; 33 - 1fe70: f8 9a sbi 0x1f, 0 ; 31 - 1fe72: 99 27 eor r25, r25 - 1fe74: 80 b5 in r24, 0x20 ; 32 - 1fe76: 08 95 ret +0001fe5e : + 1fe5e: f9 99 sbic 0x1f, 1 ; 31 + 1fe60: fe cf rjmp .-4 ; 0x1fe5e + 1fe62: 92 bd out 0x22, r25 ; 34 + 1fe64: 81 bd out 0x21, r24 ; 33 + 1fe66: f8 9a sbi 0x1f, 0 ; 31 + 1fe68: 99 27 eor r25, r25 + 1fe6a: 80 b5 in r24, 0x20 ; 32 + 1fe6c: 08 95 ret -0001fe78 : - 1fe78: 26 2f mov r18, r22 +0001fe6e : + 1fe6e: 26 2f mov r18, r22 -0001fe7a : - 1fe7a: f9 99 sbic 0x1f, 1 ; 31 - 1fe7c: fe cf rjmp .-4 ; 0x1fe7a - 1fe7e: 1f ba out 0x1f, r1 ; 31 - 1fe80: 92 bd out 0x22, r25 ; 34 - 1fe82: 81 bd out 0x21, r24 ; 33 - 1fe84: 20 bd out 0x20, r18 ; 32 - 1fe86: 0f b6 in r0, 0x3f ; 63 - 1fe88: f8 94 cli - 1fe8a: fa 9a sbi 0x1f, 2 ; 31 - 1fe8c: f9 9a sbi 0x1f, 1 ; 31 - 1fe8e: 0f be out 0x3f, r0 ; 63 - 1fe90: 01 96 adiw r24, 0x01 ; 1 - 1fe92: 08 95 ret +0001fe70 : + 1fe70: f9 99 sbic 0x1f, 1 ; 31 + 1fe72: fe cf rjmp .-4 ; 0x1fe70 + 1fe74: 1f ba out 0x1f, r1 ; 31 + 1fe76: 92 bd out 0x22, r25 ; 34 + 1fe78: 81 bd out 0x21, r24 ; 33 + 1fe7a: 20 bd out 0x20, r18 ; 32 + 1fe7c: 0f b6 in r0, 0x3f ; 63 + 1fe7e: f8 94 cli + 1fe80: fa 9a sbi 0x1f, 2 ; 31 + 1fe82: f9 9a sbi 0x1f, 1 ; 31 + 1fe84: 0f be out 0x3f, r0 ; 63 + 1fe86: 01 96 adiw r24, 0x01 ; 1 + 1fe88: 08 95 ret -0001fe94 : - 1fe94: 56 65 72 73 69 6f 6e 3d 38 2e 31 00 Version=8.1. +0001fe8a : + 1fe8a: ff . -0001fea0 : - 1fea0: 4f 50 54 49 42 4f 4f 54 5f 43 55 53 54 4f 4d 56 OPTIBOOT_CUSTOMV - 1feb0: 45 52 3d 30 00 ER=0. +0001fe8b : + 1fe8b: 56 65 72 73 69 6f 6e 3d 38 2e 33 00 Version=8.3. -0001feb5 : - 1feb5: 44 65 76 69 63 65 3d 61 74 6d 65 67 61 31 32 38 Device=atmega128 - 1fec5: 30 00 0. +0001fe97 : + 1fe97: 44 65 76 69 63 65 3d 61 74 6d 65 67 61 31 32 38 Device=atmega128 + 1fea7: 30 00 0. -0001fec7 : - 1fec7: 46 5f 43 50 55 3d 31 36 30 30 30 30 30 30 4c 00 F_CPU=16000000L. +0001fea9 : + 1fea9: 46 5f 43 50 55 3d 31 36 30 30 30 30 30 30 4c 00 F_CPU=16000000L. -0001fed7 : - 1fed7: 42 49 47 42 4f 4f 54 3d 31 00 BIGBOOT=1. +0001feb9 : + 1feb9: 42 49 47 42 4f 4f 54 3d 31 00 BIGBOOT=1. -0001fee1 : - 1fee1: 42 75 69 6c 74 3a 4d 61 79 20 32 39 20 32 30 32 Built:May 29 202 - 1fef1: 30 3a 30 31 3a 30 32 3a 34 30 00 0:01:02:40. +0001fec3 : + 1fec3: 42 75 69 6c 74 3a 4e 6f 76 20 20 34 20 32 30 32 Built:Nov 4 202 + 1fed3: 31 3a 31 38 3a 30 33 3a 30 33 00 1:18:03:03. -0001fefc : - 1fefc: 55 41 52 54 3d 30 00 UART=0. +0001fede : + 1fede: 55 41 52 54 3d 30 00 UART=0. -0001ff03 : - 1ff03: 42 41 55 44 5f 52 41 54 45 3d 31 31 35 32 30 30 BAUD_RATE=115200 +0001fee5 : + 1fee5: 42 41 55 44 5f 52 41 54 45 3d 31 31 35 32 30 30 BAUD_RATE=115200 ... -0001ff14 : - 1ff14: 4c 45 44 3d 42 37 00 LED=B7. +0001fef6 : + 1fef6: 4c 45 44 3d 42 37 00 LED=B7. -0001ff1b : - 1ff1b: 4c 45 44 5f 53 54 41 52 54 5f 46 4c 41 53 48 45 LED_START_FLASHE - 1ff2b: 53 3d 33 00 S=3. +0001fefd : + 1fefd: 4c 45 44 5f 53 54 41 52 54 5f 46 4c 41 53 48 45 LED_START_FLASHE + 1ff0d: 53 3d 33 00 S=3. diff --git a/optiboot/bootloaders/optiboot/optiboot_atmega328.hex b/optiboot/bootloaders/optiboot/optiboot_atmega328.hex index d09b1ab..ac2526d 100644 --- a/optiboot/bootloaders/optiboot/optiboot_atmega328.hex +++ b/optiboot/bootloaders/optiboot/optiboot_atmega328.hex @@ -1,33 +1,33 @@ -:107E000001C0DEC0112484B7882361F0982F9A70D6 +:107E000001C0DAC0112484B7882361F0982F9A70DA :107E1000923041F081FF02C097EF94BF282E80E09E -:107E2000BAD0EEC085E08093810082E08093C000EC +:107E2000B6D0EEC085E08093810082E08093C000F0 :107E300088E18093C10086E08093C20080E1809356 -:107E4000C4008EE0A8D0259A86E020E33CEF91E0C4 +:107E4000C4008EE0A4D0259A86E020E33CEF91E0C8 :107E5000309385002093840096BBB09BFECF1D9A83 :107E6000A8954091C00047FD02C0815089F7EE24DB -:107E7000E39495E0D92E21E1C22E81D0813471F4B2 -:107E80007ED0182F8ED0123811F481E005C0113841 -:107E900011F488E001C083E06BD067C0823411F434 -:107EA00084E103C0853419F485E083D05EC0853554 -:107EB00039F465D0C82F63D0D82FCC0FDD1F54C044 -:107EC000863521F484E075D080E0E6CF843609F071 -:107ED0002EC055D054D0F82E52D0B82E00E011E06C -:107EE0004ED0F80181938F01FE12FACF5AD0F5E4FB -:107EF000BF1201C0FFCF83E0FE0187BFE89507B640 -:107F000000FCFDCFA0E0B1E0FE018D919D910C0140 -:107F1000E7BEE89511243296FA12F7CFFE01D7BEDC -:107F2000E89507B600FCFDCFC7BEE8951EC08437B4 -:107F300071F425D024D0F82E22D033D08E01F80150 -:107F400085918F0115D0FA94F110F9CF0EC08537C5 -:107F500039F427D08EE10CD085E90AD08FE09CCF90 -:107F6000813511F488E017D01CD080E101D085CF95 -:107F70009091C00095FFFCCF8093C600089580913A -:107F8000C00087FFFCCF8091C00084FD01C0A89590 -:107F90008091C6000895E0E6F0E098E19083808348 -:107FA0000895EDDF803219F088E0F5DFFFCF84E13E -:107FB000DFCFCF93C82FE3DFC150E9F7CF91F1CFE7 -:107FC000FC010A0167BFE895112407B600FCFDCF4C -:107FD000667029F0452B19F481E187BFE895089573 -:027FFE00010878 +:107E7000E39495E0D92E21E1C22E7DD0813451F4D6 +:107E80007AD0182F8AD0113811F083E001C088E031 +:107E90006BD067C0823411F484E103C0853419F4D7 +:107EA00085E083D05EC0853539F465D0C82F63D0B6 +:107EB000D82FCC0FDD1F54C0863521F484E075D057 +:107EC00080E0E6CF843609F02EC055D054D0F82E8D +:107ED00052D0B82E00E011E04ED0F80181938F010E +:107EE000FE12FACF5AD0F5E4BF1201C0FFCF83E0F3 +:107EF000FE0187BFE89507B600FCFDCFA0E0B1E02A +:107F0000FE018D919D910C01E7BEE89511243296FA +:107F1000FA12F7CFFE01D7BEE89507B600FCFDCFF9 +:107F2000C7BEE8951EC0843771F425D024D0F82E42 +:107F300022D033D08E01F80185918F0115D0FA94AB +:107F4000F110F9CF0EC0853739F427D08EE10CD06F +:107F500085E90AD08FE09CCF813511F488E017D0F5 +:107F60001CD080E101D089CF9091C00095FFFCCF5B +:107F70008093C60008958091C00087FFFCCF809158 +:107F8000C00084FD01C0A8958091C6000895E0E678 +:107F9000F0E098E1908380830895EDDF803219F05E +:107FA00088E0F5DFFFCF84E1DFCFCF93C82FE3DF99 +:107FB000C150E9F7CF91F1CFFC010A0167BFE89505 +:107FC000112407B600FCFDCF667029F0452B19F48B +:087FD00081E187BFE8950895E7 +:027FFE00030876 :0400000300007E007B :00000001FF diff --git a/optiboot/bootloaders/optiboot/optiboot_atmega328.lst b/optiboot/bootloaders/optiboot/optiboot_atmega328.lst index 05490e1..34a6c54 100644 --- a/optiboot/bootloaders/optiboot/optiboot_atmega328.lst +++ b/optiboot/bootloaders/optiboot/optiboot_atmega328.lst @@ -3,29 +3,29 @@ optiboot_atmega328.elf: file format elf32-avr Sections: Idx Name Size VMA LMA File off Algn - 0 .data 00000000 00800100 00007fe0 00000274 2**0 - CONTENTS, ALLOC, LOAD, DATA - 1 .text 000001e0 00007e00 00007e00 00000094 2**1 + 0 .text 000001d8 00007e00 00007e00 00000074 2**0 CONTENTS, ALLOC, LOAD, READONLY, CODE - 2 .version 00000002 00007ffe 00007ffe 00000274 2**0 + 1 .trampolines 00000000 00007fd8 00007fd8 0000024c 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 2 .version 00000002 00007ffe 00007ffe 0000024c 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA - 3 .comment 0000002f 00000000 00000000 00000276 2**0 + 3 .comment 0000002f 00000000 00000000 0000024e 2**0 CONTENTS, READONLY - 4 .debug_aranges 00000030 00000000 00000000 000002a5 2**0 + 4 .debug_aranges 00000030 00000000 00000000 0000027d 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_info 000005f9 00000000 00000000 000002d5 2**0 + 5 .debug_info 00000638 00000000 00000000 000002ad 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_abbrev 000002c1 00000000 00000000 000008ce 2**0 + 6 .debug_abbrev 000002e6 00000000 00000000 000008e5 2**0 CONTENTS, READONLY, DEBUGGING - 7 .debug_line 0000033b 00000000 00000000 00000b8f 2**0 + 7 .debug_line 00000344 00000000 00000000 00000bcb 2**0 CONTENTS, READONLY, DEBUGGING - 8 .debug_frame 0000009c 00000000 00000000 00000ecc 2**2 + 8 .debug_frame 000000ac 00000000 00000000 00000f10 2**2 CONTENTS, READONLY, DEBUGGING - 9 .debug_str 00000200 00000000 00000000 00000f68 2**0 + 9 .debug_str 00000220 00000000 00000000 00000fbc 2**0 CONTENTS, READONLY, DEBUGGING - 10 .debug_loc 00000359 00000000 00000000 00001168 2**0 + 10 .debug_loc 00000359 00000000 00000000 000011dc 2**0 CONTENTS, READONLY, DEBUGGING - 11 .debug_ranges 00000080 00000000 00000000 000014c1 2**0 + 11 .debug_ranges 00000068 00000000 00000000 00001535 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: @@ -33,12 +33,12 @@ Disassembly of section .text: 00007e00 : /* everything that needs to run VERY early */ void pre_main(void) { - // Allow convenient way of calling do_spm function - jump table, - // so entry to this function will always be here, indepedent of compilation, - // features etc + // Allow convenient way of calling do_spm function - jump table, so + // entry to this function will always be here, independent of + // compilation, features etc asm volatile ( 7e00: 01 c0 rjmp .+2 ; 0x7e04
- 7e02: de c0 rjmp .+444 ; 0x7fc0 + 7e02: da c0 rjmp .+436 ; 0x7fb8 00007e04
: // SP points to RAMEND @@ -46,121 +46,125 @@ void pre_main(void) { // // If not, uncomment the following instructions: // cli(); - asm volatile ("clr __zero_reg__"); + asm volatile (" clr __zero_reg__"); 7e04: 11 24 eor r1, r1 -#if defined(__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) || \ - defined(__AVR_ATmega16__) || defined(__AVR_ATmega162__) || \ - defined (__AVR_ATmega128__) - ch = MCUCSR; -#else +# warning "START_APP_ON_EXTR is defined and NO_START_APP_ON_POR isn't" +# define APP_START_REASONS 1 /* Always start rge App. */ +# define WDRF_CLR_REASONS 0 /* Never clear WDRF */ +#endif + ch = MCUSR; 7e06: 84 b7 in r24, 0x34 ; 52 -#endif + // Skip all logic and run bootloader if MCUSR is cleared (application request) if (ch != 0) { 7e08: 88 23 and r24, r24 7e0a: 61 f0 breq .+24 ; 0x7e24 - * 2. we clear WDRF if it's set with EXTRF to avoid loops - * One problematic scenario: broken application code sets watchdog timer - * without clearing MCUSR before and triggers it quickly. But it's - * recoverable by power-on with pushed reset button. - */ - if ((ch & (_BV(WDRF) | _BV(EXTRF))) != _BV(EXTRF)) { + * One problematic scenario: broken application code sets watchdog timer + * without clearing MCUSR before and triggers it quickly. But it's + * recoverable by power-on with pushed reset button. + */ + + if (APP_START_REASONS) { 7e0c: 98 2f mov r25, r24 7e0e: 9a 70 andi r25, 0x0A ; 10 7e10: 92 30 cpi r25, 0x02 ; 2 7e12: 41 f0 breq .+16 ; 0x7e24 - if (ch & _BV(EXTRF)) { + if (WDRF_CLR_REASONS) { 7e14: 81 ff sbrs r24, 1 7e16: 02 c0 rjmp .+4 ; 0x7e1c - defined(__AVR_ATmega16__) || defined(__AVR_ATmega162__) || \ - defined(__AVR_ATmega128__) - // Fix missing definitions in avr-libc - MCUCSR = ~(_BV(WDRF)); -#else - MCUSR = ~(_BV(WDRF)); + /* + * Clear WDRF if it was most probably set by wdr in bootloader. + */ + if ((uint16_t)&MCUSR > 0x1F) { + MCUSR = ~(_BV(WDRF)); // optimize to LDI/OUT 7e18: 97 ef ldi r25, 0xF7 ; 247 7e1a: 94 bf out 0x34, r25 ; 52 - /* - * save the reset flags in the designated register - * This can be saved in a main program by putting code in .init0 (which - * executes before normal c init code) to save R2 to a global variable. - */ - __asm__ __volatile__ ("mov r2, %0\n" :: "r" (ch)); + /* + * save the reset flags in the designated register + * This can be saved in a main program by putting code in .init0 (which + * executes before normal c init code) to save R2 to a global variable. + */ + __asm__ __volatile__ (" mov r2, %0\n" :: "r" (ch)); 7e1c: 28 2e mov r2, r24 - // switch off watchdog - watchdogConfig(WATCHDOG_OFF); + // switch off watchdog + watchdogConfig(WATCHDOG_OFF); 7e1e: 80 e0 ldi r24, 0x00 ; 0 - 7e20: ba d0 rcall .+372 ; 0x7f96 - // Note that appstart_vec is defined so that this works with either - // real or virtual boot partitions. - __asm__ __volatile__ ( - 7e22: ee c0 rjmp .+476 ; 0x8000 + 7e20: b6 d0 rcall .+364 ; 0x7f8e + // Note that appstart_vec is defined so that this works with either + // real or virtual boot partitions. + __asm__ __volatile__ ( + 7e22: ee c0 rjmp .+476 ; 0x8000 <__VERSION_START__+0x2> #elif defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)||defined(__AVR_ATtiny85__) - TCCR1 = 0x0E; //div 8196 - it's an 8-bit timer. + TCCR1 = 0x0E; //div 8196 - it's an 8-bit timer. #elif defined(__AVR_ATtiny43__) - #error "LED flash for Tiny43 not yet supported" +#error "LED flash for Tiny43 not yet supported" #else TCCR1B = _BV(CS12) | _BV(CS10); // div 1024 7e24: 85 e0 ldi r24, 0x05 ; 5 - 7e26: 80 93 81 00 sts 0x0081, r24 ; 0x800081 <__TEXT_REGION_LENGTH__+0x7e0081> + 7e26: 80 93 81 00 sts 0x0081, r24 ; 0x800081 <__RAM__+0x81> LINBTR = (1 << LDISR) | (8 << LBT0); - LINCR = _BV(LENA) | _BV(LCMD2) | _BV(LCMD1) | _BV(LCMD0); + LINCR = _BV(LENA) | _BV(LCMD2) | _BV(LCMD1) | _BV(LCMD0); LINDAT=0; - #else - #ifndef SINGLESPEED +#else +#if (SINGLESPEED == 0) UART_SRA = _BV(U2X0); //Double speed mode USART0 7e2a: 82 e0 ldi r24, 0x02 ; 2 - 7e2c: 80 93 c0 00 sts 0x00C0, r24 ; 0x8000c0 <__TEXT_REGION_LENGTH__+0x7e00c0> - #endif + 7e2c: 80 93 c0 00 sts 0x00C0, r24 ; 0x8000c0 <__RAM__+0xc0> +#endif UART_SRB = _BV(RXEN0) | _BV(TXEN0); 7e30: 88 e1 ldi r24, 0x18 ; 24 - 7e32: 80 93 c1 00 sts 0x00C1, r24 ; 0x8000c1 <__TEXT_REGION_LENGTH__+0x7e00c1> + 7e32: 80 93 c1 00 sts 0x00C1, r24 ; 0x8000c1 <__RAM__+0xc1> UART_SRC = _BV(UCSZ00) | _BV(UCSZ01); 7e36: 86 e0 ldi r24, 0x06 ; 6 - 7e38: 80 93 c2 00 sts 0x00C2, r24 ; 0x8000c2 <__TEXT_REGION_LENGTH__+0x7e00c2> + 7e38: 80 93 c2 00 sts 0x00C2, r24 ; 0x8000c2 <__RAM__+0xc2> UART_SRL = (uint8_t)BAUD_SETTING; 7e3c: 80 e1 ldi r24, 0x10 ; 16 - 7e3e: 80 93 c4 00 sts 0x00C4, r24 ; 0x8000c4 <__TEXT_REGION_LENGTH__+0x7e00c4> - #endif // LIN_UART - #endif // mega8/etc -#endif // soft_uart + 7e3e: 80 93 c4 00 sts 0x00C4, r24 ; 0x8000c4 <__RAM__+0xc4> + RS485_PORT &= ~_BV(RS485_BIT); + #endif +#endif // Set up watchdog to trigger after desired timeout watchdogConfig(WDTPERIOD); 7e42: 8e e0 ldi r24, 0x0E ; 14 - 7e44: a8 d0 rcall .+336 ; 0x7f96 + 7e44: a4 d0 rcall .+328 ; 0x7f8e -#if (LED_START_FLASHES > 0) || defined(LED_DATA_FLASH) || defined(LED_START_ON) +#if (LED_START_FLASHES > 0) || LED_DATA_FLASH || LED_START_ON /* Set LED pin as output */ LED_DDR |= _BV(LED); 7e46: 25 9a sbi 0x04, 5 ; 4 7e48: 86 e0 ldi r24, 0x06 ; 6 - TIFR = _BV(TOV1); - while(!(TIFR & _BV(TOV1))); - #elif defined(__AVR_ATtiny43__) - #error "LED flash for Tiny43 not yet supported" - #else - TCNT1 = -(F_CPU/(1024*16)); + TIFR = _BV(TOV1); + while (!(TIFR & _BV(TOV1))); +#elif defined(__AVR_ATtiny43__) +#error "LED flash for Tiny43 not yet supported" +#else + TCNT1 = -(F_CPU/(1024*16)); 7e4a: 20 e3 ldi r18, 0x30 ; 48 7e4c: 3c ef ldi r19, 0xFC ; 252 - TIFR1 = _BV(TOV1); + TIFR1 = _BV(TOV1); 7e4e: 91 e0 ldi r25, 0x01 ; 1 - TCNT1 = -(F_CPU/(1024*16)); - 7e50: 30 93 85 00 sts 0x0085, r19 ; 0x800085 <__TEXT_REGION_LENGTH__+0x7e0085> - 7e54: 20 93 84 00 sts 0x0084, r18 ; 0x800084 <__TEXT_REGION_LENGTH__+0x7e0084> - TIFR1 = _BV(TOV1); + TIFR = _BV(TOV1); + while (!(TIFR & _BV(TOV1))); +#elif defined(__AVR_ATtiny43__) +#error "LED flash for Tiny43 not yet supported" +#else + TCNT1 = -(F_CPU/(1024*16)); + 7e50: 30 93 85 00 sts 0x0085, r19 ; 0x800085 <__RAM__+0x85> + 7e54: 20 93 84 00 sts 0x0084, r18 ; 0x800084 <__RAM__+0x84> + TIFR1 = _BV(TOV1); 7e58: 96 bb out 0x16, r25 ; 22 - while(!(TIFR1 & _BV(TOV1))); + while (!(TIFR1 & _BV(TOV1))); 7e5a: b0 9b sbis 0x16, 0 ; 22 7e5c: fe cf rjmp .-4 ; 0x7e5a - defined(__AVR_ATmega8535__) || defined(__AVR_ATmega16__) || \ - defined(__AVR_ATmega162__) || defined(__AVR_ATmega32__) || \ - defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - LED_PORT ^= _BV(LED); + defined(__AVR_ATmega8535__) || defined(__AVR_ATmega16__) || \ + defined(__AVR_ATmega162__) || defined(__AVR_ATmega32__) || \ + defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) + LED_PORT ^= _BV(LED); #else - LED_PIN |= _BV(LED); + LED_PIN |= _BV(LED); // Newer AVRs can toggle by writing PINx 7e5e: 1d 9a sbi 0x03, 5 ; 3 } #endif @@ -169,305 +173,464 @@ void pre_main(void) { void watchdogReset() { __asm__ __volatile__ ( 7e60: a8 95 wdr + * by the UART hardware, avrdude sends several attempts in rather + * quick succession, some of which will be lost and cause us to + * get out of sync. So if we see any data; stop blinking. + */ +#ifndef LIN_UART if (UART_SRA & _BV(RXC0)) - 7e62: 40 91 c0 00 lds r20, 0x00C0 ; 0x8000c0 <__TEXT_REGION_LENGTH__+0x7e00c0> + 7e62: 40 91 c0 00 lds r20, 0x00C0 ; 0x8000c0 <__RAM__+0xc0> 7e66: 47 fd sbrc r20, 7 7e68: 02 c0 rjmp .+4 ; 0x7e6e 7e6a: 81 50 subi r24, 0x01 ; 1 +#else +// This doesn't seem to work? +// if ((UART_PIN & (1< - putch(optiboot_version & 0xFF); + + /* + * Copy data from the buffer into the flash write buffer. + */ + do { + __boot_page_fill_short((uint16_t)(void*)addrPtr, *(mybuff.wptr++)); 7e6e: ee 24 eor r14, r14 7e70: e3 94 inc r14 - } while (len -= 2); + } while (len -= 2); - /* - * Actually Write the buffer to flash (and wait for it to finish.) - */ - __boot_page_write_short(address.word); + /* + * Actually Write the buffer to flash (and wait for it to finish.) + */ + __boot_page_write_short(address.word); 7e72: 95 e0 ldi r25, 0x05 ; 5 7e74: d9 2e mov r13, r25 - boot_spm_busy_wait(); + boot_spm_busy_wait(); #if defined(RWWSRE) - // Reenable read access to flash - __boot_rww_enable_short(); + // Reenable read access to flash + __boot_rww_enable_short(); 7e76: 21 e1 ldi r18, 0x11 ; 17 +#endif + + /* Forever loop: exits by causing WDT reset */ + for (;;) { + /* get character from UART */ ch = getch(); 7e78: c2 2e mov r12, r18 - if(ch == STK_GET_PARAMETER) { - 7e7a: 81 d0 rcall .+258 ; 0x7f7e + + if (ch == STK_GET_PARAMETER) { + 7e7a: 7d d0 rcall .+250 ; 0x7f76 unsigned char which = getch(); 7e7c: 81 34 cpi r24, 0x41 ; 65 - 7e7e: 71 f4 brne .+28 ; 0x7e9c - 7e80: 7e d0 rcall .+252 ; 0x7f7e + 7e7e: 51 f4 brne .+20 ; 0x7e94 + 7e80: 7a d0 rcall .+244 ; 0x7f76 verifySpace(); 7e82: 18 2f mov r17, r24 - 7e84: 8e d0 rcall .+284 ; 0x7fa2 + 7e84: 8a d0 rcall .+276 ; 0x7f9a + * Send optiboot version as "SW version" + * Note that the references to memory are optimized away. + */ if (which == STK_SW_MINOR) { - 7e86: 12 38 cpi r17, 0x82 ; 130 - 7e88: 11 f4 brne .+4 ; 0x7e8e - putch(optiboot_version & 0xFF); - 7e8a: 81 e0 ldi r24, 0x01 ; 1 - 7e8c: 05 c0 rjmp .+10 ; 0x7e98 + putch(optiboot_version & 0xFF); } else if (which == STK_SW_MAJOR) { - 7e8e: 11 38 cpi r17, 0x81 ; 129 - putch(optiboot_version >> 8); - 7e90: 11 f4 brne .+4 ; 0x7e96 - 7e92: 88 e0 ldi r24, 0x08 ; 8 - putch(0x03); - 7e94: 01 c0 rjmp .+2 ; 0x7e98 - 7e96: 83 e0 ldi r24, 0x03 ; 3 - 7e98: 6b d0 rcall .+214 ; 0x7f70 - 7e9a: 67 c0 rjmp .+206 ; 0x7f6a - else if(ch == STK_SET_DEVICE) { - 7e9c: 82 34 cpi r24, 0x42 ; 66 + 7e86: 11 38 cpi r17, 0x81 ; 129 + /* + * Send optiboot version as "SW version" + * Note that the references to memory are optimized away. + */ + if (which == STK_SW_MINOR) { + putch(optiboot_version & 0xFF); + 7e88: 11 f0 breq .+4 ; 0x7e8e + 7e8a: 83 e0 ldi r24, 0x03 ; 3 + } else if (which == STK_SW_MAJOR) { + putch(optiboot_version >> 8); + 7e8c: 01 c0 rjmp .+2 ; 0x7e90 + 7e8e: 88 e0 ldi r24, 0x08 ; 8 + 7e90: 6b d0 rcall .+214 ; 0x7f68 + 7e92: 67 c0 rjmp .+206 ; 0x7f62 + * other parameters - enough to keep Avrdude happy + */ + putch(0x03); + } + } + else if (ch == STK_SET_DEVICE) { + 7e94: 82 34 cpi r24, 0x42 ; 66 + // SET DEVICE is ignored getNch(20); - 7e9e: 11 f4 brne .+4 ; 0x7ea4 - 7ea0: 84 e1 ldi r24, 0x14 ; 20 - else if(ch == STK_SET_DEVICE_EXT) { - 7ea2: 03 c0 rjmp .+6 ; 0x7eaa + 7e96: 11 f4 brne .+4 ; 0x7e9c + 7e98: 84 e1 ldi r24, 0x14 ; 20 + } + else if (ch == STK_SET_DEVICE_EXT) { + 7e9a: 03 c0 rjmp .+6 ; 0x7ea2 + // SET DEVICE EXT is ignored getNch(5); - 7ea4: 85 34 cpi r24, 0x45 ; 69 - 7ea6: 19 f4 brne .+6 ; 0x7eae - 7ea8: 85 e0 ldi r24, 0x05 ; 5 - else if(ch == STK_LOAD_ADDRESS) { - 7eaa: 83 d0 rcall .+262 ; 0x7fb2 - 7eac: 5e c0 rjmp .+188 ; 0x7f6a + 7e9c: 85 34 cpi r24, 0x45 ; 69 + 7e9e: 19 f4 brne .+6 ; 0x7ea6 + 7ea0: 85 e0 ldi r24, 0x05 ; 5 + } + else if (ch == STK_LOAD_ADDRESS) { + 7ea2: 83 d0 rcall .+262 ; 0x7faa + 7ea4: 5e c0 rjmp .+188 ; 0x7f62 + // LOAD ADDRESS address.bytes[0] = getch(); - 7eae: 85 35 cpi r24, 0x55 ; 85 - 7eb0: 39 f4 brne .+14 ; 0x7ec0 - 7eb2: 65 d0 rcall .+202 ; 0x7f7e + 7ea6: 85 35 cpi r24, 0x55 ; 85 + 7ea8: 39 f4 brne .+14 ; 0x7eb8 + 7eaa: 65 d0 rcall .+202 ; 0x7f76 address.bytes[1] = getch(); - 7eb4: c8 2f mov r28, r24 - 7eb6: 63 d0 rcall .+198 ; 0x7f7e - address.word *= 2; // Convert from word address to byte address - 7eb8: d8 2f mov r29, r24 - 7eba: cc 0f add r28, r28 - 7ebc: dd 1f adc r29, r29 - else if(ch == STK_UNIVERSAL) { - 7ebe: 54 c0 rjmp .+168 ; 0x7f68 - getNch(4); - 7ec0: 86 35 cpi r24, 0x56 ; 86 - 7ec2: 21 f4 brne .+8 ; 0x7ecc - putch(0x00); - 7ec4: 84 e0 ldi r24, 0x04 ; 4 - 7ec6: 75 d0 rcall .+234 ; 0x7fb2 - else if(ch == STK_PROG_PAGE) { - 7ec8: 80 e0 ldi r24, 0x00 ; 0 - 7eca: e6 cf rjmp .-52 ; 0x7e98 - GETLENGTH(length); - 7ecc: 84 36 cpi r24, 0x64 ; 100 - 7ece: 09 f0 breq .+2 ; 0x7ed2 - 7ed0: 2e c0 rjmp .+92 ; 0x7f2e - 7ed2: 55 d0 rcall .+170 ; 0x7f7e - desttype = getch(); - 7ed4: 54 d0 rcall .+168 ; 0x7f7e - 7ed6: f8 2e mov r15, r24 - 7ed8: 52 d0 rcall .+164 ; 0x7f7e - 7eda: b8 2e mov r11, r24 - 7edc: 00 e0 ldi r16, 0x00 ; 0 - do *bufPtr++ = getch(); - 7ede: 11 e0 ldi r17, 0x01 ; 1 - 7ee0: 4e d0 rcall .+156 ; 0x7f7e - 7ee2: f8 01 movw r30, r16 - 7ee4: 81 93 st Z+, r24 - 7ee6: 8f 01 movw r16, r30 - while (--length); - 7ee8: fe 12 cpse r15, r30 - 7eea: fa cf rjmp .-12 ; 0x7ee0 - verifySpace(); - 7eec: 5a d0 rcall .+180 ; 0x7fa2 - 7eee: f5 e4 ldi r31, 0x45 ; 69 - switch (memtype) { - 7ef0: bf 12 cpse r11, r31 - 7ef2: 01 c0 rjmp .+2 ; 0x7ef6 - 7ef4: ff cf rjmp .-2 ; 0x7ef4 - 7ef6: 83 e0 ldi r24, 0x03 ; 3 - __boot_page_erase_short(address.word); - 7ef8: fe 01 movw r30, r28 - 7efa: 87 bf out 0x37, r24 ; 55 - 7efc: e8 95 spm - 7efe: 07 b6 in r0, 0x37 ; 55 - boot_spm_busy_wait(); - 7f00: 00 fc sbrc r0, 0 - 7f02: fd cf rjmp .-6 ; 0x7efe - 7f04: a0 e0 ldi r26, 0x00 ; 0 - 7f06: b1 e0 ldi r27, 0x01 ; 1 - 7f08: fe 01 movw r30, r28 - 7f0a: 8d 91 ld r24, X+ - __boot_page_fill_short((uint16_t)(void*)addrPtr, *(mybuff.wptr++)); - 7f0c: 9d 91 ld r25, X+ - 7f0e: 0c 01 movw r0, r24 - 7f10: e7 be out 0x37, r14 ; 55 - 7f12: e8 95 spm - 7f14: 11 24 eor r1, r1 - 7f16: 32 96 adiw r30, 0x02 ; 2 - } while (len -= 2); - 7f18: fa 12 cpse r15, r26 - __boot_page_write_short(address.word); - 7f1a: f7 cf rjmp .-18 ; 0x7f0a - 7f1c: fe 01 movw r30, r28 - boot_spm_busy_wait(); - 7f1e: d7 be out 0x37, r13 ; 55 - 7f20: e8 95 spm - __boot_rww_enable_short(); - 7f22: 07 b6 in r0, 0x37 ; 55 - 7f24: 00 fc sbrc r0, 0 - 7f26: fd cf rjmp .-6 ; 0x7f22 - else if(ch == STK_READ_PAGE) { - 7f28: c7 be out 0x37, r12 ; 55 - 7f2a: e8 95 spm - GETLENGTH(length); - 7f2c: 1e c0 rjmp .+60 ; 0x7f6a - 7f2e: 84 37 cpi r24, 0x74 ; 116 - 7f30: 71 f4 brne .+28 ; 0x7f4e - desttype = getch(); - 7f32: 25 d0 rcall .+74 ; 0x7f7e - verifySpace(); - 7f34: 24 d0 rcall .+72 ; 0x7f7e - 7f36: f8 2e mov r15, r24 - 7f38: 22 d0 rcall .+68 ; 0x7f7e - // while (--length); - // read a Flash and increment the address (may increment RAMPZ) - __asm__ ("elpm %0,Z+\n" : "=r" (ch), "=z" (address.bptr): "1" (address)); -#else - // read a Flash byte and increment the address - __asm__ ("lpm %0,Z+\n" : "=r" (ch), "=z" (address.bptr): "1" (address)); - 7f3a: 33 d0 rcall .+102 ; 0x7fa2 - 7f3c: 8e 01 movw r16, r28 + 7eac: c8 2f mov r28, r24 + 7eae: 63 d0 rcall .+198 ; 0x7f76 + } + else { + RAMPZ &= 0xFE; + } #endif - putch(ch); - 7f3e: f8 01 movw r30, r16 - } while (--length); - 7f40: 85 91 lpm r24, Z+ - 7f42: 8f 01 movw r16, r30 - 7f44: 15 d0 rcall .+42 ; 0x7f70 - 7f46: fa 94 dec r15 - else if(ch == STK_READ_SIGN) { - 7f48: f1 10 cpse r15, r1 - 7f4a: f9 cf rjmp .-14 ; 0x7f3e + address.word *= 2; // Convert from word address to byte address + 7eb0: d8 2f mov r29, r24 + 7eb2: cc 0f add r28, r28 + 7eb4: dd 1f adc r29, r29 verifySpace(); - 7f4c: 0e c0 rjmp .+28 ; 0x7f6a - 7f4e: 85 37 cpi r24, 0x75 ; 117 + } + else if (ch == STK_UNIVERSAL) { + 7eb6: 54 c0 rjmp .+168 ; 0x7f60 + getNch(3); + putch(0x00); + } +#else + // UNIVERSAL command is ignored + getNch(4); + 7eb8: 86 35 cpi r24, 0x56 ; 86 + 7eba: 21 f4 brne .+8 ; 0x7ec4 + putch(0x00); + 7ebc: 84 e0 ldi r24, 0x04 ; 4 + 7ebe: 75 d0 rcall .+234 ; 0x7faa +#endif + } + /* Write memory, length is big endian and is in bytes */ + else if (ch == STK_PROG_PAGE) { + 7ec0: 80 e0 ldi r24, 0x00 ; 0 + 7ec2: e6 cf rjmp .-52 ; 0x7e90 + // PROGRAM PAGE - we support flash programming only, not EEPROM + uint8_t desttype; + uint8_t *bufPtr; + pagelen_t savelength; + + GETLENGTH(length); + 7ec4: 84 36 cpi r24, 0x64 ; 100 + 7ec6: 09 f0 breq .+2 ; 0x7eca + 7ec8: 2e c0 rjmp .+92 ; 0x7f26 + 7eca: 55 d0 rcall .+170 ; 0x7f76 + savelength = length; + desttype = getch(); + 7ecc: 54 d0 rcall .+168 ; 0x7f76 + 7ece: f8 2e mov r15, r24 + 7ed0: 52 d0 rcall .+164 ; 0x7f76 + 7ed2: b8 2e mov r11, r24 + 7ed4: 00 e0 ldi r16, 0x00 ; 0 + + // read a page worth of contents + bufPtr = buff.bptr; + do *bufPtr++ = getch(); + 7ed6: 11 e0 ldi r17, 0x01 ; 1 + 7ed8: 4e d0 rcall .+156 ; 0x7f76 + 7eda: f8 01 movw r30, r16 + 7edc: 81 93 st Z+, r24 + 7ede: 8f 01 movw r16, r30 + while (--length); + 7ee0: fe 12 cpse r15, r30 + 7ee2: fa cf rjmp .-12 ; 0x7ed8 + + // Read command terminator, start reply + verifySpace(); + 7ee4: 5a d0 rcall .+180 ; 0x7f9a + 7ee6: f5 e4 ldi r31, 0x45 ; 69 + * void writebuffer(memtype, buffer, address, length) + */ +static inline void writebuffer(int8_t memtype, addr16_t mybuff, + addr16_t address, pagelen_t len) +{ + switch (memtype) { + 7ee8: bf 12 cpse r11, r31 + 7eea: 01 c0 rjmp .+2 ; 0x7eee + 7eec: ff cf rjmp .-2 ; 0x7eec + 7eee: 83 e0 ldi r24, 0x03 ; 3 + * and we needed the space back. + */ +#ifdef FOURPAGEERASE + if ((address.bytes[0] & ((SPM_PAGESIZE<<2)-1))==0) { +#endif + __boot_page_erase_short(address.word); + 7ef0: fe 01 movw r30, r28 + 7ef2: 87 bf out 0x37, r24 ; 55 + 7ef4: e8 95 spm + 7ef6: 07 b6 in r0, 0x37 ; 55 + boot_spm_busy_wait(); + 7ef8: 00 fc sbrc r0, 0 + 7efa: fd cf rjmp .-6 ; 0x7ef6 + 7efc: a0 e0 ldi r26, 0x00 ; 0 + 7efe: b1 e0 ldi r27, 0x01 ; 1 + 7f00: fe 01 movw r30, r28 + 7f02: 8d 91 ld r24, X+ + + /* + * Copy data from the buffer into the flash write buffer. + */ + do { + __boot_page_fill_short((uint16_t)(void*)addrPtr, *(mybuff.wptr++)); + 7f04: 9d 91 ld r25, X+ + 7f06: 0c 01 movw r0, r24 + 7f08: e7 be out 0x37, r14 ; 55 + 7f0a: e8 95 spm + 7f0c: 11 24 eor r1, r1 + 7f0e: 32 96 adiw r30, 0x02 ; 2 + addrPtr += 2; + } while (len -= 2); + 7f10: fa 12 cpse r15, r26 + + /* + * Actually Write the buffer to flash (and wait for it to finish.) + */ + __boot_page_write_short(address.word); + 7f12: f7 cf rjmp .-18 ; 0x7f02 + 7f14: fe 01 movw r30, r28 + boot_spm_busy_wait(); + 7f16: d7 be out 0x37, r13 ; 55 + 7f18: e8 95 spm +#if defined(RWWSRE) + // Reenable read access to flash + __boot_rww_enable_short(); + 7f1a: 07 b6 in r0, 0x37 ; 55 + 7f1c: 00 fc sbrc r0, 0 + 7f1e: fd cf rjmp .-6 ; 0x7f1a + writebuffer(desttype, buff, address, savelength); + + + } +/* Read memory block mode, length is big endian. */ + else if (ch == STK_READ_PAGE) { + 7f20: c7 be out 0x37, r12 ; 55 + 7f22: e8 95 spm + uint8_t desttype; + GETLENGTH(length); + 7f24: 1e c0 rjmp .+60 ; 0x7f62 + 7f26: 84 37 cpi r24, 0x74 ; 116 + 7f28: 71 f4 brne .+28 ; 0x7f46 + + desttype = getch(); + 7f2a: 25 d0 rcall .+74 ; 0x7f76 + + verifySpace(); + 7f2c: 24 d0 rcall .+72 ; 0x7f76 + 7f2e: f8 2e mov r15, r24 + 7f30: 22 d0 rcall .+68 ; 0x7f76 + // while (--length); + // read a Flash and increment the address (may increment RAMPZ) + __asm__ (" elpm %0,Z+\n" : "=r" (ch), "=z" (address.bptr): "1" (address)); +#else + // read a Flash byte and increment the address + __asm__ (" lpm %0,Z+\n" : "=r" (ch), "=z" (address.bptr): "1" (address)); + 7f32: 33 d0 rcall .+102 ; 0x7f9a + 7f34: 8e 01 movw r16, r28 +#endif + putch(ch); + 7f36: f8 01 movw r30, r16 + } while (--length); + 7f38: 85 91 lpm r24, Z+ + 7f3a: 8f 01 movw r16, r30 + 7f3c: 15 d0 rcall .+42 ; 0x7f68 + 7f3e: fa 94 dec r15 + + read_mem(desttype, address, length); + } + +/* Get device signature bytes */ + else if (ch == STK_READ_SIGN) { + 7f40: f1 10 cpse r15, r1 + 7f42: f9 cf rjmp .-14 ; 0x7f36 + // READ SIGN - return what Avrdude wants to hear + verifySpace(); + 7f44: 0e c0 rjmp .+28 ; 0x7f62 + 7f46: 85 37 cpi r24, 0x75 ; 117 putch(SIGNATURE_0); - 7f50: 39 f4 brne .+14 ; 0x7f60 - 7f52: 27 d0 rcall .+78 ; 0x7fa2 - 7f54: 8e e1 ldi r24, 0x1E ; 30 + 7f48: 39 f4 brne .+14 ; 0x7f58 + 7f4a: 27 d0 rcall .+78 ; 0x7f9a + 7f4c: 8e e1 ldi r24, 0x1E ; 30 putch(SIGNATURE_1); - 7f56: 0c d0 rcall .+24 ; 0x7f70 - 7f58: 85 e9 ldi r24, 0x95 ; 149 - 7f5a: 0a d0 rcall .+20 ; 0x7f70 + 7f4e: 0c d0 rcall .+24 ; 0x7f68 + 7f50: 85 e9 ldi r24, 0x95 ; 149 + 7f52: 0a d0 rcall .+20 ; 0x7f68 putch(SIGNATURE_2); - 7f5c: 8f e0 ldi r24, 0x0F ; 15 - 7f5e: 9c cf rjmp .-200 ; 0x7e98 + 7f54: 8f e0 ldi r24, 0x0F ; 15 + 7f56: 9c cf rjmp .-200 ; 0x7e90 + } else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */ - 7f60: 81 35 cpi r24, 0x51 ; 81 - 7f62: 11 f4 brne .+4 ; 0x7f68 + 7f58: 81 35 cpi r24, 0x51 ; 81 + 7f5a: 11 f4 brne .+4 ; 0x7f60 + // Adaboot no-wait mod watchdogConfig(WATCHDOG_16MS); - 7f64: 88 e0 ldi r24, 0x08 ; 8 - 7f66: 17 d0 rcall .+46 ; 0x7f96 - 7f68: 1c d0 rcall .+56 ; 0x7fa2 + 7f5c: 88 e0 ldi r24, 0x08 ; 8 + 7f5e: 17 d0 rcall .+46 ; 0x7f8e + 7f60: 1c d0 rcall .+56 ; 0x7f9a verifySpace(); - 7f6a: 80 e1 ldi r24, 0x10 ; 16 - 7f6c: 01 d0 rcall .+2 ; 0x7f70 + } + else { + // This covers the response to commands like STK_ENTER_PROGMODE + verifySpace(); + 7f62: 80 e1 ldi r24, 0x10 ; 16 + 7f64: 01 d0 rcall .+2 ; 0x7f68 + } putch(STK_OK); - 7f6e: 85 cf rjmp .-246 ; 0x7e7a + 7f66: 89 cf rjmp .-238 ; 0x7e7a -00007f70 : - 7f70: 90 91 c0 00 lds r25, 0x00C0 ; 0x8000c0 <__TEXT_REGION_LENGTH__+0x7e00c0> +00007f68 : + 7f68: 90 91 c0 00 lds r25, 0x00C0 ; 0x8000c0 <__RAM__+0xc0> } - 7f74: 95 ff sbrs r25, 5 - while (!(UART_SRA & _BV(UDRE0))) { /* Spin */ } - 7f76: fc cf rjmp .-8 ; 0x7f70 + 7f6c: 95 ff sbrs r25, 5 + RS485_PORT |= _BV(RS485_BIT); +# else + RS485_PORT &= ~_BV(RS485_BIT); +# endif +#else //not RS485 + while (!(UART_SRA & _BV(UDRE0))) { /* Spin */ } + 7f6e: fc cf rjmp .-8 ; 0x7f68 UART_UDR = ch; - 7f78: 80 93 c6 00 sts 0x00C6, r24 ; 0x8000c6 <__TEXT_REGION_LENGTH__+0x7e00c6> - 7f7c: 08 95 ret + 7f70: 80 93 c6 00 sts 0x00C6, r24 ; 0x8000c6 <__RAM__+0xc6> + 7f74: 08 95 ret -00007f7e : - while(!(UART_SRA & _BV(RXC0))) { /* Spin */ } - 7f7e: 80 91 c0 00 lds r24, 0x00C0 ; 0x8000c0 <__TEXT_REGION_LENGTH__+0x7e00c0> - 7f82: 87 ff sbrs r24, 7 - 7f84: fc cf rjmp .-8 ; 0x7f7e +00007f76 : + : + "r25" + ); +#else +#ifndef LIN_UART + while (!(UART_SRA & _BV(RXC0))) { /* Spin */ } + 7f76: 80 91 c0 00 lds r24, 0x00C0 ; 0x8000c0 <__RAM__+0xc0> + 7f7a: 87 ff sbrs r24, 7 + 7f7c: fc cf rjmp .-8 ; 0x7f76 if (!(UART_SRA & _BV(FE0))) { - 7f86: 80 91 c0 00 lds r24, 0x00C0 ; 0x8000c0 <__TEXT_REGION_LENGTH__+0x7e00c0> - 7f8a: 84 fd sbrc r24, 4 - 7f8c: 01 c0 rjmp .+2 ; 0x7f90 + 7f7e: 80 91 c0 00 lds r24, 0x00C0 ; 0x8000c0 <__RAM__+0xc0> + 7f82: 84 fd sbrc r24, 4 + 7f84: 01 c0 rjmp .+2 ; 0x7f88 +} +#endif + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { __asm__ __volatile__ ( - 7f8e: a8 95 wdr + 7f86: a8 95 wdr + while (!(LINSIR & _BV(LRXOK))) { /* Spin */ } + if (!(LINSIR & _BV(LFERR))) { + watchdogReset(); /* Eventually abort if wrong speed */ + } +#endif ch = UART_UDR; - 7f90: 80 91 c6 00 lds r24, 0x00C6 ; 0x8000c6 <__TEXT_REGION_LENGTH__+0x7e00c6> -} - 7f94: 08 95 ret + 7f88: 80 91 c6 00 lds r24, 0x00C6 ; 0x8000c6 <__RAM__+0xc6> +#if LED_DATA_FLASH + toggle_led(); +#endif -00007f96 : + return ch; +} + 7f8c: 08 95 ret + +00007f8e : +} + +void watchdogConfig(uint8_t x) { +#ifdef WDCE //does it have a Watchdog Change Enable? +#ifdef WDTCSR WDTCSR = _BV(WDCE) | _BV(WDE); - 7f96: e0 e6 ldi r30, 0x60 ; 96 - 7f98: f0 e0 ldi r31, 0x00 ; 0 - 7f9a: 98 e1 ldi r25, 0x18 ; 24 - 7f9c: 90 83 st Z, r25 + 7f8e: e0 e6 ldi r30, 0x60 ; 96 + 7f90: f0 e0 ldi r31, 0x00 ; 0 + 7f92: 98 e1 ldi r25, 0x18 ; 24 + 7f94: 90 83 st Z, r25 +#else //then it must be one of those newfangled ones that use CCP + CCP=0xD8; //so write this magic number to CCP +#endif + +#ifdef WDTCSR WDTCSR = x; - 7f9e: 80 83 st Z, r24 - 7fa0: 08 95 ret + 7f96: 80 83 st Z, r24 + 7f98: 08 95 ret -00007fa2 : - if (getch() != CRC_EOP) { - 7fa2: ed df rcall .-38 ; 0x7f7e - 7fa4: 80 32 cpi r24, 0x20 ; 32 - 7fa6: 19 f0 breq .+6 ; 0x7fae - watchdogConfig(WATCHDOG_16MS); // shorten WD timeout - 7fa8: 88 e0 ldi r24, 0x08 ; 8 - 7faa: f5 df rcall .-22 ; 0x7f96 - 7fac: ff cf rjmp .-2 ; 0x7fac - putch(STK_INSYNC); - 7fae: 84 e1 ldi r24, 0x14 ; 20 - 7fb0: df cf rjmp .-66 ; 0x7f70 - -00007fb2 : -void getNch(uint8_t count) { - 7fb2: cf 93 push r28 - 7fb4: c8 2f mov r28, r24 +00007f9a : do getch(); while (--count); - 7fb6: e3 df rcall .-58 ; 0x7f7e - 7fb8: c1 50 subi r28, 0x01 ; 1 - 7fba: e9 f7 brne .-6 ; 0x7fb6 -} - 7fbc: cf 91 pop r28 verifySpace(); - 7fbe: f1 cf rjmp .-30 ; 0x7fa2 +} -00007fc0 : - 7fc0: fc 01 movw r30, r24 +void verifySpace() { + if (getch() != CRC_EOP) { + 7f9a: ed df rcall .-38 ; 0x7f76 + 7f9c: 80 32 cpi r24, 0x20 ; 32 + 7f9e: 19 f0 breq .+6 ; 0x7fa6 + watchdogConfig(WATCHDOG_16MS); // shorten WD timeout + 7fa0: 88 e0 ldi r24, 0x08 ; 8 + 7fa2: f5 df rcall .-22 ; 0x7f8e + 7fa4: ff cf rjmp .-2 ; 0x7fa4 + while (1) // and busy-loop so that WD causes + ; // a reset and app start. + } + putch(STK_INSYNC); + 7fa6: 84 e1 ldi r24, 0x14 ; 20 + 7fa8: df cf rjmp .-66 ; 0x7f68 + +00007faa : + ::[count] "M" (UART_B_VALUE) + ); +} +#endif + +void getNch(uint8_t count) { + 7faa: cf 93 push r28 + 7fac: c8 2f mov r28, r24 + do getch(); while (--count); + 7fae: e3 df rcall .-58 ; 0x7f76 + 7fb0: c1 50 subi r28, 0x01 ; 1 + 7fb2: e9 f7 brne .-6 ; 0x7fae + verifySpace(); +} + 7fb4: cf 91 pop r28 +} +#endif + +void getNch(uint8_t count) { + do getch(); while (--count); + verifySpace(); + 7fb6: f1 cf rjmp .-30 ; 0x7f9a + +00007fb8 : + 7fb8: fc 01 movw r30, r24 * data=0 in WRITE */ static void do_spm(uint16_t address, uint8_t command, uint16_t data) __attribute__ ((used)); static void do_spm(uint16_t address, uint8_t command, uint16_t data) { - // Do spm stuff - asm volatile ( - 7fc2: 0a 01 movw r0, r20 - 7fc4: 67 bf out 0x37, r22 ; 55 - 7fc6: e8 95 spm - 7fc8: 11 24 eor r1, r1 - 7fca: 07 b6 in r0, 0x37 ; 55 + // Do spm stuff + asm volatile ( + 7fba: 0a 01 movw r0, r20 + 7fbc: 67 bf out 0x37, r22 ; 55 + 7fbe: e8 95 spm + 7fc0: 11 24 eor r1, r1 + 7fc2: 07 b6 in r0, 0x37 ; 55 ); - // wait for spm to complete - // it doesn't have much sense for __BOOT_PAGE_FILL, - // but it doesn't hurt and saves some bytes on 'if' - boot_spm_busy_wait(); - 7fcc: 00 fc sbrc r0, 0 - 7fce: fd cf rjmp .-6 ; 0x7fca - 7fd0: 66 70 andi r22, 0x06 ; 6 + // wait for spm to complete + // it doesn't have much sense for __BOOT_PAGE_FILL, + // but it doesn't hurt and saves some bytes on 'if' + boot_spm_busy_wait(); + 7fc4: 00 fc sbrc r0, 0 + 7fc6: fd cf rjmp .-6 ; 0x7fc2 + 7fc8: 66 70 andi r22, 0x06 ; 6 #if defined(RWWSRE) - // this 'if' condition should be: (command == __BOOT_PAGE_WRITE || command == __BOOT_PAGE_ERASE)... - // but it's tweaked a little assuming that in every command we are interested in here, there - // must be also SELFPRGEN set. If we skip checking this bit, we save here 4B - if ((command & (_BV(PGWRT)|_BV(PGERS))) && (data == 0) ) { - 7fd2: 29 f0 breq .+10 ; 0x7fde - 7fd4: 45 2b or r20, r21 - 7fd6: 19 f4 brne .+6 ; 0x7fde - 7fd8: 81 e1 ldi r24, 0x11 ; 17 - // Reenable read access to flash - __boot_rww_enable_short(); - 7fda: 87 bf out 0x37, r24 ; 55 - 7fdc: e8 95 spm - 7fde: 08 95 ret + // this 'if' condition should be: (command == __BOOT_PAGE_WRITE || command == __BOOT_PAGE_ERASE)... + // but it's tweaked a little assuming that in every command we are interested in here, there + // must be also SELFPRGEN set. If we skip checking this bit, we save here 4B + if ((command & (_BV(PGWRT)|_BV(PGERS))) && (data == 0) ) { + 7fca: 29 f0 breq .+10 ; 0x7fd6 + 7fcc: 45 2b or r20, r21 + 7fce: 19 f4 brne .+6 ; 0x7fd6 + 7fd0: 81 e1 ldi r24, 0x11 ; 17 + // Reenable read access to flash + __boot_rww_enable_short(); + 7fd2: 87 bf out 0x37, r24 ; 55 + 7fd4: e8 95 spm + 7fd6: 08 95 ret diff --git a/optiboot/bootloaders/optiboot/optiboot_atmega644p.hex b/optiboot/bootloaders/optiboot/optiboot_atmega644p.hex index 90c43e9..c3ec7e3 100644 --- a/optiboot/bootloaders/optiboot/optiboot_atmega644p.hex +++ b/optiboot/bootloaders/optiboot/optiboot_atmega644p.hex @@ -1,52 +1,50 @@ -:10FC000001C00DC1112484B7882361F0982F9A7028 +:10FC000001C009C1112484B7882361F0982F9A702C :10FC1000923041F081FF02C097EF94BF282E80E020 -:10FC2000E9D0EEC185E08093810082E08093C0003E +:10FC2000E5D0EEC185E08093810082E08093C00042 :10FC300088E18093C10086E08093C20080E18093D8 -:10FC4000C4008EE0D7D0209A86E020E33CEF91E01C +:10FC4000C4008EE0D3D0209A86E020E33CEF91E020 :10FC5000309385002093840096BBB09BFECF189A0A :10FC6000A8954091C00047FD02C0815089F7FF244C -:10FC7000F39455E0E52E61E1D62EB0D0813471F4D5 -:10FC8000ADD0C82FBDD0C23811F481E005C0C13855 -:10FC900011F488E001C083E09AD096C0823411F458 -:10FCA00084E103C0853419F485E0B2D08DC0853578 -:10FCB00039F494D0082F92D0182F000F111F83C051 -:10FCC000863521F484E0A4D080E0E6CF843609F0C4 -:10FCD00048C084D0C82FD0E0DC2FCC277FD0C82BE1 -:10FCE0007DD0C82E5E01812C9924939477D0F401A5 -:10FCF00081934F01F1E0AF1AB108C1F781D085E4DB -:10FD0000C81212C0D3954801A12CBB24B394AC16E1 -:10FD1000BD0609F459C0F50161915F01C40197D096 -:10FD2000FFEF8F1A9F0AF3CF83E0F80187BFE895B2 -:10FD300007B600FCFDCFA0E0B1E0F8018D919D91E8 -:10FD40000C01F7BEE8951124229732962097B1F75F -:10FD5000F801E7BEE89507B600FCFDCFD7BEE895F1 -:10FD600033C0843719F53AD0C82FD0E0DC2FCC2728 -:10FD700035D05E01A82A32D0982E42D0E801F5E4B1 -:10FD80009F120BC0CE015BD022D081E0A81AB1082F -:10FD90002196A114B104B1F717C0FE018591EF01BE -:10FDA00016D0E1E0AE1AB108C1F70EC0853739F4BC -:10FDB00027D08EE10CD086E90AD08AE06DCF81355C -:10FDC00011F488E017D01CD080E101D056CF90917B -:10FDD000C00095FFFCCF8093C60008958091C000BD -:10FDE00087FFFCCF8091C00084FD01C0A895809161 -:10FDF000C6000895E0E6F0E098E1908380830895DE -:10FE0000EDDF803219F088E0F5DFFFCF84E1DFCF4E -:10FE1000CF93C82FE3DFC150E9F7CF91F1CFFC01B9 -:10FE20000A0167BFE895112407B600FCFDCF667094 -:10FE300029F0452B19F481E187BFE8950895F999D8 -:10FE4000FECF92BD81BDF89A992780B50895262FDF -:10FE5000F999FECF1FBA92BD81BD20BD0FB6F894AF -:10FE6000FA9AF99A0FBE0196089556657273696FF2 -:10FE70006E3D382E31004F505449424F4F545F432E -:10FE80005553544F4D5645523D3000446576696395 -:10FE9000653D61746D6567613634347000465F435B -:10FEA00050553D31363030303030304C00424947CB -:10FEB000424F4F543D31004275696C743A4D61793F -:10FEC00020323920323032303A30313A30323A3220 -:10FED0003600554152543D3000424155445F524135 -:10FEE00054453D313135323030004C45443D42308F -:10FEF000004C45445F53544152545F464C41534873 -:05FF000045533D3300F4 -:02FFFE000108F8 +:10FC7000F39455E0E52E61E1D62EACD0813451F4F9 +:10FC8000A9D0C82FB9D0C13811F083E001C088E0F5 +:10FC90009AD096C0823411F484E103C0853419F4FB +:10FCA00085E0B2D08DC0853539F494D0082F92D03C +:10FCB000182F000F111F83C0863521F484E0A4D0D3 +:10FCC00080E0E6CF843609F048C084D0C82FD0E069 +:10FCD000DC2FCC277FD0C82B7DD0C82E5E01812C95 +:10FCE0009924939477D0F40181934F01F1E0AF1AF6 +:10FCF000B108C1F781D085E4C81212C0D39548017C +:10FD0000A12CBB24B394AC16BD0609F459C0F5016F +:10FD100061915F01C40197D0FFEF8F1A9F0AF3CF63 +:10FD200083E0F80187BFE89507B600FCFDCFA0E0AF +:10FD3000B1E0F8018D919D910C01F7BEE895112479 +:10FD4000229732962097B1F7F801E7BEE89507B6FB +:10FD500000FCFDCFD7BEE89533C0843719F53AD003 +:10FD6000C82FD0E0DC2FCC2735D05E01A82A32D0B6 +:10FD7000982E42D0E801F5E49F120BC0CE015BD073 +:10FD800022D081E0A81AB1082196A114B104B1F7DC +:10FD900017C0FE018591EF0116D0E1E0AE1AB1085F +:10FDA000C1F70EC0853739F427D08EE10CD086E933 +:10FDB0000AD08AE06DCF813511F488E017D01CD0CD +:10FDC00080E101D05ACF9091C00095FFFCCF809385 +:10FDD000C60008958091C00087FFFCCF8091C000CD +:10FDE00084FD01C0A8958091C6000895E0E6F0E08A +:10FDF00098E1908380830895EDDF803219F088E0E8 +:10FE0000F5DFFFCF84E1DFCFCF93C82FE3DFC15011 +:10FE1000E9F7CF91F1CFFC010A0167BFE895112402 +:10FE200007B600FCFDCF667029F0452B19F481E17F +:10FE300087BFE8950895F999FECF92BD81BDF89AE4 +:10FE4000992780B50895262FF999FECF1FBA92BD44 +:10FE500081BD20BD0FB6F894FA9AF99A0FBE0196AB +:10FE60000895FF56657273696F6E3D382E330044F6 +:10FE700065766963653D61746D65676136343470BC +:10FE800000465F4350553D31363030303030304CD5 +:10FE900000424947424F4F543D31004275696C74EE +:10FEA0003A4E6F7620203420323032313A31383AAF +:10FEB00030333A313400554152543D3000424155BF +:10FEC000445F524154453D313135323030004C456C +:10FED000443D4230004C45445F53544152545F46C8 +:09FEE0004C41534845533D3300E9 +:02FFFE000308F6 :040000030000FC00FD :00000001FF diff --git a/optiboot/bootloaders/optiboot/optiboot_atmega644p.lst b/optiboot/bootloaders/optiboot/optiboot_atmega644p.lst index 2b5ad90..b0ebd6b 100644 --- a/optiboot/bootloaders/optiboot/optiboot_atmega644p.lst +++ b/optiboot/bootloaders/optiboot/optiboot_atmega644p.lst @@ -3,29 +3,29 @@ optiboot_atmega644p.elf: file format elf32-avr Sections: Idx Name Size VMA LMA File off Algn - 0 .data 00000000 00800100 0000ff05 00000399 2**0 - CONTENTS, ALLOC, LOAD, DATA - 1 .text 00000305 0000fc00 0000fc00 00000094 2**1 + 0 .text 000002e9 0000fc00 0000fc00 00000094 2**0 CONTENTS, ALLOC, LOAD, READONLY, CODE - 2 .version 00000002 0000fffe 0000fffe 00000399 2**0 + 1 .trampolines 00000000 0000feea 0000feea 0000037e 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 2 .version 00000002 0000fffe 0000fffe 0000037e 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA - 3 .comment 0000002f 00000000 00000000 0000039b 2**0 + 3 .comment 0000002f 00000000 00000000 00000380 2**0 CONTENTS, READONLY - 4 .debug_aranges 00000030 00000000 00000000 000003ca 2**0 + 4 .debug_aranges 00000030 00000000 00000000 000003af 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_info 000007db 00000000 00000000 000003fa 2**0 + 5 .debug_info 00000805 00000000 00000000 000003df 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_abbrev 000002c5 00000000 00000000 00000bd5 2**0 + 6 .debug_abbrev 000002ea 00000000 00000000 00000be4 2**0 CONTENTS, READONLY, DEBUGGING - 7 .debug_line 000003a1 00000000 00000000 00000e9a 2**0 + 7 .debug_line 000003a9 00000000 00000000 00000ece 2**0 CONTENTS, READONLY, DEBUGGING - 8 .debug_frame 0000009c 00000000 00000000 0000123c 2**2 + 8 .debug_frame 000000ac 00000000 00000000 00001278 2**2 CONTENTS, READONLY, DEBUGGING - 9 .debug_str 0000028b 00000000 00000000 000012d8 2**0 + 9 .debug_str 000002a1 00000000 00000000 00001324 2**0 CONTENTS, READONLY, DEBUGGING - 10 .debug_loc 00000449 00000000 00000000 00001563 2**0 + 10 .debug_loc 00000449 00000000 00000000 000015c5 2**0 CONTENTS, READONLY, DEBUGGING - 11 .debug_ranges 00000080 00000000 00000000 000019ac 2**0 + 11 .debug_ranges 00000068 00000000 00000000 00001a0e 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: @@ -33,12 +33,12 @@ Disassembly of section .text: 0000fc00 : /* everything that needs to run VERY early */ void pre_main(void) { - // Allow convenient way of calling do_spm function - jump table, - // so entry to this function will always be here, indepedent of compilation, - // features etc + // Allow convenient way of calling do_spm function - jump table, so + // entry to this function will always be here, independent of + // compilation, features etc asm volatile ( fc00: 01 c0 rjmp .+2 ; 0xfc04
- fc02: 0d c1 rjmp .+538 ; 0xfe1e + fc02: 09 c1 rjmp .+530 ; 0xfe16 0000fc04
: // SP points to RAMEND @@ -46,121 +46,125 @@ void pre_main(void) { // // If not, uncomment the following instructions: // cli(); - asm volatile ("clr __zero_reg__"); + asm volatile (" clr __zero_reg__"); fc04: 11 24 eor r1, r1 -#if defined(__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) || \ - defined(__AVR_ATmega16__) || defined(__AVR_ATmega162__) || \ - defined (__AVR_ATmega128__) - ch = MCUCSR; -#else +# warning "START_APP_ON_EXTR is defined and NO_START_APP_ON_POR isn't" +# define APP_START_REASONS 1 /* Always start rge App. */ +# define WDRF_CLR_REASONS 0 /* Never clear WDRF */ +#endif + ch = MCUSR; fc06: 84 b7 in r24, 0x34 ; 52 -#endif + // Skip all logic and run bootloader if MCUSR is cleared (application request) if (ch != 0) { fc08: 88 23 and r24, r24 fc0a: 61 f0 breq .+24 ; 0xfc24 - * 2. we clear WDRF if it's set with EXTRF to avoid loops - * One problematic scenario: broken application code sets watchdog timer - * without clearing MCUSR before and triggers it quickly. But it's - * recoverable by power-on with pushed reset button. - */ - if ((ch & (_BV(WDRF) | _BV(EXTRF))) != _BV(EXTRF)) { + * One problematic scenario: broken application code sets watchdog timer + * without clearing MCUSR before and triggers it quickly. But it's + * recoverable by power-on with pushed reset button. + */ + + if (APP_START_REASONS) { fc0c: 98 2f mov r25, r24 fc0e: 9a 70 andi r25, 0x0A ; 10 fc10: 92 30 cpi r25, 0x02 ; 2 fc12: 41 f0 breq .+16 ; 0xfc24 - if (ch & _BV(EXTRF)) { + if (WDRF_CLR_REASONS) { fc14: 81 ff sbrs r24, 1 fc16: 02 c0 rjmp .+4 ; 0xfc1c - defined(__AVR_ATmega16__) || defined(__AVR_ATmega162__) || \ - defined(__AVR_ATmega128__) - // Fix missing definitions in avr-libc - MCUCSR = ~(_BV(WDRF)); -#else - MCUSR = ~(_BV(WDRF)); + /* + * Clear WDRF if it was most probably set by wdr in bootloader. + */ + if ((uint16_t)&MCUSR > 0x1F) { + MCUSR = ~(_BV(WDRF)); // optimize to LDI/OUT fc18: 97 ef ldi r25, 0xF7 ; 247 fc1a: 94 bf out 0x34, r25 ; 52 - /* - * save the reset flags in the designated register - * This can be saved in a main program by putting code in .init0 (which - * executes before normal c init code) to save R2 to a global variable. - */ - __asm__ __volatile__ ("mov r2, %0\n" :: "r" (ch)); + /* + * save the reset flags in the designated register + * This can be saved in a main program by putting code in .init0 (which + * executes before normal c init code) to save R2 to a global variable. + */ + __asm__ __volatile__ (" mov r2, %0\n" :: "r" (ch)); fc1c: 28 2e mov r2, r24 - // switch off watchdog - watchdogConfig(WATCHDOG_OFF); + // switch off watchdog + watchdogConfig(WATCHDOG_OFF); fc1e: 80 e0 ldi r24, 0x00 ; 0 - fc20: e9 d0 rcall .+466 ; 0xfdf4 - // Note that appstart_vec is defined so that this works with either - // real or virtual boot partitions. - __asm__ __volatile__ ( - fc22: ee c1 rjmp .+988 ; 0x10000 <__EEPROM_REGION_LENGTH__> + fc20: e5 d0 rcall .+458 ; 0xfdec + // Note that appstart_vec is defined so that this works with either + // real or virtual boot partitions. + __asm__ __volatile__ ( + fc22: ee c1 rjmp .+988 ; 0x10000 <__VERSION_START__+0x2> #elif defined(__AVR_ATtiny25__)||defined(__AVR_ATtiny45__)||defined(__AVR_ATtiny85__) - TCCR1 = 0x0E; //div 8196 - it's an 8-bit timer. + TCCR1 = 0x0E; //div 8196 - it's an 8-bit timer. #elif defined(__AVR_ATtiny43__) - #error "LED flash for Tiny43 not yet supported" +#error "LED flash for Tiny43 not yet supported" #else TCCR1B = _BV(CS12) | _BV(CS10); // div 1024 fc24: 85 e0 ldi r24, 0x05 ; 5 - fc26: 80 93 81 00 sts 0x0081, r24 ; 0x800081 <__TEXT_REGION_LENGTH__+0x7e0081> + fc26: 80 93 81 00 sts 0x0081, r24 ; 0x800081 <__RAM__+0x81> LINBTR = (1 << LDISR) | (8 << LBT0); - LINCR = _BV(LENA) | _BV(LCMD2) | _BV(LCMD1) | _BV(LCMD0); + LINCR = _BV(LENA) | _BV(LCMD2) | _BV(LCMD1) | _BV(LCMD0); LINDAT=0; - #else - #ifndef SINGLESPEED +#else +#if (SINGLESPEED == 0) UART_SRA = _BV(U2X0); //Double speed mode USART0 fc2a: 82 e0 ldi r24, 0x02 ; 2 - fc2c: 80 93 c0 00 sts 0x00C0, r24 ; 0x8000c0 <__TEXT_REGION_LENGTH__+0x7e00c0> - #endif + fc2c: 80 93 c0 00 sts 0x00C0, r24 ; 0x8000c0 <__RAM__+0xc0> +#endif UART_SRB = _BV(RXEN0) | _BV(TXEN0); fc30: 88 e1 ldi r24, 0x18 ; 24 - fc32: 80 93 c1 00 sts 0x00C1, r24 ; 0x8000c1 <__TEXT_REGION_LENGTH__+0x7e00c1> + fc32: 80 93 c1 00 sts 0x00C1, r24 ; 0x8000c1 <__RAM__+0xc1> UART_SRC = _BV(UCSZ00) | _BV(UCSZ01); fc36: 86 e0 ldi r24, 0x06 ; 6 - fc38: 80 93 c2 00 sts 0x00C2, r24 ; 0x8000c2 <__TEXT_REGION_LENGTH__+0x7e00c2> + fc38: 80 93 c2 00 sts 0x00C2, r24 ; 0x8000c2 <__RAM__+0xc2> UART_SRL = (uint8_t)BAUD_SETTING; fc3c: 80 e1 ldi r24, 0x10 ; 16 - fc3e: 80 93 c4 00 sts 0x00C4, r24 ; 0x8000c4 <__TEXT_REGION_LENGTH__+0x7e00c4> - #endif // LIN_UART - #endif // mega8/etc -#endif // soft_uart + fc3e: 80 93 c4 00 sts 0x00C4, r24 ; 0x8000c4 <__RAM__+0xc4> + RS485_PORT &= ~_BV(RS485_BIT); + #endif +#endif // Set up watchdog to trigger after desired timeout watchdogConfig(WDTPERIOD); fc42: 8e e0 ldi r24, 0x0E ; 14 - fc44: d7 d0 rcall .+430 ; 0xfdf4 + fc44: d3 d0 rcall .+422 ; 0xfdec -#if (LED_START_FLASHES > 0) || defined(LED_DATA_FLASH) || defined(LED_START_ON) +#if (LED_START_FLASHES > 0) || LED_DATA_FLASH || LED_START_ON /* Set LED pin as output */ LED_DDR |= _BV(LED); fc46: 20 9a sbi 0x04, 0 ; 4 fc48: 86 e0 ldi r24, 0x06 ; 6 - TIFR = _BV(TOV1); - while(!(TIFR & _BV(TOV1))); - #elif defined(__AVR_ATtiny43__) - #error "LED flash for Tiny43 not yet supported" - #else - TCNT1 = -(F_CPU/(1024*16)); + TIFR = _BV(TOV1); + while (!(TIFR & _BV(TOV1))); +#elif defined(__AVR_ATtiny43__) +#error "LED flash for Tiny43 not yet supported" +#else + TCNT1 = -(F_CPU/(1024*16)); fc4a: 20 e3 ldi r18, 0x30 ; 48 fc4c: 3c ef ldi r19, 0xFC ; 252 - TIFR1 = _BV(TOV1); + TIFR1 = _BV(TOV1); fc4e: 91 e0 ldi r25, 0x01 ; 1 - TCNT1 = -(F_CPU/(1024*16)); - fc50: 30 93 85 00 sts 0x0085, r19 ; 0x800085 <__TEXT_REGION_LENGTH__+0x7e0085> - fc54: 20 93 84 00 sts 0x0084, r18 ; 0x800084 <__TEXT_REGION_LENGTH__+0x7e0084> - TIFR1 = _BV(TOV1); + TIFR = _BV(TOV1); + while (!(TIFR & _BV(TOV1))); +#elif defined(__AVR_ATtiny43__) +#error "LED flash for Tiny43 not yet supported" +#else + TCNT1 = -(F_CPU/(1024*16)); + fc50: 30 93 85 00 sts 0x0085, r19 ; 0x800085 <__RAM__+0x85> + fc54: 20 93 84 00 sts 0x0084, r18 ; 0x800084 <__RAM__+0x84> + TIFR1 = _BV(TOV1); fc58: 96 bb out 0x16, r25 ; 22 - while(!(TIFR1 & _BV(TOV1))); + while (!(TIFR1 & _BV(TOV1))); fc5a: b0 9b sbis 0x16, 0 ; 22 fc5c: fe cf rjmp .-4 ; 0xfc5a - defined(__AVR_ATmega8535__) || defined(__AVR_ATmega16__) || \ - defined(__AVR_ATmega162__) || defined(__AVR_ATmega32__) || \ - defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) - LED_PORT ^= _BV(LED); + defined(__AVR_ATmega8535__) || defined(__AVR_ATmega16__) || \ + defined(__AVR_ATmega162__) || defined(__AVR_ATmega32__) || \ + defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) + LED_PORT ^= _BV(LED); #else - LED_PIN |= _BV(LED); + LED_PIN |= _BV(LED); // Newer AVRs can toggle by writing PINx fc5e: 18 9a sbi 0x03, 0 ; 3 } #endif @@ -169,430 +173,596 @@ void pre_main(void) { void watchdogReset() { __asm__ __volatile__ ( fc60: a8 95 wdr + * by the UART hardware, avrdude sends several attempts in rather + * quick succession, some of which will be lost and cause us to + * get out of sync. So if we see any data; stop blinking. + */ +#ifndef LIN_UART if (UART_SRA & _BV(RXC0)) - fc62: 40 91 c0 00 lds r20, 0x00C0 ; 0x8000c0 <__TEXT_REGION_LENGTH__+0x7e00c0> + fc62: 40 91 c0 00 lds r20, 0x00C0 ; 0x8000c0 <__RAM__+0xc0> fc66: 47 fd sbrc r20, 7 fc68: 02 c0 rjmp .+4 ; 0xfc6e fc6a: 81 50 subi r24, 0x01 ; 1 +#else +// This doesn't seem to work? +// if ((UART_PIN & (1< - putch(optiboot_version & 0xFF); + + /* + * Copy data from the buffer into the flash write buffer. + */ + do { + __boot_page_fill_short((uint16_t)(void*)addrPtr, *(mybuff.wptr++)); fc6e: ff 24 eor r15, r15 fc70: f3 94 inc r15 - } while (len -= 2); + } while (len -= 2); - /* - * Actually Write the buffer to flash (and wait for it to finish.) - */ - __boot_page_write_short(address.word); + /* + * Actually Write the buffer to flash (and wait for it to finish.) + */ + __boot_page_write_short(address.word); fc72: 55 e0 ldi r21, 0x05 ; 5 fc74: e5 2e mov r14, r21 - boot_spm_busy_wait(); + boot_spm_busy_wait(); #if defined(RWWSRE) - // Reenable read access to flash - __boot_rww_enable_short(); + // Reenable read access to flash + __boot_rww_enable_short(); fc76: 61 e1 ldi r22, 0x11 ; 17 +#endif + + /* Forever loop: exits by causing WDT reset */ + for (;;) { + /* get character from UART */ ch = getch(); fc78: d6 2e mov r13, r22 - if(ch == STK_GET_PARAMETER) { - fc7a: b0 d0 rcall .+352 ; 0xfddc + + if (ch == STK_GET_PARAMETER) { + fc7a: ac d0 rcall .+344 ; 0xfdd4 unsigned char which = getch(); fc7c: 81 34 cpi r24, 0x41 ; 65 - fc7e: 71 f4 brne .+28 ; 0xfc9c - fc80: ad d0 rcall .+346 ; 0xfddc + fc7e: 51 f4 brne .+20 ; 0xfc94 + fc80: a9 d0 rcall .+338 ; 0xfdd4 verifySpace(); fc82: c8 2f mov r28, r24 - fc84: bd d0 rcall .+378 ; 0xfe00 + fc84: b9 d0 rcall .+370 ; 0xfdf8 + * Send optiboot version as "SW version" + * Note that the references to memory are optimized away. + */ if (which == STK_SW_MINOR) { - fc86: c2 38 cpi r28, 0x82 ; 130 - fc88: 11 f4 brne .+4 ; 0xfc8e - putch(optiboot_version & 0xFF); - fc8a: 81 e0 ldi r24, 0x01 ; 1 - fc8c: 05 c0 rjmp .+10 ; 0xfc98 + putch(optiboot_version & 0xFF); } else if (which == STK_SW_MAJOR) { - fc8e: c1 38 cpi r28, 0x81 ; 129 - putch(optiboot_version >> 8); - fc90: 11 f4 brne .+4 ; 0xfc96 - fc92: 88 e0 ldi r24, 0x08 ; 8 - putch(0x03); - fc94: 01 c0 rjmp .+2 ; 0xfc98 - fc96: 83 e0 ldi r24, 0x03 ; 3 - fc98: 9a d0 rcall .+308 ; 0xfdce - fc9a: 96 c0 rjmp .+300 ; 0xfdc8 - else if(ch == STK_SET_DEVICE) { - fc9c: 82 34 cpi r24, 0x42 ; 66 + fc86: c1 38 cpi r28, 0x81 ; 129 + /* + * Send optiboot version as "SW version" + * Note that the references to memory are optimized away. + */ + if (which == STK_SW_MINOR) { + putch(optiboot_version & 0xFF); + fc88: 11 f0 breq .+4 ; 0xfc8e + fc8a: 83 e0 ldi r24, 0x03 ; 3 + } else if (which == STK_SW_MAJOR) { + putch(optiboot_version >> 8); + fc8c: 01 c0 rjmp .+2 ; 0xfc90 + fc8e: 88 e0 ldi r24, 0x08 ; 8 + fc90: 9a d0 rcall .+308 ; 0xfdc6 + fc92: 96 c0 rjmp .+300 ; 0xfdc0 + * other parameters - enough to keep Avrdude happy + */ + putch(0x03); + } + } + else if (ch == STK_SET_DEVICE) { + fc94: 82 34 cpi r24, 0x42 ; 66 + // SET DEVICE is ignored getNch(20); - fc9e: 11 f4 brne .+4 ; 0xfca4 - fca0: 84 e1 ldi r24, 0x14 ; 20 - else if(ch == STK_SET_DEVICE_EXT) { - fca2: 03 c0 rjmp .+6 ; 0xfcaa + fc96: 11 f4 brne .+4 ; 0xfc9c + fc98: 84 e1 ldi r24, 0x14 ; 20 + } + else if (ch == STK_SET_DEVICE_EXT) { + fc9a: 03 c0 rjmp .+6 ; 0xfca2 + // SET DEVICE EXT is ignored getNch(5); - fca4: 85 34 cpi r24, 0x45 ; 69 - fca6: 19 f4 brne .+6 ; 0xfcae - fca8: 85 e0 ldi r24, 0x05 ; 5 - else if(ch == STK_LOAD_ADDRESS) { - fcaa: b2 d0 rcall .+356 ; 0xfe10 - fcac: 8d c0 rjmp .+282 ; 0xfdc8 + fc9c: 85 34 cpi r24, 0x45 ; 69 + fc9e: 19 f4 brne .+6 ; 0xfca6 + fca0: 85 e0 ldi r24, 0x05 ; 5 + } + else if (ch == STK_LOAD_ADDRESS) { + fca2: b2 d0 rcall .+356 ; 0xfe08 + fca4: 8d c0 rjmp .+282 ; 0xfdc0 + // LOAD ADDRESS address.bytes[0] = getch(); - fcae: 85 35 cpi r24, 0x55 ; 85 - fcb0: 39 f4 brne .+14 ; 0xfcc0 - fcb2: 94 d0 rcall .+296 ; 0xfddc + fca6: 85 35 cpi r24, 0x55 ; 85 + fca8: 39 f4 brne .+14 ; 0xfcb8 + fcaa: 94 d0 rcall .+296 ; 0xfdd4 address.bytes[1] = getch(); - fcb4: 08 2f mov r16, r24 - fcb6: 92 d0 rcall .+292 ; 0xfddc + fcac: 08 2f mov r16, r24 + fcae: 92 d0 rcall .+292 ; 0xfdd4 + } + else { + RAMPZ &= 0xFE; + } +#endif address.word *= 2; // Convert from word address to byte address - fcb8: 18 2f mov r17, r24 - fcba: 00 0f add r16, r16 - fcbc: 11 1f adc r17, r17 - else if(ch == STK_UNIVERSAL) { - fcbe: 83 c0 rjmp .+262 ; 0xfdc6 + fcb0: 18 2f mov r17, r24 + fcb2: 00 0f add r16, r16 + fcb4: 11 1f adc r17, r17 + verifySpace(); + } + else if (ch == STK_UNIVERSAL) { + fcb6: 83 c0 rjmp .+262 ; 0xfdbe + getNch(3); + putch(0x00); + } +#else + // UNIVERSAL command is ignored getNch(4); - fcc0: 86 35 cpi r24, 0x56 ; 86 - fcc2: 21 f4 brne .+8 ; 0xfccc - fcc4: 84 e0 ldi r24, 0x04 ; 4 + fcb8: 86 35 cpi r24, 0x56 ; 86 + fcba: 21 f4 brne .+8 ; 0xfcc4 + fcbc: 84 e0 ldi r24, 0x04 ; 4 putch(0x00); - fcc6: a4 d0 rcall .+328 ; 0xfe10 - else if(ch == STK_PROG_PAGE) { - fcc8: 80 e0 ldi r24, 0x00 ; 0 - fcca: e6 cf rjmp .-52 ; 0xfc98 + fcbe: a4 d0 rcall .+328 ; 0xfe08 +#endif + } + /* Write memory, length is big endian and is in bytes */ + else if (ch == STK_PROG_PAGE) { + fcc0: 80 e0 ldi r24, 0x00 ; 0 + fcc2: e6 cf rjmp .-52 ; 0xfc90 + // PROGRAM PAGE - we support flash programming only, not EEPROM + uint8_t desttype; + uint8_t *bufPtr; + pagelen_t savelength; + GETLENGTH(length); - fccc: 84 36 cpi r24, 0x64 ; 100 - fcce: 09 f0 breq .+2 ; 0xfcd2 - fcd0: 48 c0 rjmp .+144 ; 0xfd62 - fcd2: 84 d0 rcall .+264 ; 0xfddc - fcd4: c8 2f mov r28, r24 - fcd6: d0 e0 ldi r29, 0x00 ; 0 - fcd8: dc 2f mov r29, r28 - fcda: cc 27 eor r28, r28 + fcc4: 84 36 cpi r24, 0x64 ; 100 + fcc6: 09 f0 breq .+2 ; 0xfcca + fcc8: 48 c0 rjmp .+144 ; 0xfd5a + fcca: 84 d0 rcall .+264 ; 0xfdd4 + fccc: c8 2f mov r28, r24 + fcce: d0 e0 ldi r29, 0x00 ; 0 + fcd0: dc 2f mov r29, r28 + fcd2: cc 27 eor r28, r28 + savelength = length; desttype = getch(); - fcdc: 7f d0 rcall .+254 ; 0xfddc - fcde: c8 2b or r28, r24 + fcd4: 7f d0 rcall .+254 ; 0xfdd4 + fcd6: c8 2b or r28, r24 + // PROGRAM PAGE - we support flash programming only, not EEPROM + uint8_t desttype; + uint8_t *bufPtr; + pagelen_t savelength; + GETLENGTH(length); - fce0: 7d d0 rcall .+250 ; 0xfddc + fcd8: 7d d0 rcall .+250 ; 0xfdd4 + savelength = length; desttype = getch(); - fce2: c8 2e mov r12, r24 - fce4: 5e 01 movw r10, r28 - fce6: 81 2c mov r8, r1 + fcda: c8 2e mov r12, r24 + fcdc: 5e 01 movw r10, r28 + fcde: 81 2c mov r8, r1 + + // read a page worth of contents + bufPtr = buff.bptr; do *bufPtr++ = getch(); - fce8: 99 24 eor r9, r9 - fcea: 93 94 inc r9 - fcec: 77 d0 rcall .+238 ; 0xfddc - fcee: f4 01 movw r30, r8 - fcf0: 81 93 st Z+, r24 + fce0: 99 24 eor r9, r9 + fce2: 93 94 inc r9 + fce4: 77 d0 rcall .+238 ; 0xfdd4 + fce6: f4 01 movw r30, r8 + fce8: 81 93 st Z+, r24 while (--length); - fcf2: 4f 01 movw r8, r30 - fcf4: f1 e0 ldi r31, 0x01 ; 1 - fcf6: af 1a sub r10, r31 - fcf8: b1 08 sbc r11, r1 + fcea: 4f 01 movw r8, r30 + fcec: f1 e0 ldi r31, 0x01 ; 1 + fcee: af 1a sub r10, r31 + fcf0: b1 08 sbc r11, r1 + + // Read command terminator, start reply verifySpace(); - fcfa: c1 f7 brne .-16 ; 0xfcec - fcfc: 81 d0 rcall .+258 ; 0xfe00 - switch (memtype) { - fcfe: 85 e4 ldi r24, 0x45 ; 69 - fd00: c8 12 cpse r12, r24 - fd02: 12 c0 rjmp .+36 ; 0xfd28 - fd04: d3 95 inc r29 - fd06: 48 01 movw r8, r16 - fd08: a1 2c mov r10, r1 - fd0a: bb 24 eor r11, r11 - while(len--) { - fd0c: b3 94 inc r11 - fd0e: ac 16 cp r10, r28 - fd10: bd 06 cpc r11, r29 - fd12: 09 f4 brne .+2 ; 0xfd16 - eeprom_write_byte((address.bptr++), *(mybuff.bptr++)); - fd14: 59 c0 rjmp .+178 ; 0xfdc8 - fd16: f5 01 movw r30, r10 - fd18: 61 91 ld r22, Z+ - fd1a: 5f 01 movw r10, r30 - fd1c: c4 01 movw r24, r8 - fd1e: 97 d0 rcall .+302 ; 0xfe4e - fd20: ff ef ldi r31, 0xFF ; 255 - fd22: 8f 1a sub r8, r31 - fd24: 9f 0a sbc r9, r31 - fd26: f3 cf rjmp .-26 ; 0xfd0e - __boot_page_erase_short(address.word); - fd28: 83 e0 ldi r24, 0x03 ; 3 - fd2a: f8 01 movw r30, r16 - fd2c: 87 bf out 0x37, r24 ; 55 - fd2e: e8 95 spm - boot_spm_busy_wait(); - fd30: 07 b6 in r0, 0x37 ; 55 - fd32: 00 fc sbrc r0, 0 - fd34: fd cf rjmp .-6 ; 0xfd30 - fd36: a0 e0 ldi r26, 0x00 ; 0 - fd38: b1 e0 ldi r27, 0x01 ; 1 - fd3a: f8 01 movw r30, r16 - __boot_page_fill_short((uint16_t)(void*)addrPtr, *(mybuff.wptr++)); - fd3c: 8d 91 ld r24, X+ - fd3e: 9d 91 ld r25, X+ - fd40: 0c 01 movw r0, r24 - fd42: f7 be out 0x37, r15 ; 55 - fd44: e8 95 spm - } while (len -= 2); - fd46: 11 24 eor r1, r1 - fd48: 22 97 sbiw r28, 0x02 ; 2 - fd4a: 32 96 adiw r30, 0x02 ; 2 - fd4c: 20 97 sbiw r28, 0x00 ; 0 - __boot_page_write_short(address.word); - fd4e: b1 f7 brne .-20 ; 0xfd3c - fd50: f8 01 movw r30, r16 - boot_spm_busy_wait(); - fd52: e7 be out 0x37, r14 ; 55 - fd54: e8 95 spm - __boot_rww_enable_short(); - fd56: 07 b6 in r0, 0x37 ; 55 - fd58: 00 fc sbrc r0, 0 - fd5a: fd cf rjmp .-6 ; 0xfd56 - else if(ch == STK_READ_PAGE) { - fd5c: d7 be out 0x37, r13 ; 55 - fd5e: e8 95 spm + fcf2: c1 f7 brne .-16 ; 0xfce4 + fcf4: 81 d0 rcall .+258 ; 0xfdf8 + * void writebuffer(memtype, buffer, address, length) + */ +static inline void writebuffer(int8_t memtype, addr16_t mybuff, + addr16_t address, pagelen_t len) +{ + switch (memtype) { + fcf6: 85 e4 ldi r24, 0x45 ; 69 + fcf8: c8 12 cpse r12, r24 + fcfa: 12 c0 rjmp .+36 ; 0xfd20 + fcfc: d3 95 inc r29 + fcfe: 48 01 movw r8, r16 + fd00: a1 2c mov r10, r1 + fd02: bb 24 eor r11, r11 + case 'E': // EEPROM +#if SUPPORT_EEPROM || BIGBOOT + while (len--) { + fd04: b3 94 inc r11 + fd06: ac 16 cp r10, r28 + fd08: bd 06 cpc r11, r29 + fd0a: 09 f4 brne .+2 ; 0xfd0e + eeprom_write_byte((address.bptr++), *(mybuff.bptr++)); + fd0c: 59 c0 rjmp .+178 ; 0xfdc0 + fd0e: f5 01 movw r30, r10 + fd10: 61 91 ld r22, Z+ + fd12: 5f 01 movw r10, r30 + fd14: c4 01 movw r24, r8 + fd16: 97 d0 rcall .+302 ; 0xfe46 + fd18: ff ef ldi r31, 0xFF ; 255 + fd1a: 8f 1a sub r8, r31 + fd1c: 9f 0a sbc r9, r31 + fd1e: f3 cf rjmp .-26 ; 0xfd06 + * and we needed the space back. + */ +#ifdef FOURPAGEERASE + if ((address.bytes[0] & ((SPM_PAGESIZE<<2)-1))==0) { +#endif + __boot_page_erase_short(address.word); + fd20: 83 e0 ldi r24, 0x03 ; 3 + fd22: f8 01 movw r30, r16 + fd24: 87 bf out 0x37, r24 ; 55 + fd26: e8 95 spm + boot_spm_busy_wait(); + fd28: 07 b6 in r0, 0x37 ; 55 + fd2a: 00 fc sbrc r0, 0 + fd2c: fd cf rjmp .-6 ; 0xfd28 + fd2e: a0 e0 ldi r26, 0x00 ; 0 + fd30: b1 e0 ldi r27, 0x01 ; 1 + fd32: f8 01 movw r30, r16 + + /* + * Copy data from the buffer into the flash write buffer. + */ + do { + __boot_page_fill_short((uint16_t)(void*)addrPtr, *(mybuff.wptr++)); + fd34: 8d 91 ld r24, X+ + fd36: 9d 91 ld r25, X+ + fd38: 0c 01 movw r0, r24 + fd3a: f7 be out 0x37, r15 ; 55 + fd3c: e8 95 spm + addrPtr += 2; + } while (len -= 2); + fd3e: 11 24 eor r1, r1 + fd40: 22 97 sbiw r28, 0x02 ; 2 + fd42: 32 96 adiw r30, 0x02 ; 2 + fd44: 20 97 sbiw r28, 0x00 ; 0 + + /* + * Actually Write the buffer to flash (and wait for it to finish.) + */ + __boot_page_write_short(address.word); + fd46: b1 f7 brne .-20 ; 0xfd34 + fd48: f8 01 movw r30, r16 + boot_spm_busy_wait(); + fd4a: e7 be out 0x37, r14 ; 55 + fd4c: e8 95 spm +#if defined(RWWSRE) + // Reenable read access to flash + __boot_rww_enable_short(); + fd4e: 07 b6 in r0, 0x37 ; 55 + fd50: 00 fc sbrc r0, 0 + fd52: fd cf rjmp .-6 ; 0xfd4e + writebuffer(desttype, buff, address, savelength); + + + } +/* Read memory block mode, length is big endian. */ + else if (ch == STK_READ_PAGE) { + fd54: d7 be out 0x37, r13 ; 55 + fd56: e8 95 spm + uint8_t desttype; GETLENGTH(length); - fd60: 33 c0 rjmp .+102 ; 0xfdc8 - fd62: 84 37 cpi r24, 0x74 ; 116 - fd64: 19 f5 brne .+70 ; 0xfdac - fd66: 3a d0 rcall .+116 ; 0xfddc - fd68: c8 2f mov r28, r24 - fd6a: d0 e0 ldi r29, 0x00 ; 0 - fd6c: dc 2f mov r29, r28 - fd6e: cc 27 eor r28, r28 + fd58: 33 c0 rjmp .+102 ; 0xfdc0 + fd5a: 84 37 cpi r24, 0x74 ; 116 + fd5c: 19 f5 brne .+70 ; 0xfda4 + fd5e: 3a d0 rcall .+116 ; 0xfdd4 + fd60: c8 2f mov r28, r24 + fd62: d0 e0 ldi r29, 0x00 ; 0 + fd64: dc 2f mov r29, r28 + fd66: cc 27 eor r28, r28 + desttype = getch(); - fd70: 35 d0 rcall .+106 ; 0xfddc - fd72: 5e 01 movw r10, r28 - fd74: a8 2a or r10, r24 + fd68: 35 d0 rcall .+106 ; 0xfdd4 + fd6a: 5e 01 movw r10, r28 + fd6c: a8 2a or r10, r24 + verifySpace(); - fd76: 32 d0 rcall .+100 ; 0xfddc - fd78: 98 2e mov r9, r24 + fd6e: 32 d0 rcall .+100 ; 0xfdd4 + fd70: 98 2e mov r9, r24 static inline void read_mem(uint8_t memtype, addr16_t address, pagelen_t length) { - uint8_t ch; + uint8_t ch; - switch (memtype) { - fd7a: 42 d0 rcall .+132 ; 0xfe00 - fd7c: e8 01 movw r28, r16 - fd7e: f5 e4 ldi r31, 0x45 ; 69 + switch (memtype) { + fd72: 42 d0 rcall .+132 ; 0xfdf8 + fd74: e8 01 movw r28, r16 + fd76: f5 e4 ldi r31, 0x45 ; 69 -#if defined(SUPPORT_EEPROM) || defined(BIGBOOT) - case 'E': // EEPROM - do { - putch(eeprom_read_byte((address.bptr++))); - fd80: 9f 12 cpse r9, r31 - fd82: 0b c0 rjmp .+22 ; 0xfd9a - fd84: ce 01 movw r24, r28 - fd86: 5b d0 rcall .+182 ; 0xfe3e - } while (--length); - fd88: 22 d0 rcall .+68 ; 0xfdce - fd8a: 81 e0 ldi r24, 0x01 ; 1 - fd8c: a8 1a sub r10, r24 - fd8e: b1 08 sbc r11, r1 - fd90: 21 96 adiw r28, 0x01 ; 1 - fd92: a1 14 cp r10, r1 - fd94: b1 04 cpc r11, r1 - // while (--length); - // read a Flash and increment the address (may increment RAMPZ) - __asm__ ("elpm %0,Z+\n" : "=r" (ch), "=z" (address.bptr): "1" (address)); +#if SUPPORT_EEPROM || BIGBOOT + case 'E': // EEPROM + do { + putch(eeprom_read_byte((address.bptr++))); + fd78: 9f 12 cpse r9, r31 + fd7a: 0b c0 rjmp .+22 ; 0xfd92 + fd7c: ce 01 movw r24, r28 + fd7e: 5b d0 rcall .+182 ; 0xfe36 + } while (--length); + fd80: 22 d0 rcall .+68 ; 0xfdc6 + fd82: 81 e0 ldi r24, 0x01 ; 1 + fd84: a8 1a sub r10, r24 + fd86: b1 08 sbc r11, r1 + fd88: 21 96 adiw r28, 0x01 ; 1 + fd8a: a1 14 cp r10, r1 + fd8c: b1 04 cpc r11, r1 + // while (--length); + // read a Flash and increment the address (may increment RAMPZ) + __asm__ (" elpm %0,Z+\n" : "=r" (ch), "=z" (address.bptr): "1" (address)); #else - // read a Flash byte and increment the address - __asm__ ("lpm %0,Z+\n" : "=r" (ch), "=z" (address.bptr): "1" (address)); - fd96: b1 f7 brne .-20 ; 0xfd84 - fd98: 17 c0 rjmp .+46 ; 0xfdc8 + // read a Flash byte and increment the address + __asm__ (" lpm %0,Z+\n" : "=r" (ch), "=z" (address.bptr): "1" (address)); + fd8e: b1 f7 brne .-20 ; 0xfd7c + fd90: 17 c0 rjmp .+46 ; 0xfdc0 #endif - putch(ch); - fd9a: fe 01 movw r30, r28 - fd9c: 85 91 lpm r24, Z+ - } while (--length); - fd9e: ef 01 movw r28, r30 - fda0: 16 d0 rcall .+44 ; 0xfdce - fda2: e1 e0 ldi r30, 0x01 ; 1 - fda4: ae 1a sub r10, r30 - fda6: b1 08 sbc r11, r1 - else if(ch == STK_READ_SIGN) { - fda8: c1 f7 brne .-16 ; 0xfd9a - fdaa: 0e c0 rjmp .+28 ; 0xfdc8 + putch(ch); + fd92: fe 01 movw r30, r28 + fd94: 85 91 lpm r24, Z+ + } while (--length); + fd96: ef 01 movw r28, r30 + fd98: 16 d0 rcall .+44 ; 0xfdc6 + fd9a: e1 e0 ldi r30, 0x01 ; 1 + fd9c: ae 1a sub r10, r30 + fd9e: b1 08 sbc r11, r1 + + read_mem(desttype, address, length); + } + +/* Get device signature bytes */ + else if (ch == STK_READ_SIGN) { + fda0: c1 f7 brne .-16 ; 0xfd92 + fda2: 0e c0 rjmp .+28 ; 0xfdc0 + // READ SIGN - return what Avrdude wants to hear verifySpace(); - fdac: 85 37 cpi r24, 0x75 ; 117 - fdae: 39 f4 brne .+14 ; 0xfdbe + fda4: 85 37 cpi r24, 0x75 ; 117 + fda6: 39 f4 brne .+14 ; 0xfdb6 putch(SIGNATURE_0); - fdb0: 27 d0 rcall .+78 ; 0xfe00 - fdb2: 8e e1 ldi r24, 0x1E ; 30 - fdb4: 0c d0 rcall .+24 ; 0xfdce + fda8: 27 d0 rcall .+78 ; 0xfdf8 + fdaa: 8e e1 ldi r24, 0x1E ; 30 + fdac: 0c d0 rcall .+24 ; 0xfdc6 putch(SIGNATURE_1); - fdb6: 86 e9 ldi r24, 0x96 ; 150 - fdb8: 0a d0 rcall .+20 ; 0xfdce - fdba: 8a e0 ldi r24, 0x0A ; 10 + fdae: 86 e9 ldi r24, 0x96 ; 150 + fdb0: 0a d0 rcall .+20 ; 0xfdc6 + fdb2: 8a e0 ldi r24, 0x0A ; 10 putch(SIGNATURE_2); - fdbc: 6d cf rjmp .-294 ; 0xfc98 - fdbe: 81 35 cpi r24, 0x51 ; 81 + fdb4: 6d cf rjmp .-294 ; 0xfc90 + fdb6: 81 35 cpi r24, 0x51 ; 81 + } else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */ - fdc0: 11 f4 brne .+4 ; 0xfdc6 - fdc2: 88 e0 ldi r24, 0x08 ; 8 + fdb8: 11 f4 brne .+4 ; 0xfdbe + fdba: 88 e0 ldi r24, 0x08 ; 8 + // Adaboot no-wait mod watchdogConfig(WATCHDOG_16MS); - fdc4: 17 d0 rcall .+46 ; 0xfdf4 - fdc6: 1c d0 rcall .+56 ; 0xfe00 - fdc8: 80 e1 ldi r24, 0x10 ; 16 + fdbc: 17 d0 rcall .+46 ; 0xfdec + fdbe: 1c d0 rcall .+56 ; 0xfdf8 + fdc0: 80 e1 ldi r24, 0x10 ; 16 verifySpace(); - fdca: 01 d0 rcall .+2 ; 0xfdce - fdcc: 56 cf rjmp .-340 ; 0xfc7a + } + else { + // This covers the response to commands like STK_ENTER_PROGMODE + verifySpace(); + fdc2: 01 d0 rcall .+2 ; 0xfdc6 + fdc4: 5a cf rjmp .-332 ; 0xfc7a -0000fdce : +0000fdc6 : + } putch(STK_OK); - fdce: 90 91 c0 00 lds r25, 0x00C0 ; 0x8000c0 <__TEXT_REGION_LENGTH__+0x7e00c0> - fdd2: 95 ff sbrs r25, 5 + fdc6: 90 91 c0 00 lds r25, 0x00C0 ; 0x8000c0 <__RAM__+0xc0> + fdca: 95 ff sbrs r25, 5 } - fdd4: fc cf rjmp .-8 ; 0xfdce + fdcc: fc cf rjmp .-8 ; 0xfdc6 +# else + RS485_PORT &= ~_BV(RS485_BIT); +# endif +#else //not RS485 + while (!(UART_SRA & _BV(UDRE0))) { /* Spin */ } UART_UDR = ch; - fdd6: 80 93 c6 00 sts 0x00C6, r24 ; 0x8000c6 <__TEXT_REGION_LENGTH__+0x7e00c6> - fdda: 08 95 ret + fdce: 80 93 c6 00 sts 0x00C6, r24 ; 0x8000c6 <__RAM__+0xc6> + fdd2: 08 95 ret -0000fddc : - while(!(UART_SRA & _BV(RXC0))) { /* Spin */ } - fddc: 80 91 c0 00 lds r24, 0x00C0 ; 0x8000c0 <__TEXT_REGION_LENGTH__+0x7e00c0> - fde0: 87 ff sbrs r24, 7 - fde2: fc cf rjmp .-8 ; 0xfddc +0000fdd4 : + : + "r25" + ); +#else +#ifndef LIN_UART + while (!(UART_SRA & _BV(RXC0))) { /* Spin */ } + fdd4: 80 91 c0 00 lds r24, 0x00C0 ; 0x8000c0 <__RAM__+0xc0> + fdd8: 87 ff sbrs r24, 7 + fdda: fc cf rjmp .-8 ; 0xfdd4 if (!(UART_SRA & _BV(FE0))) { - fde4: 80 91 c0 00 lds r24, 0x00C0 ; 0x8000c0 <__TEXT_REGION_LENGTH__+0x7e00c0> - fde8: 84 fd sbrc r24, 4 - fdea: 01 c0 rjmp .+2 ; 0xfdee + fddc: 80 91 c0 00 lds r24, 0x00C0 ; 0x8000c0 <__RAM__+0xc0> + fde0: 84 fd sbrc r24, 4 + fde2: 01 c0 rjmp .+2 ; 0xfde6 +} +#endif + +// Watchdog functions. These are only safe with interrupts turned off. +void watchdogReset() { __asm__ __volatile__ ( - fdec: a8 95 wdr + fde4: a8 95 wdr + while (!(LINSIR & _BV(LRXOK))) { /* Spin */ } + if (!(LINSIR & _BV(LFERR))) { + watchdogReset(); /* Eventually abort if wrong speed */ + } +#endif ch = UART_UDR; - fdee: 80 91 c6 00 lds r24, 0x00C6 ; 0x8000c6 <__TEXT_REGION_LENGTH__+0x7e00c6> -} - fdf2: 08 95 ret + fde6: 80 91 c6 00 lds r24, 0x00C6 ; 0x8000c6 <__RAM__+0xc6> +#if LED_DATA_FLASH + toggle_led(); +#endif -0000fdf4 : + return ch; +} + fdea: 08 95 ret + +0000fdec : +} + +void watchdogConfig(uint8_t x) { +#ifdef WDCE //does it have a Watchdog Change Enable? +#ifdef WDTCSR WDTCSR = _BV(WDCE) | _BV(WDE); - fdf4: e0 e6 ldi r30, 0x60 ; 96 - fdf6: f0 e0 ldi r31, 0x00 ; 0 - fdf8: 98 e1 ldi r25, 0x18 ; 24 - fdfa: 90 83 st Z, r25 + fdec: e0 e6 ldi r30, 0x60 ; 96 + fdee: f0 e0 ldi r31, 0x00 ; 0 + fdf0: 98 e1 ldi r25, 0x18 ; 24 + fdf2: 90 83 st Z, r25 +#else //then it must be one of those newfangled ones that use CCP + CCP=0xD8; //so write this magic number to CCP +#endif + +#ifdef WDTCSR WDTCSR = x; - fdfc: 80 83 st Z, r24 - fdfe: 08 95 ret + fdf4: 80 83 st Z, r24 + fdf6: 08 95 ret -0000fe00 : - if (getch() != CRC_EOP) { - fe00: ed df rcall .-38 ; 0xfddc - fe02: 80 32 cpi r24, 0x20 ; 32 - fe04: 19 f0 breq .+6 ; 0xfe0c - watchdogConfig(WATCHDOG_16MS); // shorten WD timeout - fe06: 88 e0 ldi r24, 0x08 ; 8 - fe08: f5 df rcall .-22 ; 0xfdf4 - fe0a: ff cf rjmp .-2 ; 0xfe0a - putch(STK_INSYNC); - fe0c: 84 e1 ldi r24, 0x14 ; 20 - fe0e: df cf rjmp .-66 ; 0xfdce - -0000fe10 : -void getNch(uint8_t count) { - fe10: cf 93 push r28 - fe12: c8 2f mov r28, r24 +0000fdf8 : do getch(); while (--count); - fe14: e3 df rcall .-58 ; 0xfddc - fe16: c1 50 subi r28, 0x01 ; 1 - fe18: e9 f7 brne .-6 ; 0xfe14 -} - fe1a: cf 91 pop r28 verifySpace(); - fe1c: f1 cf rjmp .-30 ; 0xfe00 +} -0000fe1e : - fe1e: fc 01 movw r30, r24 +void verifySpace() { + if (getch() != CRC_EOP) { + fdf8: ed df rcall .-38 ; 0xfdd4 + fdfa: 80 32 cpi r24, 0x20 ; 32 + fdfc: 19 f0 breq .+6 ; 0xfe04 + watchdogConfig(WATCHDOG_16MS); // shorten WD timeout + fdfe: 88 e0 ldi r24, 0x08 ; 8 + fe00: f5 df rcall .-22 ; 0xfdec + fe02: ff cf rjmp .-2 ; 0xfe02 + while (1) // and busy-loop so that WD causes + ; // a reset and app start. + } + putch(STK_INSYNC); + fe04: 84 e1 ldi r24, 0x14 ; 20 + fe06: df cf rjmp .-66 ; 0xfdc6 + +0000fe08 : + ::[count] "M" (UART_B_VALUE) + ); +} +#endif + +void getNch(uint8_t count) { + fe08: cf 93 push r28 + fe0a: c8 2f mov r28, r24 + do getch(); while (--count); + fe0c: e3 df rcall .-58 ; 0xfdd4 + fe0e: c1 50 subi r28, 0x01 ; 1 + fe10: e9 f7 brne .-6 ; 0xfe0c + verifySpace(); +} + fe12: cf 91 pop r28 +} +#endif + +void getNch(uint8_t count) { + do getch(); while (--count); + verifySpace(); + fe14: f1 cf rjmp .-30 ; 0xfdf8 + +0000fe16 : + fe16: fc 01 movw r30, r24 * data=0 in WRITE */ static void do_spm(uint16_t address, uint8_t command, uint16_t data) __attribute__ ((used)); static void do_spm(uint16_t address, uint8_t command, uint16_t data) { - // Do spm stuff - asm volatile ( - fe20: 0a 01 movw r0, r20 - fe22: 67 bf out 0x37, r22 ; 55 - fe24: e8 95 spm - fe26: 11 24 eor r1, r1 - fe28: 07 b6 in r0, 0x37 ; 55 + // Do spm stuff + asm volatile ( + fe18: 0a 01 movw r0, r20 + fe1a: 67 bf out 0x37, r22 ; 55 + fe1c: e8 95 spm + fe1e: 11 24 eor r1, r1 + fe20: 07 b6 in r0, 0x37 ; 55 ); - // wait for spm to complete - // it doesn't have much sense for __BOOT_PAGE_FILL, - // but it doesn't hurt and saves some bytes on 'if' - boot_spm_busy_wait(); - fe2a: 00 fc sbrc r0, 0 - fe2c: fd cf rjmp .-6 ; 0xfe28 - fe2e: 66 70 andi r22, 0x06 ; 6 + // wait for spm to complete + // it doesn't have much sense for __BOOT_PAGE_FILL, + // but it doesn't hurt and saves some bytes on 'if' + boot_spm_busy_wait(); + fe22: 00 fc sbrc r0, 0 + fe24: fd cf rjmp .-6 ; 0xfe20 + fe26: 66 70 andi r22, 0x06 ; 6 #if defined(RWWSRE) - // this 'if' condition should be: (command == __BOOT_PAGE_WRITE || command == __BOOT_PAGE_ERASE)... - // but it's tweaked a little assuming that in every command we are interested in here, there - // must be also SELFPRGEN set. If we skip checking this bit, we save here 4B - if ((command & (_BV(PGWRT)|_BV(PGERS))) && (data == 0) ) { - fe30: 29 f0 breq .+10 ; 0xfe3c - fe32: 45 2b or r20, r21 - fe34: 19 f4 brne .+6 ; 0xfe3c - fe36: 81 e1 ldi r24, 0x11 ; 17 - // Reenable read access to flash - __boot_rww_enable_short(); - fe38: 87 bf out 0x37, r24 ; 55 - fe3a: e8 95 spm - fe3c: 08 95 ret + // this 'if' condition should be: (command == __BOOT_PAGE_WRITE || command == __BOOT_PAGE_ERASE)... + // but it's tweaked a little assuming that in every command we are interested in here, there + // must be also SELFPRGEN set. If we skip checking this bit, we save here 4B + if ((command & (_BV(PGWRT)|_BV(PGERS))) && (data == 0) ) { + fe28: 29 f0 breq .+10 ; 0xfe34 + fe2a: 45 2b or r20, r21 + fe2c: 19 f4 brne .+6 ; 0xfe34 + fe2e: 81 e1 ldi r24, 0x11 ; 17 + // Reenable read access to flash + __boot_rww_enable_short(); + fe30: 87 bf out 0x37, r24 ; 55 + fe32: e8 95 spm + fe34: 08 95 ret -0000fe3e : - fe3e: f9 99 sbic 0x1f, 1 ; 31 - fe40: fe cf rjmp .-4 ; 0xfe3e - fe42: 92 bd out 0x22, r25 ; 34 - fe44: 81 bd out 0x21, r24 ; 33 - fe46: f8 9a sbi 0x1f, 0 ; 31 - fe48: 99 27 eor r25, r25 - fe4a: 80 b5 in r24, 0x20 ; 32 - fe4c: 08 95 ret +0000fe36 : + fe36: f9 99 sbic 0x1f, 1 ; 31 + fe38: fe cf rjmp .-4 ; 0xfe36 + fe3a: 92 bd out 0x22, r25 ; 34 + fe3c: 81 bd out 0x21, r24 ; 33 + fe3e: f8 9a sbi 0x1f, 0 ; 31 + fe40: 99 27 eor r25, r25 + fe42: 80 b5 in r24, 0x20 ; 32 + fe44: 08 95 ret -0000fe4e : - fe4e: 26 2f mov r18, r22 +0000fe46 : + fe46: 26 2f mov r18, r22 -0000fe50 : - fe50: f9 99 sbic 0x1f, 1 ; 31 - fe52: fe cf rjmp .-4 ; 0xfe50 - fe54: 1f ba out 0x1f, r1 ; 31 - fe56: 92 bd out 0x22, r25 ; 34 - fe58: 81 bd out 0x21, r24 ; 33 - fe5a: 20 bd out 0x20, r18 ; 32 - fe5c: 0f b6 in r0, 0x3f ; 63 - fe5e: f8 94 cli - fe60: fa 9a sbi 0x1f, 2 ; 31 - fe62: f9 9a sbi 0x1f, 1 ; 31 - fe64: 0f be out 0x3f, r0 ; 63 - fe66: 01 96 adiw r24, 0x01 ; 1 - fe68: 08 95 ret +0000fe48 : + fe48: f9 99 sbic 0x1f, 1 ; 31 + fe4a: fe cf rjmp .-4 ; 0xfe48 + fe4c: 1f ba out 0x1f, r1 ; 31 + fe4e: 92 bd out 0x22, r25 ; 34 + fe50: 81 bd out 0x21, r24 ; 33 + fe52: 20 bd out 0x20, r18 ; 32 + fe54: 0f b6 in r0, 0x3f ; 63 + fe56: f8 94 cli + fe58: fa 9a sbi 0x1f, 2 ; 31 + fe5a: f9 9a sbi 0x1f, 1 ; 31 + fe5c: 0f be out 0x3f, r0 ; 63 + fe5e: 01 96 adiw r24, 0x01 ; 1 + fe60: 08 95 ret -0000fe6a : - fe6a: 56 65 72 73 69 6f 6e 3d 38 2e 31 00 Version=8.1. +0000fe62 : + fe62: ff . -0000fe76 : - fe76: 4f 50 54 49 42 4f 4f 54 5f 43 55 53 54 4f 4d 56 OPTIBOOT_CUSTOMV - fe86: 45 52 3d 30 00 ER=0. +0000fe63 : + fe63: 56 65 72 73 69 6f 6e 3d 38 2e 33 00 Version=8.3. -0000fe8b : - fe8b: 44 65 76 69 63 65 3d 61 74 6d 65 67 61 36 34 34 Device=atmega644 - fe9b: 70 00 p. +0000fe6f : + fe6f: 44 65 76 69 63 65 3d 61 74 6d 65 67 61 36 34 34 Device=atmega644 + fe7f: 70 00 p. -0000fe9d : - fe9d: 46 5f 43 50 55 3d 31 36 30 30 30 30 30 30 4c 00 F_CPU=16000000L. +0000fe81 : + fe81: 46 5f 43 50 55 3d 31 36 30 30 30 30 30 30 4c 00 F_CPU=16000000L. -0000fead : - fead: 42 49 47 42 4f 4f 54 3d 31 00 BIGBOOT=1. +0000fe91 : + fe91: 42 49 47 42 4f 4f 54 3d 31 00 BIGBOOT=1. -0000feb7 : - feb7: 42 75 69 6c 74 3a 4d 61 79 20 32 39 20 32 30 32 Built:May 29 202 - fec7: 30 3a 30 31 3a 30 32 3a 32 36 00 0:01:02:26. +0000fe9b : + fe9b: 42 75 69 6c 74 3a 4e 6f 76 20 20 34 20 32 30 32 Built:Nov 4 202 + feab: 31 3a 31 38 3a 30 33 3a 31 34 00 1:18:03:14. -0000fed2 : - fed2: 55 41 52 54 3d 30 00 UART=0. +0000feb6 : + feb6: 55 41 52 54 3d 30 00 UART=0. -0000fed9 : - fed9: 42 41 55 44 5f 52 41 54 45 3d 31 31 35 32 30 30 BAUD_RATE=115200 +0000febd : + febd: 42 41 55 44 5f 52 41 54 45 3d 31 31 35 32 30 30 BAUD_RATE=115200 ... -0000feea : - feea: 4c 45 44 3d 42 30 00 LED=B0. +0000fece : + fece: 4c 45 44 3d 42 30 00 LED=B0. -0000fef1 : - fef1: 4c 45 44 5f 53 54 41 52 54 5f 46 4c 41 53 48 45 LED_START_FLASHE - ff01: 53 3d 33 00 S=3. +0000fed5 : + fed5: 4c 45 44 5f 53 54 41 52 54 5f 46 4c 41 53 48 45 LED_START_FLASHE + fee5: 53 3d 33 00 S=3.