Browse Source

Update Version number to 5.0 (for the makefile changes.)
Now that there's a prior "version" demonstrating identical
binaries, update to 5.0 so we can tell whether anyone uses it.
This causes much churn in the .hex and .lst files, even though
only the version number has changed.
Also, add some entries to boards.txt and update it with
build.variant lines for post IDE 1.0.2 (may no longer work
with older versions of the IDE.)
Remove the optiboot_lilypad_resonator .hex and .lst, since they
should be identical to optiboot_lilypad (only fuses change.)

westfw 12 years ago
parent
commit
706f04e209
24 changed files with 2483 additions and 3070 deletions
  1. 54 7
      optiboot/boards.txt
  2. 1 1
      optiboot/bootloaders/optiboot/makeall
  3. 2 2
      optiboot/bootloaders/optiboot/optiboot.c
  4. 29 30
      optiboot/bootloaders/optiboot/optiboot_atmega1280.hex
  5. 220 235
      optiboot/bootloaders/optiboot/optiboot_atmega1280.lst
  6. 28 28
      optiboot/bootloaders/optiboot/optiboot_atmega328.hex
  7. 213 212
      optiboot/bootloaders/optiboot/optiboot_atmega328.lst
  8. 28 28
      optiboot/bootloaders/optiboot/optiboot_atmega328_pro_8MHz.hex
  9. 214 213
      optiboot/bootloaders/optiboot/optiboot_atmega328_pro_8MHz.lst
  10. 28 28
      optiboot/bootloaders/optiboot/optiboot_atmega644p.hex
  11. 213 212
      optiboot/bootloaders/optiboot/optiboot_atmega644p.lst
  12. 169 181
      optiboot/bootloaders/optiboot/optiboot_diecimila.lst
  13. 28 28
      optiboot/bootloaders/optiboot/optiboot_lilypad.hex
  14. 214 212
      optiboot/bootloaders/optiboot/optiboot_lilypad.lst
  15. 0 34
      optiboot/bootloaders/optiboot/optiboot_lilypad_resonator.hex
  16. 0 584
      optiboot/bootloaders/optiboot/optiboot_lilypad_resonator.lst
  17. 37 38
      optiboot/bootloaders/optiboot/optiboot_luminet.hex
  18. 279 277
      optiboot/bootloaders/optiboot/optiboot_luminet.lst
  19. 28 28
      optiboot/bootloaders/optiboot/optiboot_pro_16MHz.hex
  20. 214 212
      optiboot/bootloaders/optiboot/optiboot_pro_16MHz.lst
  21. 28 28
      optiboot/bootloaders/optiboot/optiboot_pro_20mhz.hex
  22. 214 212
      optiboot/bootloaders/optiboot/optiboot_pro_20mhz.lst
  23. 28 28
      optiboot/bootloaders/optiboot/optiboot_pro_8MHz.hex
  24. 214 212
      optiboot/bootloaders/optiboot/optiboot_pro_8MHz.lst

+ 54 - 7
optiboot/boards.txt

@@ -1,6 +1,7 @@
 # Optiboot Arduino support
 # http://optiboot.googlecode.com
 # Peter Knight, 2010
+# Bill Westfield, 2013 - now includes build.variant for 1.0.2 and later
 
 ##############################################################
 
@@ -18,12 +19,13 @@ atmega328o.bootloader.lock_bits=0x0F
 atmega328o.build.mcu=atmega328p
 atmega328o.build.f_cpu=16000000L
 atmega328o.build.core=arduino:arduino
+atmega328o.build.variant=arduino:standard
 
 ##############################################################
 
 diecimilao.name=[Optiboot] Arduino Diecimila, Duemilanove, Nano, NG w/ ATmega168
 diecimilao.upload.protocol=stk500
-diecimilao.upload.maximum_size=15360
+diecimilao.upload.maximum_size=15872
 diecimilao.upload.speed=115200
 diecimilao.bootloader.low_fuses=0xff
 diecimilao.bootloader.high_fuses=0xdd
@@ -35,12 +37,13 @@ diecimilao.bootloader.lock_bits=0x0F
 diecimilao.build.mcu=atmega168
 diecimilao.build.f_cpu=16000000L
 diecimilao.build.core=arduino:arduino
+diecimilao.build.variant=arduino:standard
 
 ##############################################################
 
 minio.name=[Optiboot] Arduino Mini
 minio.upload.protocol=stk500
-minio.upload.maximum_size=15360
+minio.upload.maximum_size=15872
 minio.upload.speed=115200
 minio.bootloader.low_fuses=0xff
 minio.bootloader.high_fuses=0xdd
@@ -52,12 +55,13 @@ minio.bootloader.lock_bits=0x0F
 minio.build.mcu=atmega168
 minio.build.f_cpu=16000000L
 minio.build.core=arduino:arduino
+minio.build.variant=arduino:eightanaloginputs
 
 ##############################################################
 
 lilypad328o.name=[Optiboot] LilyPad Arduino w/ ATmega328
 lilypad328o.upload.protocol=stk500
-lilypad328o.upload.maximum_size=31744
+lilypad328o.upload.maximum_size=32256
 lilypad328o.upload.speed=115200
 lilypad328o.bootloader.low_fuses=0xff
 lilypad328o.bootloader.high_fuses=0xdc
@@ -69,12 +73,13 @@ lilypad328o.bootloader.lock_bits=0x0F
 lilypad328o.build.mcu=atmega328p
 lilypad328o.build.f_cpu=8000000L
 lilypad328o.build.core=arduino:arduino
+lilypad328o.build.variant=arduino:standard
 
 ##############################################################
 
 lilypado.name=[Optiboot] LilyPad Arduino w/ ATmega168
 lilypado.upload.protocol=stk500
-lilypado.upload.maximum_size=14336
+lilypado.upload.maximum_size=15872
 lilypado.upload.speed=115200
 lilypado.bootloader.low_fuses=0xe2
 lilypado.bootloader.high_fuses=0xdd
@@ -86,12 +91,13 @@ lilypado.bootloader.lock_bits=0x0F
 lilypado.build.mcu=atmega168
 lilypado.build.f_cpu=8000000L
 lilypado.build.core=arduino:arduino
+lilypado.build.variant=arduino:standard
 
 ##############################################################
 
 pro328o.name=[Optiboot] Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328
 pro328o.upload.protocol=stk500
-pro328o.upload.maximum_size=30720
+pro328o.upload.maximum_size=32256
 pro328o.upload.speed=115200
 pro328o.bootloader.low_fuses=0xff
 pro328o.bootloader.high_fuses=0xdc
@@ -103,12 +109,13 @@ pro328o.bootloader.lock_bits=0x0F
 pro328o.build.mcu=atmega328p
 pro328o.build.f_cpu=8000000L
 pro328o.build.core=arduino:arduino
+pro328o.build.variant=arduino:standard
 
 ##############################################################
 
 proo.name=[Optiboot] Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega168
 proo.upload.protocol=stk500
-proo.upload.maximum_size=14336
+proo.upload.maximum_size=15872
 proo.upload.speed=115200
 proo.bootloader.low_fuses=0xc6
 proo.bootloader.high_fuses=0xdd
@@ -120,10 +127,11 @@ proo.bootloader.lock_bits=0x0F
 proo.build.mcu=atmega168
 proo.build.f_cpu=8000000L
 proo.build.core=arduino:arduino
+proo.build.variant=arduino:standard
 
 ##############################################################
 
-megao.name=[Optiboot] Arduino Mega
+megao.name=[Optiboot] Arduino Mega1280
 megao.upload.protocol=stk500
 megao.upload.maximum_size=130048
 megao.upload.speed=115200
@@ -137,6 +145,7 @@ megao.bootloader.lock_bits=0x0F
 megao.build.mcu=atmega1280
 megao.build.f_cpu=16000000L
 megao.build.core=arduino:arduino
+megao.build.variant=arduino:mega
 
 atmega8o.name=[Optiboot] Arduino NG or older w/ ATmega8
 atmega8o.upload.protocol=stk500
@@ -151,6 +160,7 @@ atmega8o.bootloader.lock_bits=0x0F
 atmega8o.build.mcu=atmega8
 atmega8o.build.f_cpu=16000000L
 atmega8o.build.core=arduino:arduino
+atmega8o.build.variant=arduino:standard
 
 atmega88o.name=[Optiboot] Arduino NG or older w/ ATmega88
 atmega88o.upload.protocol=stk500
@@ -166,6 +176,7 @@ atmega88o.bootloader.lock_bits=0x0F
 atmega88o.build.mcu=atmega88
 atmega88o.build.f_cpu=16000000L
 atmega88o.build.core=arduino:arduino
+atmega88o.build.variant=arduino:standard
 
 ##############################################################
 #
@@ -183,6 +194,7 @@ atmega88o.build.core=arduino:arduino
 # sanguinoo.build.mcu=atmega644p
 # sanguinoo.build.f_cpu=16000000L
 # sanguinoo.build.core=sanguino:sanguino
+# sanguinoo.build.variant=sanguino:sanguino
 
 ##############################################################
 #
@@ -198,3 +210,38 @@ atmega88o.build.core=arduino:arduino
 # lumineto.build.mcu=attiny84
 # lumineto.build.f_cpu=1000000L
 # lumineto.build.core=luminet:luminet
+
+##############################################################
+
+atmega32o.name=[Optiboot] ATmega32 based board
+atmega32o.upload.protocol=stk500
+atmega32o.upload.maximum_size=32256
+atmega32o.upload.speed=115200
+atmega32o.bootloader.low_fuses=0xff
+atmega32o.bootloader.high_fuses=0xde
+atmega32o.bootloader.path=optiboot
+atmega32o.bootloader.file=optiboot_atmega32.hex
+atmega32o.bootloader.unlock_bits=0x3F
+atmega32o.bootloader.lock_bits=0x0F
+atmega32o.build.mcu=atmega32
+atmega32o.build.f_cpu=16000000L
+atmega32o.build.core=arduino:arduino
+atmega32o.build.variant=arduino:standard
+
+##############################################################
+
+atmega1284o.name=[Optiboot] ATmega1284p
+atmega1284o.upload.protocol=stk500
+atmega1284o.upload.maximum_size=130048
+atmega1284o.upload.speed=115200
+atmega1284o.bootloader.low_fuses=0xf7
+atmega1284o.bootloader.high_fuses=0xde
+atmega1284o.bootloader.extended_fuses=0x05
+atmega1284o.bootloader.path=optiboot
+atmega1284o.bootloader.file=optiboot_atmega1284p.hex
+atmega1284o.bootloader.unlock_bits=0x3F
+atmega1284o.bootloader.lock_bits=0x0F
+atmega1284o.build.mcu=atmega1284p
+atmega1284o.build.f_cpu=16000000L
+atmega1284o.build.core=arduino:arduino
+atmega1284o.build.variant=arduino:standard

+ 1 - 1
optiboot/bootloaders/optiboot/makeall

@@ -3,7 +3,6 @@ make clean
 #
 #  buildable platforms of somewhat questionable support level
 make lilypad
-make lilypad_resonator
 make pro8
 make pro16
 make pro20
@@ -12,6 +11,7 @@ make sanguino
 make mega
 make atmega88
 make luminet
+make diecimila
 #
 # The "big three" standard bootloaders.
 # These need to be built AFTER the platforms, or they'll get removed

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

@@ -193,8 +193,8 @@
 /* 4.1 WestfW: put version number in binary.		  */
 /**********************************************************/
 
-#define OPTIBOOT_MAJVER 4
-#define OPTIBOOT_MINVER 6
+#define OPTIBOOT_MAJVER 5
+#define OPTIBOOT_MINVER 0
 
 #define MAKESTR(a) #a
 #define MAKEVER(a, b) MAKESTR(a*256+b)

+ 29 - 30
optiboot/bootloaders/optiboot/optiboot_atmega1280.hex

@@ -1,36 +1,35 @@
-:020000000404F6
 :020000021000EC
-:10FC0000112484B714BE81FFF2D085E08093810077
+:10FC0000112484B714BE81FFE8D085E08093810081
 :10FC100082E08093C00088E18093C10086E08093F9
-:10FC2000C20080E18093C4008EE0CBD0279A86E0AA
+:10FC2000C20080E18093C4008EE0C1D0279A86E0B4
 :10FC300020E33CEF91E0309385002093840096BB55
-:10FC4000B09BFECF1F9AA8958150A9F7CC24DD2444
-:10FC500099249394A5E0BA2EF1E1AF2EA6D0813479
-:10FC600061F4A3D0082FB3D0023811F0013811F499
-:10FC700084E001C083E091D08DC0823411F484E12E
-:10FC800003C0853419F485E0AAD084C08535A1F479
-:10FC90008CD0082F10E089D0E82EFF24FE2CEE2413
+:10FC4000B09BFECF1F9AA8958150A9F7EE24FF2400
+:10FC5000BB24B394A5E0CA2EF1E1DF2E9CD0813401
+:10FC600061F499D0082FA9D0023841F1013811F47C
+:10FC700085E001C083E087D083C0823411F484E141
+:10FC800003C0853419F485E0A0D07AC0853591F49D
+:10FC900082D0082F10E07FD0E82EFF24FE2CEE2427
 :10FCA000E02AF12A8F2D881F8827881F8BBFEE0C32
-:10FCB000FF1C8DD067016EC0863521F484E08FD0A3
-:10FCC00080E0D9CF843609F042C06FD06ED0082FC3
-:10FCD0006CD080E0C81680EED80620F483E0F601F0
-:10FCE00087BFE895C0E0D2E060D089930C17E1F7B8
-:10FCF000F0E0CF16F0EEDF0620F083E0F60187BFDC
-:10FD0000E89565D007B600FCFDCFA601A0E0B2E003
-:10FD10002C9130E011968C91119790E0982F8827C4
-:10FD2000822B932B1296FA010C0197BEE8951124B1
-:10FD30004E5F5F4FF3E0A030BF0751F7F601B7BE4B
-:10FD4000E89507B600FCFDCFA7BEE89523C0843731
-:10FD5000A1F42BD02AD0E82E28D039D0E6010E2DE0
-:10FD6000FE0186911AD021960150D1F70894C11C4A
-:10FD7000D11CEA94CE0CD11C0DC0853731F427D0AC
-:10FD80008EE10BD087E909D075CF813511F488E079
-:10FD900018D01DD080E101D061CF982F8091C00094
-:10FDA00085FFFCCF9093C60008958091C00087FF27
-:10FDB000FCCF8091C00084FD01C0A8958091C60051
-:10FDC0000895E0E6F0E098E1908380830895EDDF08
-:10FDD000803219F088E0F5DFFFCF84E1DECF1F939A
-:10FDE000182FE3DF1150E9F7F2DF1F91089580E04B
-:08FDF000E8DFEE27FF2709946C
+:10FCB000FF1C65C0863521F484E087D080E0DBCF6F
+:10FCC000843609F042C067D066D0082F64D080E047
+:10FCD000E81680EEF80620F483E0F70187BFE89588
+:10FCE000C0E0D2E058D089930C17E1F7F0E0EF16AE
+:10FCF000F0EEFF0620F083E0F70187BFE8955DD0C6
+:10FD000007B600FCFDCFA701A0E0B2E02C9130E0E7
+:10FD100011968C91119790E0982F8827822B932B26
+:10FD20001296FA010C01B7BEE89511244E5F5F4FA1
+:10FD3000F3E0A030BF0751F7F701C7BEE89507B65B
+:10FD400000FCFDCFD7BEE8951BC0843761F423D0FB
+:10FD500022D0082F20D031D0F70187917F0113D016
+:10FD60000150D1F70DC0853731F427D08EE10BD08B
+:10FD700087E909D07FCF813511F488E018D01DD0F4
+:10FD800080E101D06BCF982F8091C00085FFFCCF20
+:10FD90009093C60008958091C00087FFFCCF8091AA
+:10FDA000C00084FD01C0A8958091C6000895E0E6DA
+:10FDB000F0E098E1908380830895EDDF803219F0C0
+:10FDC00088E0F5DFFFCF84E1DECF1F93182FE3DF5C
+:10FDD0001150E9F7F2DF1F910895282E80E0E7DF48
+:06FDE000EE27FF27099445
+:02FFFE000005FC
 :040000031000FC00ED
 :00000001FF

+ 220 - 235
optiboot/bootloaders/optiboot/optiboot_atmega1280.lst

@@ -3,40 +3,40 @@ optiboot_atmega1280.elf:     file format elf32-avr
 
 Sections:
 Idx Name          Size      VMA       LMA       File off  Algn
-  0 .text         000001f8  0001fc00  0001fc00  00000054  2**1
+  0 .text         000001e6  0001fc00  0001fc00  00000054  2**1
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
-  1 .debug_aranges 00000028  00000000  00000000  0000024c  2**0
+  1 .version      00000002  0001fffe  0001fffe  0000023a  2**0
+                  CONTENTS, READONLY
+  2 .debug_aranges 00000028  00000000  00000000  0000023c  2**0
                   CONTENTS, READONLY, DEBUGGING
-  2 .debug_pubnames 0000005f  00000000  00000000  00000274  2**0
+  3 .debug_pubnames 0000005f  00000000  00000000  00000264  2**0
                   CONTENTS, READONLY, DEBUGGING
-  3 .debug_info   0000029c  00000000  00000000  000002d3  2**0
+  4 .debug_info   00000294  00000000  00000000  000002c3  2**0
                   CONTENTS, READONLY, DEBUGGING
-  4 .debug_abbrev 0000016b  00000000  00000000  0000056f  2**0
+  5 .debug_abbrev 0000016b  00000000  00000000  00000557  2**0
                   CONTENTS, READONLY, DEBUGGING
-  5 .debug_line   00000471  00000000  00000000  000006da  2**0
+  6 .debug_line   0000040f  00000000  00000000  000006c2  2**0
                   CONTENTS, READONLY, DEBUGGING
-  6 .debug_frame  00000080  00000000  00000000  00000b4c  2**2
+  7 .debug_frame  00000080  00000000  00000000  00000ad4  2**2
                   CONTENTS, READONLY, DEBUGGING
-  7 .debug_str    00000138  00000000  00000000  00000bcc  2**0
+  8 .debug_str    00000131  00000000  00000000  00000b54  2**0
                   CONTENTS, READONLY, DEBUGGING
-  8 .debug_loc    000002b3  00000000  00000000  00000d04  2**0
+  9 .debug_loc    00000256  00000000  00000000  00000c85  2**0
                   CONTENTS, READONLY, DEBUGGING
-  9 .version      00000002  00000000  00000000  00000fb7  2**0
-                  CONTENTS, READONLY
- 10 .debug_ranges 00000078  00000000  00000000  00000fb9  2**0
+ 10 .debug_ranges 00000078  00000000  00000000  00000edb  2**0
                   CONTENTS, READONLY, DEBUGGING
 
 Disassembly of section .text:
 
 0001fc00 <main>:
-#define rstVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+4))
-#define wdtVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+6))
+# define UART_SRL UBRR3L
+# define UART_UDR UDR3
 #endif
 
 /* main program starts here */
 int main(void) {
    1fc00:	11 24       	eor	r1, r1
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__)
   SP=RAMEND;  // This is done by hardware reset
 #endif
 
@@ -45,9 +45,9 @@ int main(void) {
    1fc02:	84 b7       	in	r24, 0x34	; 52
   MCUSR = 0;
    1fc04:	14 be       	out	0x34, r1	; 52
-  if (!(ch & _BV(EXTRF))) appStart();
+  if (!(ch & _BV(EXTRF))) appStart(ch);
    1fc06:	81 ff       	sbrs	r24, 1
-   1fc08:	f2 d0       	rcall	.+484    	; 0x1fdee <appStart>
+   1fc08:	e8 d0       	rcall	.+464    	; 0x1fdda <appStart>
 
 #if LED_START_FLASHES > 0
   // Set up Timer 1 for timeout counter
@@ -59,16 +59,16 @@ int main(void) {
   UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0);  // config USART; 8N1
   UBRRL = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
 #else
-  UCSR0A = _BV(U2X0); //Double speed mode USART0
+  UART_SRA = _BV(U2X0); //Double speed mode USART0
    1fc10:	82 e0       	ldi	r24, 0x02	; 2
    1fc12:	80 93 c0 00 	sts	0x00C0, r24
-  UCSR0B = _BV(RXEN0) | _BV(TXEN0);
+  UART_SRB = _BV(RXEN0) | _BV(TXEN0);
    1fc16:	88 e1       	ldi	r24, 0x18	; 24
    1fc18:	80 93 c1 00 	sts	0x00C1, r24
-  UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
+  UART_SRC = _BV(UCSZ00) | _BV(UCSZ01);
    1fc1c:	86 e0       	ldi	r24, 0x06	; 6
    1fc1e:	80 93 c2 00 	sts	0x00C2, r24
-  UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
+  UART_SRL = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
    1fc22:	80 e1       	ldi	r24, 0x10	; 16
    1fc24:	80 93 c4 00 	sts	0x00C4, r24
 #endif
@@ -77,8 +77,9 @@ int main(void) {
   // Set up watchdog to trigger after 500ms
   watchdogConfig(WATCHDOG_1S);
    1fc28:	8e e0       	ldi	r24, 0x0E	; 14
-   1fc2a:	cb d0       	rcall	.+406    	; 0x1fdc2 <watchdogConfig>
+   1fc2a:	c1 d0       	rcall	.+386    	; 0x1fdae <watchdogConfig>
 
+#if (LED_START_FLASHES > 0) || defined(LED_DATA_FLASH)
   /* Set LED pin as output */
   LED_DDR |= _BV(LED);
    1fc2c:	27 9a       	sbi	0x04, 7	; 4
@@ -106,7 +107,7 @@ void flash_led(uint8_t count) {
     while(!(TIFR1 & _BV(TOV1)));
    1fc40:	b0 9b       	sbis	0x16, 0	; 22
    1fc42:	fe cf       	rjmp	.-4      	; 0x1fc40 <main+0x40>
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__)  || defined (__AVR_ATmega32__)
     LED_PORT ^= _BV(LED);
 #else
     LED_PIN |= _BV(LED);
@@ -126,49 +127,49 @@ void watchdogReset() {
   } while (--count);
    1fc48:	81 50       	subi	r24, 0x01	; 1
    1fc4a:	a9 f7       	brne	.-22     	; 0x1fc36 <main+0x36>
-   1fc4c:	cc 24       	eor	r12, r12
-   1fc4e:	dd 24       	eor	r13, r13
+   1fc4c:	ee 24       	eor	r14, r14
+   1fc4e:	ff 24       	eor	r15, r15
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
         a |= (*bufPtr++) << 8;
         __boot_page_fill_short((uint16_t)(void*)addrPtr,a);
-   1fc50:	99 24       	eor	r9, r9
-   1fc52:	93 94       	inc	r9
+   1fc50:	bb 24       	eor	r11, r11
+   1fc52:	b3 94       	inc	r11
         addrPtr += 2;
       } while (--ch);
 
       // Write from programming buffer
       __boot_page_write_short((uint16_t)(void*)address);
    1fc54:	a5 e0       	ldi	r26, 0x05	; 5
-   1fc56:	ba 2e       	mov	r11, r26
+   1fc56:	ca 2e       	mov	r12, r26
       boot_spm_busy_wait();
 
 #if defined(RWWSRE)
       // Reenable read access to flash
       boot_rww_enable();
    1fc58:	f1 e1       	ldi	r31, 0x11	; 17
-   1fc5a:	af 2e       	mov	r10, r31
+   1fc5a:	df 2e       	mov	r13, r31
 #endif
 
   /* Forever loop */
   for (;;) {
     /* get character from UART */
     ch = getch();
-   1fc5c:	a6 d0       	rcall	.+332    	; 0x1fdaa <getch>
+   1fc5c:	9c d0       	rcall	.+312    	; 0x1fd96 <getch>
 
     if(ch == STK_GET_PARAMETER) {
    1fc5e:	81 34       	cpi	r24, 0x41	; 65
    1fc60:	61 f4       	brne	.+24     	; 0x1fc7a <main+0x7a>
       unsigned char which = getch();
-   1fc62:	a3 d0       	rcall	.+326    	; 0x1fdaa <getch>
+   1fc62:	99 d0       	rcall	.+306    	; 0x1fd96 <getch>
    1fc64:	08 2f       	mov	r16, r24
       verifySpace();
-   1fc66:	b3 d0       	rcall	.+358    	; 0x1fdce <verifySpace>
+   1fc66:	a9 d0       	rcall	.+338    	; 0x1fdba <verifySpace>
       if (which == 0x82) {
    1fc68:	02 38       	cpi	r16, 0x82	; 130
-   1fc6a:	11 f0       	breq	.+4      	; 0x1fc70 <main+0x70>
+   1fc6a:	41 f1       	breq	.+80     	; 0x1fcbc <main+0xbc>
 	/*
 	 * Send optiboot version as "minor SW version"
 	 */
@@ -177,7 +178,7 @@ void watchdogReset() {
    1fc6c:	01 38       	cpi	r16, 0x81	; 129
    1fc6e:	11 f4       	brne	.+4      	; 0x1fc74 <main+0x74>
 	  putch(OPTIBOOT_MAJVER);
-   1fc70:	84 e0       	ldi	r24, 0x04	; 4
+   1fc70:	85 e0       	ldi	r24, 0x05	; 5
    1fc72:	01 c0       	rjmp	.+2      	; 0x1fc76 <main+0x76>
       } else {
 	/*
@@ -186,8 +187,8 @@ void watchdogReset() {
 	 */
 	putch(0x03);
    1fc74:	83 e0       	ldi	r24, 0x03	; 3
-   1fc76:	91 d0       	rcall	.+290    	; 0x1fd9a <putch>
-   1fc78:	8d c0       	rjmp	.+282    	; 0x1fd94 <main+0x194>
+   1fc76:	87 d0       	rcall	.+270    	; 0x1fd86 <putch>
+   1fc78:	83 c0       	rjmp	.+262    	; 0x1fd80 <main+0x180>
       }
     }
     else if(ch == STK_SET_DEVICE) {
@@ -204,20 +205,20 @@ void watchdogReset() {
       // SET DEVICE EXT is ignored
       getNch(5);
    1fc86:	85 e0       	ldi	r24, 0x05	; 5
-   1fc88:	aa d0       	rcall	.+340    	; 0x1fdde <getNch>
-   1fc8a:	84 c0       	rjmp	.+264    	; 0x1fd94 <main+0x194>
+   1fc88:	a0 d0       	rcall	.+320    	; 0x1fdca <getNch>
+   1fc8a:	7a c0       	rjmp	.+244    	; 0x1fd80 <main+0x180>
     }
     else if(ch == STK_LOAD_ADDRESS) {
    1fc8c:	85 35       	cpi	r24, 0x55	; 85
-   1fc8e:	a1 f4       	brne	.+40     	; 0x1fcb8 <main+0xb8>
+   1fc8e:	91 f4       	brne	.+36     	; 0x1fcb4 <main+0xb4>
       // LOAD ADDRESS
       uint16_t newAddress;
       newAddress = getch();
-   1fc90:	8c d0       	rcall	.+280    	; 0x1fdaa <getch>
+   1fc90:	82 d0       	rcall	.+260    	; 0x1fd96 <getch>
       newAddress = (newAddress & 0xff) | (getch() << 8);
    1fc92:	08 2f       	mov	r16, r24
    1fc94:	10 e0       	ldi	r17, 0x00	; 0
-   1fc96:	89 d0       	rcall	.+274    	; 0x1fdaa <getch>
+   1fc96:	7f d0       	rcall	.+254    	; 0x1fd96 <getch>
    1fc98:	e8 2e       	mov	r14, r24
    1fc9a:	ff 24       	eor	r15, r15
    1fc9c:	fe 2c       	mov	r15, r14
@@ -236,362 +237,346 @@ void watchdogReset() {
       newAddress += newAddress; // Convert from word address to byte address
    1fcae:	ee 0c       	add	r14, r14
    1fcb0:	ff 1c       	adc	r15, r15
+   1fcb2:	65 c0       	rjmp	.+202    	; 0x1fd7e <main+0x17e>
       address = newAddress;
       verifySpace();
-   1fcb2:	8d d0       	rcall	.+282    	; 0x1fdce <verifySpace>
-   1fcb4:	67 01       	movw	r12, r14
-   1fcb6:	6e c0       	rjmp	.+220    	; 0x1fd94 <main+0x194>
     }
     else if(ch == STK_UNIVERSAL) {
-   1fcb8:	86 35       	cpi	r24, 0x56	; 86
-   1fcba:	21 f4       	brne	.+8      	; 0x1fcc4 <main+0xc4>
+   1fcb4:	86 35       	cpi	r24, 0x56	; 86
+   1fcb6:	21 f4       	brne	.+8      	; 0x1fcc0 <main+0xc0>
       // UNIVERSAL command is ignored
       getNch(4);
-   1fcbc:	84 e0       	ldi	r24, 0x04	; 4
-   1fcbe:	8f d0       	rcall	.+286    	; 0x1fdde <getNch>
+   1fcb8:	84 e0       	ldi	r24, 0x04	; 4
+   1fcba:	87 d0       	rcall	.+270    	; 0x1fdca <getNch>
       putch(0x00);
-   1fcc0:	80 e0       	ldi	r24, 0x00	; 0
-   1fcc2:	d9 cf       	rjmp	.-78     	; 0x1fc76 <main+0x76>
+   1fcbc:	80 e0       	ldi	r24, 0x00	; 0
+   1fcbe:	db cf       	rjmp	.-74     	; 0x1fc76 <main+0x76>
     }
     /* Write memory, length is big endian and is in bytes */
     else if(ch == STK_PROG_PAGE) {
-   1fcc4:	84 36       	cpi	r24, 0x64	; 100
-   1fcc6:	09 f0       	breq	.+2      	; 0x1fcca <main+0xca>
-   1fcc8:	42 c0       	rjmp	.+132    	; 0x1fd4e <main+0x14e>
+   1fcc0:	84 36       	cpi	r24, 0x64	; 100
+   1fcc2:	09 f0       	breq	.+2      	; 0x1fcc6 <main+0xc6>
+   1fcc4:	42 c0       	rjmp	.+132    	; 0x1fd4a <main+0x14a>
       // PROGRAM PAGE - we support flash programming only, not EEPROM
       uint8_t *bufPtr;
       uint16_t addrPtr;
 
       getch();			/* getlen() */
-   1fcca:	6f d0       	rcall	.+222    	; 0x1fdaa <getch>
+   1fcc6:	67 d0       	rcall	.+206    	; 0x1fd96 <getch>
       length = getch();
-   1fccc:	6e d0       	rcall	.+220    	; 0x1fdaa <getch>
-   1fcce:	08 2f       	mov	r16, r24
+   1fcc8:	66 d0       	rcall	.+204    	; 0x1fd96 <getch>
+   1fcca:	08 2f       	mov	r16, r24
       getch();
-   1fcd0:	6c d0       	rcall	.+216    	; 0x1fdaa <getch>
+   1fccc:	64 d0       	rcall	.+200    	; 0x1fd96 <getch>
 
       // If we are in RWW section, immediately start page erase
       if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-   1fcd2:	80 e0       	ldi	r24, 0x00	; 0
-   1fcd4:	c8 16       	cp	r12, r24
-   1fcd6:	80 ee       	ldi	r24, 0xE0	; 224
-   1fcd8:	d8 06       	cpc	r13, r24
-   1fcda:	20 f4       	brcc	.+8      	; 0x1fce4 <main+0xe4>
-   1fcdc:	83 e0       	ldi	r24, 0x03	; 3
-   1fcde:	f6 01       	movw	r30, r12
-   1fce0:	87 bf       	out	0x37, r24	; 55
-   1fce2:	e8 95       	spm
-   1fce4:	c0 e0       	ldi	r28, 0x00	; 0
-   1fce6:	d2 e0       	ldi	r29, 0x02	; 2
+   1fcce:	80 e0       	ldi	r24, 0x00	; 0
+   1fcd0:	e8 16       	cp	r14, r24
+   1fcd2:	80 ee       	ldi	r24, 0xE0	; 224
+   1fcd4:	f8 06       	cpc	r15, r24
+   1fcd6:	20 f4       	brcc	.+8      	; 0x1fce0 <main+0xe0>
+   1fcd8:	83 e0       	ldi	r24, 0x03	; 3
+   1fcda:	f7 01       	movw	r30, r14
+   1fcdc:	87 bf       	out	0x37, r24	; 55
+   1fcde:	e8 95       	spm
+   1fce0:	c0 e0       	ldi	r28, 0x00	; 0
+   1fce2:	d2 e0       	ldi	r29, 0x02	; 2
 
       // While that is going on, read in page contents
       bufPtr = buff;
       do *bufPtr++ = getch();
-   1fce8:	60 d0       	rcall	.+192    	; 0x1fdaa <getch>
-   1fcea:	89 93       	st	Y+, r24
+   1fce4:	58 d0       	rcall	.+176    	; 0x1fd96 <getch>
+   1fce6:	89 93       	st	Y+, r24
       while (--length);
-   1fcec:	0c 17       	cp	r16, r28
-   1fcee:	e1 f7       	brne	.-8      	; 0x1fce8 <main+0xe8>
+   1fce8:	0c 17       	cp	r16, r28
+   1fcea:	e1 f7       	brne	.-8      	; 0x1fce4 <main+0xe4>
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-   1fcf0:	f0 e0       	ldi	r31, 0x00	; 0
-   1fcf2:	cf 16       	cp	r12, r31
-   1fcf4:	f0 ee       	ldi	r31, 0xE0	; 224
-   1fcf6:	df 06       	cpc	r13, r31
-   1fcf8:	20 f0       	brcs	.+8      	; 0x1fd02 <main+0x102>
-   1fcfa:	83 e0       	ldi	r24, 0x03	; 3
-   1fcfc:	f6 01       	movw	r30, r12
-   1fcfe:	87 bf       	out	0x37, r24	; 55
-   1fd00:	e8 95       	spm
+   1fcec:	f0 e0       	ldi	r31, 0x00	; 0
+   1fcee:	ef 16       	cp	r14, r31
+   1fcf0:	f0 ee       	ldi	r31, 0xE0	; 224
+   1fcf2:	ff 06       	cpc	r15, r31
+   1fcf4:	20 f0       	brcs	.+8      	; 0x1fcfe <main+0xfe>
+   1fcf6:	83 e0       	ldi	r24, 0x03	; 3
+   1fcf8:	f7 01       	movw	r30, r14
+   1fcfa:	87 bf       	out	0x37, r24	; 55
+   1fcfc:	e8 95       	spm
 
       // Read command terminator, start reply
       verifySpace();
-   1fd02:	65 d0       	rcall	.+202    	; 0x1fdce <verifySpace>
+   1fcfe:	5d d0       	rcall	.+186    	; 0x1fdba <verifySpace>
 
       // If only a partial page is to be programmed, the erase might not be complete.
       // So check that here
       boot_spm_busy_wait();
-   1fd04:	07 b6       	in	r0, 0x37	; 55
-   1fd06:	00 fc       	sbrc	r0, 0
-   1fd08:	fd cf       	rjmp	.-6      	; 0x1fd04 <main+0x104>
-   1fd0a:	a6 01       	movw	r20, r12
-   1fd0c:	a0 e0       	ldi	r26, 0x00	; 0
-   1fd0e:	b2 e0       	ldi	r27, 0x02	; 2
+   1fd00:	07 b6       	in	r0, 0x37	; 55
+   1fd02:	00 fc       	sbrc	r0, 0
+   1fd04:	fd cf       	rjmp	.-6      	; 0x1fd00 <main+0x100>
+   1fd06:	a7 01       	movw	r20, r14
+   1fd08:	a0 e0       	ldi	r26, 0x00	; 0
+   1fd0a:	b2 e0       	ldi	r27, 0x02	; 2
       bufPtr = buff;
       addrPtr = (uint16_t)(void*)address;
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
-   1fd10:	2c 91       	ld	r18, X
-   1fd12:	30 e0       	ldi	r19, 0x00	; 0
+   1fd0c:	2c 91       	ld	r18, X
+   1fd0e:	30 e0       	ldi	r19, 0x00	; 0
         a |= (*bufPtr++) << 8;
-   1fd14:	11 96       	adiw	r26, 0x01	; 1
-   1fd16:	8c 91       	ld	r24, X
-   1fd18:	11 97       	sbiw	r26, 0x01	; 1
-   1fd1a:	90 e0       	ldi	r25, 0x00	; 0
-   1fd1c:	98 2f       	mov	r25, r24
-   1fd1e:	88 27       	eor	r24, r24
-   1fd20:	82 2b       	or	r24, r18
-   1fd22:	93 2b       	or	r25, r19
-#define rstVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+4))
-#define wdtVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+6))
+   1fd10:	11 96       	adiw	r26, 0x01	; 1
+   1fd12:	8c 91       	ld	r24, X
+   1fd14:	11 97       	sbiw	r26, 0x01	; 1
+   1fd16:	90 e0       	ldi	r25, 0x00	; 0
+   1fd18:	98 2f       	mov	r25, r24
+   1fd1a:	88 27       	eor	r24, r24
+   1fd1c:	82 2b       	or	r24, r18
+   1fd1e:	93 2b       	or	r25, r19
+# define UART_SRL UBRR3L
+# define UART_UDR UDR3
 #endif
 
 /* main program starts here */
 int main(void) {
-   1fd24:	12 96       	adiw	r26, 0x02	; 2
+   1fd20:	12 96       	adiw	r26, 0x02	; 2
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
         a |= (*bufPtr++) << 8;
         __boot_page_fill_short((uint16_t)(void*)addrPtr,a);
-   1fd26:	fa 01       	movw	r30, r20
-   1fd28:	0c 01       	movw	r0, r24
-   1fd2a:	97 be       	out	0x37, r9	; 55
-   1fd2c:	e8 95       	spm
-   1fd2e:	11 24       	eor	r1, r1
+   1fd22:	fa 01       	movw	r30, r20
+   1fd24:	0c 01       	movw	r0, r24
+   1fd26:	b7 be       	out	0x37, r11	; 55
+   1fd28:	e8 95       	spm
+   1fd2a:	11 24       	eor	r1, r1
         addrPtr += 2;
-   1fd30:	4e 5f       	subi	r20, 0xFE	; 254
-   1fd32:	5f 4f       	sbci	r21, 0xFF	; 255
+   1fd2c:	4e 5f       	subi	r20, 0xFE	; 254
+   1fd2e:	5f 4f       	sbci	r21, 0xFF	; 255
       } while (--ch);
-   1fd34:	f3 e0       	ldi	r31, 0x03	; 3
-   1fd36:	a0 30       	cpi	r26, 0x00	; 0
-   1fd38:	bf 07       	cpc	r27, r31
-   1fd3a:	51 f7       	brne	.-44     	; 0x1fd10 <main+0x110>
+   1fd30:	f3 e0       	ldi	r31, 0x03	; 3
+   1fd32:	a0 30       	cpi	r26, 0x00	; 0
+   1fd34:	bf 07       	cpc	r27, r31
+   1fd36:	51 f7       	brne	.-44     	; 0x1fd0c <main+0x10c>
 
       // Write from programming buffer
       __boot_page_write_short((uint16_t)(void*)address);
-   1fd3c:	f6 01       	movw	r30, r12
-   1fd3e:	b7 be       	out	0x37, r11	; 55
-   1fd40:	e8 95       	spm
+   1fd38:	f7 01       	movw	r30, r14
+   1fd3a:	c7 be       	out	0x37, r12	; 55
+   1fd3c:	e8 95       	spm
       boot_spm_busy_wait();
-   1fd42:	07 b6       	in	r0, 0x37	; 55
-   1fd44:	00 fc       	sbrc	r0, 0
-   1fd46:	fd cf       	rjmp	.-6      	; 0x1fd42 <main+0x142>
+   1fd3e:	07 b6       	in	r0, 0x37	; 55
+   1fd40:	00 fc       	sbrc	r0, 0
+   1fd42:	fd cf       	rjmp	.-6      	; 0x1fd3e <main+0x13e>
 
 #if defined(RWWSRE)
       // Reenable read access to flash
       boot_rww_enable();
-   1fd48:	a7 be       	out	0x37, r10	; 55
-   1fd4a:	e8 95       	spm
-   1fd4c:	23 c0       	rjmp	.+70     	; 0x1fd94 <main+0x194>
+   1fd44:	d7 be       	out	0x37, r13	; 55
+   1fd46:	e8 95       	spm
+   1fd48:	1b c0       	rjmp	.+54     	; 0x1fd80 <main+0x180>
 #endif
 
     }
     /* Read memory block mode, length is big endian.  */
     else if(ch == STK_READ_PAGE) {
-   1fd4e:	84 37       	cpi	r24, 0x74	; 116
-   1fd50:	a1 f4       	brne	.+40     	; 0x1fd7a <main+0x17a>
+   1fd4a:	84 37       	cpi	r24, 0x74	; 116
+   1fd4c:	61 f4       	brne	.+24     	; 0x1fd66 <main+0x166>
       // READ PAGE - we only read flash
       getch();			/* getlen() */
-   1fd52:	2b d0       	rcall	.+86     	; 0x1fdaa <getch>
+   1fd4e:	23 d0       	rcall	.+70     	; 0x1fd96 <getch>
       length = getch();
-   1fd54:	2a d0       	rcall	.+84     	; 0x1fdaa <getch>
-   1fd56:	e8 2e       	mov	r14, r24
+   1fd50:	22 d0       	rcall	.+68     	; 0x1fd96 <getch>
+   1fd52:	08 2f       	mov	r16, r24
       getch();
-   1fd58:	28 d0       	rcall	.+80     	; 0x1fdaa <getch>
+   1fd54:	20 d0       	rcall	.+64     	; 0x1fd96 <getch>
 
       verifySpace();
-   1fd5a:	39 d0       	rcall	.+114    	; 0x1fdce <verifySpace>
-   1fd5c:	e6 01       	movw	r28, r12
-   1fd5e:	0e 2d       	mov	r16, r14
-// Since RAMPZ should already be set, we need to use EPLM directly.
-//      do putch(pgm_read_byte_near(address++));
-//      while (--length);
-      do {
-        uint8_t result;
-        __asm__ ("elpm %0,Z\n":"=r"(result):"z"(address));
-   1fd60:	fe 01       	movw	r30, r28
-   1fd62:	86 91       	elpm	r24, Z+
-        putch(result);
-   1fd64:	1a d0       	rcall	.+52     	; 0x1fd9a <putch>
-        address++;
-   1fd66:	21 96       	adiw	r28, 0x01	; 1
-      }
-      while (--length);
-   1fd68:	01 50       	subi	r16, 0x01	; 1
-   1fd6a:	d1 f7       	brne	.-12     	; 0x1fd60 <main+0x160>
-#define rstVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+4))
-#define wdtVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+6))
-#endif
-
-/* main program starts here */
-int main(void) {
-   1fd6c:	08 94       	sec
-   1fd6e:	c1 1c       	adc	r12, r1
-   1fd70:	d1 1c       	adc	r13, r1
-   1fd72:	ea 94       	dec	r14
-   1fd74:	ce 0c       	add	r12, r14
-   1fd76:	d1 1c       	adc	r13, r1
-   1fd78:	0d c0       	rjmp	.+26     	; 0x1fd94 <main+0x194>
-#endif
+   1fd56:	31 d0       	rcall	.+98     	; 0x1fdba <verifySpace>
+        __asm__ ("elpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
+#else
+        // read a Flash byte and increment the address
+        __asm__ ("lpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #endif
+        putch(ch);
+   1fd58:	f7 01       	movw	r30, r14
+   1fd5a:	87 91       	elpm	r24, Z+
+   1fd5c:	7f 01       	movw	r14, r30
+   1fd5e:	13 d0       	rcall	.+38     	; 0x1fd86 <putch>
+      } while (--length);
+   1fd60:	01 50       	subi	r16, 0x01	; 1
+   1fd62:	d1 f7       	brne	.-12     	; 0x1fd58 <main+0x158>
+   1fd64:	0d c0       	rjmp	.+26     	; 0x1fd80 <main+0x180>
     }
 
     /* Get device signature bytes  */
     else if(ch == STK_READ_SIGN) {
-   1fd7a:	85 37       	cpi	r24, 0x75	; 117
-   1fd7c:	31 f4       	brne	.+12     	; 0x1fd8a <main+0x18a>
+   1fd66:	85 37       	cpi	r24, 0x75	; 117
+   1fd68:	31 f4       	brne	.+12     	; 0x1fd76 <main+0x176>
       // READ SIGN - return what Avrdude wants to hear
       verifySpace();
-   1fd7e:	27 d0       	rcall	.+78     	; 0x1fdce <verifySpace>
+   1fd6a:	27 d0       	rcall	.+78     	; 0x1fdba <verifySpace>
       putch(SIGNATURE_0);
-   1fd80:	8e e1       	ldi	r24, 0x1E	; 30
-   1fd82:	0b d0       	rcall	.+22     	; 0x1fd9a <putch>
+   1fd6c:	8e e1       	ldi	r24, 0x1E	; 30
+   1fd6e:	0b d0       	rcall	.+22     	; 0x1fd86 <putch>
       putch(SIGNATURE_1);
-   1fd84:	87 e9       	ldi	r24, 0x97	; 151
-   1fd86:	09 d0       	rcall	.+18     	; 0x1fd9a <putch>
-   1fd88:	75 cf       	rjmp	.-278    	; 0x1fc74 <main+0x74>
+   1fd70:	87 e9       	ldi	r24, 0x97	; 151
+   1fd72:	09 d0       	rcall	.+18     	; 0x1fd86 <putch>
+   1fd74:	7f cf       	rjmp	.-258    	; 0x1fc74 <main+0x74>
       putch(SIGNATURE_2);
     }
-    else if (ch == 'Q') {
-   1fd8a:	81 35       	cpi	r24, 0x51	; 81
-   1fd8c:	11 f4       	brne	.+4      	; 0x1fd92 <main+0x192>
+    else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */
+   1fd76:	81 35       	cpi	r24, 0x51	; 81
+   1fd78:	11 f4       	brne	.+4      	; 0x1fd7e <main+0x17e>
       // Adaboot no-wait mod
       watchdogConfig(WATCHDOG_16MS);
-   1fd8e:	88 e0       	ldi	r24, 0x08	; 8
-   1fd90:	18 d0       	rcall	.+48     	; 0x1fdc2 <watchdogConfig>
+   1fd7a:	88 e0       	ldi	r24, 0x08	; 8
+   1fd7c:	18 d0       	rcall	.+48     	; 0x1fdae <watchdogConfig>
       verifySpace();
     }
     else {
       // This covers the response to commands like STK_ENTER_PROGMODE
       verifySpace();
-   1fd92:	1d d0       	rcall	.+58     	; 0x1fdce <verifySpace>
+   1fd7e:	1d d0       	rcall	.+58     	; 0x1fdba <verifySpace>
     }
     putch(STK_OK);
-   1fd94:	80 e1       	ldi	r24, 0x10	; 16
-   1fd96:	01 d0       	rcall	.+2      	; 0x1fd9a <putch>
-   1fd98:	61 cf       	rjmp	.-318    	; 0x1fc5c <main+0x5c>
+   1fd80:	80 e1       	ldi	r24, 0x10	; 16
+   1fd82:	01 d0       	rcall	.+2      	; 0x1fd86 <putch>
+   1fd84:	6b cf       	rjmp	.-298    	; 0x1fc5c <main+0x5c>
 
-0001fd9a <putch>:
+0001fd86 <putch>:
   }
 }
 
 void putch(char ch) {
-   1fd9a:	98 2f       	mov	r25, r24
+   1fd86:	98 2f       	mov	r25, r24
 #ifndef SOFT_UART
-  while (!(UCSR0A & _BV(UDRE0)));
-   1fd9c:	80 91 c0 00 	lds	r24, 0x00C0
-   1fda0:	85 ff       	sbrs	r24, 5
-   1fda2:	fc cf       	rjmp	.-8      	; 0x1fd9c <putch+0x2>
-  UDR0 = ch;
-   1fda4:	90 93 c6 00 	sts	0x00C6, r25
+  while (!(UART_SRA & _BV(UDRE0)));
+   1fd88:	80 91 c0 00 	lds	r24, 0x00C0
+   1fd8c:	85 ff       	sbrs	r24, 5
+   1fd8e:	fc cf       	rjmp	.-8      	; 0x1fd88 <putch+0x2>
+  UART_UDR = ch;
+   1fd90:	90 93 c6 00 	sts	0x00C6, r25
       [uartBit] "I" (UART_TX_BIT)
     :
       "r25"
   );
 #endif
 }
-   1fda8:	08 95       	ret
+   1fd94:	08 95       	ret
 
-0001fdaa <getch>:
+0001fd96 <getch>:
       [uartBit] "I" (UART_RX_BIT)
     :
       "r25"
 );
 #else
-  while(!(UCSR0A & _BV(RXC0)))
-   1fdaa:	80 91 c0 00 	lds	r24, 0x00C0
-   1fdae:	87 ff       	sbrs	r24, 7
-   1fdb0:	fc cf       	rjmp	.-8      	; 0x1fdaa <getch>
+  while(!(UART_SRA & _BV(RXC0)))
+   1fd96:	80 91 c0 00 	lds	r24, 0x00C0
+   1fd9a:	87 ff       	sbrs	r24, 7
+   1fd9c:	fc cf       	rjmp	.-8      	; 0x1fd96 <getch>
     ;
-  if (!(UCSR0A & _BV(FE0))) {
-   1fdb2:	80 91 c0 00 	lds	r24, 0x00C0
-   1fdb6:	84 fd       	sbrc	r24, 4
-   1fdb8:	01 c0       	rjmp	.+2      	; 0x1fdbc <getch+0x12>
+  if (!(UART_SRA & _BV(FE0))) {
+   1fd9e:	80 91 c0 00 	lds	r24, 0x00C0
+   1fda2:	84 fd       	sbrc	r24, 4
+   1fda4:	01 c0       	rjmp	.+2      	; 0x1fda8 <getch+0x12>
 }
 #endif
 
 // Watchdog functions. These are only safe with interrupts turned off.
 void watchdogReset() {
   __asm__ __volatile__ (
-   1fdba:	a8 95       	wdr
+   1fda6:	a8 95       	wdr
        * don't care that an invalid char is returned...)
        */
     watchdogReset();
   }
   
-  ch = UDR0;
-   1fdbc:	80 91 c6 00 	lds	r24, 0x00C6
+  ch = UART_UDR;
+   1fda8:	80 91 c6 00 	lds	r24, 0x00C6
   LED_PIN |= _BV(LED);
 #endif
 #endif
 
   return ch;
 }
-   1fdc0:	08 95       	ret
+   1fdac:	08 95       	ret
 
-0001fdc2 <watchdogConfig>:
+0001fdae <watchdogConfig>:
     "wdr\n"
   );
 }
 
 void watchdogConfig(uint8_t x) {
   WDTCSR = _BV(WDCE) | _BV(WDE);
-   1fdc2:	e0 e6       	ldi	r30, 0x60	; 96
-   1fdc4:	f0 e0       	ldi	r31, 0x00	; 0
-   1fdc6:	98 e1       	ldi	r25, 0x18	; 24
-   1fdc8:	90 83       	st	Z, r25
+   1fdae:	e0 e6       	ldi	r30, 0x60	; 96
+   1fdb0:	f0 e0       	ldi	r31, 0x00	; 0
+   1fdb2:	98 e1       	ldi	r25, 0x18	; 24
+   1fdb4:	90 83       	st	Z, r25
   WDTCSR = x;
-   1fdca:	80 83       	st	Z, r24
+   1fdb6:	80 83       	st	Z, r24
 }
-   1fdcc:	08 95       	ret
+   1fdb8:	08 95       	ret
 
-0001fdce <verifySpace>:
+0001fdba <verifySpace>:
   do getch(); while (--count);
   verifySpace();
 }
 
 void verifySpace() {
   if (getch() != CRC_EOP) {
-   1fdce:	ed df       	rcall	.-38     	; 0x1fdaa <getch>
-   1fdd0:	80 32       	cpi	r24, 0x20	; 32
-   1fdd2:	19 f0       	breq	.+6      	; 0x1fdda <verifySpace+0xc>
+   1fdba:	ed df       	rcall	.-38     	; 0x1fd96 <getch>
+   1fdbc:	80 32       	cpi	r24, 0x20	; 32
+   1fdbe:	19 f0       	breq	.+6      	; 0x1fdc6 <verifySpace+0xc>
     watchdogConfig(WATCHDOG_16MS);    // shorten WD timeout
-   1fdd4:	88 e0       	ldi	r24, 0x08	; 8
-   1fdd6:	f5 df       	rcall	.-22     	; 0x1fdc2 <watchdogConfig>
-   1fdd8:	ff cf       	rjmp	.-2      	; 0x1fdd8 <verifySpace+0xa>
+   1fdc0:	88 e0       	ldi	r24, 0x08	; 8
+   1fdc2:	f5 df       	rcall	.-22     	; 0x1fdae <watchdogConfig>
+   1fdc4:	ff cf       	rjmp	.-2      	; 0x1fdc4 <verifySpace+0xa>
     while (1)			      // and busy-loop so that WD causes
       ;				      //  a reset and app start.
   }
   putch(STK_INSYNC);
-   1fdda:	84 e1       	ldi	r24, 0x14	; 20
+   1fdc6:	84 e1       	ldi	r24, 0x14	; 20
 }
-   1fddc:	de cf       	rjmp	.-68     	; 0x1fd9a <putch>
+   1fdc8:	de cf       	rjmp	.-68     	; 0x1fd86 <putch>
 
-0001fdde <getNch>:
+0001fdca <getNch>:
     ::[count] "M" (UART_B_VALUE)
   );
 }
 #endif
 
 void getNch(uint8_t count) {
-   1fdde:	1f 93       	push	r17
-   1fde0:	18 2f       	mov	r17, r24
+   1fdca:	1f 93       	push	r17
+   1fdcc:	18 2f       	mov	r17, r24
   do getch(); while (--count);
-   1fde2:	e3 df       	rcall	.-58     	; 0x1fdaa <getch>
-   1fde4:	11 50       	subi	r17, 0x01	; 1
-   1fde6:	e9 f7       	brne	.-6      	; 0x1fde2 <getNch+0x4>
+   1fdce:	e3 df       	rcall	.-58     	; 0x1fd96 <getch>
+   1fdd0:	11 50       	subi	r17, 0x01	; 1
+   1fdd2:	e9 f7       	brne	.-6      	; 0x1fdce <getNch+0x4>
   verifySpace();
-   1fde8:	f2 df       	rcall	.-28     	; 0x1fdce <verifySpace>
+   1fdd4:	f2 df       	rcall	.-28     	; 0x1fdba <verifySpace>
 }
-   1fdea:	1f 91       	pop	r17
-   1fdec:	08 95       	ret
+   1fdd6:	1f 91       	pop	r17
+   1fdd8:	08 95       	ret
 
-0001fdee <appStart>:
-  WDTCSR = _BV(WDCE) | _BV(WDE);
-  WDTCSR = x;
-}
+0001fdda <appStart>:
+
+void appStart(uint8_t rstFlags) {
+  // 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" (rstFlags));
+   1fdda:	28 2e       	mov	r2, r24
 
-void appStart() {
   watchdogConfig(WATCHDOG_OFF);
-   1fdee:	80 e0       	ldi	r24, 0x00	; 0
-   1fdf0:	e8 df       	rcall	.-48     	; 0x1fdc2 <watchdogConfig>
+   1fddc:	80 e0       	ldi	r24, 0x00	; 0
+   1fdde:	e7 df       	rcall	.-50     	; 0x1fdae <watchdogConfig>
   __asm__ __volatile__ (
-   1fdf2:	ee 27       	eor	r30, r30
-   1fdf4:	ff 27       	eor	r31, r31
-   1fdf6:	09 94       	ijmp
+   1fde0:	ee 27       	eor	r30, r30
+   1fde2:	ff 27       	eor	r31, r31
+   1fde4:	09 94       	ijmp

+ 28 - 28
optiboot/bootloaders/optiboot/optiboot_atmega328.hex

@@ -1,34 +1,34 @@
-:107E0000112484B714BE81FFE8D085E080938100FF
+:107E0000112484B714BE81FFE6D085E08093810001
 :107E100082E08093C00088E18093C10086E0809377
-:107E2000C20080E18093C4008EE0C1D0259A86E034
+:107E2000C20080E18093C4008EE0BFD0259A86E036
 :107E300020E33CEF91E0309385002093840096BBD3
 :107E4000B09BFECF1D9AA8958150A9F7EE24FF2480
 :107E5000AA24A394B5E0CB2EA1E1BA2EF3E0DF2E45
-:107E60009AD0813471F497D0082FA7D0023811F43A
-:107E700086E005C0013811F484E001C083E083D0BE
-:107E80007FC0823411F484E103C0853419F485E0A5
-:107E90009CD076C0853579F47ED0E82EFF247BD047
-:107EA000082F10E0102F00270E291F29000F111F87
-:107EB00084D0780165C0863521F484E086D080E0E6
-:107EC000DECF843609F040C066D065D0082F63D07D
-:107ED00080E0E81680E7F80618F4F701D7BEE895C9
-:107EE000C0E0D1E058D089930C17E1F7F0E0EF162D
-:107EF000F0E7FF0618F0F701D7BEE8955ED007B6A9
-:107F000000FCFDCFA701A0E0B1E02C9130E011967C
-:107F10008C91119790E0982F8827822B932B1296A3
-:107F2000FA010C01A7BEE89511244E5F5F4FF1E006
-:107F3000A038BF0751F7F701C7BEE89507B600FCA8
-:107F4000FDCFB7BEE8951CC0843761F424D023D0A0
-:107F5000082F21D032D0F70185917F0114D0015034
-:107F6000D1F70EC0853739F428D08EE10CD085E9E1
-:107F70000AD08FE084CF813511F488E018D01DD06D
-:107F800080E101D06DCF982F8091C00085FFFCCF9C
-:107F90009093C60008958091C00087FFFCCF809128
-:107FA000C00084FD01C0A8958091C6000895E0E658
-:107FB000F0E098E1908380830895EDDF803219F03E
-:107FC00088E0F5DFFFCF84E1DECF1F93182FE3DFDA
-:107FD0001150E9F7F2DF1F910895282E80E0E7DFC6
-:067FE000EE27FF270994C3
-:027FFE00060477
+:107E600098D0813461F495D0082FA5D0023829F13B
+:107E7000013811F485E001C083E083D07FC08234F3
+:107E800011F484E103C0853419F485E09CD076C0F8
+:107E9000853579F47ED0E82EFF247BD0082F10E0C2
+:107EA000102F00270E291F29000F111F84D07801E1
+:107EB00065C0863521F484E086D080E0DECF84364C
+:107EC00009F040C066D065D0082F63D080E0E81686
+:107ED00080E7F80618F4F701D7BEE895C0E0D1E0D6
+:107EE00058D089930C17E1F7F0E0EF16F0E7FF06A2
+:107EF00018F0F701D7BEE8955ED007B600FCFDCFBD
+:107F0000A701A0E0B1E02C9130E011968C9111977F
+:107F100090E0982F8827822B932B1296FA010C0160
+:107F2000A7BEE89511244E5F5F4FF1E0A038BF0770
+:107F300051F7F701C7BEE89507B600FCFDCFB7BE05
+:107F4000E8951CC0843761F424D023D0082F21D0B9
+:107F500032D0F70185917F0114D00150D1F70EC0C6
+:107F6000853739F428D08EE10CD085E90AD08FE02E
+:107F700084CF813511F488E018D01DD080E101D084
+:107F80006FCF982F8091C00085FFFCCF9093C600E3
+:107F900008958091C00087FFFCCF8091C00084FDD0
+:107FA00001C0A8958091C6000895E0E6F0E098E150
+:107FB000908380830895EDDF803219F088E0F5DF4B
+:107FC000FFCF84E1DECF1F93182FE3DF1150E9F7D5
+:107FD000F2DF1F910895282E80E0E7DFEE27FF27CC
+:027FE000099402
+:027FFE0000057C
 :0400000300007E007B
 :00000001FF

+ 213 - 212
optiboot/bootloaders/optiboot/optiboot_atmega328.lst

@@ -3,27 +3,27 @@ optiboot_atmega328.elf:     file format elf32-avr
 
 Sections:
 Idx Name          Size      VMA       LMA       File off  Algn
-  0 .text         000001e6  00007e00  00007e00  00000054  2**1
+  0 .text         000001e2  00007e00  00007e00  00000054  2**1
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
-  1 .version      00000002  00007ffe  00007ffe  0000023a  2**0
+  1 .version      00000002  00007ffe  00007ffe  00000236  2**0
                   CONTENTS, READONLY
-  2 .debug_aranges 00000028  00000000  00000000  0000023c  2**0
+  2 .debug_aranges 00000028  00000000  00000000  00000238  2**0
                   CONTENTS, READONLY, DEBUGGING
-  3 .debug_pubnames 0000005f  00000000  00000000  00000264  2**0
+  3 .debug_pubnames 0000005f  00000000  00000000  00000260  2**0
                   CONTENTS, READONLY, DEBUGGING
-  4 .debug_info   00000294  00000000  00000000  000002c3  2**0
+  4 .debug_info   00000294  00000000  00000000  000002bf  2**0
                   CONTENTS, READONLY, DEBUGGING
-  5 .debug_abbrev 0000016b  00000000  00000000  00000557  2**0
+  5 .debug_abbrev 0000016b  00000000  00000000  00000553  2**0
                   CONTENTS, READONLY, DEBUGGING
-  6 .debug_line   00000470  00000000  00000000  000006c2  2**0
+  6 .debug_line   00000421  00000000  00000000  000006be  2**0
                   CONTENTS, READONLY, DEBUGGING
-  7 .debug_frame  00000080  00000000  00000000  00000b34  2**2
+  7 .debug_frame  00000080  00000000  00000000  00000ae0  2**2
                   CONTENTS, READONLY, DEBUGGING
-  8 .debug_str    00000131  00000000  00000000  00000bb4  2**0
+  8 .debug_str    00000131  00000000  00000000  00000b60  2**0
                   CONTENTS, READONLY, DEBUGGING
-  9 .debug_loc    00000266  00000000  00000000  00000ce5  2**0
+  9 .debug_loc    00000266  00000000  00000000  00000c91  2**0
                   CONTENTS, READONLY, DEBUGGING
- 10 .debug_ranges 00000078  00000000  00000000  00000f4b  2**0
+ 10 .debug_ranges 00000078  00000000  00000000  00000ef7  2**0
                   CONTENTS, READONLY, DEBUGGING
 
 Disassembly of section .text:
@@ -36,7 +36,7 @@ Disassembly of section .text:
 /* main program starts here */
 int main(void) {
     7e00:	11 24       	eor	r1, r1
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__)
   SP=RAMEND;  // This is done by hardware reset
 #endif
 
@@ -47,7 +47,7 @@ int main(void) {
     7e04:	14 be       	out	0x34, r1	; 52
   if (!(ch & _BV(EXTRF))) appStart(ch);
     7e06:	81 ff       	sbrs	r24, 1
-    7e08:	e8 d0       	rcall	.+464    	; 0x7fda <appStart>
+    7e08:	e6 d0       	rcall	.+460    	; 0x7fd6 <appStart>
 
 #if LED_START_FLASHES > 0
   // Set up Timer 1 for timeout counter
@@ -77,8 +77,9 @@ int main(void) {
   // Set up watchdog to trigger after 500ms
   watchdogConfig(WATCHDOG_1S);
     7e28:	8e e0       	ldi	r24, 0x0E	; 14
-    7e2a:	c1 d0       	rcall	.+386    	; 0x7fae <watchdogConfig>
+    7e2a:	bf d0       	rcall	.+382    	; 0x7faa <watchdogConfig>
 
+#if (LED_START_FLASHES > 0) || defined(LED_DATA_FLASH)
   /* Set LED pin as output */
   LED_DDR |= _BV(LED);
     7e2c:	25 9a       	sbi	0x04, 5	; 4
@@ -106,7 +107,7 @@ void flash_led(uint8_t count) {
     while(!(TIFR1 & _BV(TOV1)));
     7e40:	b0 9b       	sbis	0x16, 0	; 22
     7e42:	fe cf       	rjmp	.-4      	; 0x7e40 <main+0x40>
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__)  || defined (__AVR_ATmega32__)
     LED_PORT ^= _BV(LED);
 #else
     LED_PIN |= _BV(LED);
@@ -150,11 +151,11 @@ void watchdogReset() {
       boot_rww_enable();
     7e58:	a1 e1       	ldi	r26, 0x11	; 17
     7e5a:	ba 2e       	mov	r11, r26
-      do *bufPtr++ = getch();
-      while (--length);
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
     7e5c:	f3 e0       	ldi	r31, 0x03	; 3
     7e5e:	df 2e       	mov	r13, r31
@@ -164,422 +165,422 @@ void watchdogReset() {
   for (;;) {
     /* get character from UART */
     ch = getch();
-    7e60:	9a d0       	rcall	.+308    	; 0x7f96 <getch>
+    7e60:	98 d0       	rcall	.+304    	; 0x7f92 <getch>
 
     if(ch == STK_GET_PARAMETER) {
     7e62:	81 34       	cpi	r24, 0x41	; 65
-    7e64:	71 f4       	brne	.+28     	; 0x7e82 <main+0x82>
+    7e64:	61 f4       	brne	.+24     	; 0x7e7e <main+0x7e>
       unsigned char which = getch();
-    7e66:	97 d0       	rcall	.+302    	; 0x7f96 <getch>
+    7e66:	95 d0       	rcall	.+298    	; 0x7f92 <getch>
     7e68:	08 2f       	mov	r16, r24
       verifySpace();
-    7e6a:	a7 d0       	rcall	.+334    	; 0x7fba <verifySpace>
+    7e6a:	a5 d0       	rcall	.+330    	; 0x7fb6 <verifySpace>
       if (which == 0x82) {
     7e6c:	02 38       	cpi	r16, 0x82	; 130
-    7e6e:	11 f4       	brne	.+4      	; 0x7e74 <main+0x74>
+    7e6e:	29 f1       	breq	.+74     	; 0x7eba <main+0xba>
 	/*
 	 * Send optiboot version as "minor SW version"
 	 */
 	putch(OPTIBOOT_MINVER);
-    7e70:	86 e0       	ldi	r24, 0x06	; 6
-    7e72:	05 c0       	rjmp	.+10     	; 0x7e7e <main+0x7e>
       } else if (which == 0x81) {
-    7e74:	01 38       	cpi	r16, 0x81	; 129
-    7e76:	11 f4       	brne	.+4      	; 0x7e7c <main+0x7c>
+    7e70:	01 38       	cpi	r16, 0x81	; 129
+    7e72:	11 f4       	brne	.+4      	; 0x7e78 <main+0x78>
 	  putch(OPTIBOOT_MAJVER);
-    7e78:	84 e0       	ldi	r24, 0x04	; 4
-    7e7a:	01 c0       	rjmp	.+2      	; 0x7e7e <main+0x7e>
+    7e74:	85 e0       	ldi	r24, 0x05	; 5
+    7e76:	01 c0       	rjmp	.+2      	; 0x7e7a <main+0x7a>
       } else {
 	/*
 	 * GET PARAMETER returns a generic 0x03 reply for
          * other parameters - enough to keep Avrdude happy
 	 */
 	putch(0x03);
-    7e7c:	83 e0       	ldi	r24, 0x03	; 3
-    7e7e:	83 d0       	rcall	.+262    	; 0x7f86 <putch>
-    7e80:	7f c0       	rjmp	.+254    	; 0x7f80 <main+0x180>
+    7e78:	83 e0       	ldi	r24, 0x03	; 3
+    7e7a:	83 d0       	rcall	.+262    	; 0x7f82 <putch>
+    7e7c:	7f c0       	rjmp	.+254    	; 0x7f7c <main+0x17c>
       }
     }
     else if(ch == STK_SET_DEVICE) {
-    7e82:	82 34       	cpi	r24, 0x42	; 66
-    7e84:	11 f4       	brne	.+4      	; 0x7e8a <main+0x8a>
+    7e7e:	82 34       	cpi	r24, 0x42	; 66
+    7e80:	11 f4       	brne	.+4      	; 0x7e86 <main+0x86>
       // SET DEVICE is ignored
       getNch(20);
-    7e86:	84 e1       	ldi	r24, 0x14	; 20
-    7e88:	03 c0       	rjmp	.+6      	; 0x7e90 <main+0x90>
+    7e82:	84 e1       	ldi	r24, 0x14	; 20
+    7e84:	03 c0       	rjmp	.+6      	; 0x7e8c <main+0x8c>
     }
     else if(ch == STK_SET_DEVICE_EXT) {
-    7e8a:	85 34       	cpi	r24, 0x45	; 69
-    7e8c:	19 f4       	brne	.+6      	; 0x7e94 <main+0x94>
+    7e86:	85 34       	cpi	r24, 0x45	; 69
+    7e88:	19 f4       	brne	.+6      	; 0x7e90 <main+0x90>
       // SET DEVICE EXT is ignored
       getNch(5);
-    7e8e:	85 e0       	ldi	r24, 0x05	; 5
-    7e90:	9c d0       	rcall	.+312    	; 0x7fca <getNch>
-    7e92:	76 c0       	rjmp	.+236    	; 0x7f80 <main+0x180>
+    7e8a:	85 e0       	ldi	r24, 0x05	; 5
+    7e8c:	9c d0       	rcall	.+312    	; 0x7fc6 <getNch>
+    7e8e:	76 c0       	rjmp	.+236    	; 0x7f7c <main+0x17c>
     }
     else if(ch == STK_LOAD_ADDRESS) {
-    7e94:	85 35       	cpi	r24, 0x55	; 85
-    7e96:	79 f4       	brne	.+30     	; 0x7eb6 <main+0xb6>
+    7e90:	85 35       	cpi	r24, 0x55	; 85
+    7e92:	79 f4       	brne	.+30     	; 0x7eb2 <main+0xb2>
       // LOAD ADDRESS
       uint16_t newAddress;
       newAddress = getch();
-    7e98:	7e d0       	rcall	.+252    	; 0x7f96 <getch>
+    7e94:	7e d0       	rcall	.+252    	; 0x7f92 <getch>
       newAddress = (newAddress & 0xff) | (getch() << 8);
-    7e9a:	e8 2e       	mov	r14, r24
-    7e9c:	ff 24       	eor	r15, r15
-    7e9e:	7b d0       	rcall	.+246    	; 0x7f96 <getch>
-    7ea0:	08 2f       	mov	r16, r24
-    7ea2:	10 e0       	ldi	r17, 0x00	; 0
-    7ea4:	10 2f       	mov	r17, r16
-    7ea6:	00 27       	eor	r16, r16
-    7ea8:	0e 29       	or	r16, r14
-    7eaa:	1f 29       	or	r17, r15
+    7e96:	e8 2e       	mov	r14, r24
+    7e98:	ff 24       	eor	r15, r15
+    7e9a:	7b d0       	rcall	.+246    	; 0x7f92 <getch>
+    7e9c:	08 2f       	mov	r16, r24
+    7e9e:	10 e0       	ldi	r17, 0x00	; 0
+    7ea0:	10 2f       	mov	r17, r16
+    7ea2:	00 27       	eor	r16, r16
+    7ea4:	0e 29       	or	r16, r14
+    7ea6:	1f 29       	or	r17, r15
 #ifdef RAMPZ
       // Transfer top bit to RAMPZ
       RAMPZ = (newAddress & 0x8000) ? 1 : 0;
 #endif
       newAddress += newAddress; // Convert from word address to byte address
-    7eac:	00 0f       	add	r16, r16
-    7eae:	11 1f       	adc	r17, r17
+    7ea8:	00 0f       	add	r16, r16
+    7eaa:	11 1f       	adc	r17, r17
       address = newAddress;
       verifySpace();
-    7eb0:	84 d0       	rcall	.+264    	; 0x7fba <verifySpace>
-    7eb2:	78 01       	movw	r14, r16
-    7eb4:	65 c0       	rjmp	.+202    	; 0x7f80 <main+0x180>
+    7eac:	84 d0       	rcall	.+264    	; 0x7fb6 <verifySpace>
+    7eae:	78 01       	movw	r14, r16
+    7eb0:	65 c0       	rjmp	.+202    	; 0x7f7c <main+0x17c>
     }
     else if(ch == STK_UNIVERSAL) {
-    7eb6:	86 35       	cpi	r24, 0x56	; 86
-    7eb8:	21 f4       	brne	.+8      	; 0x7ec2 <main+0xc2>
+    7eb2:	86 35       	cpi	r24, 0x56	; 86
+    7eb4:	21 f4       	brne	.+8      	; 0x7ebe <main+0xbe>
       // UNIVERSAL command is ignored
       getNch(4);
-    7eba:	84 e0       	ldi	r24, 0x04	; 4
-    7ebc:	86 d0       	rcall	.+268    	; 0x7fca <getNch>
+    7eb6:	84 e0       	ldi	r24, 0x04	; 4
+    7eb8:	86 d0       	rcall	.+268    	; 0x7fc6 <getNch>
       putch(0x00);
-    7ebe:	80 e0       	ldi	r24, 0x00	; 0
-    7ec0:	de cf       	rjmp	.-68     	; 0x7e7e <main+0x7e>
+    7eba:	80 e0       	ldi	r24, 0x00	; 0
+    7ebc:	de cf       	rjmp	.-68     	; 0x7e7a <main+0x7a>
     }
     /* Write memory, length is big endian and is in bytes */
     else if(ch == STK_PROG_PAGE) {
-    7ec2:	84 36       	cpi	r24, 0x64	; 100
-    7ec4:	09 f0       	breq	.+2      	; 0x7ec8 <main+0xc8>
-    7ec6:	40 c0       	rjmp	.+128    	; 0x7f48 <main+0x148>
+    7ebe:	84 36       	cpi	r24, 0x64	; 100
+    7ec0:	09 f0       	breq	.+2      	; 0x7ec4 <main+0xc4>
+    7ec2:	40 c0       	rjmp	.+128    	; 0x7f44 <main+0x144>
       // PROGRAM PAGE - we support flash programming only, not EEPROM
       uint8_t *bufPtr;
       uint16_t addrPtr;
 
       getch();			/* getlen() */
-    7ec8:	66 d0       	rcall	.+204    	; 0x7f96 <getch>
+    7ec4:	66 d0       	rcall	.+204    	; 0x7f92 <getch>
       length = getch();
-    7eca:	65 d0       	rcall	.+202    	; 0x7f96 <getch>
-    7ecc:	08 2f       	mov	r16, r24
+    7ec6:	65 d0       	rcall	.+202    	; 0x7f92 <getch>
+    7ec8:	08 2f       	mov	r16, r24
       getch();
-    7ece:	63 d0       	rcall	.+198    	; 0x7f96 <getch>
+    7eca:	63 d0       	rcall	.+198    	; 0x7f92 <getch>
 
       // If we are in RWW section, immediately start page erase
       if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    7ed0:	80 e0       	ldi	r24, 0x00	; 0
-    7ed2:	e8 16       	cp	r14, r24
-    7ed4:	80 e7       	ldi	r24, 0x70	; 112
-    7ed6:	f8 06       	cpc	r15, r24
-    7ed8:	18 f4       	brcc	.+6      	; 0x7ee0 <main+0xe0>
-    7eda:	f7 01       	movw	r30, r14
-    7edc:	d7 be       	out	0x37, r13	; 55
-    7ede:	e8 95       	spm
-    7ee0:	c0 e0       	ldi	r28, 0x00	; 0
-    7ee2:	d1 e0       	ldi	r29, 0x01	; 1
+    7ecc:	80 e0       	ldi	r24, 0x00	; 0
+    7ece:	e8 16       	cp	r14, r24
+    7ed0:	80 e7       	ldi	r24, 0x70	; 112
+    7ed2:	f8 06       	cpc	r15, r24
+    7ed4:	18 f4       	brcc	.+6      	; 0x7edc <main+0xdc>
+    7ed6:	f7 01       	movw	r30, r14
+    7ed8:	d7 be       	out	0x37, r13	; 55
+    7eda:	e8 95       	spm
+    7edc:	c0 e0       	ldi	r28, 0x00	; 0
+    7ede:	d1 e0       	ldi	r29, 0x01	; 1
 
       // While that is going on, read in page contents
       bufPtr = buff;
       do *bufPtr++ = getch();
-    7ee4:	58 d0       	rcall	.+176    	; 0x7f96 <getch>
-    7ee6:	89 93       	st	Y+, r24
+    7ee0:	58 d0       	rcall	.+176    	; 0x7f92 <getch>
+    7ee2:	89 93       	st	Y+, r24
       while (--length);
-    7ee8:	0c 17       	cp	r16, r28
-    7eea:	e1 f7       	brne	.-8      	; 0x7ee4 <main+0xe4>
+    7ee4:	0c 17       	cp	r16, r28
+    7ee6:	e1 f7       	brne	.-8      	; 0x7ee0 <main+0xe0>
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    7eec:	f0 e0       	ldi	r31, 0x00	; 0
-    7eee:	ef 16       	cp	r14, r31
-    7ef0:	f0 e7       	ldi	r31, 0x70	; 112
-    7ef2:	ff 06       	cpc	r15, r31
-    7ef4:	18 f0       	brcs	.+6      	; 0x7efc <main+0xfc>
-    7ef6:	f7 01       	movw	r30, r14
-    7ef8:	d7 be       	out	0x37, r13	; 55
-    7efa:	e8 95       	spm
+    7ee8:	f0 e0       	ldi	r31, 0x00	; 0
+    7eea:	ef 16       	cp	r14, r31
+    7eec:	f0 e7       	ldi	r31, 0x70	; 112
+    7eee:	ff 06       	cpc	r15, r31
+    7ef0:	18 f0       	brcs	.+6      	; 0x7ef8 <main+0xf8>
+    7ef2:	f7 01       	movw	r30, r14
+    7ef4:	d7 be       	out	0x37, r13	; 55
+    7ef6:	e8 95       	spm
 
       // Read command terminator, start reply
       verifySpace();
-    7efc:	5e d0       	rcall	.+188    	; 0x7fba <verifySpace>
+    7ef8:	5e d0       	rcall	.+188    	; 0x7fb6 <verifySpace>
 
       // If only a partial page is to be programmed, the erase might not be complete.
       // So check that here
       boot_spm_busy_wait();
-    7efe:	07 b6       	in	r0, 0x37	; 55
-    7f00:	00 fc       	sbrc	r0, 0
-    7f02:	fd cf       	rjmp	.-6      	; 0x7efe <main+0xfe>
-    7f04:	a7 01       	movw	r20, r14
-    7f06:	a0 e0       	ldi	r26, 0x00	; 0
-    7f08:	b1 e0       	ldi	r27, 0x01	; 1
+    7efa:	07 b6       	in	r0, 0x37	; 55
+    7efc:	00 fc       	sbrc	r0, 0
+    7efe:	fd cf       	rjmp	.-6      	; 0x7efa <main+0xfa>
+    7f00:	a7 01       	movw	r20, r14
+    7f02:	a0 e0       	ldi	r26, 0x00	; 0
+    7f04:	b1 e0       	ldi	r27, 0x01	; 1
       bufPtr = buff;
       addrPtr = (uint16_t)(void*)address;
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
-    7f0a:	2c 91       	ld	r18, X
-    7f0c:	30 e0       	ldi	r19, 0x00	; 0
+    7f06:	2c 91       	ld	r18, X
+    7f08:	30 e0       	ldi	r19, 0x00	; 0
         a |= (*bufPtr++) << 8;
-    7f0e:	11 96       	adiw	r26, 0x01	; 1
-    7f10:	8c 91       	ld	r24, X
-    7f12:	11 97       	sbiw	r26, 0x01	; 1
-    7f14:	90 e0       	ldi	r25, 0x00	; 0
-    7f16:	98 2f       	mov	r25, r24
-    7f18:	88 27       	eor	r24, r24
-    7f1a:	82 2b       	or	r24, r18
-    7f1c:	93 2b       	or	r25, r19
+    7f0a:	11 96       	adiw	r26, 0x01	; 1
+    7f0c:	8c 91       	ld	r24, X
+    7f0e:	11 97       	sbiw	r26, 0x01	; 1
+    7f10:	90 e0       	ldi	r25, 0x00	; 0
+    7f12:	98 2f       	mov	r25, r24
+    7f14:	88 27       	eor	r24, r24
+    7f16:	82 2b       	or	r24, r18
+    7f18:	93 2b       	or	r25, r19
 # define UART_SRL UBRR3L
 # define UART_UDR UDR3
 #endif
 
 /* main program starts here */
 int main(void) {
-    7f1e:	12 96       	adiw	r26, 0x02	; 2
+    7f1a:	12 96       	adiw	r26, 0x02	; 2
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
         a |= (*bufPtr++) << 8;
         __boot_page_fill_short((uint16_t)(void*)addrPtr,a);
-    7f20:	fa 01       	movw	r30, r20
-    7f22:	0c 01       	movw	r0, r24
-    7f24:	a7 be       	out	0x37, r10	; 55
-    7f26:	e8 95       	spm
-    7f28:	11 24       	eor	r1, r1
+    7f1c:	fa 01       	movw	r30, r20
+    7f1e:	0c 01       	movw	r0, r24
+    7f20:	a7 be       	out	0x37, r10	; 55
+    7f22:	e8 95       	spm
+    7f24:	11 24       	eor	r1, r1
         addrPtr += 2;
-    7f2a:	4e 5f       	subi	r20, 0xFE	; 254
-    7f2c:	5f 4f       	sbci	r21, 0xFF	; 255
+    7f26:	4e 5f       	subi	r20, 0xFE	; 254
+    7f28:	5f 4f       	sbci	r21, 0xFF	; 255
       } while (--ch);
-    7f2e:	f1 e0       	ldi	r31, 0x01	; 1
-    7f30:	a0 38       	cpi	r26, 0x80	; 128
-    7f32:	bf 07       	cpc	r27, r31
-    7f34:	51 f7       	brne	.-44     	; 0x7f0a <main+0x10a>
+    7f2a:	f1 e0       	ldi	r31, 0x01	; 1
+    7f2c:	a0 38       	cpi	r26, 0x80	; 128
+    7f2e:	bf 07       	cpc	r27, r31
+    7f30:	51 f7       	brne	.-44     	; 0x7f06 <main+0x106>
 
       // Write from programming buffer
       __boot_page_write_short((uint16_t)(void*)address);
-    7f36:	f7 01       	movw	r30, r14
-    7f38:	c7 be       	out	0x37, r12	; 55
-    7f3a:	e8 95       	spm
+    7f32:	f7 01       	movw	r30, r14
+    7f34:	c7 be       	out	0x37, r12	; 55
+    7f36:	e8 95       	spm
       boot_spm_busy_wait();
-    7f3c:	07 b6       	in	r0, 0x37	; 55
-    7f3e:	00 fc       	sbrc	r0, 0
-    7f40:	fd cf       	rjmp	.-6      	; 0x7f3c <main+0x13c>
+    7f38:	07 b6       	in	r0, 0x37	; 55
+    7f3a:	00 fc       	sbrc	r0, 0
+    7f3c:	fd cf       	rjmp	.-6      	; 0x7f38 <main+0x138>
 
 #if defined(RWWSRE)
       // Reenable read access to flash
       boot_rww_enable();
-    7f42:	b7 be       	out	0x37, r11	; 55
-    7f44:	e8 95       	spm
-    7f46:	1c c0       	rjmp	.+56     	; 0x7f80 <main+0x180>
+    7f3e:	b7 be       	out	0x37, r11	; 55
+    7f40:	e8 95       	spm
+    7f42:	1c c0       	rjmp	.+56     	; 0x7f7c <main+0x17c>
 #endif
 
     }
     /* Read memory block mode, length is big endian.  */
     else if(ch == STK_READ_PAGE) {
-    7f48:	84 37       	cpi	r24, 0x74	; 116
-    7f4a:	61 f4       	brne	.+24     	; 0x7f64 <main+0x164>
+    7f44:	84 37       	cpi	r24, 0x74	; 116
+    7f46:	61 f4       	brne	.+24     	; 0x7f60 <main+0x160>
       // READ PAGE - we only read flash
       getch();			/* getlen() */
-    7f4c:	24 d0       	rcall	.+72     	; 0x7f96 <getch>
+    7f48:	24 d0       	rcall	.+72     	; 0x7f92 <getch>
       length = getch();
-    7f4e:	23 d0       	rcall	.+70     	; 0x7f96 <getch>
-    7f50:	08 2f       	mov	r16, r24
+    7f4a:	23 d0       	rcall	.+70     	; 0x7f92 <getch>
+    7f4c:	08 2f       	mov	r16, r24
       getch();
-    7f52:	21 d0       	rcall	.+66     	; 0x7f96 <getch>
+    7f4e:	21 d0       	rcall	.+66     	; 0x7f92 <getch>
 
       verifySpace();
-    7f54:	32 d0       	rcall	.+100    	; 0x7fba <verifySpace>
+    7f50:	32 d0       	rcall	.+100    	; 0x7fb6 <verifySpace>
         __asm__ ("elpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #else
         // read a Flash byte and increment the address
         __asm__ ("lpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #endif
         putch(ch);
-    7f56:	f7 01       	movw	r30, r14
-    7f58:	85 91       	lpm	r24, Z+
-    7f5a:	7f 01       	movw	r14, r30
-    7f5c:	14 d0       	rcall	.+40     	; 0x7f86 <putch>
+    7f52:	f7 01       	movw	r30, r14
+    7f54:	85 91       	lpm	r24, Z+
+    7f56:	7f 01       	movw	r14, r30
+    7f58:	14 d0       	rcall	.+40     	; 0x7f82 <putch>
       } while (--length);
-    7f5e:	01 50       	subi	r16, 0x01	; 1
-    7f60:	d1 f7       	brne	.-12     	; 0x7f56 <main+0x156>
-    7f62:	0e c0       	rjmp	.+28     	; 0x7f80 <main+0x180>
+    7f5a:	01 50       	subi	r16, 0x01	; 1
+    7f5c:	d1 f7       	brne	.-12     	; 0x7f52 <main+0x152>
+    7f5e:	0e c0       	rjmp	.+28     	; 0x7f7c <main+0x17c>
     }
 
     /* Get device signature bytes  */
     else if(ch == STK_READ_SIGN) {
-    7f64:	85 37       	cpi	r24, 0x75	; 117
-    7f66:	39 f4       	brne	.+14     	; 0x7f76 <main+0x176>
+    7f60:	85 37       	cpi	r24, 0x75	; 117
+    7f62:	39 f4       	brne	.+14     	; 0x7f72 <main+0x172>
       // READ SIGN - return what Avrdude wants to hear
       verifySpace();
-    7f68:	28 d0       	rcall	.+80     	; 0x7fba <verifySpace>
+    7f64:	28 d0       	rcall	.+80     	; 0x7fb6 <verifySpace>
       putch(SIGNATURE_0);
-    7f6a:	8e e1       	ldi	r24, 0x1E	; 30
-    7f6c:	0c d0       	rcall	.+24     	; 0x7f86 <putch>
+    7f66:	8e e1       	ldi	r24, 0x1E	; 30
+    7f68:	0c d0       	rcall	.+24     	; 0x7f82 <putch>
       putch(SIGNATURE_1);
-    7f6e:	85 e9       	ldi	r24, 0x95	; 149
-    7f70:	0a d0       	rcall	.+20     	; 0x7f86 <putch>
+    7f6a:	85 e9       	ldi	r24, 0x95	; 149
+    7f6c:	0a d0       	rcall	.+20     	; 0x7f82 <putch>
       putch(SIGNATURE_2);
-    7f72:	8f e0       	ldi	r24, 0x0F	; 15
-    7f74:	84 cf       	rjmp	.-248    	; 0x7e7e <main+0x7e>
+    7f6e:	8f e0       	ldi	r24, 0x0F	; 15
+    7f70:	84 cf       	rjmp	.-248    	; 0x7e7a <main+0x7a>
     }
     else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */
-    7f76:	81 35       	cpi	r24, 0x51	; 81
-    7f78:	11 f4       	brne	.+4      	; 0x7f7e <main+0x17e>
+    7f72:	81 35       	cpi	r24, 0x51	; 81
+    7f74:	11 f4       	brne	.+4      	; 0x7f7a <main+0x17a>
       // Adaboot no-wait mod
       watchdogConfig(WATCHDOG_16MS);
-    7f7a:	88 e0       	ldi	r24, 0x08	; 8
-    7f7c:	18 d0       	rcall	.+48     	; 0x7fae <watchdogConfig>
+    7f76:	88 e0       	ldi	r24, 0x08	; 8
+    7f78:	18 d0       	rcall	.+48     	; 0x7faa <watchdogConfig>
       verifySpace();
     }
     else {
       // This covers the response to commands like STK_ENTER_PROGMODE
       verifySpace();
-    7f7e:	1d d0       	rcall	.+58     	; 0x7fba <verifySpace>
+    7f7a:	1d d0       	rcall	.+58     	; 0x7fb6 <verifySpace>
     }
     putch(STK_OK);
-    7f80:	80 e1       	ldi	r24, 0x10	; 16
-    7f82:	01 d0       	rcall	.+2      	; 0x7f86 <putch>
-    7f84:	6d cf       	rjmp	.-294    	; 0x7e60 <main+0x60>
+    7f7c:	80 e1       	ldi	r24, 0x10	; 16
+    7f7e:	01 d0       	rcall	.+2      	; 0x7f82 <putch>
+    7f80:	6f cf       	rjmp	.-290    	; 0x7e60 <main+0x60>
 
-00007f86 <putch>:
+00007f82 <putch>:
   }
 }
 
 void putch(char ch) {
-    7f86:	98 2f       	mov	r25, r24
+    7f82:	98 2f       	mov	r25, r24
 #ifndef SOFT_UART
   while (!(UART_SRA & _BV(UDRE0)));
-    7f88:	80 91 c0 00 	lds	r24, 0x00C0
-    7f8c:	85 ff       	sbrs	r24, 5
-    7f8e:	fc cf       	rjmp	.-8      	; 0x7f88 <putch+0x2>
+    7f84:	80 91 c0 00 	lds	r24, 0x00C0
+    7f88:	85 ff       	sbrs	r24, 5
+    7f8a:	fc cf       	rjmp	.-8      	; 0x7f84 <putch+0x2>
   UART_UDR = ch;
-    7f90:	90 93 c6 00 	sts	0x00C6, r25
+    7f8c:	90 93 c6 00 	sts	0x00C6, r25
       [uartBit] "I" (UART_TX_BIT)
     :
       "r25"
   );
 #endif
 }
-    7f94:	08 95       	ret
+    7f90:	08 95       	ret
 
-00007f96 <getch>:
+00007f92 <getch>:
       [uartBit] "I" (UART_RX_BIT)
     :
       "r25"
 );
 #else
   while(!(UART_SRA & _BV(RXC0)))
-    7f96:	80 91 c0 00 	lds	r24, 0x00C0
-    7f9a:	87 ff       	sbrs	r24, 7
-    7f9c:	fc cf       	rjmp	.-8      	; 0x7f96 <getch>
+    7f92:	80 91 c0 00 	lds	r24, 0x00C0
+    7f96:	87 ff       	sbrs	r24, 7
+    7f98:	fc cf       	rjmp	.-8      	; 0x7f92 <getch>
     ;
   if (!(UART_SRA & _BV(FE0))) {
-    7f9e:	80 91 c0 00 	lds	r24, 0x00C0
-    7fa2:	84 fd       	sbrc	r24, 4
-    7fa4:	01 c0       	rjmp	.+2      	; 0x7fa8 <getch+0x12>
+    7f9a:	80 91 c0 00 	lds	r24, 0x00C0
+    7f9e:	84 fd       	sbrc	r24, 4
+    7fa0:	01 c0       	rjmp	.+2      	; 0x7fa4 <getch+0x12>
 }
 #endif
 
 // Watchdog functions. These are only safe with interrupts turned off.
 void watchdogReset() {
   __asm__ __volatile__ (
-    7fa6:	a8 95       	wdr
+    7fa2:	a8 95       	wdr
        * don't care that an invalid char is returned...)
        */
     watchdogReset();
   }
   
   ch = UART_UDR;
-    7fa8:	80 91 c6 00 	lds	r24, 0x00C6
+    7fa4:	80 91 c6 00 	lds	r24, 0x00C6
   LED_PIN |= _BV(LED);
 #endif
 #endif
 
   return ch;
 }
-    7fac:	08 95       	ret
+    7fa8:	08 95       	ret
 
-00007fae <watchdogConfig>:
+00007faa <watchdogConfig>:
     "wdr\n"
   );
 }
 
 void watchdogConfig(uint8_t x) {
   WDTCSR = _BV(WDCE) | _BV(WDE);
-    7fae:	e0 e6       	ldi	r30, 0x60	; 96
-    7fb0:	f0 e0       	ldi	r31, 0x00	; 0
-    7fb2:	98 e1       	ldi	r25, 0x18	; 24
-    7fb4:	90 83       	st	Z, r25
+    7faa:	e0 e6       	ldi	r30, 0x60	; 96
+    7fac:	f0 e0       	ldi	r31, 0x00	; 0
+    7fae:	98 e1       	ldi	r25, 0x18	; 24
+    7fb0:	90 83       	st	Z, r25
   WDTCSR = x;
-    7fb6:	80 83       	st	Z, r24
+    7fb2:	80 83       	st	Z, r24
 }
-    7fb8:	08 95       	ret
+    7fb4:	08 95       	ret
 
-00007fba <verifySpace>:
+00007fb6 <verifySpace>:
   do getch(); while (--count);
   verifySpace();
 }
 
 void verifySpace() {
   if (getch() != CRC_EOP) {
-    7fba:	ed df       	rcall	.-38     	; 0x7f96 <getch>
-    7fbc:	80 32       	cpi	r24, 0x20	; 32
-    7fbe:	19 f0       	breq	.+6      	; 0x7fc6 <verifySpace+0xc>
+    7fb6:	ed df       	rcall	.-38     	; 0x7f92 <getch>
+    7fb8:	80 32       	cpi	r24, 0x20	; 32
+    7fba:	19 f0       	breq	.+6      	; 0x7fc2 <verifySpace+0xc>
     watchdogConfig(WATCHDOG_16MS);    // shorten WD timeout
-    7fc0:	88 e0       	ldi	r24, 0x08	; 8
-    7fc2:	f5 df       	rcall	.-22     	; 0x7fae <watchdogConfig>
-    7fc4:	ff cf       	rjmp	.-2      	; 0x7fc4 <verifySpace+0xa>
+    7fbc:	88 e0       	ldi	r24, 0x08	; 8
+    7fbe:	f5 df       	rcall	.-22     	; 0x7faa <watchdogConfig>
+    7fc0:	ff cf       	rjmp	.-2      	; 0x7fc0 <verifySpace+0xa>
     while (1)			      // and busy-loop so that WD causes
       ;				      //  a reset and app start.
   }
   putch(STK_INSYNC);
-    7fc6:	84 e1       	ldi	r24, 0x14	; 20
+    7fc2:	84 e1       	ldi	r24, 0x14	; 20
 }
-    7fc8:	de cf       	rjmp	.-68     	; 0x7f86 <putch>
+    7fc4:	de cf       	rjmp	.-68     	; 0x7f82 <putch>
 
-00007fca <getNch>:
+00007fc6 <getNch>:
     ::[count] "M" (UART_B_VALUE)
   );
 }
 #endif
 
 void getNch(uint8_t count) {
-    7fca:	1f 93       	push	r17
-    7fcc:	18 2f       	mov	r17, r24
+    7fc6:	1f 93       	push	r17
+    7fc8:	18 2f       	mov	r17, r24
   do getch(); while (--count);
-    7fce:	e3 df       	rcall	.-58     	; 0x7f96 <getch>
-    7fd0:	11 50       	subi	r17, 0x01	; 1
-    7fd2:	e9 f7       	brne	.-6      	; 0x7fce <getNch+0x4>
+    7fca:	e3 df       	rcall	.-58     	; 0x7f92 <getch>
+    7fcc:	11 50       	subi	r17, 0x01	; 1
+    7fce:	e9 f7       	brne	.-6      	; 0x7fca <getNch+0x4>
   verifySpace();
-    7fd4:	f2 df       	rcall	.-28     	; 0x7fba <verifySpace>
+    7fd0:	f2 df       	rcall	.-28     	; 0x7fb6 <verifySpace>
 }
-    7fd6:	1f 91       	pop	r17
-    7fd8:	08 95       	ret
+    7fd2:	1f 91       	pop	r17
+    7fd4:	08 95       	ret
 
-00007fda <appStart>:
+00007fd6 <appStart>:
 
 void appStart(uint8_t rstFlags) {
   // 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" (rstFlags));
-    7fda:	28 2e       	mov	r2, r24
+    7fd6:	28 2e       	mov	r2, r24
 
   watchdogConfig(WATCHDOG_OFF);
-    7fdc:	80 e0       	ldi	r24, 0x00	; 0
-    7fde:	e7 df       	rcall	.-50     	; 0x7fae <watchdogConfig>
+    7fd8:	80 e0       	ldi	r24, 0x00	; 0
+    7fda:	e7 df       	rcall	.-50     	; 0x7faa <watchdogConfig>
   __asm__ __volatile__ (
-    7fe0:	ee 27       	eor	r30, r30
-    7fe2:	ff 27       	eor	r31, r31
-    7fe4:	09 94       	ijmp
+    7fdc:	ee 27       	eor	r30, r30
+    7fde:	ff 27       	eor	r31, r31
+    7fe0:	09 94       	ijmp

+ 28 - 28
optiboot/bootloaders/optiboot/optiboot_atmega328_pro_8MHz.hex

@@ -1,34 +1,34 @@
-:107E0000112484B714BE81FFE8D085E080938100FF
+:107E0000112484B714BE81FFE6D085E08093810001
 :107E100082E08093C00088E18093C10086E0809377
-:107E2000C20088E08093C4008EE0C1D0259A86E02D
+:107E2000C20088E08093C4008EE0BFD0259A86E02F
 :107E300028E13EEF91E0309385002093840096BBCB
 :107E4000B09BFECF1D9AA8958150A9F7EE24FF2480
 :107E5000AA24A394B5E0CB2EA1E1BA2EF3E0DF2E45
-:107E60009AD0813471F497D0082FA7D0023811F43A
-:107E700086E005C0013811F484E001C083E083D0BE
-:107E80007FC0823411F484E103C0853419F485E0A5
-:107E90009CD076C0853579F47ED0E82EFF247BD047
-:107EA000082F10E0102F00270E291F29000F111F87
-:107EB00084D0780165C0863521F484E086D080E0E6
-:107EC000DECF843609F040C066D065D0082F63D07D
-:107ED00080E0E81680E7F80618F4F701D7BEE895C9
-:107EE000C0E0D1E058D089930C17E1F7F0E0EF162D
-:107EF000F0E7FF0618F0F701D7BEE8955ED007B6A9
-:107F000000FCFDCFA701A0E0B1E02C9130E011967C
-:107F10008C91119790E0982F8827822B932B1296A3
-:107F2000FA010C01A7BEE89511244E5F5F4FF1E006
-:107F3000A038BF0751F7F701C7BEE89507B600FCA8
-:107F4000FDCFB7BEE8951CC0843761F424D023D0A0
-:107F5000082F21D032D0F70185917F0114D0015034
-:107F6000D1F70EC0853739F428D08EE10CD085E9E1
-:107F70000AD08FE084CF813511F488E018D01DD06D
-:107F800080E101D06DCF982F8091C00085FFFCCF9C
-:107F90009093C60008958091C00087FFFCCF809128
-:107FA000C00084FD01C0A8958091C6000895E0E658
-:107FB000F0E098E1908380830895EDDF803219F03E
-:107FC00088E0F5DFFFCF84E1DECF1F93182FE3DFDA
-:107FD0001150E9F7F2DF1F910895282E80E0E7DFC6
-:067FE000EE27FF270994C3
-:027FFE00060477
+:107E600098D0813461F495D0082FA5D0023829F13B
+:107E7000013811F485E001C083E083D07FC08234F3
+:107E800011F484E103C0853419F485E09CD076C0F8
+:107E9000853579F47ED0E82EFF247BD0082F10E0C2
+:107EA000102F00270E291F29000F111F84D07801E1
+:107EB00065C0863521F484E086D080E0DECF84364C
+:107EC00009F040C066D065D0082F63D080E0E81686
+:107ED00080E7F80618F4F701D7BEE895C0E0D1E0D6
+:107EE00058D089930C17E1F7F0E0EF16F0E7FF06A2
+:107EF00018F0F701D7BEE8955ED007B600FCFDCFBD
+:107F0000A701A0E0B1E02C9130E011968C9111977F
+:107F100090E0982F8827822B932B1296FA010C0160
+:107F2000A7BEE89511244E5F5F4FF1E0A038BF0770
+:107F300051F7F701C7BEE89507B600FCFDCFB7BE05
+:107F4000E8951CC0843761F424D023D0082F21D0B9
+:107F500032D0F70185917F0114D00150D1F70EC0C6
+:107F6000853739F428D08EE10CD085E90AD08FE02E
+:107F700084CF813511F488E018D01DD080E101D084
+:107F80006FCF982F8091C00085FFFCCF9093C600E3
+:107F900008958091C00087FFFCCF8091C00084FDD0
+:107FA00001C0A8958091C6000895E0E6F0E098E150
+:107FB000908380830895EDDF803219F088E0F5DF4B
+:107FC000FFCF84E1DECF1F93182FE3DF1150E9F7D5
+:107FD000F2DF1F910895282E80E0E7DFEE27FF27CC
+:027FE000099402
+:027FFE0000057C
 :0400000300007E007B
 :00000001FF

+ 214 - 213
optiboot/bootloaders/optiboot/optiboot_atmega328_pro_8MHz.lst

@@ -1,29 +1,29 @@
 
-optiboot_atmega328_pro_8MHz.elf:     file format elf32-avr
+optiboot_atmega328.elf:     file format elf32-avr
 
 Sections:
 Idx Name          Size      VMA       LMA       File off  Algn
-  0 .text         000001e6  00007e00  00007e00  00000054  2**1
+  0 .text         000001e2  00007e00  00007e00  00000054  2**1
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
-  1 .version      00000002  00007ffe  00007ffe  0000023a  2**0
+  1 .version      00000002  00007ffe  00007ffe  00000236  2**0
                   CONTENTS, READONLY
-  2 .debug_aranges 00000028  00000000  00000000  0000023c  2**0
+  2 .debug_aranges 00000028  00000000  00000000  00000238  2**0
                   CONTENTS, READONLY, DEBUGGING
-  3 .debug_pubnames 0000005f  00000000  00000000  00000264  2**0
+  3 .debug_pubnames 0000005f  00000000  00000000  00000260  2**0
                   CONTENTS, READONLY, DEBUGGING
-  4 .debug_info   00000294  00000000  00000000  000002c3  2**0
+  4 .debug_info   00000294  00000000  00000000  000002bf  2**0
                   CONTENTS, READONLY, DEBUGGING
-  5 .debug_abbrev 0000016b  00000000  00000000  00000557  2**0
+  5 .debug_abbrev 0000016b  00000000  00000000  00000553  2**0
                   CONTENTS, READONLY, DEBUGGING
-  6 .debug_line   00000470  00000000  00000000  000006c2  2**0
+  6 .debug_line   00000421  00000000  00000000  000006be  2**0
                   CONTENTS, READONLY, DEBUGGING
-  7 .debug_frame  00000080  00000000  00000000  00000b34  2**2
+  7 .debug_frame  00000080  00000000  00000000  00000ae0  2**2
                   CONTENTS, READONLY, DEBUGGING
-  8 .debug_str    00000131  00000000  00000000  00000bb4  2**0
+  8 .debug_str    00000131  00000000  00000000  00000b60  2**0
                   CONTENTS, READONLY, DEBUGGING
-  9 .debug_loc    00000266  00000000  00000000  00000ce5  2**0
+  9 .debug_loc    00000266  00000000  00000000  00000c91  2**0
                   CONTENTS, READONLY, DEBUGGING
- 10 .debug_ranges 00000078  00000000  00000000  00000f4b  2**0
+ 10 .debug_ranges 00000078  00000000  00000000  00000ef7  2**0
                   CONTENTS, READONLY, DEBUGGING
 
 Disassembly of section .text:
@@ -36,7 +36,7 @@ Disassembly of section .text:
 /* main program starts here */
 int main(void) {
     7e00:	11 24       	eor	r1, r1
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__)
   SP=RAMEND;  // This is done by hardware reset
 #endif
 
@@ -47,7 +47,7 @@ int main(void) {
     7e04:	14 be       	out	0x34, r1	; 52
   if (!(ch & _BV(EXTRF))) appStart(ch);
     7e06:	81 ff       	sbrs	r24, 1
-    7e08:	e8 d0       	rcall	.+464    	; 0x7fda <appStart>
+    7e08:	e6 d0       	rcall	.+460    	; 0x7fd6 <appStart>
 
 #if LED_START_FLASHES > 0
   // Set up Timer 1 for timeout counter
@@ -77,8 +77,9 @@ int main(void) {
   // Set up watchdog to trigger after 500ms
   watchdogConfig(WATCHDOG_1S);
     7e28:	8e e0       	ldi	r24, 0x0E	; 14
-    7e2a:	c1 d0       	rcall	.+386    	; 0x7fae <watchdogConfig>
+    7e2a:	bf d0       	rcall	.+382    	; 0x7faa <watchdogConfig>
 
+#if (LED_START_FLASHES > 0) || defined(LED_DATA_FLASH)
   /* Set LED pin as output */
   LED_DDR |= _BV(LED);
     7e2c:	25 9a       	sbi	0x04, 5	; 4
@@ -106,7 +107,7 @@ void flash_led(uint8_t count) {
     while(!(TIFR1 & _BV(TOV1)));
     7e40:	b0 9b       	sbis	0x16, 0	; 22
     7e42:	fe cf       	rjmp	.-4      	; 0x7e40 <main+0x40>
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__)  || defined (__AVR_ATmega32__)
     LED_PORT ^= _BV(LED);
 #else
     LED_PIN |= _BV(LED);
@@ -150,11 +151,11 @@ void watchdogReset() {
       boot_rww_enable();
     7e58:	a1 e1       	ldi	r26, 0x11	; 17
     7e5a:	ba 2e       	mov	r11, r26
-      do *bufPtr++ = getch();
-      while (--length);
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
     7e5c:	f3 e0       	ldi	r31, 0x03	; 3
     7e5e:	df 2e       	mov	r13, r31
@@ -164,422 +165,422 @@ void watchdogReset() {
   for (;;) {
     /* get character from UART */
     ch = getch();
-    7e60:	9a d0       	rcall	.+308    	; 0x7f96 <getch>
+    7e60:	98 d0       	rcall	.+304    	; 0x7f92 <getch>
 
     if(ch == STK_GET_PARAMETER) {
     7e62:	81 34       	cpi	r24, 0x41	; 65
-    7e64:	71 f4       	brne	.+28     	; 0x7e82 <main+0x82>
+    7e64:	61 f4       	brne	.+24     	; 0x7e7e <main+0x7e>
       unsigned char which = getch();
-    7e66:	97 d0       	rcall	.+302    	; 0x7f96 <getch>
+    7e66:	95 d0       	rcall	.+298    	; 0x7f92 <getch>
     7e68:	08 2f       	mov	r16, r24
       verifySpace();
-    7e6a:	a7 d0       	rcall	.+334    	; 0x7fba <verifySpace>
+    7e6a:	a5 d0       	rcall	.+330    	; 0x7fb6 <verifySpace>
       if (which == 0x82) {
     7e6c:	02 38       	cpi	r16, 0x82	; 130
-    7e6e:	11 f4       	brne	.+4      	; 0x7e74 <main+0x74>
+    7e6e:	29 f1       	breq	.+74     	; 0x7eba <main+0xba>
 	/*
 	 * Send optiboot version as "minor SW version"
 	 */
 	putch(OPTIBOOT_MINVER);
-    7e70:	86 e0       	ldi	r24, 0x06	; 6
-    7e72:	05 c0       	rjmp	.+10     	; 0x7e7e <main+0x7e>
       } else if (which == 0x81) {
-    7e74:	01 38       	cpi	r16, 0x81	; 129
-    7e76:	11 f4       	brne	.+4      	; 0x7e7c <main+0x7c>
+    7e70:	01 38       	cpi	r16, 0x81	; 129
+    7e72:	11 f4       	brne	.+4      	; 0x7e78 <main+0x78>
 	  putch(OPTIBOOT_MAJVER);
-    7e78:	84 e0       	ldi	r24, 0x04	; 4
-    7e7a:	01 c0       	rjmp	.+2      	; 0x7e7e <main+0x7e>
+    7e74:	85 e0       	ldi	r24, 0x05	; 5
+    7e76:	01 c0       	rjmp	.+2      	; 0x7e7a <main+0x7a>
       } else {
 	/*
 	 * GET PARAMETER returns a generic 0x03 reply for
          * other parameters - enough to keep Avrdude happy
 	 */
 	putch(0x03);
-    7e7c:	83 e0       	ldi	r24, 0x03	; 3
-    7e7e:	83 d0       	rcall	.+262    	; 0x7f86 <putch>
-    7e80:	7f c0       	rjmp	.+254    	; 0x7f80 <main+0x180>
+    7e78:	83 e0       	ldi	r24, 0x03	; 3
+    7e7a:	83 d0       	rcall	.+262    	; 0x7f82 <putch>
+    7e7c:	7f c0       	rjmp	.+254    	; 0x7f7c <main+0x17c>
       }
     }
     else if(ch == STK_SET_DEVICE) {
-    7e82:	82 34       	cpi	r24, 0x42	; 66
-    7e84:	11 f4       	brne	.+4      	; 0x7e8a <main+0x8a>
+    7e7e:	82 34       	cpi	r24, 0x42	; 66
+    7e80:	11 f4       	brne	.+4      	; 0x7e86 <main+0x86>
       // SET DEVICE is ignored
       getNch(20);
-    7e86:	84 e1       	ldi	r24, 0x14	; 20
-    7e88:	03 c0       	rjmp	.+6      	; 0x7e90 <main+0x90>
+    7e82:	84 e1       	ldi	r24, 0x14	; 20
+    7e84:	03 c0       	rjmp	.+6      	; 0x7e8c <main+0x8c>
     }
     else if(ch == STK_SET_DEVICE_EXT) {
-    7e8a:	85 34       	cpi	r24, 0x45	; 69
-    7e8c:	19 f4       	brne	.+6      	; 0x7e94 <main+0x94>
+    7e86:	85 34       	cpi	r24, 0x45	; 69
+    7e88:	19 f4       	brne	.+6      	; 0x7e90 <main+0x90>
       // SET DEVICE EXT is ignored
       getNch(5);
-    7e8e:	85 e0       	ldi	r24, 0x05	; 5
-    7e90:	9c d0       	rcall	.+312    	; 0x7fca <getNch>
-    7e92:	76 c0       	rjmp	.+236    	; 0x7f80 <main+0x180>
+    7e8a:	85 e0       	ldi	r24, 0x05	; 5
+    7e8c:	9c d0       	rcall	.+312    	; 0x7fc6 <getNch>
+    7e8e:	76 c0       	rjmp	.+236    	; 0x7f7c <main+0x17c>
     }
     else if(ch == STK_LOAD_ADDRESS) {
-    7e94:	85 35       	cpi	r24, 0x55	; 85
-    7e96:	79 f4       	brne	.+30     	; 0x7eb6 <main+0xb6>
+    7e90:	85 35       	cpi	r24, 0x55	; 85
+    7e92:	79 f4       	brne	.+30     	; 0x7eb2 <main+0xb2>
       // LOAD ADDRESS
       uint16_t newAddress;
       newAddress = getch();
-    7e98:	7e d0       	rcall	.+252    	; 0x7f96 <getch>
+    7e94:	7e d0       	rcall	.+252    	; 0x7f92 <getch>
       newAddress = (newAddress & 0xff) | (getch() << 8);
-    7e9a:	e8 2e       	mov	r14, r24
-    7e9c:	ff 24       	eor	r15, r15
-    7e9e:	7b d0       	rcall	.+246    	; 0x7f96 <getch>
-    7ea0:	08 2f       	mov	r16, r24
-    7ea2:	10 e0       	ldi	r17, 0x00	; 0
-    7ea4:	10 2f       	mov	r17, r16
-    7ea6:	00 27       	eor	r16, r16
-    7ea8:	0e 29       	or	r16, r14
-    7eaa:	1f 29       	or	r17, r15
+    7e96:	e8 2e       	mov	r14, r24
+    7e98:	ff 24       	eor	r15, r15
+    7e9a:	7b d0       	rcall	.+246    	; 0x7f92 <getch>
+    7e9c:	08 2f       	mov	r16, r24
+    7e9e:	10 e0       	ldi	r17, 0x00	; 0
+    7ea0:	10 2f       	mov	r17, r16
+    7ea2:	00 27       	eor	r16, r16
+    7ea4:	0e 29       	or	r16, r14
+    7ea6:	1f 29       	or	r17, r15
 #ifdef RAMPZ
       // Transfer top bit to RAMPZ
       RAMPZ = (newAddress & 0x8000) ? 1 : 0;
 #endif
       newAddress += newAddress; // Convert from word address to byte address
-    7eac:	00 0f       	add	r16, r16
-    7eae:	11 1f       	adc	r17, r17
+    7ea8:	00 0f       	add	r16, r16
+    7eaa:	11 1f       	adc	r17, r17
       address = newAddress;
       verifySpace();
-    7eb0:	84 d0       	rcall	.+264    	; 0x7fba <verifySpace>
-    7eb2:	78 01       	movw	r14, r16
-    7eb4:	65 c0       	rjmp	.+202    	; 0x7f80 <main+0x180>
+    7eac:	84 d0       	rcall	.+264    	; 0x7fb6 <verifySpace>
+    7eae:	78 01       	movw	r14, r16
+    7eb0:	65 c0       	rjmp	.+202    	; 0x7f7c <main+0x17c>
     }
     else if(ch == STK_UNIVERSAL) {
-    7eb6:	86 35       	cpi	r24, 0x56	; 86
-    7eb8:	21 f4       	brne	.+8      	; 0x7ec2 <main+0xc2>
+    7eb2:	86 35       	cpi	r24, 0x56	; 86
+    7eb4:	21 f4       	brne	.+8      	; 0x7ebe <main+0xbe>
       // UNIVERSAL command is ignored
       getNch(4);
-    7eba:	84 e0       	ldi	r24, 0x04	; 4
-    7ebc:	86 d0       	rcall	.+268    	; 0x7fca <getNch>
+    7eb6:	84 e0       	ldi	r24, 0x04	; 4
+    7eb8:	86 d0       	rcall	.+268    	; 0x7fc6 <getNch>
       putch(0x00);
-    7ebe:	80 e0       	ldi	r24, 0x00	; 0
-    7ec0:	de cf       	rjmp	.-68     	; 0x7e7e <main+0x7e>
+    7eba:	80 e0       	ldi	r24, 0x00	; 0
+    7ebc:	de cf       	rjmp	.-68     	; 0x7e7a <main+0x7a>
     }
     /* Write memory, length is big endian and is in bytes */
     else if(ch == STK_PROG_PAGE) {
-    7ec2:	84 36       	cpi	r24, 0x64	; 100
-    7ec4:	09 f0       	breq	.+2      	; 0x7ec8 <main+0xc8>
-    7ec6:	40 c0       	rjmp	.+128    	; 0x7f48 <main+0x148>
+    7ebe:	84 36       	cpi	r24, 0x64	; 100
+    7ec0:	09 f0       	breq	.+2      	; 0x7ec4 <main+0xc4>
+    7ec2:	40 c0       	rjmp	.+128    	; 0x7f44 <main+0x144>
       // PROGRAM PAGE - we support flash programming only, not EEPROM
       uint8_t *bufPtr;
       uint16_t addrPtr;
 
       getch();			/* getlen() */
-    7ec8:	66 d0       	rcall	.+204    	; 0x7f96 <getch>
+    7ec4:	66 d0       	rcall	.+204    	; 0x7f92 <getch>
       length = getch();
-    7eca:	65 d0       	rcall	.+202    	; 0x7f96 <getch>
-    7ecc:	08 2f       	mov	r16, r24
+    7ec6:	65 d0       	rcall	.+202    	; 0x7f92 <getch>
+    7ec8:	08 2f       	mov	r16, r24
       getch();
-    7ece:	63 d0       	rcall	.+198    	; 0x7f96 <getch>
+    7eca:	63 d0       	rcall	.+198    	; 0x7f92 <getch>
 
       // If we are in RWW section, immediately start page erase
       if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    7ed0:	80 e0       	ldi	r24, 0x00	; 0
-    7ed2:	e8 16       	cp	r14, r24
-    7ed4:	80 e7       	ldi	r24, 0x70	; 112
-    7ed6:	f8 06       	cpc	r15, r24
-    7ed8:	18 f4       	brcc	.+6      	; 0x7ee0 <main+0xe0>
-    7eda:	f7 01       	movw	r30, r14
-    7edc:	d7 be       	out	0x37, r13	; 55
-    7ede:	e8 95       	spm
-    7ee0:	c0 e0       	ldi	r28, 0x00	; 0
-    7ee2:	d1 e0       	ldi	r29, 0x01	; 1
+    7ecc:	80 e0       	ldi	r24, 0x00	; 0
+    7ece:	e8 16       	cp	r14, r24
+    7ed0:	80 e7       	ldi	r24, 0x70	; 112
+    7ed2:	f8 06       	cpc	r15, r24
+    7ed4:	18 f4       	brcc	.+6      	; 0x7edc <main+0xdc>
+    7ed6:	f7 01       	movw	r30, r14
+    7ed8:	d7 be       	out	0x37, r13	; 55
+    7eda:	e8 95       	spm
+    7edc:	c0 e0       	ldi	r28, 0x00	; 0
+    7ede:	d1 e0       	ldi	r29, 0x01	; 1
 
       // While that is going on, read in page contents
       bufPtr = buff;
       do *bufPtr++ = getch();
-    7ee4:	58 d0       	rcall	.+176    	; 0x7f96 <getch>
-    7ee6:	89 93       	st	Y+, r24
+    7ee0:	58 d0       	rcall	.+176    	; 0x7f92 <getch>
+    7ee2:	89 93       	st	Y+, r24
       while (--length);
-    7ee8:	0c 17       	cp	r16, r28
-    7eea:	e1 f7       	brne	.-8      	; 0x7ee4 <main+0xe4>
+    7ee4:	0c 17       	cp	r16, r28
+    7ee6:	e1 f7       	brne	.-8      	; 0x7ee0 <main+0xe0>
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    7eec:	f0 e0       	ldi	r31, 0x00	; 0
-    7eee:	ef 16       	cp	r14, r31
-    7ef0:	f0 e7       	ldi	r31, 0x70	; 112
-    7ef2:	ff 06       	cpc	r15, r31
-    7ef4:	18 f0       	brcs	.+6      	; 0x7efc <main+0xfc>
-    7ef6:	f7 01       	movw	r30, r14
-    7ef8:	d7 be       	out	0x37, r13	; 55
-    7efa:	e8 95       	spm
+    7ee8:	f0 e0       	ldi	r31, 0x00	; 0
+    7eea:	ef 16       	cp	r14, r31
+    7eec:	f0 e7       	ldi	r31, 0x70	; 112
+    7eee:	ff 06       	cpc	r15, r31
+    7ef0:	18 f0       	brcs	.+6      	; 0x7ef8 <main+0xf8>
+    7ef2:	f7 01       	movw	r30, r14
+    7ef4:	d7 be       	out	0x37, r13	; 55
+    7ef6:	e8 95       	spm
 
       // Read command terminator, start reply
       verifySpace();
-    7efc:	5e d0       	rcall	.+188    	; 0x7fba <verifySpace>
+    7ef8:	5e d0       	rcall	.+188    	; 0x7fb6 <verifySpace>
 
       // If only a partial page is to be programmed, the erase might not be complete.
       // So check that here
       boot_spm_busy_wait();
-    7efe:	07 b6       	in	r0, 0x37	; 55
-    7f00:	00 fc       	sbrc	r0, 0
-    7f02:	fd cf       	rjmp	.-6      	; 0x7efe <main+0xfe>
-    7f04:	a7 01       	movw	r20, r14
-    7f06:	a0 e0       	ldi	r26, 0x00	; 0
-    7f08:	b1 e0       	ldi	r27, 0x01	; 1
+    7efa:	07 b6       	in	r0, 0x37	; 55
+    7efc:	00 fc       	sbrc	r0, 0
+    7efe:	fd cf       	rjmp	.-6      	; 0x7efa <main+0xfa>
+    7f00:	a7 01       	movw	r20, r14
+    7f02:	a0 e0       	ldi	r26, 0x00	; 0
+    7f04:	b1 e0       	ldi	r27, 0x01	; 1
       bufPtr = buff;
       addrPtr = (uint16_t)(void*)address;
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
-    7f0a:	2c 91       	ld	r18, X
-    7f0c:	30 e0       	ldi	r19, 0x00	; 0
+    7f06:	2c 91       	ld	r18, X
+    7f08:	30 e0       	ldi	r19, 0x00	; 0
         a |= (*bufPtr++) << 8;
-    7f0e:	11 96       	adiw	r26, 0x01	; 1
-    7f10:	8c 91       	ld	r24, X
-    7f12:	11 97       	sbiw	r26, 0x01	; 1
-    7f14:	90 e0       	ldi	r25, 0x00	; 0
-    7f16:	98 2f       	mov	r25, r24
-    7f18:	88 27       	eor	r24, r24
-    7f1a:	82 2b       	or	r24, r18
-    7f1c:	93 2b       	or	r25, r19
+    7f0a:	11 96       	adiw	r26, 0x01	; 1
+    7f0c:	8c 91       	ld	r24, X
+    7f0e:	11 97       	sbiw	r26, 0x01	; 1
+    7f10:	90 e0       	ldi	r25, 0x00	; 0
+    7f12:	98 2f       	mov	r25, r24
+    7f14:	88 27       	eor	r24, r24
+    7f16:	82 2b       	or	r24, r18
+    7f18:	93 2b       	or	r25, r19
 # define UART_SRL UBRR3L
 # define UART_UDR UDR3
 #endif
 
 /* main program starts here */
 int main(void) {
-    7f1e:	12 96       	adiw	r26, 0x02	; 2
+    7f1a:	12 96       	adiw	r26, 0x02	; 2
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
         a |= (*bufPtr++) << 8;
         __boot_page_fill_short((uint16_t)(void*)addrPtr,a);
-    7f20:	fa 01       	movw	r30, r20
-    7f22:	0c 01       	movw	r0, r24
-    7f24:	a7 be       	out	0x37, r10	; 55
-    7f26:	e8 95       	spm
-    7f28:	11 24       	eor	r1, r1
+    7f1c:	fa 01       	movw	r30, r20
+    7f1e:	0c 01       	movw	r0, r24
+    7f20:	a7 be       	out	0x37, r10	; 55
+    7f22:	e8 95       	spm
+    7f24:	11 24       	eor	r1, r1
         addrPtr += 2;
-    7f2a:	4e 5f       	subi	r20, 0xFE	; 254
-    7f2c:	5f 4f       	sbci	r21, 0xFF	; 255
+    7f26:	4e 5f       	subi	r20, 0xFE	; 254
+    7f28:	5f 4f       	sbci	r21, 0xFF	; 255
       } while (--ch);
-    7f2e:	f1 e0       	ldi	r31, 0x01	; 1
-    7f30:	a0 38       	cpi	r26, 0x80	; 128
-    7f32:	bf 07       	cpc	r27, r31
-    7f34:	51 f7       	brne	.-44     	; 0x7f0a <main+0x10a>
+    7f2a:	f1 e0       	ldi	r31, 0x01	; 1
+    7f2c:	a0 38       	cpi	r26, 0x80	; 128
+    7f2e:	bf 07       	cpc	r27, r31
+    7f30:	51 f7       	brne	.-44     	; 0x7f06 <main+0x106>
 
       // Write from programming buffer
       __boot_page_write_short((uint16_t)(void*)address);
-    7f36:	f7 01       	movw	r30, r14
-    7f38:	c7 be       	out	0x37, r12	; 55
-    7f3a:	e8 95       	spm
+    7f32:	f7 01       	movw	r30, r14
+    7f34:	c7 be       	out	0x37, r12	; 55
+    7f36:	e8 95       	spm
       boot_spm_busy_wait();
-    7f3c:	07 b6       	in	r0, 0x37	; 55
-    7f3e:	00 fc       	sbrc	r0, 0
-    7f40:	fd cf       	rjmp	.-6      	; 0x7f3c <main+0x13c>
+    7f38:	07 b6       	in	r0, 0x37	; 55
+    7f3a:	00 fc       	sbrc	r0, 0
+    7f3c:	fd cf       	rjmp	.-6      	; 0x7f38 <main+0x138>
 
 #if defined(RWWSRE)
       // Reenable read access to flash
       boot_rww_enable();
-    7f42:	b7 be       	out	0x37, r11	; 55
-    7f44:	e8 95       	spm
-    7f46:	1c c0       	rjmp	.+56     	; 0x7f80 <main+0x180>
+    7f3e:	b7 be       	out	0x37, r11	; 55
+    7f40:	e8 95       	spm
+    7f42:	1c c0       	rjmp	.+56     	; 0x7f7c <main+0x17c>
 #endif
 
     }
     /* Read memory block mode, length is big endian.  */
     else if(ch == STK_READ_PAGE) {
-    7f48:	84 37       	cpi	r24, 0x74	; 116
-    7f4a:	61 f4       	brne	.+24     	; 0x7f64 <main+0x164>
+    7f44:	84 37       	cpi	r24, 0x74	; 116
+    7f46:	61 f4       	brne	.+24     	; 0x7f60 <main+0x160>
       // READ PAGE - we only read flash
       getch();			/* getlen() */
-    7f4c:	24 d0       	rcall	.+72     	; 0x7f96 <getch>
+    7f48:	24 d0       	rcall	.+72     	; 0x7f92 <getch>
       length = getch();
-    7f4e:	23 d0       	rcall	.+70     	; 0x7f96 <getch>
-    7f50:	08 2f       	mov	r16, r24
+    7f4a:	23 d0       	rcall	.+70     	; 0x7f92 <getch>
+    7f4c:	08 2f       	mov	r16, r24
       getch();
-    7f52:	21 d0       	rcall	.+66     	; 0x7f96 <getch>
+    7f4e:	21 d0       	rcall	.+66     	; 0x7f92 <getch>
 
       verifySpace();
-    7f54:	32 d0       	rcall	.+100    	; 0x7fba <verifySpace>
+    7f50:	32 d0       	rcall	.+100    	; 0x7fb6 <verifySpace>
         __asm__ ("elpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #else
         // read a Flash byte and increment the address
         __asm__ ("lpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #endif
         putch(ch);
-    7f56:	f7 01       	movw	r30, r14
-    7f58:	85 91       	lpm	r24, Z+
-    7f5a:	7f 01       	movw	r14, r30
-    7f5c:	14 d0       	rcall	.+40     	; 0x7f86 <putch>
+    7f52:	f7 01       	movw	r30, r14
+    7f54:	85 91       	lpm	r24, Z+
+    7f56:	7f 01       	movw	r14, r30
+    7f58:	14 d0       	rcall	.+40     	; 0x7f82 <putch>
       } while (--length);
-    7f5e:	01 50       	subi	r16, 0x01	; 1
-    7f60:	d1 f7       	brne	.-12     	; 0x7f56 <main+0x156>
-    7f62:	0e c0       	rjmp	.+28     	; 0x7f80 <main+0x180>
+    7f5a:	01 50       	subi	r16, 0x01	; 1
+    7f5c:	d1 f7       	brne	.-12     	; 0x7f52 <main+0x152>
+    7f5e:	0e c0       	rjmp	.+28     	; 0x7f7c <main+0x17c>
     }
 
     /* Get device signature bytes  */
     else if(ch == STK_READ_SIGN) {
-    7f64:	85 37       	cpi	r24, 0x75	; 117
-    7f66:	39 f4       	brne	.+14     	; 0x7f76 <main+0x176>
+    7f60:	85 37       	cpi	r24, 0x75	; 117
+    7f62:	39 f4       	brne	.+14     	; 0x7f72 <main+0x172>
       // READ SIGN - return what Avrdude wants to hear
       verifySpace();
-    7f68:	28 d0       	rcall	.+80     	; 0x7fba <verifySpace>
+    7f64:	28 d0       	rcall	.+80     	; 0x7fb6 <verifySpace>
       putch(SIGNATURE_0);
-    7f6a:	8e e1       	ldi	r24, 0x1E	; 30
-    7f6c:	0c d0       	rcall	.+24     	; 0x7f86 <putch>
+    7f66:	8e e1       	ldi	r24, 0x1E	; 30
+    7f68:	0c d0       	rcall	.+24     	; 0x7f82 <putch>
       putch(SIGNATURE_1);
-    7f6e:	85 e9       	ldi	r24, 0x95	; 149
-    7f70:	0a d0       	rcall	.+20     	; 0x7f86 <putch>
+    7f6a:	85 e9       	ldi	r24, 0x95	; 149
+    7f6c:	0a d0       	rcall	.+20     	; 0x7f82 <putch>
       putch(SIGNATURE_2);
-    7f72:	8f e0       	ldi	r24, 0x0F	; 15
-    7f74:	84 cf       	rjmp	.-248    	; 0x7e7e <main+0x7e>
+    7f6e:	8f e0       	ldi	r24, 0x0F	; 15
+    7f70:	84 cf       	rjmp	.-248    	; 0x7e7a <main+0x7a>
     }
     else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */
-    7f76:	81 35       	cpi	r24, 0x51	; 81
-    7f78:	11 f4       	brne	.+4      	; 0x7f7e <main+0x17e>
+    7f72:	81 35       	cpi	r24, 0x51	; 81
+    7f74:	11 f4       	brne	.+4      	; 0x7f7a <main+0x17a>
       // Adaboot no-wait mod
       watchdogConfig(WATCHDOG_16MS);
-    7f7a:	88 e0       	ldi	r24, 0x08	; 8
-    7f7c:	18 d0       	rcall	.+48     	; 0x7fae <watchdogConfig>
+    7f76:	88 e0       	ldi	r24, 0x08	; 8
+    7f78:	18 d0       	rcall	.+48     	; 0x7faa <watchdogConfig>
       verifySpace();
     }
     else {
       // This covers the response to commands like STK_ENTER_PROGMODE
       verifySpace();
-    7f7e:	1d d0       	rcall	.+58     	; 0x7fba <verifySpace>
+    7f7a:	1d d0       	rcall	.+58     	; 0x7fb6 <verifySpace>
     }
     putch(STK_OK);
-    7f80:	80 e1       	ldi	r24, 0x10	; 16
-    7f82:	01 d0       	rcall	.+2      	; 0x7f86 <putch>
-    7f84:	6d cf       	rjmp	.-294    	; 0x7e60 <main+0x60>
+    7f7c:	80 e1       	ldi	r24, 0x10	; 16
+    7f7e:	01 d0       	rcall	.+2      	; 0x7f82 <putch>
+    7f80:	6f cf       	rjmp	.-290    	; 0x7e60 <main+0x60>
 
-00007f86 <putch>:
+00007f82 <putch>:
   }
 }
 
 void putch(char ch) {
-    7f86:	98 2f       	mov	r25, r24
+    7f82:	98 2f       	mov	r25, r24
 #ifndef SOFT_UART
   while (!(UART_SRA & _BV(UDRE0)));
-    7f88:	80 91 c0 00 	lds	r24, 0x00C0
-    7f8c:	85 ff       	sbrs	r24, 5
-    7f8e:	fc cf       	rjmp	.-8      	; 0x7f88 <putch+0x2>
+    7f84:	80 91 c0 00 	lds	r24, 0x00C0
+    7f88:	85 ff       	sbrs	r24, 5
+    7f8a:	fc cf       	rjmp	.-8      	; 0x7f84 <putch+0x2>
   UART_UDR = ch;
-    7f90:	90 93 c6 00 	sts	0x00C6, r25
+    7f8c:	90 93 c6 00 	sts	0x00C6, r25
       [uartBit] "I" (UART_TX_BIT)
     :
       "r25"
   );
 #endif
 }
-    7f94:	08 95       	ret
+    7f90:	08 95       	ret
 
-00007f96 <getch>:
+00007f92 <getch>:
       [uartBit] "I" (UART_RX_BIT)
     :
       "r25"
 );
 #else
   while(!(UART_SRA & _BV(RXC0)))
-    7f96:	80 91 c0 00 	lds	r24, 0x00C0
-    7f9a:	87 ff       	sbrs	r24, 7
-    7f9c:	fc cf       	rjmp	.-8      	; 0x7f96 <getch>
+    7f92:	80 91 c0 00 	lds	r24, 0x00C0
+    7f96:	87 ff       	sbrs	r24, 7
+    7f98:	fc cf       	rjmp	.-8      	; 0x7f92 <getch>
     ;
   if (!(UART_SRA & _BV(FE0))) {
-    7f9e:	80 91 c0 00 	lds	r24, 0x00C0
-    7fa2:	84 fd       	sbrc	r24, 4
-    7fa4:	01 c0       	rjmp	.+2      	; 0x7fa8 <getch+0x12>
+    7f9a:	80 91 c0 00 	lds	r24, 0x00C0
+    7f9e:	84 fd       	sbrc	r24, 4
+    7fa0:	01 c0       	rjmp	.+2      	; 0x7fa4 <getch+0x12>
 }
 #endif
 
 // Watchdog functions. These are only safe with interrupts turned off.
 void watchdogReset() {
   __asm__ __volatile__ (
-    7fa6:	a8 95       	wdr
+    7fa2:	a8 95       	wdr
        * don't care that an invalid char is returned...)
        */
     watchdogReset();
   }
   
   ch = UART_UDR;
-    7fa8:	80 91 c6 00 	lds	r24, 0x00C6
+    7fa4:	80 91 c6 00 	lds	r24, 0x00C6
   LED_PIN |= _BV(LED);
 #endif
 #endif
 
   return ch;
 }
-    7fac:	08 95       	ret
+    7fa8:	08 95       	ret
 
-00007fae <watchdogConfig>:
+00007faa <watchdogConfig>:
     "wdr\n"
   );
 }
 
 void watchdogConfig(uint8_t x) {
   WDTCSR = _BV(WDCE) | _BV(WDE);
-    7fae:	e0 e6       	ldi	r30, 0x60	; 96
-    7fb0:	f0 e0       	ldi	r31, 0x00	; 0
-    7fb2:	98 e1       	ldi	r25, 0x18	; 24
-    7fb4:	90 83       	st	Z, r25
+    7faa:	e0 e6       	ldi	r30, 0x60	; 96
+    7fac:	f0 e0       	ldi	r31, 0x00	; 0
+    7fae:	98 e1       	ldi	r25, 0x18	; 24
+    7fb0:	90 83       	st	Z, r25
   WDTCSR = x;
-    7fb6:	80 83       	st	Z, r24
+    7fb2:	80 83       	st	Z, r24
 }
-    7fb8:	08 95       	ret
+    7fb4:	08 95       	ret
 
-00007fba <verifySpace>:
+00007fb6 <verifySpace>:
   do getch(); while (--count);
   verifySpace();
 }
 
 void verifySpace() {
   if (getch() != CRC_EOP) {
-    7fba:	ed df       	rcall	.-38     	; 0x7f96 <getch>
-    7fbc:	80 32       	cpi	r24, 0x20	; 32
-    7fbe:	19 f0       	breq	.+6      	; 0x7fc6 <verifySpace+0xc>
+    7fb6:	ed df       	rcall	.-38     	; 0x7f92 <getch>
+    7fb8:	80 32       	cpi	r24, 0x20	; 32
+    7fba:	19 f0       	breq	.+6      	; 0x7fc2 <verifySpace+0xc>
     watchdogConfig(WATCHDOG_16MS);    // shorten WD timeout
-    7fc0:	88 e0       	ldi	r24, 0x08	; 8
-    7fc2:	f5 df       	rcall	.-22     	; 0x7fae <watchdogConfig>
-    7fc4:	ff cf       	rjmp	.-2      	; 0x7fc4 <verifySpace+0xa>
+    7fbc:	88 e0       	ldi	r24, 0x08	; 8
+    7fbe:	f5 df       	rcall	.-22     	; 0x7faa <watchdogConfig>
+    7fc0:	ff cf       	rjmp	.-2      	; 0x7fc0 <verifySpace+0xa>
     while (1)			      // and busy-loop so that WD causes
       ;				      //  a reset and app start.
   }
   putch(STK_INSYNC);
-    7fc6:	84 e1       	ldi	r24, 0x14	; 20
+    7fc2:	84 e1       	ldi	r24, 0x14	; 20
 }
-    7fc8:	de cf       	rjmp	.-68     	; 0x7f86 <putch>
+    7fc4:	de cf       	rjmp	.-68     	; 0x7f82 <putch>
 
-00007fca <getNch>:
+00007fc6 <getNch>:
     ::[count] "M" (UART_B_VALUE)
   );
 }
 #endif
 
 void getNch(uint8_t count) {
-    7fca:	1f 93       	push	r17
-    7fcc:	18 2f       	mov	r17, r24
+    7fc6:	1f 93       	push	r17
+    7fc8:	18 2f       	mov	r17, r24
   do getch(); while (--count);
-    7fce:	e3 df       	rcall	.-58     	; 0x7f96 <getch>
-    7fd0:	11 50       	subi	r17, 0x01	; 1
-    7fd2:	e9 f7       	brne	.-6      	; 0x7fce <getNch+0x4>
+    7fca:	e3 df       	rcall	.-58     	; 0x7f92 <getch>
+    7fcc:	11 50       	subi	r17, 0x01	; 1
+    7fce:	e9 f7       	brne	.-6      	; 0x7fca <getNch+0x4>
   verifySpace();
-    7fd4:	f2 df       	rcall	.-28     	; 0x7fba <verifySpace>
+    7fd0:	f2 df       	rcall	.-28     	; 0x7fb6 <verifySpace>
 }
-    7fd6:	1f 91       	pop	r17
-    7fd8:	08 95       	ret
+    7fd2:	1f 91       	pop	r17
+    7fd4:	08 95       	ret
 
-00007fda <appStart>:
+00007fd6 <appStart>:
 
 void appStart(uint8_t rstFlags) {
   // 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" (rstFlags));
-    7fda:	28 2e       	mov	r2, r24
+    7fd6:	28 2e       	mov	r2, r24
 
   watchdogConfig(WATCHDOG_OFF);
-    7fdc:	80 e0       	ldi	r24, 0x00	; 0
-    7fde:	e7 df       	rcall	.-50     	; 0x7fae <watchdogConfig>
+    7fd8:	80 e0       	ldi	r24, 0x00	; 0
+    7fda:	e7 df       	rcall	.-50     	; 0x7faa <watchdogConfig>
   __asm__ __volatile__ (
-    7fe0:	ee 27       	eor	r30, r30
-    7fe2:	ff 27       	eor	r31, r31
-    7fe4:	09 94       	ijmp
+    7fdc:	ee 27       	eor	r30, r30
+    7fde:	ff 27       	eor	r31, r31
+    7fe0:	09 94       	ijmp

+ 28 - 28
optiboot/bootloaders/optiboot/optiboot_atmega644p.hex

@@ -1,34 +1,34 @@
-:10FC0000112484B714BE81FFE8D085E08093810081
+:10FC0000112484B714BE81FFE6D085E08093810083
 :10FC100082E08093C00088E18093C10086E08093F9
-:10FC2000C20080E18093C4008EE0C1D0209A86E0BB
+:10FC2000C20080E18093C4008EE0BFD0209A86E0BD
 :10FC300020E33CEF91E0309385002093840096BB55
 :10FC4000B09BFECF189AA8958150A9F7EE24FF2407
 :10FC5000AA24A394B5E0CB2EA1E1BA2EF3E0DF2EC7
-:10FC60009AD0813471F497D0082FA7D0023811F4BC
-:10FC700086E005C0013811F484E001C083E083D040
-:10FC80007FC0823411F484E103C0853419F485E027
-:10FC90009CD076C0853579F47ED0E82EFF247BD0C9
-:10FCA000082F10E0102F00270E291F29000F111F09
-:10FCB00084D0780165C0863521F484E086D080E068
-:10FCC000DECF843609F040C066D065D0082F63D0FF
-:10FCD00080E0E81680EEF80618F4F701D7BEE89544
-:10FCE000C0E0D1E058D089930C17E1F7F0E0EF16AF
-:10FCF000F0EEFF0618F0F701D7BEE8955ED007B624
-:10FD000000FCFDCFA701A0E0B1E02C9130E01196FE
-:10FD10008C91119790E0982F8827822B932B129625
-:10FD2000FA010C01A7BEE89511244E5F5F4FF2E087
-:10FD3000A030BF0751F7F701C7BEE89507B600FC32
-:10FD4000FDCFB7BEE8951CC0843761F424D023D022
-:10FD5000082F21D032D0F70185917F0114D00150B6
-:10FD6000D1F70EC0853739F428D08EE10CD086E962
-:10FD70000AD08AE084CF813511F488E018D01DD0F4
-:10FD800080E101D06DCF982F8091C00085FFFCCF1E
-:10FD90009093C60008958091C00087FFFCCF8091AA
-:10FDA000C00084FD01C0A8958091C6000895E0E6DA
-:10FDB000F0E098E1908380830895EDDF803219F0C0
-:10FDC00088E0F5DFFFCF84E1DECF1F93182FE3DF5C
-:10FDD0001150E9F7F2DF1F910895282E80E0E7DF48
-:06FDE000EE27FF27099445
-:02FFFE000604F7
+:10FC600098D0813461F495D0082FA5D0023829F1BD
+:10FC7000013811F485E001C083E083D07FC0823475
+:10FC800011F484E103C0853419F485E09CD076C07A
+:10FC9000853579F47ED0E82EFF247BD0082F10E044
+:10FCA000102F00270E291F29000F111F84D0780163
+:10FCB00065C0863521F484E086D080E0DECF8436CE
+:10FCC00009F040C066D065D0082F63D080E0E81608
+:10FCD00080EEF80618F4F701D7BEE895C0E0D1E051
+:10FCE00058D089930C17E1F7F0E0EF16F0EEFF061D
+:10FCF00018F0F701D7BEE8955ED007B600FCFDCF3F
+:10FD0000A701A0E0B1E02C9130E011968C91119701
+:10FD100090E0982F8827822B932B1296FA010C01E2
+:10FD2000A7BEE89511244E5F5F4FF2E0A030BF07F9
+:10FD300051F7F701C7BEE89507B600FCFDCFB7BE87
+:10FD4000E8951CC0843761F424D023D0082F21D03B
+:10FD500032D0F70185917F0114D00150D1F70EC048
+:10FD6000853739F428D08EE10CD086E90AD08AE0B4
+:10FD700084CF813511F488E018D01DD080E101D006
+:10FD80006FCF982F8091C00085FFFCCF9093C60065
+:10FD900008958091C00087FFFCCF8091C00084FD52
+:10FDA00001C0A8958091C6000895E0E6F0E098E1D2
+:10FDB000908380830895EDDF803219F088E0F5DFCD
+:10FDC000FFCF84E1DECF1F93182FE3DF1150E9F757
+:10FDD000F2DF1F910895282E80E0E7DFEE27FF274E
+:02FDE000099484
+:02FFFE000005FC
 :040000030000FC00FD
 :00000001FF

+ 213 - 212
optiboot/bootloaders/optiboot/optiboot_atmega644p.lst

@@ -3,27 +3,27 @@ optiboot_atmega644p.elf:     file format elf32-avr
 
 Sections:
 Idx Name          Size      VMA       LMA       File off  Algn
-  0 .text         000001e6  0000fc00  0000fc00  00000054  2**1
+  0 .text         000001e2  0000fc00  0000fc00  00000054  2**1
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
-  1 .version      00000002  0000fffe  0000fffe  0000023a  2**0
+  1 .version      00000002  0000fffe  0000fffe  00000236  2**0
                   CONTENTS, READONLY
-  2 .debug_aranges 00000028  00000000  00000000  0000023c  2**0
+  2 .debug_aranges 00000028  00000000  00000000  00000238  2**0
                   CONTENTS, READONLY, DEBUGGING
-  3 .debug_pubnames 0000005f  00000000  00000000  00000264  2**0
+  3 .debug_pubnames 0000005f  00000000  00000000  00000260  2**0
                   CONTENTS, READONLY, DEBUGGING
-  4 .debug_info   00000294  00000000  00000000  000002c3  2**0
+  4 .debug_info   00000294  00000000  00000000  000002bf  2**0
                   CONTENTS, READONLY, DEBUGGING
-  5 .debug_abbrev 0000016b  00000000  00000000  00000557  2**0
+  5 .debug_abbrev 0000016b  00000000  00000000  00000553  2**0
                   CONTENTS, READONLY, DEBUGGING
-  6 .debug_line   00000470  00000000  00000000  000006c2  2**0
+  6 .debug_line   00000421  00000000  00000000  000006be  2**0
                   CONTENTS, READONLY, DEBUGGING
-  7 .debug_frame  00000080  00000000  00000000  00000b34  2**2
+  7 .debug_frame  00000080  00000000  00000000  00000ae0  2**2
                   CONTENTS, READONLY, DEBUGGING
-  8 .debug_str    00000131  00000000  00000000  00000bb4  2**0
+  8 .debug_str    00000131  00000000  00000000  00000b60  2**0
                   CONTENTS, READONLY, DEBUGGING
-  9 .debug_loc    00000266  00000000  00000000  00000ce5  2**0
+  9 .debug_loc    00000266  00000000  00000000  00000c91  2**0
                   CONTENTS, READONLY, DEBUGGING
- 10 .debug_ranges 00000078  00000000  00000000  00000f4b  2**0
+ 10 .debug_ranges 00000078  00000000  00000000  00000ef7  2**0
                   CONTENTS, READONLY, DEBUGGING
 
 Disassembly of section .text:
@@ -36,7 +36,7 @@ Disassembly of section .text:
 /* main program starts here */
 int main(void) {
     fc00:	11 24       	eor	r1, r1
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__)
   SP=RAMEND;  // This is done by hardware reset
 #endif
 
@@ -47,7 +47,7 @@ int main(void) {
     fc04:	14 be       	out	0x34, r1	; 52
   if (!(ch & _BV(EXTRF))) appStart(ch);
     fc06:	81 ff       	sbrs	r24, 1
-    fc08:	e8 d0       	rcall	.+464    	; 0xfdda <appStart>
+    fc08:	e6 d0       	rcall	.+460    	; 0xfdd6 <appStart>
 
 #if LED_START_FLASHES > 0
   // Set up Timer 1 for timeout counter
@@ -77,8 +77,9 @@ int main(void) {
   // Set up watchdog to trigger after 500ms
   watchdogConfig(WATCHDOG_1S);
     fc28:	8e e0       	ldi	r24, 0x0E	; 14
-    fc2a:	c1 d0       	rcall	.+386    	; 0xfdae <watchdogConfig>
+    fc2a:	bf d0       	rcall	.+382    	; 0xfdaa <watchdogConfig>
 
+#if (LED_START_FLASHES > 0) || defined(LED_DATA_FLASH)
   /* Set LED pin as output */
   LED_DDR |= _BV(LED);
     fc2c:	20 9a       	sbi	0x04, 0	; 4
@@ -106,7 +107,7 @@ void flash_led(uint8_t count) {
     while(!(TIFR1 & _BV(TOV1)));
     fc40:	b0 9b       	sbis	0x16, 0	; 22
     fc42:	fe cf       	rjmp	.-4      	; 0xfc40 <main+0x40>
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__)  || defined (__AVR_ATmega32__)
     LED_PORT ^= _BV(LED);
 #else
     LED_PIN |= _BV(LED);
@@ -150,11 +151,11 @@ void watchdogReset() {
       boot_rww_enable();
     fc58:	a1 e1       	ldi	r26, 0x11	; 17
     fc5a:	ba 2e       	mov	r11, r26
-      do *bufPtr++ = getch();
-      while (--length);
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
     fc5c:	f3 e0       	ldi	r31, 0x03	; 3
     fc5e:	df 2e       	mov	r13, r31
@@ -164,422 +165,422 @@ void watchdogReset() {
   for (;;) {
     /* get character from UART */
     ch = getch();
-    fc60:	9a d0       	rcall	.+308    	; 0xfd96 <getch>
+    fc60:	98 d0       	rcall	.+304    	; 0xfd92 <getch>
 
     if(ch == STK_GET_PARAMETER) {
     fc62:	81 34       	cpi	r24, 0x41	; 65
-    fc64:	71 f4       	brne	.+28     	; 0xfc82 <main+0x82>
+    fc64:	61 f4       	brne	.+24     	; 0xfc7e <main+0x7e>
       unsigned char which = getch();
-    fc66:	97 d0       	rcall	.+302    	; 0xfd96 <getch>
+    fc66:	95 d0       	rcall	.+298    	; 0xfd92 <getch>
     fc68:	08 2f       	mov	r16, r24
       verifySpace();
-    fc6a:	a7 d0       	rcall	.+334    	; 0xfdba <verifySpace>
+    fc6a:	a5 d0       	rcall	.+330    	; 0xfdb6 <verifySpace>
       if (which == 0x82) {
     fc6c:	02 38       	cpi	r16, 0x82	; 130
-    fc6e:	11 f4       	brne	.+4      	; 0xfc74 <main+0x74>
+    fc6e:	29 f1       	breq	.+74     	; 0xfcba <main+0xba>
 	/*
 	 * Send optiboot version as "minor SW version"
 	 */
 	putch(OPTIBOOT_MINVER);
-    fc70:	86 e0       	ldi	r24, 0x06	; 6
-    fc72:	05 c0       	rjmp	.+10     	; 0xfc7e <main+0x7e>
       } else if (which == 0x81) {
-    fc74:	01 38       	cpi	r16, 0x81	; 129
-    fc76:	11 f4       	brne	.+4      	; 0xfc7c <main+0x7c>
+    fc70:	01 38       	cpi	r16, 0x81	; 129
+    fc72:	11 f4       	brne	.+4      	; 0xfc78 <main+0x78>
 	  putch(OPTIBOOT_MAJVER);
-    fc78:	84 e0       	ldi	r24, 0x04	; 4
-    fc7a:	01 c0       	rjmp	.+2      	; 0xfc7e <main+0x7e>
+    fc74:	85 e0       	ldi	r24, 0x05	; 5
+    fc76:	01 c0       	rjmp	.+2      	; 0xfc7a <main+0x7a>
       } else {
 	/*
 	 * GET PARAMETER returns a generic 0x03 reply for
          * other parameters - enough to keep Avrdude happy
 	 */
 	putch(0x03);
-    fc7c:	83 e0       	ldi	r24, 0x03	; 3
-    fc7e:	83 d0       	rcall	.+262    	; 0xfd86 <putch>
-    fc80:	7f c0       	rjmp	.+254    	; 0xfd80 <main+0x180>
+    fc78:	83 e0       	ldi	r24, 0x03	; 3
+    fc7a:	83 d0       	rcall	.+262    	; 0xfd82 <putch>
+    fc7c:	7f c0       	rjmp	.+254    	; 0xfd7c <main+0x17c>
       }
     }
     else if(ch == STK_SET_DEVICE) {
-    fc82:	82 34       	cpi	r24, 0x42	; 66
-    fc84:	11 f4       	brne	.+4      	; 0xfc8a <main+0x8a>
+    fc7e:	82 34       	cpi	r24, 0x42	; 66
+    fc80:	11 f4       	brne	.+4      	; 0xfc86 <main+0x86>
       // SET DEVICE is ignored
       getNch(20);
-    fc86:	84 e1       	ldi	r24, 0x14	; 20
-    fc88:	03 c0       	rjmp	.+6      	; 0xfc90 <main+0x90>
+    fc82:	84 e1       	ldi	r24, 0x14	; 20
+    fc84:	03 c0       	rjmp	.+6      	; 0xfc8c <main+0x8c>
     }
     else if(ch == STK_SET_DEVICE_EXT) {
-    fc8a:	85 34       	cpi	r24, 0x45	; 69
-    fc8c:	19 f4       	brne	.+6      	; 0xfc94 <main+0x94>
+    fc86:	85 34       	cpi	r24, 0x45	; 69
+    fc88:	19 f4       	brne	.+6      	; 0xfc90 <main+0x90>
       // SET DEVICE EXT is ignored
       getNch(5);
-    fc8e:	85 e0       	ldi	r24, 0x05	; 5
-    fc90:	9c d0       	rcall	.+312    	; 0xfdca <getNch>
-    fc92:	76 c0       	rjmp	.+236    	; 0xfd80 <main+0x180>
+    fc8a:	85 e0       	ldi	r24, 0x05	; 5
+    fc8c:	9c d0       	rcall	.+312    	; 0xfdc6 <getNch>
+    fc8e:	76 c0       	rjmp	.+236    	; 0xfd7c <main+0x17c>
     }
     else if(ch == STK_LOAD_ADDRESS) {
-    fc94:	85 35       	cpi	r24, 0x55	; 85
-    fc96:	79 f4       	brne	.+30     	; 0xfcb6 <main+0xb6>
+    fc90:	85 35       	cpi	r24, 0x55	; 85
+    fc92:	79 f4       	brne	.+30     	; 0xfcb2 <main+0xb2>
       // LOAD ADDRESS
       uint16_t newAddress;
       newAddress = getch();
-    fc98:	7e d0       	rcall	.+252    	; 0xfd96 <getch>
+    fc94:	7e d0       	rcall	.+252    	; 0xfd92 <getch>
       newAddress = (newAddress & 0xff) | (getch() << 8);
-    fc9a:	e8 2e       	mov	r14, r24
-    fc9c:	ff 24       	eor	r15, r15
-    fc9e:	7b d0       	rcall	.+246    	; 0xfd96 <getch>
-    fca0:	08 2f       	mov	r16, r24
-    fca2:	10 e0       	ldi	r17, 0x00	; 0
-    fca4:	10 2f       	mov	r17, r16
-    fca6:	00 27       	eor	r16, r16
-    fca8:	0e 29       	or	r16, r14
-    fcaa:	1f 29       	or	r17, r15
+    fc96:	e8 2e       	mov	r14, r24
+    fc98:	ff 24       	eor	r15, r15
+    fc9a:	7b d0       	rcall	.+246    	; 0xfd92 <getch>
+    fc9c:	08 2f       	mov	r16, r24
+    fc9e:	10 e0       	ldi	r17, 0x00	; 0
+    fca0:	10 2f       	mov	r17, r16
+    fca2:	00 27       	eor	r16, r16
+    fca4:	0e 29       	or	r16, r14
+    fca6:	1f 29       	or	r17, r15
 #ifdef RAMPZ
       // Transfer top bit to RAMPZ
       RAMPZ = (newAddress & 0x8000) ? 1 : 0;
 #endif
       newAddress += newAddress; // Convert from word address to byte address
-    fcac:	00 0f       	add	r16, r16
-    fcae:	11 1f       	adc	r17, r17
+    fca8:	00 0f       	add	r16, r16
+    fcaa:	11 1f       	adc	r17, r17
       address = newAddress;
       verifySpace();
-    fcb0:	84 d0       	rcall	.+264    	; 0xfdba <verifySpace>
-    fcb2:	78 01       	movw	r14, r16
-    fcb4:	65 c0       	rjmp	.+202    	; 0xfd80 <main+0x180>
+    fcac:	84 d0       	rcall	.+264    	; 0xfdb6 <verifySpace>
+    fcae:	78 01       	movw	r14, r16
+    fcb0:	65 c0       	rjmp	.+202    	; 0xfd7c <main+0x17c>
     }
     else if(ch == STK_UNIVERSAL) {
-    fcb6:	86 35       	cpi	r24, 0x56	; 86
-    fcb8:	21 f4       	brne	.+8      	; 0xfcc2 <main+0xc2>
+    fcb2:	86 35       	cpi	r24, 0x56	; 86
+    fcb4:	21 f4       	brne	.+8      	; 0xfcbe <main+0xbe>
       // UNIVERSAL command is ignored
       getNch(4);
-    fcba:	84 e0       	ldi	r24, 0x04	; 4
-    fcbc:	86 d0       	rcall	.+268    	; 0xfdca <getNch>
+    fcb6:	84 e0       	ldi	r24, 0x04	; 4
+    fcb8:	86 d0       	rcall	.+268    	; 0xfdc6 <getNch>
       putch(0x00);
-    fcbe:	80 e0       	ldi	r24, 0x00	; 0
-    fcc0:	de cf       	rjmp	.-68     	; 0xfc7e <main+0x7e>
+    fcba:	80 e0       	ldi	r24, 0x00	; 0
+    fcbc:	de cf       	rjmp	.-68     	; 0xfc7a <main+0x7a>
     }
     /* Write memory, length is big endian and is in bytes */
     else if(ch == STK_PROG_PAGE) {
-    fcc2:	84 36       	cpi	r24, 0x64	; 100
-    fcc4:	09 f0       	breq	.+2      	; 0xfcc8 <main+0xc8>
-    fcc6:	40 c0       	rjmp	.+128    	; 0xfd48 <main+0x148>
+    fcbe:	84 36       	cpi	r24, 0x64	; 100
+    fcc0:	09 f0       	breq	.+2      	; 0xfcc4 <main+0xc4>
+    fcc2:	40 c0       	rjmp	.+128    	; 0xfd44 <main+0x144>
       // PROGRAM PAGE - we support flash programming only, not EEPROM
       uint8_t *bufPtr;
       uint16_t addrPtr;
 
       getch();			/* getlen() */
-    fcc8:	66 d0       	rcall	.+204    	; 0xfd96 <getch>
+    fcc4:	66 d0       	rcall	.+204    	; 0xfd92 <getch>
       length = getch();
-    fcca:	65 d0       	rcall	.+202    	; 0xfd96 <getch>
-    fccc:	08 2f       	mov	r16, r24
+    fcc6:	65 d0       	rcall	.+202    	; 0xfd92 <getch>
+    fcc8:	08 2f       	mov	r16, r24
       getch();
-    fcce:	63 d0       	rcall	.+198    	; 0xfd96 <getch>
+    fcca:	63 d0       	rcall	.+198    	; 0xfd92 <getch>
 
       // If we are in RWW section, immediately start page erase
       if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    fcd0:	80 e0       	ldi	r24, 0x00	; 0
-    fcd2:	e8 16       	cp	r14, r24
-    fcd4:	80 ee       	ldi	r24, 0xE0	; 224
-    fcd6:	f8 06       	cpc	r15, r24
-    fcd8:	18 f4       	brcc	.+6      	; 0xfce0 <main+0xe0>
-    fcda:	f7 01       	movw	r30, r14
-    fcdc:	d7 be       	out	0x37, r13	; 55
-    fcde:	e8 95       	spm
-    fce0:	c0 e0       	ldi	r28, 0x00	; 0
-    fce2:	d1 e0       	ldi	r29, 0x01	; 1
+    fccc:	80 e0       	ldi	r24, 0x00	; 0
+    fcce:	e8 16       	cp	r14, r24
+    fcd0:	80 ee       	ldi	r24, 0xE0	; 224
+    fcd2:	f8 06       	cpc	r15, r24
+    fcd4:	18 f4       	brcc	.+6      	; 0xfcdc <main+0xdc>
+    fcd6:	f7 01       	movw	r30, r14
+    fcd8:	d7 be       	out	0x37, r13	; 55
+    fcda:	e8 95       	spm
+    fcdc:	c0 e0       	ldi	r28, 0x00	; 0
+    fcde:	d1 e0       	ldi	r29, 0x01	; 1
 
       // While that is going on, read in page contents
       bufPtr = buff;
       do *bufPtr++ = getch();
-    fce4:	58 d0       	rcall	.+176    	; 0xfd96 <getch>
-    fce6:	89 93       	st	Y+, r24
+    fce0:	58 d0       	rcall	.+176    	; 0xfd92 <getch>
+    fce2:	89 93       	st	Y+, r24
       while (--length);
-    fce8:	0c 17       	cp	r16, r28
-    fcea:	e1 f7       	brne	.-8      	; 0xfce4 <main+0xe4>
+    fce4:	0c 17       	cp	r16, r28
+    fce6:	e1 f7       	brne	.-8      	; 0xfce0 <main+0xe0>
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    fcec:	f0 e0       	ldi	r31, 0x00	; 0
-    fcee:	ef 16       	cp	r14, r31
-    fcf0:	f0 ee       	ldi	r31, 0xE0	; 224
-    fcf2:	ff 06       	cpc	r15, r31
-    fcf4:	18 f0       	brcs	.+6      	; 0xfcfc <main+0xfc>
-    fcf6:	f7 01       	movw	r30, r14
-    fcf8:	d7 be       	out	0x37, r13	; 55
-    fcfa:	e8 95       	spm
+    fce8:	f0 e0       	ldi	r31, 0x00	; 0
+    fcea:	ef 16       	cp	r14, r31
+    fcec:	f0 ee       	ldi	r31, 0xE0	; 224
+    fcee:	ff 06       	cpc	r15, r31
+    fcf0:	18 f0       	brcs	.+6      	; 0xfcf8 <main+0xf8>
+    fcf2:	f7 01       	movw	r30, r14
+    fcf4:	d7 be       	out	0x37, r13	; 55
+    fcf6:	e8 95       	spm
 
       // Read command terminator, start reply
       verifySpace();
-    fcfc:	5e d0       	rcall	.+188    	; 0xfdba <verifySpace>
+    fcf8:	5e d0       	rcall	.+188    	; 0xfdb6 <verifySpace>
 
       // If only a partial page is to be programmed, the erase might not be complete.
       // So check that here
       boot_spm_busy_wait();
-    fcfe:	07 b6       	in	r0, 0x37	; 55
-    fd00:	00 fc       	sbrc	r0, 0
-    fd02:	fd cf       	rjmp	.-6      	; 0xfcfe <main+0xfe>
-    fd04:	a7 01       	movw	r20, r14
-    fd06:	a0 e0       	ldi	r26, 0x00	; 0
-    fd08:	b1 e0       	ldi	r27, 0x01	; 1
+    fcfa:	07 b6       	in	r0, 0x37	; 55
+    fcfc:	00 fc       	sbrc	r0, 0
+    fcfe:	fd cf       	rjmp	.-6      	; 0xfcfa <main+0xfa>
+    fd00:	a7 01       	movw	r20, r14
+    fd02:	a0 e0       	ldi	r26, 0x00	; 0
+    fd04:	b1 e0       	ldi	r27, 0x01	; 1
       bufPtr = buff;
       addrPtr = (uint16_t)(void*)address;
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
-    fd0a:	2c 91       	ld	r18, X
-    fd0c:	30 e0       	ldi	r19, 0x00	; 0
+    fd06:	2c 91       	ld	r18, X
+    fd08:	30 e0       	ldi	r19, 0x00	; 0
         a |= (*bufPtr++) << 8;
-    fd0e:	11 96       	adiw	r26, 0x01	; 1
-    fd10:	8c 91       	ld	r24, X
-    fd12:	11 97       	sbiw	r26, 0x01	; 1
-    fd14:	90 e0       	ldi	r25, 0x00	; 0
-    fd16:	98 2f       	mov	r25, r24
-    fd18:	88 27       	eor	r24, r24
-    fd1a:	82 2b       	or	r24, r18
-    fd1c:	93 2b       	or	r25, r19
+    fd0a:	11 96       	adiw	r26, 0x01	; 1
+    fd0c:	8c 91       	ld	r24, X
+    fd0e:	11 97       	sbiw	r26, 0x01	; 1
+    fd10:	90 e0       	ldi	r25, 0x00	; 0
+    fd12:	98 2f       	mov	r25, r24
+    fd14:	88 27       	eor	r24, r24
+    fd16:	82 2b       	or	r24, r18
+    fd18:	93 2b       	or	r25, r19
 # define UART_SRL UBRR3L
 # define UART_UDR UDR3
 #endif
 
 /* main program starts here */
 int main(void) {
-    fd1e:	12 96       	adiw	r26, 0x02	; 2
+    fd1a:	12 96       	adiw	r26, 0x02	; 2
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
         a |= (*bufPtr++) << 8;
         __boot_page_fill_short((uint16_t)(void*)addrPtr,a);
-    fd20:	fa 01       	movw	r30, r20
-    fd22:	0c 01       	movw	r0, r24
-    fd24:	a7 be       	out	0x37, r10	; 55
-    fd26:	e8 95       	spm
-    fd28:	11 24       	eor	r1, r1
+    fd1c:	fa 01       	movw	r30, r20
+    fd1e:	0c 01       	movw	r0, r24
+    fd20:	a7 be       	out	0x37, r10	; 55
+    fd22:	e8 95       	spm
+    fd24:	11 24       	eor	r1, r1
         addrPtr += 2;
-    fd2a:	4e 5f       	subi	r20, 0xFE	; 254
-    fd2c:	5f 4f       	sbci	r21, 0xFF	; 255
+    fd26:	4e 5f       	subi	r20, 0xFE	; 254
+    fd28:	5f 4f       	sbci	r21, 0xFF	; 255
       } while (--ch);
-    fd2e:	f2 e0       	ldi	r31, 0x02	; 2
-    fd30:	a0 30       	cpi	r26, 0x00	; 0
-    fd32:	bf 07       	cpc	r27, r31
-    fd34:	51 f7       	brne	.-44     	; 0xfd0a <main+0x10a>
+    fd2a:	f2 e0       	ldi	r31, 0x02	; 2
+    fd2c:	a0 30       	cpi	r26, 0x00	; 0
+    fd2e:	bf 07       	cpc	r27, r31
+    fd30:	51 f7       	brne	.-44     	; 0xfd06 <main+0x106>
 
       // Write from programming buffer
       __boot_page_write_short((uint16_t)(void*)address);
-    fd36:	f7 01       	movw	r30, r14
-    fd38:	c7 be       	out	0x37, r12	; 55
-    fd3a:	e8 95       	spm
+    fd32:	f7 01       	movw	r30, r14
+    fd34:	c7 be       	out	0x37, r12	; 55
+    fd36:	e8 95       	spm
       boot_spm_busy_wait();
-    fd3c:	07 b6       	in	r0, 0x37	; 55
-    fd3e:	00 fc       	sbrc	r0, 0
-    fd40:	fd cf       	rjmp	.-6      	; 0xfd3c <main+0x13c>
+    fd38:	07 b6       	in	r0, 0x37	; 55
+    fd3a:	00 fc       	sbrc	r0, 0
+    fd3c:	fd cf       	rjmp	.-6      	; 0xfd38 <main+0x138>
 
 #if defined(RWWSRE)
       // Reenable read access to flash
       boot_rww_enable();
-    fd42:	b7 be       	out	0x37, r11	; 55
-    fd44:	e8 95       	spm
-    fd46:	1c c0       	rjmp	.+56     	; 0xfd80 <main+0x180>
+    fd3e:	b7 be       	out	0x37, r11	; 55
+    fd40:	e8 95       	spm
+    fd42:	1c c0       	rjmp	.+56     	; 0xfd7c <main+0x17c>
 #endif
 
     }
     /* Read memory block mode, length is big endian.  */
     else if(ch == STK_READ_PAGE) {
-    fd48:	84 37       	cpi	r24, 0x74	; 116
-    fd4a:	61 f4       	brne	.+24     	; 0xfd64 <main+0x164>
+    fd44:	84 37       	cpi	r24, 0x74	; 116
+    fd46:	61 f4       	brne	.+24     	; 0xfd60 <main+0x160>
       // READ PAGE - we only read flash
       getch();			/* getlen() */
-    fd4c:	24 d0       	rcall	.+72     	; 0xfd96 <getch>
+    fd48:	24 d0       	rcall	.+72     	; 0xfd92 <getch>
       length = getch();
-    fd4e:	23 d0       	rcall	.+70     	; 0xfd96 <getch>
-    fd50:	08 2f       	mov	r16, r24
+    fd4a:	23 d0       	rcall	.+70     	; 0xfd92 <getch>
+    fd4c:	08 2f       	mov	r16, r24
       getch();
-    fd52:	21 d0       	rcall	.+66     	; 0xfd96 <getch>
+    fd4e:	21 d0       	rcall	.+66     	; 0xfd92 <getch>
 
       verifySpace();
-    fd54:	32 d0       	rcall	.+100    	; 0xfdba <verifySpace>
+    fd50:	32 d0       	rcall	.+100    	; 0xfdb6 <verifySpace>
         __asm__ ("elpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #else
         // read a Flash byte and increment the address
         __asm__ ("lpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #endif
         putch(ch);
-    fd56:	f7 01       	movw	r30, r14
-    fd58:	85 91       	lpm	r24, Z+
-    fd5a:	7f 01       	movw	r14, r30
-    fd5c:	14 d0       	rcall	.+40     	; 0xfd86 <putch>
+    fd52:	f7 01       	movw	r30, r14
+    fd54:	85 91       	lpm	r24, Z+
+    fd56:	7f 01       	movw	r14, r30
+    fd58:	14 d0       	rcall	.+40     	; 0xfd82 <putch>
       } while (--length);
-    fd5e:	01 50       	subi	r16, 0x01	; 1
-    fd60:	d1 f7       	brne	.-12     	; 0xfd56 <main+0x156>
-    fd62:	0e c0       	rjmp	.+28     	; 0xfd80 <main+0x180>
+    fd5a:	01 50       	subi	r16, 0x01	; 1
+    fd5c:	d1 f7       	brne	.-12     	; 0xfd52 <main+0x152>
+    fd5e:	0e c0       	rjmp	.+28     	; 0xfd7c <main+0x17c>
     }
 
     /* Get device signature bytes  */
     else if(ch == STK_READ_SIGN) {
-    fd64:	85 37       	cpi	r24, 0x75	; 117
-    fd66:	39 f4       	brne	.+14     	; 0xfd76 <main+0x176>
+    fd60:	85 37       	cpi	r24, 0x75	; 117
+    fd62:	39 f4       	brne	.+14     	; 0xfd72 <main+0x172>
       // READ SIGN - return what Avrdude wants to hear
       verifySpace();
-    fd68:	28 d0       	rcall	.+80     	; 0xfdba <verifySpace>
+    fd64:	28 d0       	rcall	.+80     	; 0xfdb6 <verifySpace>
       putch(SIGNATURE_0);
-    fd6a:	8e e1       	ldi	r24, 0x1E	; 30
-    fd6c:	0c d0       	rcall	.+24     	; 0xfd86 <putch>
+    fd66:	8e e1       	ldi	r24, 0x1E	; 30
+    fd68:	0c d0       	rcall	.+24     	; 0xfd82 <putch>
       putch(SIGNATURE_1);
-    fd6e:	86 e9       	ldi	r24, 0x96	; 150
-    fd70:	0a d0       	rcall	.+20     	; 0xfd86 <putch>
+    fd6a:	86 e9       	ldi	r24, 0x96	; 150
+    fd6c:	0a d0       	rcall	.+20     	; 0xfd82 <putch>
       putch(SIGNATURE_2);
-    fd72:	8a e0       	ldi	r24, 0x0A	; 10
-    fd74:	84 cf       	rjmp	.-248    	; 0xfc7e <main+0x7e>
+    fd6e:	8a e0       	ldi	r24, 0x0A	; 10
+    fd70:	84 cf       	rjmp	.-248    	; 0xfc7a <main+0x7a>
     }
     else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */
-    fd76:	81 35       	cpi	r24, 0x51	; 81
-    fd78:	11 f4       	brne	.+4      	; 0xfd7e <main+0x17e>
+    fd72:	81 35       	cpi	r24, 0x51	; 81
+    fd74:	11 f4       	brne	.+4      	; 0xfd7a <main+0x17a>
       // Adaboot no-wait mod
       watchdogConfig(WATCHDOG_16MS);
-    fd7a:	88 e0       	ldi	r24, 0x08	; 8
-    fd7c:	18 d0       	rcall	.+48     	; 0xfdae <watchdogConfig>
+    fd76:	88 e0       	ldi	r24, 0x08	; 8
+    fd78:	18 d0       	rcall	.+48     	; 0xfdaa <watchdogConfig>
       verifySpace();
     }
     else {
       // This covers the response to commands like STK_ENTER_PROGMODE
       verifySpace();
-    fd7e:	1d d0       	rcall	.+58     	; 0xfdba <verifySpace>
+    fd7a:	1d d0       	rcall	.+58     	; 0xfdb6 <verifySpace>
     }
     putch(STK_OK);
-    fd80:	80 e1       	ldi	r24, 0x10	; 16
-    fd82:	01 d0       	rcall	.+2      	; 0xfd86 <putch>
-    fd84:	6d cf       	rjmp	.-294    	; 0xfc60 <main+0x60>
+    fd7c:	80 e1       	ldi	r24, 0x10	; 16
+    fd7e:	01 d0       	rcall	.+2      	; 0xfd82 <putch>
+    fd80:	6f cf       	rjmp	.-290    	; 0xfc60 <main+0x60>
 
-0000fd86 <putch>:
+0000fd82 <putch>:
   }
 }
 
 void putch(char ch) {
-    fd86:	98 2f       	mov	r25, r24
+    fd82:	98 2f       	mov	r25, r24
 #ifndef SOFT_UART
   while (!(UART_SRA & _BV(UDRE0)));
-    fd88:	80 91 c0 00 	lds	r24, 0x00C0
-    fd8c:	85 ff       	sbrs	r24, 5
-    fd8e:	fc cf       	rjmp	.-8      	; 0xfd88 <putch+0x2>
+    fd84:	80 91 c0 00 	lds	r24, 0x00C0
+    fd88:	85 ff       	sbrs	r24, 5
+    fd8a:	fc cf       	rjmp	.-8      	; 0xfd84 <putch+0x2>
   UART_UDR = ch;
-    fd90:	90 93 c6 00 	sts	0x00C6, r25
+    fd8c:	90 93 c6 00 	sts	0x00C6, r25
       [uartBit] "I" (UART_TX_BIT)
     :
       "r25"
   );
 #endif
 }
-    fd94:	08 95       	ret
+    fd90:	08 95       	ret
 
-0000fd96 <getch>:
+0000fd92 <getch>:
       [uartBit] "I" (UART_RX_BIT)
     :
       "r25"
 );
 #else
   while(!(UART_SRA & _BV(RXC0)))
-    fd96:	80 91 c0 00 	lds	r24, 0x00C0
-    fd9a:	87 ff       	sbrs	r24, 7
-    fd9c:	fc cf       	rjmp	.-8      	; 0xfd96 <getch>
+    fd92:	80 91 c0 00 	lds	r24, 0x00C0
+    fd96:	87 ff       	sbrs	r24, 7
+    fd98:	fc cf       	rjmp	.-8      	; 0xfd92 <getch>
     ;
   if (!(UART_SRA & _BV(FE0))) {
-    fd9e:	80 91 c0 00 	lds	r24, 0x00C0
-    fda2:	84 fd       	sbrc	r24, 4
-    fda4:	01 c0       	rjmp	.+2      	; 0xfda8 <getch+0x12>
+    fd9a:	80 91 c0 00 	lds	r24, 0x00C0
+    fd9e:	84 fd       	sbrc	r24, 4
+    fda0:	01 c0       	rjmp	.+2      	; 0xfda4 <getch+0x12>
 }
 #endif
 
 // Watchdog functions. These are only safe with interrupts turned off.
 void watchdogReset() {
   __asm__ __volatile__ (
-    fda6:	a8 95       	wdr
+    fda2:	a8 95       	wdr
        * don't care that an invalid char is returned...)
        */
     watchdogReset();
   }
   
   ch = UART_UDR;
-    fda8:	80 91 c6 00 	lds	r24, 0x00C6
+    fda4:	80 91 c6 00 	lds	r24, 0x00C6
   LED_PIN |= _BV(LED);
 #endif
 #endif
 
   return ch;
 }
-    fdac:	08 95       	ret
+    fda8:	08 95       	ret
 
-0000fdae <watchdogConfig>:
+0000fdaa <watchdogConfig>:
     "wdr\n"
   );
 }
 
 void watchdogConfig(uint8_t x) {
   WDTCSR = _BV(WDCE) | _BV(WDE);
-    fdae:	e0 e6       	ldi	r30, 0x60	; 96
-    fdb0:	f0 e0       	ldi	r31, 0x00	; 0
-    fdb2:	98 e1       	ldi	r25, 0x18	; 24
-    fdb4:	90 83       	st	Z, r25
+    fdaa:	e0 e6       	ldi	r30, 0x60	; 96
+    fdac:	f0 e0       	ldi	r31, 0x00	; 0
+    fdae:	98 e1       	ldi	r25, 0x18	; 24
+    fdb0:	90 83       	st	Z, r25
   WDTCSR = x;
-    fdb6:	80 83       	st	Z, r24
+    fdb2:	80 83       	st	Z, r24
 }
-    fdb8:	08 95       	ret
+    fdb4:	08 95       	ret
 
-0000fdba <verifySpace>:
+0000fdb6 <verifySpace>:
   do getch(); while (--count);
   verifySpace();
 }
 
 void verifySpace() {
   if (getch() != CRC_EOP) {
-    fdba:	ed df       	rcall	.-38     	; 0xfd96 <getch>
-    fdbc:	80 32       	cpi	r24, 0x20	; 32
-    fdbe:	19 f0       	breq	.+6      	; 0xfdc6 <verifySpace+0xc>
+    fdb6:	ed df       	rcall	.-38     	; 0xfd92 <getch>
+    fdb8:	80 32       	cpi	r24, 0x20	; 32
+    fdba:	19 f0       	breq	.+6      	; 0xfdc2 <verifySpace+0xc>
     watchdogConfig(WATCHDOG_16MS);    // shorten WD timeout
-    fdc0:	88 e0       	ldi	r24, 0x08	; 8
-    fdc2:	f5 df       	rcall	.-22     	; 0xfdae <watchdogConfig>
-    fdc4:	ff cf       	rjmp	.-2      	; 0xfdc4 <verifySpace+0xa>
+    fdbc:	88 e0       	ldi	r24, 0x08	; 8
+    fdbe:	f5 df       	rcall	.-22     	; 0xfdaa <watchdogConfig>
+    fdc0:	ff cf       	rjmp	.-2      	; 0xfdc0 <verifySpace+0xa>
     while (1)			      // and busy-loop so that WD causes
       ;				      //  a reset and app start.
   }
   putch(STK_INSYNC);
-    fdc6:	84 e1       	ldi	r24, 0x14	; 20
+    fdc2:	84 e1       	ldi	r24, 0x14	; 20
 }
-    fdc8:	de cf       	rjmp	.-68     	; 0xfd86 <putch>
+    fdc4:	de cf       	rjmp	.-68     	; 0xfd82 <putch>
 
-0000fdca <getNch>:
+0000fdc6 <getNch>:
     ::[count] "M" (UART_B_VALUE)
   );
 }
 #endif
 
 void getNch(uint8_t count) {
-    fdca:	1f 93       	push	r17
-    fdcc:	18 2f       	mov	r17, r24
+    fdc6:	1f 93       	push	r17
+    fdc8:	18 2f       	mov	r17, r24
   do getch(); while (--count);
-    fdce:	e3 df       	rcall	.-58     	; 0xfd96 <getch>
-    fdd0:	11 50       	subi	r17, 0x01	; 1
-    fdd2:	e9 f7       	brne	.-6      	; 0xfdce <getNch+0x4>
+    fdca:	e3 df       	rcall	.-58     	; 0xfd92 <getch>
+    fdcc:	11 50       	subi	r17, 0x01	; 1
+    fdce:	e9 f7       	brne	.-6      	; 0xfdca <getNch+0x4>
   verifySpace();
-    fdd4:	f2 df       	rcall	.-28     	; 0xfdba <verifySpace>
+    fdd0:	f2 df       	rcall	.-28     	; 0xfdb6 <verifySpace>
 }
-    fdd6:	1f 91       	pop	r17
-    fdd8:	08 95       	ret
+    fdd2:	1f 91       	pop	r17
+    fdd4:	08 95       	ret
 
-0000fdda <appStart>:
+0000fdd6 <appStart>:
 
 void appStart(uint8_t rstFlags) {
   // 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" (rstFlags));
-    fdda:	28 2e       	mov	r2, r24
+    fdd6:	28 2e       	mov	r2, r24
 
   watchdogConfig(WATCHDOG_OFF);
-    fddc:	80 e0       	ldi	r24, 0x00	; 0
-    fdde:	e7 df       	rcall	.-50     	; 0xfdae <watchdogConfig>
+    fdd8:	80 e0       	ldi	r24, 0x00	; 0
+    fdda:	e7 df       	rcall	.-50     	; 0xfdaa <watchdogConfig>
   __asm__ __volatile__ (
-    fde0:	ee 27       	eor	r30, r30
-    fde2:	ff 27       	eor	r31, r31
-    fde4:	09 94       	ijmp
+    fddc:	ee 27       	eor	r30, r30
+    fdde:	ff 27       	eor	r31, r31
+    fde0:	09 94       	ijmp

+ 169 - 181
optiboot/bootloaders/optiboot/optiboot_diecimila.lst

@@ -1,42 +1,42 @@
 
-optiboot_diecimila.elf:     file format elf32-avr
+optiboot_atmega168.elf:     file format elf32-avr
 
 Sections:
 Idx Name          Size      VMA       LMA       File off  Algn
-  0 .text         000001f4  00003e00  00003e00  00000054  2**1
+  0 .text         000001e2  00003e00  00003e00  00000054  2**1
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
-  1 .version      00000002  00003ffe  00003ffe  00000248  2**0
+  1 .version      00000002  00003ffe  00003ffe  00000236  2**0
                   CONTENTS, READONLY
-  2 .debug_aranges 00000028  00000000  00000000  0000024a  2**0
+  2 .debug_aranges 00000028  00000000  00000000  00000238  2**0
                   CONTENTS, READONLY, DEBUGGING
-  3 .debug_pubnames 0000005f  00000000  00000000  00000272  2**0
+  3 .debug_pubnames 0000005f  00000000  00000000  00000260  2**0
                   CONTENTS, READONLY, DEBUGGING
-  4 .debug_info   000002a8  00000000  00000000  000002d1  2**0
+  4 .debug_info   00000294  00000000  00000000  000002bf  2**0
                   CONTENTS, READONLY, DEBUGGING
-  5 .debug_abbrev 00000178  00000000  00000000  00000579  2**0
+  5 .debug_abbrev 0000016b  00000000  00000000  00000553  2**0
                   CONTENTS, READONLY, DEBUGGING
-  6 .debug_line   0000046b  00000000  00000000  000006f1  2**0
+  6 .debug_line   00000421  00000000  00000000  000006be  2**0
                   CONTENTS, READONLY, DEBUGGING
-  7 .debug_frame  00000080  00000000  00000000  00000b5c  2**2
+  7 .debug_frame  00000080  00000000  00000000  00000ae0  2**2
                   CONTENTS, READONLY, DEBUGGING
-  8 .debug_str    00000143  00000000  00000000  00000bdc  2**0
+  8 .debug_str    00000131  00000000  00000000  00000b60  2**0
                   CONTENTS, READONLY, DEBUGGING
-  9 .debug_loc    000002d8  00000000  00000000  00000d1f  2**0
+  9 .debug_loc    00000266  00000000  00000000  00000c91  2**0
                   CONTENTS, READONLY, DEBUGGING
- 10 .debug_ranges 00000078  00000000  00000000  00000ff7  2**0
+ 10 .debug_ranges 00000078  00000000  00000000  00000ef7  2**0
                   CONTENTS, READONLY, DEBUGGING
 
 Disassembly of section .text:
 
 00003e00 <main>:
-#define rstVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+4))
-#define wdtVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+6))
+# define UART_SRL UBRR3L
+# define UART_UDR UDR3
 #endif
 
 /* main program starts here */
 int main(void) {
     3e00:	11 24       	eor	r1, r1
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__)
   SP=RAMEND;  // This is done by hardware reset
 #endif
 
@@ -45,9 +45,9 @@ int main(void) {
     3e02:	84 b7       	in	r24, 0x34	; 52
   MCUSR = 0;
     3e04:	14 be       	out	0x34, r1	; 52
-  if (!(ch & _BV(EXTRF))) appStart();
+  if (!(ch & _BV(EXTRF))) appStart(ch);
     3e06:	81 ff       	sbrs	r24, 1
-    3e08:	f0 d0       	rcall	.+480    	; 0x3fea <appStart>
+    3e08:	e6 d0       	rcall	.+460    	; 0x3fd6 <appStart>
 
 #if LED_START_FLASHES > 0
   // Set up Timer 1 for timeout counter
@@ -59,16 +59,16 @@ int main(void) {
   UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0);  // config USART; 8N1
   UBRRL = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
 #else
-  UCSR0A = _BV(U2X0); //Double speed mode USART0
+  UART_SRA = _BV(U2X0); //Double speed mode USART0
     3e10:	82 e0       	ldi	r24, 0x02	; 2
     3e12:	80 93 c0 00 	sts	0x00C0, r24
-  UCSR0B = _BV(RXEN0) | _BV(TXEN0);
+  UART_SRB = _BV(RXEN0) | _BV(TXEN0);
     3e16:	88 e1       	ldi	r24, 0x18	; 24
     3e18:	80 93 c1 00 	sts	0x00C1, r24
-  UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
+  UART_SRC = _BV(UCSZ00) | _BV(UCSZ01);
     3e1c:	86 e0       	ldi	r24, 0x06	; 6
     3e1e:	80 93 c2 00 	sts	0x00C2, r24
-  UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
+  UART_SRL = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
     3e22:	80 e1       	ldi	r24, 0x10	; 16
     3e24:	80 93 c4 00 	sts	0x00C4, r24
 #endif
@@ -77,8 +77,9 @@ int main(void) {
   // Set up watchdog to trigger after 500ms
   watchdogConfig(WATCHDOG_1S);
     3e28:	8e e0       	ldi	r24, 0x0E	; 14
-    3e2a:	c9 d0       	rcall	.+402    	; 0x3fbe <watchdogConfig>
+    3e2a:	bf d0       	rcall	.+382    	; 0x3faa <watchdogConfig>
 
+#if (LED_START_FLASHES > 0) || defined(LED_DATA_FLASH)
   /* Set LED pin as output */
   LED_DDR |= _BV(LED);
     3e2c:	25 9a       	sbi	0x04, 5	; 4
@@ -106,7 +107,7 @@ void flash_led(uint8_t count) {
     while(!(TIFR1 & _BV(TOV1)));
     3e40:	b0 9b       	sbis	0x16, 0	; 22
     3e42:	fe cf       	rjmp	.-4      	; 0x3e40 <main+0x40>
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__)  || defined (__AVR_ATmega32__)
     LED_PORT ^= _BV(LED);
 #else
     LED_PIN |= _BV(LED);
@@ -126,57 +127,57 @@ void watchdogReset() {
   } while (--count);
     3e48:	81 50       	subi	r24, 0x01	; 1
     3e4a:	a9 f7       	brne	.-22     	; 0x3e36 <main+0x36>
-    3e4c:	cc 24       	eor	r12, r12
-    3e4e:	dd 24       	eor	r13, r13
+    3e4c:	ee 24       	eor	r14, r14
+    3e4e:	ff 24       	eor	r15, r15
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
         a |= (*bufPtr++) << 8;
         __boot_page_fill_short((uint16_t)(void*)addrPtr,a);
-    3e50:	88 24       	eor	r8, r8
-    3e52:	83 94       	inc	r8
+    3e50:	aa 24       	eor	r10, r10
+    3e52:	a3 94       	inc	r10
         addrPtr += 2;
       } while (--ch);
 
       // Write from programming buffer
       __boot_page_write_short((uint16_t)(void*)address);
     3e54:	b5 e0       	ldi	r27, 0x05	; 5
-    3e56:	ab 2e       	mov	r10, r27
+    3e56:	cb 2e       	mov	r12, r27
       boot_spm_busy_wait();
 
 #if defined(RWWSRE)
       // Reenable read access to flash
       boot_rww_enable();
     3e58:	a1 e1       	ldi	r26, 0x11	; 17
-    3e5a:	9a 2e       	mov	r9, r26
-      do *bufPtr++ = getch();
-      while (--length);
+    3e5a:	ba 2e       	mov	r11, r26
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
     3e5c:	f3 e0       	ldi	r31, 0x03	; 3
-    3e5e:	bf 2e       	mov	r11, r31
+    3e5e:	df 2e       	mov	r13, r31
 #endif
 
   /* Forever loop */
   for (;;) {
     /* get character from UART */
     ch = getch();
-    3e60:	a2 d0       	rcall	.+324    	; 0x3fa6 <getch>
+    3e60:	98 d0       	rcall	.+304    	; 0x3f92 <getch>
 
     if(ch == STK_GET_PARAMETER) {
     3e62:	81 34       	cpi	r24, 0x41	; 65
     3e64:	61 f4       	brne	.+24     	; 0x3e7e <main+0x7e>
       unsigned char which = getch();
-    3e66:	9f d0       	rcall	.+318    	; 0x3fa6 <getch>
+    3e66:	95 d0       	rcall	.+298    	; 0x3f92 <getch>
     3e68:	08 2f       	mov	r16, r24
       verifySpace();
-    3e6a:	af d0       	rcall	.+350    	; 0x3fca <verifySpace>
+    3e6a:	a5 d0       	rcall	.+330    	; 0x3fb6 <verifySpace>
       if (which == 0x82) {
     3e6c:	02 38       	cpi	r16, 0x82	; 130
-    3e6e:	11 f0       	breq	.+4      	; 0x3e74 <main+0x74>
+    3e6e:	29 f1       	breq	.+74     	; 0x3eba <main+0xba>
 	/*
 	 * Send optiboot version as "minor SW version"
 	 */
@@ -185,7 +186,7 @@ void watchdogReset() {
     3e70:	01 38       	cpi	r16, 0x81	; 129
     3e72:	11 f4       	brne	.+4      	; 0x3e78 <main+0x78>
 	  putch(OPTIBOOT_MAJVER);
-    3e74:	84 e0       	ldi	r24, 0x04	; 4
+    3e74:	85 e0       	ldi	r24, 0x05	; 5
     3e76:	01 c0       	rjmp	.+2      	; 0x3e7a <main+0x7a>
       } else {
 	/*
@@ -194,8 +195,8 @@ void watchdogReset() {
 	 */
 	putch(0x03);
     3e78:	83 e0       	ldi	r24, 0x03	; 3
-    3e7a:	8d d0       	rcall	.+282    	; 0x3f96 <putch>
-    3e7c:	89 c0       	rjmp	.+274    	; 0x3f90 <main+0x190>
+    3e7a:	83 d0       	rcall	.+262    	; 0x3f82 <putch>
+    3e7c:	7f c0       	rjmp	.+254    	; 0x3f7c <main+0x17c>
       }
     }
     else if(ch == STK_SET_DEVICE) {
@@ -212,8 +213,8 @@ void watchdogReset() {
       // SET DEVICE EXT is ignored
       getNch(5);
     3e8a:	85 e0       	ldi	r24, 0x05	; 5
-    3e8c:	a6 d0       	rcall	.+332    	; 0x3fda <getNch>
-    3e8e:	80 c0       	rjmp	.+256    	; 0x3f90 <main+0x190>
+    3e8c:	9c d0       	rcall	.+312    	; 0x3fc6 <getNch>
+    3e8e:	76 c0       	rjmp	.+236    	; 0x3f7c <main+0x17c>
     }
     else if(ch == STK_LOAD_ADDRESS) {
     3e90:	85 35       	cpi	r24, 0x55	; 85
@@ -221,11 +222,11 @@ void watchdogReset() {
       // LOAD ADDRESS
       uint16_t newAddress;
       newAddress = getch();
-    3e94:	88 d0       	rcall	.+272    	; 0x3fa6 <getch>
+    3e94:	7e d0       	rcall	.+252    	; 0x3f92 <getch>
       newAddress = (newAddress & 0xff) | (getch() << 8);
     3e96:	e8 2e       	mov	r14, r24
     3e98:	ff 24       	eor	r15, r15
-    3e9a:	85 d0       	rcall	.+266    	; 0x3fa6 <getch>
+    3e9a:	7b d0       	rcall	.+246    	; 0x3f92 <getch>
     3e9c:	08 2f       	mov	r16, r24
     3e9e:	10 e0       	ldi	r17, 0x00	; 0
     3ea0:	10 2f       	mov	r17, r16
@@ -241,9 +242,9 @@ void watchdogReset() {
     3eaa:	11 1f       	adc	r17, r17
       address = newAddress;
       verifySpace();
-    3eac:	8e d0       	rcall	.+284    	; 0x3fca <verifySpace>
-    3eae:	68 01       	movw	r12, r16
-    3eb0:	6f c0       	rjmp	.+222    	; 0x3f90 <main+0x190>
+    3eac:	84 d0       	rcall	.+264    	; 0x3fb6 <verifySpace>
+    3eae:	78 01       	movw	r14, r16
+    3eb0:	65 c0       	rjmp	.+202    	; 0x3f7c <main+0x17c>
     }
     else if(ch == STK_UNIVERSAL) {
     3eb2:	86 35       	cpi	r24, 0x56	; 86
@@ -251,7 +252,7 @@ void watchdogReset() {
       // UNIVERSAL command is ignored
       getNch(4);
     3eb6:	84 e0       	ldi	r24, 0x04	; 4
-    3eb8:	90 d0       	rcall	.+288    	; 0x3fda <getNch>
+    3eb8:	86 d0       	rcall	.+268    	; 0x3fc6 <getNch>
       putch(0x00);
     3eba:	80 e0       	ldi	r24, 0x00	; 0
     3ebc:	de cf       	rjmp	.-68     	; 0x3e7a <main+0x7a>
@@ -266,22 +267,22 @@ void watchdogReset() {
       uint16_t addrPtr;
 
       getch();			/* getlen() */
-    3ec4:	70 d0       	rcall	.+224    	; 0x3fa6 <getch>
+    3ec4:	66 d0       	rcall	.+204    	; 0x3f92 <getch>
       length = getch();
-    3ec6:	6f d0       	rcall	.+222    	; 0x3fa6 <getch>
+    3ec6:	65 d0       	rcall	.+202    	; 0x3f92 <getch>
     3ec8:	08 2f       	mov	r16, r24
       getch();
-    3eca:	6d d0       	rcall	.+218    	; 0x3fa6 <getch>
+    3eca:	63 d0       	rcall	.+198    	; 0x3f92 <getch>
 
       // If we are in RWW section, immediately start page erase
       if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
     3ecc:	80 e0       	ldi	r24, 0x00	; 0
-    3ece:	c8 16       	cp	r12, r24
+    3ece:	e8 16       	cp	r14, r24
     3ed0:	88 e3       	ldi	r24, 0x38	; 56
-    3ed2:	d8 06       	cpc	r13, r24
+    3ed2:	f8 06       	cpc	r15, r24
     3ed4:	18 f4       	brcc	.+6      	; 0x3edc <main+0xdc>
-    3ed6:	f6 01       	movw	r30, r12
-    3ed8:	b7 be       	out	0x37, r11	; 55
+    3ed6:	f7 01       	movw	r30, r14
+    3ed8:	d7 be       	out	0x37, r13	; 55
     3eda:	e8 95       	spm
     3edc:	c0 e0       	ldi	r28, 0x00	; 0
     3ede:	d1 e0       	ldi	r29, 0x01	; 1
@@ -289,27 +290,29 @@ void watchdogReset() {
       // While that is going on, read in page contents
       bufPtr = buff;
       do *bufPtr++ = getch();
-    3ee0:	62 d0       	rcall	.+196    	; 0x3fa6 <getch>
+    3ee0:	58 d0       	rcall	.+176    	; 0x3f92 <getch>
     3ee2:	89 93       	st	Y+, r24
       while (--length);
     3ee4:	0c 17       	cp	r16, r28
     3ee6:	e1 f7       	brne	.-8      	; 0x3ee0 <main+0xe0>
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
     3ee8:	f0 e0       	ldi	r31, 0x00	; 0
-    3eea:	cf 16       	cp	r12, r31
+    3eea:	ef 16       	cp	r14, r31
     3eec:	f8 e3       	ldi	r31, 0x38	; 56
-    3eee:	df 06       	cpc	r13, r31
+    3eee:	ff 06       	cpc	r15, r31
     3ef0:	18 f0       	brcs	.+6      	; 0x3ef8 <main+0xf8>
-    3ef2:	f6 01       	movw	r30, r12
-    3ef4:	b7 be       	out	0x37, r11	; 55
+    3ef2:	f7 01       	movw	r30, r14
+    3ef4:	d7 be       	out	0x37, r13	; 55
     3ef6:	e8 95       	spm
 
       // Read command terminator, start reply
       verifySpace();
-    3ef8:	68 d0       	rcall	.+208    	; 0x3fca <verifySpace>
+    3ef8:	5e d0       	rcall	.+188    	; 0x3fb6 <verifySpace>
 
       // If only a partial page is to be programmed, the erase might not be complete.
       // So check that here
@@ -317,7 +320,7 @@ void watchdogReset() {
     3efa:	07 b6       	in	r0, 0x37	; 55
     3efc:	00 fc       	sbrc	r0, 0
     3efe:	fd cf       	rjmp	.-6      	; 0x3efa <main+0xfa>
-    3f00:	a6 01       	movw	r20, r12
+    3f00:	a7 01       	movw	r20, r14
     3f02:	a0 e0       	ldi	r26, 0x00	; 0
     3f04:	b1 e0       	ldi	r27, 0x01	; 1
       bufPtr = buff;
@@ -337,8 +340,8 @@ void watchdogReset() {
     3f14:	88 27       	eor	r24, r24
     3f16:	82 2b       	or	r24, r18
     3f18:	93 2b       	or	r25, r19
-#define rstVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+4))
-#define wdtVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+6))
+# define UART_SRL UBRR3L
+# define UART_UDR UDR3
 #endif
 
 /* main program starts here */
@@ -352,7 +355,7 @@ int main(void) {
         __boot_page_fill_short((uint16_t)(void*)addrPtr,a);
     3f1c:	fa 01       	movw	r30, r20
     3f1e:	0c 01       	movw	r0, r24
-    3f20:	87 be       	out	0x37, r8	; 55
+    3f20:	a7 be       	out	0x37, r10	; 55
     3f22:	e8 95       	spm
     3f24:	11 24       	eor	r1, r1
         addrPtr += 2;
@@ -366,8 +369,8 @@ int main(void) {
 
       // Write from programming buffer
       __boot_page_write_short((uint16_t)(void*)address);
-    3f32:	f6 01       	movw	r30, r12
-    3f34:	a7 be       	out	0x37, r10	; 55
+    3f32:	f7 01       	movw	r30, r14
+    3f34:	c7 be       	out	0x37, r12	; 55
     3f36:	e8 95       	spm
       boot_spm_busy_wait();
     3f38:	07 b6       	in	r0, 0x37	; 55
@@ -377,222 +380,207 @@ int main(void) {
 #if defined(RWWSRE)
       // Reenable read access to flash
       boot_rww_enable();
-    3f3e:	97 be       	out	0x37, r9	; 55
+    3f3e:	b7 be       	out	0x37, r11	; 55
     3f40:	e8 95       	spm
-    3f42:	26 c0       	rjmp	.+76     	; 0x3f90 <main+0x190>
+    3f42:	1c c0       	rjmp	.+56     	; 0x3f7c <main+0x17c>
 #endif
 
     }
     /* Read memory block mode, length is big endian.  */
     else if(ch == STK_READ_PAGE) {
     3f44:	84 37       	cpi	r24, 0x74	; 116
-    3f46:	b1 f4       	brne	.+44     	; 0x3f74 <main+0x174>
+    3f46:	61 f4       	brne	.+24     	; 0x3f60 <main+0x160>
       // READ PAGE - we only read flash
       getch();			/* getlen() */
-    3f48:	2e d0       	rcall	.+92     	; 0x3fa6 <getch>
+    3f48:	24 d0       	rcall	.+72     	; 0x3f92 <getch>
       length = getch();
-    3f4a:	2d d0       	rcall	.+90     	; 0x3fa6 <getch>
-    3f4c:	f8 2e       	mov	r15, r24
+    3f4a:	23 d0       	rcall	.+70     	; 0x3f92 <getch>
+    3f4c:	08 2f       	mov	r16, r24
       getch();
-    3f4e:	2b d0       	rcall	.+86     	; 0x3fa6 <getch>
+    3f4e:	21 d0       	rcall	.+66     	; 0x3f92 <getch>
 
       verifySpace();
-    3f50:	3c d0       	rcall	.+120    	; 0x3fca <verifySpace>
-    3f52:	f6 01       	movw	r30, r12
-    3f54:	ef 2c       	mov	r14, r15
-        putch(result);
-        address++;
-      }
-      while (--length);
+    3f50:	32 d0       	rcall	.+100    	; 0x3fb6 <verifySpace>
+        __asm__ ("elpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #else
-      do putch(pgm_read_byte_near(address++));
-    3f56:	8f 01       	movw	r16, r30
-    3f58:	0f 5f       	subi	r16, 0xFF	; 255
-    3f5a:	1f 4f       	sbci	r17, 0xFF	; 255
-    3f5c:	84 91       	lpm	r24, Z+
-    3f5e:	1b d0       	rcall	.+54     	; 0x3f96 <putch>
-      while (--length);
-    3f60:	ea 94       	dec	r14
-    3f62:	f8 01       	movw	r30, r16
-    3f64:	c1 f7       	brne	.-16     	; 0x3f56 <main+0x156>
-#define rstVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+4))
-#define wdtVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+6))
-#endif
-
-/* main program starts here */
-int main(void) {
-    3f66:	08 94       	sec
-    3f68:	c1 1c       	adc	r12, r1
-    3f6a:	d1 1c       	adc	r13, r1
-    3f6c:	fa 94       	dec	r15
-    3f6e:	cf 0c       	add	r12, r15
-    3f70:	d1 1c       	adc	r13, r1
-    3f72:	0e c0       	rjmp	.+28     	; 0x3f90 <main+0x190>
-#endif
+        // read a Flash byte and increment the address
+        __asm__ ("lpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #endif
+        putch(ch);
+    3f52:	f7 01       	movw	r30, r14
+    3f54:	85 91       	lpm	r24, Z+
+    3f56:	7f 01       	movw	r14, r30
+    3f58:	14 d0       	rcall	.+40     	; 0x3f82 <putch>
+      } while (--length);
+    3f5a:	01 50       	subi	r16, 0x01	; 1
+    3f5c:	d1 f7       	brne	.-12     	; 0x3f52 <main+0x152>
+    3f5e:	0e c0       	rjmp	.+28     	; 0x3f7c <main+0x17c>
     }
 
     /* Get device signature bytes  */
     else if(ch == STK_READ_SIGN) {
-    3f74:	85 37       	cpi	r24, 0x75	; 117
-    3f76:	39 f4       	brne	.+14     	; 0x3f86 <main+0x186>
+    3f60:	85 37       	cpi	r24, 0x75	; 117
+    3f62:	39 f4       	brne	.+14     	; 0x3f72 <main+0x172>
       // READ SIGN - return what Avrdude wants to hear
       verifySpace();
-    3f78:	28 d0       	rcall	.+80     	; 0x3fca <verifySpace>
+    3f64:	28 d0       	rcall	.+80     	; 0x3fb6 <verifySpace>
       putch(SIGNATURE_0);
-    3f7a:	8e e1       	ldi	r24, 0x1E	; 30
-    3f7c:	0c d0       	rcall	.+24     	; 0x3f96 <putch>
+    3f66:	8e e1       	ldi	r24, 0x1E	; 30
+    3f68:	0c d0       	rcall	.+24     	; 0x3f82 <putch>
       putch(SIGNATURE_1);
-    3f7e:	84 e9       	ldi	r24, 0x94	; 148
-    3f80:	0a d0       	rcall	.+20     	; 0x3f96 <putch>
+    3f6a:	84 e9       	ldi	r24, 0x94	; 148
+    3f6c:	0a d0       	rcall	.+20     	; 0x3f82 <putch>
       putch(SIGNATURE_2);
-    3f82:	86 e0       	ldi	r24, 0x06	; 6
-    3f84:	7a cf       	rjmp	.-268    	; 0x3e7a <main+0x7a>
+    3f6e:	86 e0       	ldi	r24, 0x06	; 6
+    3f70:	84 cf       	rjmp	.-248    	; 0x3e7a <main+0x7a>
     }
-    else if (ch == 'Q') {
-    3f86:	81 35       	cpi	r24, 0x51	; 81
-    3f88:	11 f4       	brne	.+4      	; 0x3f8e <main+0x18e>
+    else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */
+    3f72:	81 35       	cpi	r24, 0x51	; 81
+    3f74:	11 f4       	brne	.+4      	; 0x3f7a <main+0x17a>
       // Adaboot no-wait mod
       watchdogConfig(WATCHDOG_16MS);
-    3f8a:	88 e0       	ldi	r24, 0x08	; 8
-    3f8c:	18 d0       	rcall	.+48     	; 0x3fbe <watchdogConfig>
+    3f76:	88 e0       	ldi	r24, 0x08	; 8
+    3f78:	18 d0       	rcall	.+48     	; 0x3faa <watchdogConfig>
       verifySpace();
     }
     else {
       // This covers the response to commands like STK_ENTER_PROGMODE
       verifySpace();
-    3f8e:	1d d0       	rcall	.+58     	; 0x3fca <verifySpace>
+    3f7a:	1d d0       	rcall	.+58     	; 0x3fb6 <verifySpace>
     }
     putch(STK_OK);
-    3f90:	80 e1       	ldi	r24, 0x10	; 16
-    3f92:	01 d0       	rcall	.+2      	; 0x3f96 <putch>
-    3f94:	65 cf       	rjmp	.-310    	; 0x3e60 <main+0x60>
+    3f7c:	80 e1       	ldi	r24, 0x10	; 16
+    3f7e:	01 d0       	rcall	.+2      	; 0x3f82 <putch>
+    3f80:	6f cf       	rjmp	.-290    	; 0x3e60 <main+0x60>
 
-00003f96 <putch>:
+00003f82 <putch>:
   }
 }
 
 void putch(char ch) {
-    3f96:	98 2f       	mov	r25, r24
+    3f82:	98 2f       	mov	r25, r24
 #ifndef SOFT_UART
-  while (!(UCSR0A & _BV(UDRE0)));
-    3f98:	80 91 c0 00 	lds	r24, 0x00C0
-    3f9c:	85 ff       	sbrs	r24, 5
-    3f9e:	fc cf       	rjmp	.-8      	; 0x3f98 <putch+0x2>
-  UDR0 = ch;
-    3fa0:	90 93 c6 00 	sts	0x00C6, r25
+  while (!(UART_SRA & _BV(UDRE0)));
+    3f84:	80 91 c0 00 	lds	r24, 0x00C0
+    3f88:	85 ff       	sbrs	r24, 5
+    3f8a:	fc cf       	rjmp	.-8      	; 0x3f84 <putch+0x2>
+  UART_UDR = ch;
+    3f8c:	90 93 c6 00 	sts	0x00C6, r25
       [uartBit] "I" (UART_TX_BIT)
     :
       "r25"
   );
 #endif
 }
-    3fa4:	08 95       	ret
+    3f90:	08 95       	ret
 
-00003fa6 <getch>:
+00003f92 <getch>:
       [uartBit] "I" (UART_RX_BIT)
     :
       "r25"
 );
 #else
-  while(!(UCSR0A & _BV(RXC0)))
-    3fa6:	80 91 c0 00 	lds	r24, 0x00C0
-    3faa:	87 ff       	sbrs	r24, 7
-    3fac:	fc cf       	rjmp	.-8      	; 0x3fa6 <getch>
+  while(!(UART_SRA & _BV(RXC0)))
+    3f92:	80 91 c0 00 	lds	r24, 0x00C0
+    3f96:	87 ff       	sbrs	r24, 7
+    3f98:	fc cf       	rjmp	.-8      	; 0x3f92 <getch>
     ;
-  if (!(UCSR0A & _BV(FE0))) {
-    3fae:	80 91 c0 00 	lds	r24, 0x00C0
-    3fb2:	84 fd       	sbrc	r24, 4
-    3fb4:	01 c0       	rjmp	.+2      	; 0x3fb8 <getch+0x12>
+  if (!(UART_SRA & _BV(FE0))) {
+    3f9a:	80 91 c0 00 	lds	r24, 0x00C0
+    3f9e:	84 fd       	sbrc	r24, 4
+    3fa0:	01 c0       	rjmp	.+2      	; 0x3fa4 <getch+0x12>
 }
 #endif
 
 // Watchdog functions. These are only safe with interrupts turned off.
 void watchdogReset() {
   __asm__ __volatile__ (
-    3fb6:	a8 95       	wdr
+    3fa2:	a8 95       	wdr
        * don't care that an invalid char is returned...)
        */
     watchdogReset();
   }
   
-  ch = UDR0;
-    3fb8:	80 91 c6 00 	lds	r24, 0x00C6
+  ch = UART_UDR;
+    3fa4:	80 91 c6 00 	lds	r24, 0x00C6
   LED_PIN |= _BV(LED);
 #endif
 #endif
 
   return ch;
 }
-    3fbc:	08 95       	ret
+    3fa8:	08 95       	ret
 
-00003fbe <watchdogConfig>:
+00003faa <watchdogConfig>:
     "wdr\n"
   );
 }
 
 void watchdogConfig(uint8_t x) {
   WDTCSR = _BV(WDCE) | _BV(WDE);
-    3fbe:	e0 e6       	ldi	r30, 0x60	; 96
-    3fc0:	f0 e0       	ldi	r31, 0x00	; 0
-    3fc2:	98 e1       	ldi	r25, 0x18	; 24
-    3fc4:	90 83       	st	Z, r25
+    3faa:	e0 e6       	ldi	r30, 0x60	; 96
+    3fac:	f0 e0       	ldi	r31, 0x00	; 0
+    3fae:	98 e1       	ldi	r25, 0x18	; 24
+    3fb0:	90 83       	st	Z, r25
   WDTCSR = x;
-    3fc6:	80 83       	st	Z, r24
+    3fb2:	80 83       	st	Z, r24
 }
-    3fc8:	08 95       	ret
+    3fb4:	08 95       	ret
 
-00003fca <verifySpace>:
+00003fb6 <verifySpace>:
   do getch(); while (--count);
   verifySpace();
 }
 
 void verifySpace() {
   if (getch() != CRC_EOP) {
-    3fca:	ed df       	rcall	.-38     	; 0x3fa6 <getch>
-    3fcc:	80 32       	cpi	r24, 0x20	; 32
-    3fce:	19 f0       	breq	.+6      	; 0x3fd6 <verifySpace+0xc>
+    3fb6:	ed df       	rcall	.-38     	; 0x3f92 <getch>
+    3fb8:	80 32       	cpi	r24, 0x20	; 32
+    3fba:	19 f0       	breq	.+6      	; 0x3fc2 <verifySpace+0xc>
     watchdogConfig(WATCHDOG_16MS);    // shorten WD timeout
-    3fd0:	88 e0       	ldi	r24, 0x08	; 8
-    3fd2:	f5 df       	rcall	.-22     	; 0x3fbe <watchdogConfig>
-    3fd4:	ff cf       	rjmp	.-2      	; 0x3fd4 <verifySpace+0xa>
+    3fbc:	88 e0       	ldi	r24, 0x08	; 8
+    3fbe:	f5 df       	rcall	.-22     	; 0x3faa <watchdogConfig>
+    3fc0:	ff cf       	rjmp	.-2      	; 0x3fc0 <verifySpace+0xa>
     while (1)			      // and busy-loop so that WD causes
       ;				      //  a reset and app start.
   }
   putch(STK_INSYNC);
-    3fd6:	84 e1       	ldi	r24, 0x14	; 20
+    3fc2:	84 e1       	ldi	r24, 0x14	; 20
 }
-    3fd8:	de cf       	rjmp	.-68     	; 0x3f96 <putch>
+    3fc4:	de cf       	rjmp	.-68     	; 0x3f82 <putch>
 
-00003fda <getNch>:
+00003fc6 <getNch>:
     ::[count] "M" (UART_B_VALUE)
   );
 }
 #endif
 
 void getNch(uint8_t count) {
-    3fda:	1f 93       	push	r17
-    3fdc:	18 2f       	mov	r17, r24
+    3fc6:	1f 93       	push	r17
+    3fc8:	18 2f       	mov	r17, r24
   do getch(); while (--count);
-    3fde:	e3 df       	rcall	.-58     	; 0x3fa6 <getch>
-    3fe0:	11 50       	subi	r17, 0x01	; 1
-    3fe2:	e9 f7       	brne	.-6      	; 0x3fde <getNch+0x4>
+    3fca:	e3 df       	rcall	.-58     	; 0x3f92 <getch>
+    3fcc:	11 50       	subi	r17, 0x01	; 1
+    3fce:	e9 f7       	brne	.-6      	; 0x3fca <getNch+0x4>
   verifySpace();
-    3fe4:	f2 df       	rcall	.-28     	; 0x3fca <verifySpace>
+    3fd0:	f2 df       	rcall	.-28     	; 0x3fb6 <verifySpace>
 }
-    3fe6:	1f 91       	pop	r17
-    3fe8:	08 95       	ret
+    3fd2:	1f 91       	pop	r17
+    3fd4:	08 95       	ret
 
-00003fea <appStart>:
-  WDTCSR = _BV(WDCE) | _BV(WDE);
-  WDTCSR = x;
-}
+00003fd6 <appStart>:
+
+void appStart(uint8_t rstFlags) {
+  // 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" (rstFlags));
+    3fd6:	28 2e       	mov	r2, r24
 
-void appStart() {
   watchdogConfig(WATCHDOG_OFF);
-    3fea:	80 e0       	ldi	r24, 0x00	; 0
-    3fec:	e8 df       	rcall	.-48     	; 0x3fbe <watchdogConfig>
+    3fd8:	80 e0       	ldi	r24, 0x00	; 0
+    3fda:	e7 df       	rcall	.-50     	; 0x3faa <watchdogConfig>
   __asm__ __volatile__ (
-    3fee:	ee 27       	eor	r30, r30
-    3ff0:	ff 27       	eor	r31, r31
-    3ff2:	09 94       	ijmp
+    3fdc:	ee 27       	eor	r30, r30
+    3fde:	ff 27       	eor	r31, r31
+    3fe0:	09 94       	ijmp

+ 28 - 28
optiboot/bootloaders/optiboot/optiboot_lilypad.hex

@@ -1,34 +1,34 @@
-:103E0000112484B714BE81FFE7D085E08093810040
+:103E0000112484B714BE81FFE6D085E08093810041
 :103E100082E08093C00088E18093C10086E08093B7
-:103E2000C20088E08093C4008EE0C0D0259A86E06E
+:103E2000C20088E08093C4008EE0BFD0259A86E06F
 :103E300028E13EEF91E0309385002093840096BB0B
 :103E4000B09BFECF1D9AA8958150A9F7EE24FF24C0
 :103E5000AA24A394B5E0CB2EA1E1BA2EF3E0DF2E85
-:103E600099D0813469F496D0082FA6D0023809F48D
-:103E70007FC0013811F484E001C083E083D07FC0AB
-:103E8000823411F484E103C0853419F485E09CD0B8
-:103E900076C0853579F47ED0E82EFF247BD0082FBC
-:103EA00010E0102F00270E291F29000F111F84D0AA
-:103EB000780165C0863521F484E086D080E0DECFCD
-:103EC000843609F040C066D065D0082F63D080E00A
-:103ED000E81688E3F80618F4F701D7BEE895C0E0C5
-:103EE000D1E058D089930C17E1F7F0E0EF16F8E332
-:103EF000FF0618F0F701D7BEE8955ED007B600FCC4
-:103F0000FDCFA701A0E0B1E02C9130E011968C919B
-:103F1000119790E0982F8827822B932B1296FA0105
-:103F20000C01A7BEE89511244E5F5F4FF1E0A03869
-:103F3000BF0751F7F701C7BEE89507B600FCFDCFF4
-:103F4000B7BEE8951CC0843761F424D023D0082F75
-:103F500021D032D0F70185917F0114D00150D1F7E3
-:103F60000EC0853739F428D08EE10CD084E90AD010
-:103F700086E084CF813511F488E018D01DD080E12F
-:103F800001D06ECF982F8091C00085FFFCCF909319
-:103F9000C60008958091C00087FFFCCF8091C000CB
-:103FA00084FD01C0A8958091C6000895E0E6F0E088
-:103FB00098E1908380830895EDDF803219F088E0E6
-:103FC000F5DFFFCF84E1DECF1F93182FE3DF115021
-:103FD000E9F7F2DF1F910895282E80E0E7DFEE2752
-:043FE000FF2709941A
-:023FFE000604B7
+:103E600098D0813461F495D0082FA5D0023829F17B
+:103E7000013811F485E001C083E083D07FC0823433
+:103E800011F484E103C0853419F485E09CD076C038
+:103E9000853579F47ED0E82EFF247BD0082F10E002
+:103EA000102F00270E291F29000F111F84D0780121
+:103EB00065C0863521F484E086D080E0DECF84368C
+:103EC00009F040C066D065D0082F63D080E0E816C6
+:103ED00088E3F80618F4F701D7BEE895C0E0D1E012
+:103EE00058D089930C17E1F7F0E0EF16F8E3FF06DE
+:103EF00018F0F701D7BEE8955ED007B600FCFDCFFD
+:103F0000A701A0E0B1E02C9130E011968C911197BF
+:103F100090E0982F8827822B932B1296FA010C01A0
+:103F2000A7BEE89511244E5F5F4FF1E0A038BF07B0
+:103F300051F7F701C7BEE89507B600FCFDCFB7BE45
+:103F4000E8951CC0843761F424D023D0082F21D0F9
+:103F500032D0F70185917F0114D00150D1F70EC006
+:103F6000853739F428D08EE10CD084E90AD086E078
+:103F700084CF813511F488E018D01DD080E101D0C4
+:103F80006FCF982F8091C00085FFFCCF9093C60023
+:103F900008958091C00087FFFCCF8091C00084FD10
+:103FA00001C0A8958091C6000895E0E6F0E098E190
+:103FB000908380830895EDDF803219F088E0F5DF8B
+:103FC000FFCF84E1DECF1F93182FE3DF1150E9F715
+:103FD000F2DF1F910895282E80E0E7DFEE27FF270C
+:023FE000099442
+:023FFE000005BC
 :0400000300003E00BB
 :00000001FF

+ 214 - 212
optiboot/bootloaders/optiboot/optiboot_lilypad.lst

@@ -1,29 +1,29 @@
 
-optiboot_lilypad.elf:     file format elf32-avr
+optiboot_atmega168.elf:     file format elf32-avr
 
 Sections:
 Idx Name          Size      VMA       LMA       File off  Algn
-  0 .text         000001e4  00003e00  00003e00  00000054  2**1
+  0 .text         000001e2  00003e00  00003e00  00000054  2**1
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
-  1 .version      00000002  00003ffe  00003ffe  00000238  2**0
+  1 .version      00000002  00003ffe  00003ffe  00000236  2**0
                   CONTENTS, READONLY
-  2 .debug_aranges 00000028  00000000  00000000  0000023a  2**0
+  2 .debug_aranges 00000028  00000000  00000000  00000238  2**0
                   CONTENTS, READONLY, DEBUGGING
-  3 .debug_pubnames 0000005f  00000000  00000000  00000262  2**0
+  3 .debug_pubnames 0000005f  00000000  00000000  00000260  2**0
                   CONTENTS, READONLY, DEBUGGING
-  4 .debug_info   00000294  00000000  00000000  000002c1  2**0
+  4 .debug_info   00000294  00000000  00000000  000002bf  2**0
                   CONTENTS, READONLY, DEBUGGING
-  5 .debug_abbrev 0000016b  00000000  00000000  00000555  2**0
+  5 .debug_abbrev 0000016b  00000000  00000000  00000553  2**0
                   CONTENTS, READONLY, DEBUGGING
-  6 .debug_line   00000468  00000000  00000000  000006c0  2**0
+  6 .debug_line   00000421  00000000  00000000  000006be  2**0
                   CONTENTS, READONLY, DEBUGGING
-  7 .debug_frame  00000080  00000000  00000000  00000b28  2**2
+  7 .debug_frame  00000080  00000000  00000000  00000ae0  2**2
                   CONTENTS, READONLY, DEBUGGING
-  8 .debug_str    00000131  00000000  00000000  00000ba8  2**0
+  8 .debug_str    00000131  00000000  00000000  00000b60  2**0
                   CONTENTS, READONLY, DEBUGGING
-  9 .debug_loc    00000266  00000000  00000000  00000cd9  2**0
+  9 .debug_loc    00000266  00000000  00000000  00000c91  2**0
                   CONTENTS, READONLY, DEBUGGING
- 10 .debug_ranges 00000078  00000000  00000000  00000f3f  2**0
+ 10 .debug_ranges 00000078  00000000  00000000  00000ef7  2**0
                   CONTENTS, READONLY, DEBUGGING
 
 Disassembly of section .text:
@@ -36,7 +36,7 @@ Disassembly of section .text:
 /* main program starts here */
 int main(void) {
     3e00:	11 24       	eor	r1, r1
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__)
   SP=RAMEND;  // This is done by hardware reset
 #endif
 
@@ -47,7 +47,7 @@ int main(void) {
     3e04:	14 be       	out	0x34, r1	; 52
   if (!(ch & _BV(EXTRF))) appStart(ch);
     3e06:	81 ff       	sbrs	r24, 1
-    3e08:	e7 d0       	rcall	.+462    	; 0x3fd8 <appStart>
+    3e08:	e6 d0       	rcall	.+460    	; 0x3fd6 <appStart>
 
 #if LED_START_FLASHES > 0
   // Set up Timer 1 for timeout counter
@@ -77,8 +77,9 @@ int main(void) {
   // Set up watchdog to trigger after 500ms
   watchdogConfig(WATCHDOG_1S);
     3e28:	8e e0       	ldi	r24, 0x0E	; 14
-    3e2a:	c0 d0       	rcall	.+384    	; 0x3fac <watchdogConfig>
+    3e2a:	bf d0       	rcall	.+382    	; 0x3faa <watchdogConfig>
 
+#if (LED_START_FLASHES > 0) || defined(LED_DATA_FLASH)
   /* Set LED pin as output */
   LED_DDR |= _BV(LED);
     3e2c:	25 9a       	sbi	0x04, 5	; 4
@@ -106,7 +107,7 @@ void flash_led(uint8_t count) {
     while(!(TIFR1 & _BV(TOV1)));
     3e40:	b0 9b       	sbis	0x16, 0	; 22
     3e42:	fe cf       	rjmp	.-4      	; 0x3e40 <main+0x40>
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__)  || defined (__AVR_ATmega32__)
     LED_PORT ^= _BV(LED);
 #else
     LED_PIN |= _BV(LED);
@@ -150,11 +151,11 @@ void watchdogReset() {
       boot_rww_enable();
     3e58:	a1 e1       	ldi	r26, 0x11	; 17
     3e5a:	ba 2e       	mov	r11, r26
-      do *bufPtr++ = getch();
-      while (--length);
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
     3e5c:	f3 e0       	ldi	r31, 0x03	; 3
     3e5e:	df 2e       	mov	r13, r31
@@ -164,421 +165,422 @@ void watchdogReset() {
   for (;;) {
     /* get character from UART */
     ch = getch();
-    3e60:	99 d0       	rcall	.+306    	; 0x3f94 <getch>
+    3e60:	98 d0       	rcall	.+304    	; 0x3f92 <getch>
 
     if(ch == STK_GET_PARAMETER) {
     3e62:	81 34       	cpi	r24, 0x41	; 65
-    3e64:	69 f4       	brne	.+26     	; 0x3e80 <main+0x80>
+    3e64:	61 f4       	brne	.+24     	; 0x3e7e <main+0x7e>
       unsigned char which = getch();
-    3e66:	96 d0       	rcall	.+300    	; 0x3f94 <getch>
+    3e66:	95 d0       	rcall	.+298    	; 0x3f92 <getch>
     3e68:	08 2f       	mov	r16, r24
       verifySpace();
-    3e6a:	a6 d0       	rcall	.+332    	; 0x3fb8 <verifySpace>
+    3e6a:	a5 d0       	rcall	.+330    	; 0x3fb6 <verifySpace>
       if (which == 0x82) {
     3e6c:	02 38       	cpi	r16, 0x82	; 130
-    3e6e:	09 f4       	brne	.+2      	; 0x3e72 <main+0x72>
-    3e70:	7f c0       	rjmp	.+254    	; 0x3f70 <main+0x170>
+    3e6e:	29 f1       	breq	.+74     	; 0x3eba <main+0xba>
 	/*
 	 * Send optiboot version as "minor SW version"
 	 */
 	putch(OPTIBOOT_MINVER);
       } else if (which == 0x81) {
-    3e72:	01 38       	cpi	r16, 0x81	; 129
-    3e74:	11 f4       	brne	.+4      	; 0x3e7a <main+0x7a>
+    3e70:	01 38       	cpi	r16, 0x81	; 129
+    3e72:	11 f4       	brne	.+4      	; 0x3e78 <main+0x78>
 	  putch(OPTIBOOT_MAJVER);
-    3e76:	84 e0       	ldi	r24, 0x04	; 4
-    3e78:	01 c0       	rjmp	.+2      	; 0x3e7c <main+0x7c>
+    3e74:	85 e0       	ldi	r24, 0x05	; 5
+    3e76:	01 c0       	rjmp	.+2      	; 0x3e7a <main+0x7a>
       } else {
 	/*
 	 * GET PARAMETER returns a generic 0x03 reply for
          * other parameters - enough to keep Avrdude happy
 	 */
 	putch(0x03);
-    3e7a:	83 e0       	ldi	r24, 0x03	; 3
-    3e7c:	83 d0       	rcall	.+262    	; 0x3f84 <putch>
-    3e7e:	7f c0       	rjmp	.+254    	; 0x3f7e <main+0x17e>
+    3e78:	83 e0       	ldi	r24, 0x03	; 3
+    3e7a:	83 d0       	rcall	.+262    	; 0x3f82 <putch>
+    3e7c:	7f c0       	rjmp	.+254    	; 0x3f7c <main+0x17c>
       }
     }
     else if(ch == STK_SET_DEVICE) {
-    3e80:	82 34       	cpi	r24, 0x42	; 66
-    3e82:	11 f4       	brne	.+4      	; 0x3e88 <main+0x88>
+    3e7e:	82 34       	cpi	r24, 0x42	; 66
+    3e80:	11 f4       	brne	.+4      	; 0x3e86 <main+0x86>
       // SET DEVICE is ignored
       getNch(20);
-    3e84:	84 e1       	ldi	r24, 0x14	; 20
-    3e86:	03 c0       	rjmp	.+6      	; 0x3e8e <main+0x8e>
+    3e82:	84 e1       	ldi	r24, 0x14	; 20
+    3e84:	03 c0       	rjmp	.+6      	; 0x3e8c <main+0x8c>
     }
     else if(ch == STK_SET_DEVICE_EXT) {
-    3e88:	85 34       	cpi	r24, 0x45	; 69
-    3e8a:	19 f4       	brne	.+6      	; 0x3e92 <main+0x92>
+    3e86:	85 34       	cpi	r24, 0x45	; 69
+    3e88:	19 f4       	brne	.+6      	; 0x3e90 <main+0x90>
       // SET DEVICE EXT is ignored
       getNch(5);
-    3e8c:	85 e0       	ldi	r24, 0x05	; 5
-    3e8e:	9c d0       	rcall	.+312    	; 0x3fc8 <getNch>
-    3e90:	76 c0       	rjmp	.+236    	; 0x3f7e <main+0x17e>
+    3e8a:	85 e0       	ldi	r24, 0x05	; 5
+    3e8c:	9c d0       	rcall	.+312    	; 0x3fc6 <getNch>
+    3e8e:	76 c0       	rjmp	.+236    	; 0x3f7c <main+0x17c>
     }
     else if(ch == STK_LOAD_ADDRESS) {
-    3e92:	85 35       	cpi	r24, 0x55	; 85
-    3e94:	79 f4       	brne	.+30     	; 0x3eb4 <main+0xb4>
+    3e90:	85 35       	cpi	r24, 0x55	; 85
+    3e92:	79 f4       	brne	.+30     	; 0x3eb2 <main+0xb2>
       // LOAD ADDRESS
       uint16_t newAddress;
       newAddress = getch();
-    3e96:	7e d0       	rcall	.+252    	; 0x3f94 <getch>
+    3e94:	7e d0       	rcall	.+252    	; 0x3f92 <getch>
       newAddress = (newAddress & 0xff) | (getch() << 8);
-    3e98:	e8 2e       	mov	r14, r24
-    3e9a:	ff 24       	eor	r15, r15
-    3e9c:	7b d0       	rcall	.+246    	; 0x3f94 <getch>
-    3e9e:	08 2f       	mov	r16, r24
-    3ea0:	10 e0       	ldi	r17, 0x00	; 0
-    3ea2:	10 2f       	mov	r17, r16
-    3ea4:	00 27       	eor	r16, r16
-    3ea6:	0e 29       	or	r16, r14
-    3ea8:	1f 29       	or	r17, r15
+    3e96:	e8 2e       	mov	r14, r24
+    3e98:	ff 24       	eor	r15, r15
+    3e9a:	7b d0       	rcall	.+246    	; 0x3f92 <getch>
+    3e9c:	08 2f       	mov	r16, r24
+    3e9e:	10 e0       	ldi	r17, 0x00	; 0
+    3ea0:	10 2f       	mov	r17, r16
+    3ea2:	00 27       	eor	r16, r16
+    3ea4:	0e 29       	or	r16, r14
+    3ea6:	1f 29       	or	r17, r15
 #ifdef RAMPZ
       // Transfer top bit to RAMPZ
       RAMPZ = (newAddress & 0x8000) ? 1 : 0;
 #endif
       newAddress += newAddress; // Convert from word address to byte address
-    3eaa:	00 0f       	add	r16, r16
-    3eac:	11 1f       	adc	r17, r17
+    3ea8:	00 0f       	add	r16, r16
+    3eaa:	11 1f       	adc	r17, r17
       address = newAddress;
       verifySpace();
-    3eae:	84 d0       	rcall	.+264    	; 0x3fb8 <verifySpace>
-    3eb0:	78 01       	movw	r14, r16
-    3eb2:	65 c0       	rjmp	.+202    	; 0x3f7e <main+0x17e>
+    3eac:	84 d0       	rcall	.+264    	; 0x3fb6 <verifySpace>
+    3eae:	78 01       	movw	r14, r16
+    3eb0:	65 c0       	rjmp	.+202    	; 0x3f7c <main+0x17c>
     }
     else if(ch == STK_UNIVERSAL) {
-    3eb4:	86 35       	cpi	r24, 0x56	; 86
-    3eb6:	21 f4       	brne	.+8      	; 0x3ec0 <main+0xc0>
+    3eb2:	86 35       	cpi	r24, 0x56	; 86
+    3eb4:	21 f4       	brne	.+8      	; 0x3ebe <main+0xbe>
       // UNIVERSAL command is ignored
       getNch(4);
-    3eb8:	84 e0       	ldi	r24, 0x04	; 4
-    3eba:	86 d0       	rcall	.+268    	; 0x3fc8 <getNch>
+    3eb6:	84 e0       	ldi	r24, 0x04	; 4
+    3eb8:	86 d0       	rcall	.+268    	; 0x3fc6 <getNch>
       putch(0x00);
-    3ebc:	80 e0       	ldi	r24, 0x00	; 0
-    3ebe:	de cf       	rjmp	.-68     	; 0x3e7c <main+0x7c>
+    3eba:	80 e0       	ldi	r24, 0x00	; 0
+    3ebc:	de cf       	rjmp	.-68     	; 0x3e7a <main+0x7a>
     }
     /* Write memory, length is big endian and is in bytes */
     else if(ch == STK_PROG_PAGE) {
-    3ec0:	84 36       	cpi	r24, 0x64	; 100
-    3ec2:	09 f0       	breq	.+2      	; 0x3ec6 <main+0xc6>
-    3ec4:	40 c0       	rjmp	.+128    	; 0x3f46 <main+0x146>
+    3ebe:	84 36       	cpi	r24, 0x64	; 100
+    3ec0:	09 f0       	breq	.+2      	; 0x3ec4 <main+0xc4>
+    3ec2:	40 c0       	rjmp	.+128    	; 0x3f44 <main+0x144>
       // PROGRAM PAGE - we support flash programming only, not EEPROM
       uint8_t *bufPtr;
       uint16_t addrPtr;
 
       getch();			/* getlen() */
-    3ec6:	66 d0       	rcall	.+204    	; 0x3f94 <getch>
+    3ec4:	66 d0       	rcall	.+204    	; 0x3f92 <getch>
       length = getch();
-    3ec8:	65 d0       	rcall	.+202    	; 0x3f94 <getch>
-    3eca:	08 2f       	mov	r16, r24
+    3ec6:	65 d0       	rcall	.+202    	; 0x3f92 <getch>
+    3ec8:	08 2f       	mov	r16, r24
       getch();
-    3ecc:	63 d0       	rcall	.+198    	; 0x3f94 <getch>
+    3eca:	63 d0       	rcall	.+198    	; 0x3f92 <getch>
 
       // If we are in RWW section, immediately start page erase
       if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    3ece:	80 e0       	ldi	r24, 0x00	; 0
-    3ed0:	e8 16       	cp	r14, r24
-    3ed2:	88 e3       	ldi	r24, 0x38	; 56
-    3ed4:	f8 06       	cpc	r15, r24
-    3ed6:	18 f4       	brcc	.+6      	; 0x3ede <main+0xde>
-    3ed8:	f7 01       	movw	r30, r14
-    3eda:	d7 be       	out	0x37, r13	; 55
-    3edc:	e8 95       	spm
-    3ede:	c0 e0       	ldi	r28, 0x00	; 0
-    3ee0:	d1 e0       	ldi	r29, 0x01	; 1
+    3ecc:	80 e0       	ldi	r24, 0x00	; 0
+    3ece:	e8 16       	cp	r14, r24
+    3ed0:	88 e3       	ldi	r24, 0x38	; 56
+    3ed2:	f8 06       	cpc	r15, r24
+    3ed4:	18 f4       	brcc	.+6      	; 0x3edc <main+0xdc>
+    3ed6:	f7 01       	movw	r30, r14
+    3ed8:	d7 be       	out	0x37, r13	; 55
+    3eda:	e8 95       	spm
+    3edc:	c0 e0       	ldi	r28, 0x00	; 0
+    3ede:	d1 e0       	ldi	r29, 0x01	; 1
 
       // While that is going on, read in page contents
       bufPtr = buff;
       do *bufPtr++ = getch();
-    3ee2:	58 d0       	rcall	.+176    	; 0x3f94 <getch>
-    3ee4:	89 93       	st	Y+, r24
+    3ee0:	58 d0       	rcall	.+176    	; 0x3f92 <getch>
+    3ee2:	89 93       	st	Y+, r24
       while (--length);
-    3ee6:	0c 17       	cp	r16, r28
-    3ee8:	e1 f7       	brne	.-8      	; 0x3ee2 <main+0xe2>
+    3ee4:	0c 17       	cp	r16, r28
+    3ee6:	e1 f7       	brne	.-8      	; 0x3ee0 <main+0xe0>
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    3eea:	f0 e0       	ldi	r31, 0x00	; 0
-    3eec:	ef 16       	cp	r14, r31
-    3eee:	f8 e3       	ldi	r31, 0x38	; 56
-    3ef0:	ff 06       	cpc	r15, r31
-    3ef2:	18 f0       	brcs	.+6      	; 0x3efa <main+0xfa>
-    3ef4:	f7 01       	movw	r30, r14
-    3ef6:	d7 be       	out	0x37, r13	; 55
-    3ef8:	e8 95       	spm
+    3ee8:	f0 e0       	ldi	r31, 0x00	; 0
+    3eea:	ef 16       	cp	r14, r31
+    3eec:	f8 e3       	ldi	r31, 0x38	; 56
+    3eee:	ff 06       	cpc	r15, r31
+    3ef0:	18 f0       	brcs	.+6      	; 0x3ef8 <main+0xf8>
+    3ef2:	f7 01       	movw	r30, r14
+    3ef4:	d7 be       	out	0x37, r13	; 55
+    3ef6:	e8 95       	spm
 
       // Read command terminator, start reply
       verifySpace();
-    3efa:	5e d0       	rcall	.+188    	; 0x3fb8 <verifySpace>
+    3ef8:	5e d0       	rcall	.+188    	; 0x3fb6 <verifySpace>
 
       // If only a partial page is to be programmed, the erase might not be complete.
       // So check that here
       boot_spm_busy_wait();
-    3efc:	07 b6       	in	r0, 0x37	; 55
-    3efe:	00 fc       	sbrc	r0, 0
-    3f00:	fd cf       	rjmp	.-6      	; 0x3efc <main+0xfc>
-    3f02:	a7 01       	movw	r20, r14
-    3f04:	a0 e0       	ldi	r26, 0x00	; 0
-    3f06:	b1 e0       	ldi	r27, 0x01	; 1
+    3efa:	07 b6       	in	r0, 0x37	; 55
+    3efc:	00 fc       	sbrc	r0, 0
+    3efe:	fd cf       	rjmp	.-6      	; 0x3efa <main+0xfa>
+    3f00:	a7 01       	movw	r20, r14
+    3f02:	a0 e0       	ldi	r26, 0x00	; 0
+    3f04:	b1 e0       	ldi	r27, 0x01	; 1
       bufPtr = buff;
       addrPtr = (uint16_t)(void*)address;
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
-    3f08:	2c 91       	ld	r18, X
-    3f0a:	30 e0       	ldi	r19, 0x00	; 0
+    3f06:	2c 91       	ld	r18, X
+    3f08:	30 e0       	ldi	r19, 0x00	; 0
         a |= (*bufPtr++) << 8;
-    3f0c:	11 96       	adiw	r26, 0x01	; 1
-    3f0e:	8c 91       	ld	r24, X
-    3f10:	11 97       	sbiw	r26, 0x01	; 1
-    3f12:	90 e0       	ldi	r25, 0x00	; 0
-    3f14:	98 2f       	mov	r25, r24
-    3f16:	88 27       	eor	r24, r24
-    3f18:	82 2b       	or	r24, r18
-    3f1a:	93 2b       	or	r25, r19
+    3f0a:	11 96       	adiw	r26, 0x01	; 1
+    3f0c:	8c 91       	ld	r24, X
+    3f0e:	11 97       	sbiw	r26, 0x01	; 1
+    3f10:	90 e0       	ldi	r25, 0x00	; 0
+    3f12:	98 2f       	mov	r25, r24
+    3f14:	88 27       	eor	r24, r24
+    3f16:	82 2b       	or	r24, r18
+    3f18:	93 2b       	or	r25, r19
 # define UART_SRL UBRR3L
 # define UART_UDR UDR3
 #endif
 
 /* main program starts here */
 int main(void) {
-    3f1c:	12 96       	adiw	r26, 0x02	; 2
+    3f1a:	12 96       	adiw	r26, 0x02	; 2
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
         a |= (*bufPtr++) << 8;
         __boot_page_fill_short((uint16_t)(void*)addrPtr,a);
-    3f1e:	fa 01       	movw	r30, r20
-    3f20:	0c 01       	movw	r0, r24
-    3f22:	a7 be       	out	0x37, r10	; 55
-    3f24:	e8 95       	spm
-    3f26:	11 24       	eor	r1, r1
+    3f1c:	fa 01       	movw	r30, r20
+    3f1e:	0c 01       	movw	r0, r24
+    3f20:	a7 be       	out	0x37, r10	; 55
+    3f22:	e8 95       	spm
+    3f24:	11 24       	eor	r1, r1
         addrPtr += 2;
-    3f28:	4e 5f       	subi	r20, 0xFE	; 254
-    3f2a:	5f 4f       	sbci	r21, 0xFF	; 255
+    3f26:	4e 5f       	subi	r20, 0xFE	; 254
+    3f28:	5f 4f       	sbci	r21, 0xFF	; 255
       } while (--ch);
-    3f2c:	f1 e0       	ldi	r31, 0x01	; 1
-    3f2e:	a0 38       	cpi	r26, 0x80	; 128
-    3f30:	bf 07       	cpc	r27, r31
-    3f32:	51 f7       	brne	.-44     	; 0x3f08 <main+0x108>
+    3f2a:	f1 e0       	ldi	r31, 0x01	; 1
+    3f2c:	a0 38       	cpi	r26, 0x80	; 128
+    3f2e:	bf 07       	cpc	r27, r31
+    3f30:	51 f7       	brne	.-44     	; 0x3f06 <main+0x106>
 
       // Write from programming buffer
       __boot_page_write_short((uint16_t)(void*)address);
-    3f34:	f7 01       	movw	r30, r14
-    3f36:	c7 be       	out	0x37, r12	; 55
-    3f38:	e8 95       	spm
+    3f32:	f7 01       	movw	r30, r14
+    3f34:	c7 be       	out	0x37, r12	; 55
+    3f36:	e8 95       	spm
       boot_spm_busy_wait();
-    3f3a:	07 b6       	in	r0, 0x37	; 55
-    3f3c:	00 fc       	sbrc	r0, 0
-    3f3e:	fd cf       	rjmp	.-6      	; 0x3f3a <main+0x13a>
+    3f38:	07 b6       	in	r0, 0x37	; 55
+    3f3a:	00 fc       	sbrc	r0, 0
+    3f3c:	fd cf       	rjmp	.-6      	; 0x3f38 <main+0x138>
 
 #if defined(RWWSRE)
       // Reenable read access to flash
       boot_rww_enable();
-    3f40:	b7 be       	out	0x37, r11	; 55
-    3f42:	e8 95       	spm
-    3f44:	1c c0       	rjmp	.+56     	; 0x3f7e <main+0x17e>
+    3f3e:	b7 be       	out	0x37, r11	; 55
+    3f40:	e8 95       	spm
+    3f42:	1c c0       	rjmp	.+56     	; 0x3f7c <main+0x17c>
 #endif
 
     }
     /* Read memory block mode, length is big endian.  */
     else if(ch == STK_READ_PAGE) {
-    3f46:	84 37       	cpi	r24, 0x74	; 116
-    3f48:	61 f4       	brne	.+24     	; 0x3f62 <main+0x162>
+    3f44:	84 37       	cpi	r24, 0x74	; 116
+    3f46:	61 f4       	brne	.+24     	; 0x3f60 <main+0x160>
       // READ PAGE - we only read flash
       getch();			/* getlen() */
-    3f4a:	24 d0       	rcall	.+72     	; 0x3f94 <getch>
+    3f48:	24 d0       	rcall	.+72     	; 0x3f92 <getch>
       length = getch();
-    3f4c:	23 d0       	rcall	.+70     	; 0x3f94 <getch>
-    3f4e:	08 2f       	mov	r16, r24
+    3f4a:	23 d0       	rcall	.+70     	; 0x3f92 <getch>
+    3f4c:	08 2f       	mov	r16, r24
       getch();
-    3f50:	21 d0       	rcall	.+66     	; 0x3f94 <getch>
+    3f4e:	21 d0       	rcall	.+66     	; 0x3f92 <getch>
 
       verifySpace();
-    3f52:	32 d0       	rcall	.+100    	; 0x3fb8 <verifySpace>
+    3f50:	32 d0       	rcall	.+100    	; 0x3fb6 <verifySpace>
         __asm__ ("elpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #else
         // read a Flash byte and increment the address
         __asm__ ("lpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #endif
         putch(ch);
-    3f54:	f7 01       	movw	r30, r14
-    3f56:	85 91       	lpm	r24, Z+
-    3f58:	7f 01       	movw	r14, r30
-    3f5a:	14 d0       	rcall	.+40     	; 0x3f84 <putch>
+    3f52:	f7 01       	movw	r30, r14
+    3f54:	85 91       	lpm	r24, Z+
+    3f56:	7f 01       	movw	r14, r30
+    3f58:	14 d0       	rcall	.+40     	; 0x3f82 <putch>
       } while (--length);
-    3f5c:	01 50       	subi	r16, 0x01	; 1
-    3f5e:	d1 f7       	brne	.-12     	; 0x3f54 <main+0x154>
-    3f60:	0e c0       	rjmp	.+28     	; 0x3f7e <main+0x17e>
+    3f5a:	01 50       	subi	r16, 0x01	; 1
+    3f5c:	d1 f7       	brne	.-12     	; 0x3f52 <main+0x152>
+    3f5e:	0e c0       	rjmp	.+28     	; 0x3f7c <main+0x17c>
     }
 
     /* Get device signature bytes  */
     else if(ch == STK_READ_SIGN) {
-    3f62:	85 37       	cpi	r24, 0x75	; 117
-    3f64:	39 f4       	brne	.+14     	; 0x3f74 <main+0x174>
+    3f60:	85 37       	cpi	r24, 0x75	; 117
+    3f62:	39 f4       	brne	.+14     	; 0x3f72 <main+0x172>
       // READ SIGN - return what Avrdude wants to hear
       verifySpace();
-    3f66:	28 d0       	rcall	.+80     	; 0x3fb8 <verifySpace>
+    3f64:	28 d0       	rcall	.+80     	; 0x3fb6 <verifySpace>
       putch(SIGNATURE_0);
-    3f68:	8e e1       	ldi	r24, 0x1E	; 30
-    3f6a:	0c d0       	rcall	.+24     	; 0x3f84 <putch>
+    3f66:	8e e1       	ldi	r24, 0x1E	; 30
+    3f68:	0c d0       	rcall	.+24     	; 0x3f82 <putch>
       putch(SIGNATURE_1);
-    3f6c:	84 e9       	ldi	r24, 0x94	; 148
-    3f6e:	0a d0       	rcall	.+20     	; 0x3f84 <putch>
+    3f6a:	84 e9       	ldi	r24, 0x94	; 148
+    3f6c:	0a d0       	rcall	.+20     	; 0x3f82 <putch>
       putch(SIGNATURE_2);
-    3f70:	86 e0       	ldi	r24, 0x06	; 6
-    3f72:	84 cf       	rjmp	.-248    	; 0x3e7c <main+0x7c>
+    3f6e:	86 e0       	ldi	r24, 0x06	; 6
+    3f70:	84 cf       	rjmp	.-248    	; 0x3e7a <main+0x7a>
     }
     else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */
-    3f74:	81 35       	cpi	r24, 0x51	; 81
-    3f76:	11 f4       	brne	.+4      	; 0x3f7c <main+0x17c>
+    3f72:	81 35       	cpi	r24, 0x51	; 81
+    3f74:	11 f4       	brne	.+4      	; 0x3f7a <main+0x17a>
       // Adaboot no-wait mod
       watchdogConfig(WATCHDOG_16MS);
-    3f78:	88 e0       	ldi	r24, 0x08	; 8
-    3f7a:	18 d0       	rcall	.+48     	; 0x3fac <watchdogConfig>
+    3f76:	88 e0       	ldi	r24, 0x08	; 8
+    3f78:	18 d0       	rcall	.+48     	; 0x3faa <watchdogConfig>
       verifySpace();
     }
     else {
       // This covers the response to commands like STK_ENTER_PROGMODE
       verifySpace();
-    3f7c:	1d d0       	rcall	.+58     	; 0x3fb8 <verifySpace>
+    3f7a:	1d d0       	rcall	.+58     	; 0x3fb6 <verifySpace>
     }
     putch(STK_OK);
-    3f7e:	80 e1       	ldi	r24, 0x10	; 16
-    3f80:	01 d0       	rcall	.+2      	; 0x3f84 <putch>
-    3f82:	6e cf       	rjmp	.-292    	; 0x3e60 <main+0x60>
+    3f7c:	80 e1       	ldi	r24, 0x10	; 16
+    3f7e:	01 d0       	rcall	.+2      	; 0x3f82 <putch>
+    3f80:	6f cf       	rjmp	.-290    	; 0x3e60 <main+0x60>
 
-00003f84 <putch>:
+00003f82 <putch>:
   }
 }
 
 void putch(char ch) {
-    3f84:	98 2f       	mov	r25, r24
+    3f82:	98 2f       	mov	r25, r24
 #ifndef SOFT_UART
   while (!(UART_SRA & _BV(UDRE0)));
-    3f86:	80 91 c0 00 	lds	r24, 0x00C0
-    3f8a:	85 ff       	sbrs	r24, 5
-    3f8c:	fc cf       	rjmp	.-8      	; 0x3f86 <putch+0x2>
+    3f84:	80 91 c0 00 	lds	r24, 0x00C0
+    3f88:	85 ff       	sbrs	r24, 5
+    3f8a:	fc cf       	rjmp	.-8      	; 0x3f84 <putch+0x2>
   UART_UDR = ch;
-    3f8e:	90 93 c6 00 	sts	0x00C6, r25
+    3f8c:	90 93 c6 00 	sts	0x00C6, r25
       [uartBit] "I" (UART_TX_BIT)
     :
       "r25"
   );
 #endif
 }
-    3f92:	08 95       	ret
+    3f90:	08 95       	ret
 
-00003f94 <getch>:
+00003f92 <getch>:
       [uartBit] "I" (UART_RX_BIT)
     :
       "r25"
 );
 #else
   while(!(UART_SRA & _BV(RXC0)))
-    3f94:	80 91 c0 00 	lds	r24, 0x00C0
-    3f98:	87 ff       	sbrs	r24, 7
-    3f9a:	fc cf       	rjmp	.-8      	; 0x3f94 <getch>
+    3f92:	80 91 c0 00 	lds	r24, 0x00C0
+    3f96:	87 ff       	sbrs	r24, 7
+    3f98:	fc cf       	rjmp	.-8      	; 0x3f92 <getch>
     ;
   if (!(UART_SRA & _BV(FE0))) {
-    3f9c:	80 91 c0 00 	lds	r24, 0x00C0
-    3fa0:	84 fd       	sbrc	r24, 4
-    3fa2:	01 c0       	rjmp	.+2      	; 0x3fa6 <getch+0x12>
+    3f9a:	80 91 c0 00 	lds	r24, 0x00C0
+    3f9e:	84 fd       	sbrc	r24, 4
+    3fa0:	01 c0       	rjmp	.+2      	; 0x3fa4 <getch+0x12>
 }
 #endif
 
 // Watchdog functions. These are only safe with interrupts turned off.
 void watchdogReset() {
   __asm__ __volatile__ (
-    3fa4:	a8 95       	wdr
+    3fa2:	a8 95       	wdr
        * don't care that an invalid char is returned...)
        */
     watchdogReset();
   }
   
   ch = UART_UDR;
-    3fa6:	80 91 c6 00 	lds	r24, 0x00C6
+    3fa4:	80 91 c6 00 	lds	r24, 0x00C6
   LED_PIN |= _BV(LED);
 #endif
 #endif
 
   return ch;
 }
-    3faa:	08 95       	ret
+    3fa8:	08 95       	ret
 
-00003fac <watchdogConfig>:
+00003faa <watchdogConfig>:
     "wdr\n"
   );
 }
 
 void watchdogConfig(uint8_t x) {
   WDTCSR = _BV(WDCE) | _BV(WDE);
-    3fac:	e0 e6       	ldi	r30, 0x60	; 96
-    3fae:	f0 e0       	ldi	r31, 0x00	; 0
-    3fb0:	98 e1       	ldi	r25, 0x18	; 24
-    3fb2:	90 83       	st	Z, r25
+    3faa:	e0 e6       	ldi	r30, 0x60	; 96
+    3fac:	f0 e0       	ldi	r31, 0x00	; 0
+    3fae:	98 e1       	ldi	r25, 0x18	; 24
+    3fb0:	90 83       	st	Z, r25
   WDTCSR = x;
-    3fb4:	80 83       	st	Z, r24
+    3fb2:	80 83       	st	Z, r24
 }
-    3fb6:	08 95       	ret
+    3fb4:	08 95       	ret
 
-00003fb8 <verifySpace>:
+00003fb6 <verifySpace>:
   do getch(); while (--count);
   verifySpace();
 }
 
 void verifySpace() {
   if (getch() != CRC_EOP) {
-    3fb8:	ed df       	rcall	.-38     	; 0x3f94 <getch>
-    3fba:	80 32       	cpi	r24, 0x20	; 32
-    3fbc:	19 f0       	breq	.+6      	; 0x3fc4 <verifySpace+0xc>
+    3fb6:	ed df       	rcall	.-38     	; 0x3f92 <getch>
+    3fb8:	80 32       	cpi	r24, 0x20	; 32
+    3fba:	19 f0       	breq	.+6      	; 0x3fc2 <verifySpace+0xc>
     watchdogConfig(WATCHDOG_16MS);    // shorten WD timeout
-    3fbe:	88 e0       	ldi	r24, 0x08	; 8
-    3fc0:	f5 df       	rcall	.-22     	; 0x3fac <watchdogConfig>
-    3fc2:	ff cf       	rjmp	.-2      	; 0x3fc2 <verifySpace+0xa>
+    3fbc:	88 e0       	ldi	r24, 0x08	; 8
+    3fbe:	f5 df       	rcall	.-22     	; 0x3faa <watchdogConfig>
+    3fc0:	ff cf       	rjmp	.-2      	; 0x3fc0 <verifySpace+0xa>
     while (1)			      // and busy-loop so that WD causes
       ;				      //  a reset and app start.
   }
   putch(STK_INSYNC);
-    3fc4:	84 e1       	ldi	r24, 0x14	; 20
+    3fc2:	84 e1       	ldi	r24, 0x14	; 20
 }
-    3fc6:	de cf       	rjmp	.-68     	; 0x3f84 <putch>
+    3fc4:	de cf       	rjmp	.-68     	; 0x3f82 <putch>
 
-00003fc8 <getNch>:
+00003fc6 <getNch>:
     ::[count] "M" (UART_B_VALUE)
   );
 }
 #endif
 
 void getNch(uint8_t count) {
-    3fc8:	1f 93       	push	r17
-    3fca:	18 2f       	mov	r17, r24
+    3fc6:	1f 93       	push	r17
+    3fc8:	18 2f       	mov	r17, r24
   do getch(); while (--count);
-    3fcc:	e3 df       	rcall	.-58     	; 0x3f94 <getch>
-    3fce:	11 50       	subi	r17, 0x01	; 1
-    3fd0:	e9 f7       	brne	.-6      	; 0x3fcc <getNch+0x4>
+    3fca:	e3 df       	rcall	.-58     	; 0x3f92 <getch>
+    3fcc:	11 50       	subi	r17, 0x01	; 1
+    3fce:	e9 f7       	brne	.-6      	; 0x3fca <getNch+0x4>
   verifySpace();
-    3fd2:	f2 df       	rcall	.-28     	; 0x3fb8 <verifySpace>
+    3fd0:	f2 df       	rcall	.-28     	; 0x3fb6 <verifySpace>
 }
-    3fd4:	1f 91       	pop	r17
-    3fd6:	08 95       	ret
+    3fd2:	1f 91       	pop	r17
+    3fd4:	08 95       	ret
 
-00003fd8 <appStart>:
+00003fd6 <appStart>:
 
 void appStart(uint8_t rstFlags) {
   // 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" (rstFlags));
-    3fd8:	28 2e       	mov	r2, r24
+    3fd6:	28 2e       	mov	r2, r24
 
   watchdogConfig(WATCHDOG_OFF);
-    3fda:	80 e0       	ldi	r24, 0x00	; 0
-    3fdc:	e7 df       	rcall	.-50     	; 0x3fac <watchdogConfig>
+    3fd8:	80 e0       	ldi	r24, 0x00	; 0
+    3fda:	e7 df       	rcall	.-50     	; 0x3faa <watchdogConfig>
   __asm__ __volatile__ (
-    3fde:	ee 27       	eor	r30, r30
-    3fe0:	ff 27       	eor	r31, r31
-    3fe2:	09 94       	ijmp
+    3fdc:	ee 27       	eor	r30, r30
+    3fde:	ff 27       	eor	r31, r31
+    3fe0:	09 94       	ijmp

+ 0 - 34
optiboot/bootloaders/optiboot/optiboot_lilypad_resonator.hex

@@ -1,34 +0,0 @@
-:103E0000112484B714BE81FFE7D085E08093810040
-:103E100082E08093C00088E18093C10086E08093B7
-:103E2000C20088E08093C4008EE0C0D0259A86E06E
-:103E300028E13EEF91E0309385002093840096BB0B
-:103E4000B09BFECF1D9AA8958150A9F7EE24FF24C0
-:103E5000AA24A394B5E0CB2EA1E1BA2EF3E0DF2E85
-:103E600099D0813469F496D0082FA6D0023809F48D
-:103E70007FC0013811F484E001C083E083D07FC0AB
-:103E8000823411F484E103C0853419F485E09CD0B8
-:103E900076C0853579F47ED0E82EFF247BD0082FBC
-:103EA00010E0102F00270E291F29000F111F84D0AA
-:103EB000780165C0863521F484E086D080E0DECFCD
-:103EC000843609F040C066D065D0082F63D080E00A
-:103ED000E81688E3F80618F4F701D7BEE895C0E0C5
-:103EE000D1E058D089930C17E1F7F0E0EF16F8E332
-:103EF000FF0618F0F701D7BEE8955ED007B600FCC4
-:103F0000FDCFA701A0E0B1E02C9130E011968C919B
-:103F1000119790E0982F8827822B932B1296FA0105
-:103F20000C01A7BEE89511244E5F5F4FF1E0A03869
-:103F3000BF0751F7F701C7BEE89507B600FCFDCFF4
-:103F4000B7BEE8951CC0843761F424D023D0082F75
-:103F500021D032D0F70185917F0114D00150D1F7E3
-:103F60000EC0853739F428D08EE10CD084E90AD010
-:103F700086E084CF813511F488E018D01DD080E12F
-:103F800001D06ECF982F8091C00085FFFCCF909319
-:103F9000C60008958091C00087FFFCCF8091C000CB
-:103FA00084FD01C0A8958091C6000895E0E6F0E088
-:103FB00098E1908380830895EDDF803219F088E0E6
-:103FC000F5DFFFCF84E1DECF1F93182FE3DF115021
-:103FD000E9F7F2DF1F910895282E80E0E7DFEE2752
-:043FE000FF2709941A
-:023FFE000604B7
-:0400000300003E00BB
-:00000001FF

+ 0 - 584
optiboot/bootloaders/optiboot/optiboot_lilypad_resonator.lst

@@ -1,584 +0,0 @@
-
-optiboot_lilypad_resonator.elf:     file format elf32-avr
-
-Sections:
-Idx Name          Size      VMA       LMA       File off  Algn
-  0 .text         000001e4  00003e00  00003e00  00000054  2**1
-                  CONTENTS, ALLOC, LOAD, READONLY, CODE
-  1 .version      00000002  00003ffe  00003ffe  00000238  2**0
-                  CONTENTS, READONLY
-  2 .debug_aranges 00000028  00000000  00000000  0000023a  2**0
-                  CONTENTS, READONLY, DEBUGGING
-  3 .debug_pubnames 0000005f  00000000  00000000  00000262  2**0
-                  CONTENTS, READONLY, DEBUGGING
-  4 .debug_info   00000294  00000000  00000000  000002c1  2**0
-                  CONTENTS, READONLY, DEBUGGING
-  5 .debug_abbrev 0000016b  00000000  00000000  00000555  2**0
-                  CONTENTS, READONLY, DEBUGGING
-  6 .debug_line   00000468  00000000  00000000  000006c0  2**0
-                  CONTENTS, READONLY, DEBUGGING
-  7 .debug_frame  00000080  00000000  00000000  00000b28  2**2
-                  CONTENTS, READONLY, DEBUGGING
-  8 .debug_str    00000131  00000000  00000000  00000ba8  2**0
-                  CONTENTS, READONLY, DEBUGGING
-  9 .debug_loc    00000266  00000000  00000000  00000cd9  2**0
-                  CONTENTS, READONLY, DEBUGGING
- 10 .debug_ranges 00000078  00000000  00000000  00000f3f  2**0
-                  CONTENTS, READONLY, DEBUGGING
-
-Disassembly of section .text:
-
-00003e00 <main>:
-# define UART_SRL UBRR3L
-# define UART_UDR UDR3
-#endif
-
-/* main program starts here */
-int main(void) {
-    3e00:	11 24       	eor	r1, r1
-#ifdef __AVR_ATmega8__
-  SP=RAMEND;  // This is done by hardware reset
-#endif
-
-  // Adaboot no-wait mod
-  ch = MCUSR;
-    3e02:	84 b7       	in	r24, 0x34	; 52
-  MCUSR = 0;
-    3e04:	14 be       	out	0x34, r1	; 52
-  if (!(ch & _BV(EXTRF))) appStart(ch);
-    3e06:	81 ff       	sbrs	r24, 1
-    3e08:	e7 d0       	rcall	.+462    	; 0x3fd8 <appStart>
-
-#if LED_START_FLASHES > 0
-  // Set up Timer 1 for timeout counter
-  TCCR1B = _BV(CS12) | _BV(CS10); // div 1024
-    3e0a:	85 e0       	ldi	r24, 0x05	; 5
-    3e0c:	80 93 81 00 	sts	0x0081, r24
-  UCSRA = _BV(U2X); //Double speed mode USART
-  UCSRB = _BV(RXEN) | _BV(TXEN);  // enable Rx & Tx
-  UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0);  // config USART; 8N1
-  UBRRL = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
-#else
-  UART_SRA = _BV(U2X0); //Double speed mode USART0
-    3e10:	82 e0       	ldi	r24, 0x02	; 2
-    3e12:	80 93 c0 00 	sts	0x00C0, r24
-  UART_SRB = _BV(RXEN0) | _BV(TXEN0);
-    3e16:	88 e1       	ldi	r24, 0x18	; 24
-    3e18:	80 93 c1 00 	sts	0x00C1, r24
-  UART_SRC = _BV(UCSZ00) | _BV(UCSZ01);
-    3e1c:	86 e0       	ldi	r24, 0x06	; 6
-    3e1e:	80 93 c2 00 	sts	0x00C2, r24
-  UART_SRL = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
-    3e22:	88 e0       	ldi	r24, 0x08	; 8
-    3e24:	80 93 c4 00 	sts	0x00C4, r24
-#endif
-#endif
-
-  // Set up watchdog to trigger after 500ms
-  watchdogConfig(WATCHDOG_1S);
-    3e28:	8e e0       	ldi	r24, 0x0E	; 14
-    3e2a:	c0 d0       	rcall	.+384    	; 0x3fac <watchdogConfig>
-
-  /* Set LED pin as output */
-  LED_DDR |= _BV(LED);
-    3e2c:	25 9a       	sbi	0x04, 5	; 4
-    3e2e:	86 e0       	ldi	r24, 0x06	; 6
-}
-
-#if LED_START_FLASHES > 0
-void flash_led(uint8_t count) {
-  do {
-    TCNT1 = -(F_CPU/(1024*16));
-    3e30:	28 e1       	ldi	r18, 0x18	; 24
-    3e32:	3e ef       	ldi	r19, 0xFE	; 254
-    TIFR1 = _BV(TOV1);
-    3e34:	91 e0       	ldi	r25, 0x01	; 1
-}
-
-#if LED_START_FLASHES > 0
-void flash_led(uint8_t count) {
-  do {
-    TCNT1 = -(F_CPU/(1024*16));
-    3e36:	30 93 85 00 	sts	0x0085, r19
-    3e3a:	20 93 84 00 	sts	0x0084, r18
-    TIFR1 = _BV(TOV1);
-    3e3e:	96 bb       	out	0x16, r25	; 22
-    while(!(TIFR1 & _BV(TOV1)));
-    3e40:	b0 9b       	sbis	0x16, 0	; 22
-    3e42:	fe cf       	rjmp	.-4      	; 0x3e40 <main+0x40>
-#ifdef __AVR_ATmega8__
-    LED_PORT ^= _BV(LED);
-#else
-    LED_PIN |= _BV(LED);
-    3e44:	1d 9a       	sbi	0x03, 5	; 3
-}
-#endif
-
-// Watchdog functions. These are only safe with interrupts turned off.
-void watchdogReset() {
-  __asm__ __volatile__ (
-    3e46:	a8 95       	wdr
-    LED_PORT ^= _BV(LED);
-#else
-    LED_PIN |= _BV(LED);
-#endif
-    watchdogReset();
-  } while (--count);
-    3e48:	81 50       	subi	r24, 0x01	; 1
-    3e4a:	a9 f7       	brne	.-22     	; 0x3e36 <main+0x36>
-    3e4c:	ee 24       	eor	r14, r14
-    3e4e:	ff 24       	eor	r15, r15
-      ch = SPM_PAGESIZE / 2;
-      do {
-        uint16_t a;
-        a = *bufPtr++;
-        a |= (*bufPtr++) << 8;
-        __boot_page_fill_short((uint16_t)(void*)addrPtr,a);
-    3e50:	aa 24       	eor	r10, r10
-    3e52:	a3 94       	inc	r10
-        addrPtr += 2;
-      } while (--ch);
-
-      // Write from programming buffer
-      __boot_page_write_short((uint16_t)(void*)address);
-    3e54:	b5 e0       	ldi	r27, 0x05	; 5
-    3e56:	cb 2e       	mov	r12, r27
-      boot_spm_busy_wait();
-
-#if defined(RWWSRE)
-      // Reenable read access to flash
-      boot_rww_enable();
-    3e58:	a1 e1       	ldi	r26, 0x11	; 17
-    3e5a:	ba 2e       	mov	r11, r26
-      do *bufPtr++ = getch();
-      while (--length);
-
-      // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
-      if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    3e5c:	f3 e0       	ldi	r31, 0x03	; 3
-    3e5e:	df 2e       	mov	r13, r31
-#endif
-
-  /* Forever loop */
-  for (;;) {
-    /* get character from UART */
-    ch = getch();
-    3e60:	99 d0       	rcall	.+306    	; 0x3f94 <getch>
-
-    if(ch == STK_GET_PARAMETER) {
-    3e62:	81 34       	cpi	r24, 0x41	; 65
-    3e64:	69 f4       	brne	.+26     	; 0x3e80 <main+0x80>
-      unsigned char which = getch();
-    3e66:	96 d0       	rcall	.+300    	; 0x3f94 <getch>
-    3e68:	08 2f       	mov	r16, r24
-      verifySpace();
-    3e6a:	a6 d0       	rcall	.+332    	; 0x3fb8 <verifySpace>
-      if (which == 0x82) {
-    3e6c:	02 38       	cpi	r16, 0x82	; 130
-    3e6e:	09 f4       	brne	.+2      	; 0x3e72 <main+0x72>
-    3e70:	7f c0       	rjmp	.+254    	; 0x3f70 <main+0x170>
-	/*
-	 * Send optiboot version as "minor SW version"
-	 */
-	putch(OPTIBOOT_MINVER);
-      } else if (which == 0x81) {
-    3e72:	01 38       	cpi	r16, 0x81	; 129
-    3e74:	11 f4       	brne	.+4      	; 0x3e7a <main+0x7a>
-	  putch(OPTIBOOT_MAJVER);
-    3e76:	84 e0       	ldi	r24, 0x04	; 4
-    3e78:	01 c0       	rjmp	.+2      	; 0x3e7c <main+0x7c>
-      } else {
-	/*
-	 * GET PARAMETER returns a generic 0x03 reply for
-         * other parameters - enough to keep Avrdude happy
-	 */
-	putch(0x03);
-    3e7a:	83 e0       	ldi	r24, 0x03	; 3
-    3e7c:	83 d0       	rcall	.+262    	; 0x3f84 <putch>
-    3e7e:	7f c0       	rjmp	.+254    	; 0x3f7e <main+0x17e>
-      }
-    }
-    else if(ch == STK_SET_DEVICE) {
-    3e80:	82 34       	cpi	r24, 0x42	; 66
-    3e82:	11 f4       	brne	.+4      	; 0x3e88 <main+0x88>
-      // SET DEVICE is ignored
-      getNch(20);
-    3e84:	84 e1       	ldi	r24, 0x14	; 20
-    3e86:	03 c0       	rjmp	.+6      	; 0x3e8e <main+0x8e>
-    }
-    else if(ch == STK_SET_DEVICE_EXT) {
-    3e88:	85 34       	cpi	r24, 0x45	; 69
-    3e8a:	19 f4       	brne	.+6      	; 0x3e92 <main+0x92>
-      // SET DEVICE EXT is ignored
-      getNch(5);
-    3e8c:	85 e0       	ldi	r24, 0x05	; 5
-    3e8e:	9c d0       	rcall	.+312    	; 0x3fc8 <getNch>
-    3e90:	76 c0       	rjmp	.+236    	; 0x3f7e <main+0x17e>
-    }
-    else if(ch == STK_LOAD_ADDRESS) {
-    3e92:	85 35       	cpi	r24, 0x55	; 85
-    3e94:	79 f4       	brne	.+30     	; 0x3eb4 <main+0xb4>
-      // LOAD ADDRESS
-      uint16_t newAddress;
-      newAddress = getch();
-    3e96:	7e d0       	rcall	.+252    	; 0x3f94 <getch>
-      newAddress = (newAddress & 0xff) | (getch() << 8);
-    3e98:	e8 2e       	mov	r14, r24
-    3e9a:	ff 24       	eor	r15, r15
-    3e9c:	7b d0       	rcall	.+246    	; 0x3f94 <getch>
-    3e9e:	08 2f       	mov	r16, r24
-    3ea0:	10 e0       	ldi	r17, 0x00	; 0
-    3ea2:	10 2f       	mov	r17, r16
-    3ea4:	00 27       	eor	r16, r16
-    3ea6:	0e 29       	or	r16, r14
-    3ea8:	1f 29       	or	r17, r15
-#ifdef RAMPZ
-      // Transfer top bit to RAMPZ
-      RAMPZ = (newAddress & 0x8000) ? 1 : 0;
-#endif
-      newAddress += newAddress; // Convert from word address to byte address
-    3eaa:	00 0f       	add	r16, r16
-    3eac:	11 1f       	adc	r17, r17
-      address = newAddress;
-      verifySpace();
-    3eae:	84 d0       	rcall	.+264    	; 0x3fb8 <verifySpace>
-    3eb0:	78 01       	movw	r14, r16
-    3eb2:	65 c0       	rjmp	.+202    	; 0x3f7e <main+0x17e>
-    }
-    else if(ch == STK_UNIVERSAL) {
-    3eb4:	86 35       	cpi	r24, 0x56	; 86
-    3eb6:	21 f4       	brne	.+8      	; 0x3ec0 <main+0xc0>
-      // UNIVERSAL command is ignored
-      getNch(4);
-    3eb8:	84 e0       	ldi	r24, 0x04	; 4
-    3eba:	86 d0       	rcall	.+268    	; 0x3fc8 <getNch>
-      putch(0x00);
-    3ebc:	80 e0       	ldi	r24, 0x00	; 0
-    3ebe:	de cf       	rjmp	.-68     	; 0x3e7c <main+0x7c>
-    }
-    /* Write memory, length is big endian and is in bytes */
-    else if(ch == STK_PROG_PAGE) {
-    3ec0:	84 36       	cpi	r24, 0x64	; 100
-    3ec2:	09 f0       	breq	.+2      	; 0x3ec6 <main+0xc6>
-    3ec4:	40 c0       	rjmp	.+128    	; 0x3f46 <main+0x146>
-      // PROGRAM PAGE - we support flash programming only, not EEPROM
-      uint8_t *bufPtr;
-      uint16_t addrPtr;
-
-      getch();			/* getlen() */
-    3ec6:	66 d0       	rcall	.+204    	; 0x3f94 <getch>
-      length = getch();
-    3ec8:	65 d0       	rcall	.+202    	; 0x3f94 <getch>
-    3eca:	08 2f       	mov	r16, r24
-      getch();
-    3ecc:	63 d0       	rcall	.+198    	; 0x3f94 <getch>
-
-      // If we are in RWW section, immediately start page erase
-      if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    3ece:	80 e0       	ldi	r24, 0x00	; 0
-    3ed0:	e8 16       	cp	r14, r24
-    3ed2:	88 e3       	ldi	r24, 0x38	; 56
-    3ed4:	f8 06       	cpc	r15, r24
-    3ed6:	18 f4       	brcc	.+6      	; 0x3ede <main+0xde>
-    3ed8:	f7 01       	movw	r30, r14
-    3eda:	d7 be       	out	0x37, r13	; 55
-    3edc:	e8 95       	spm
-    3ede:	c0 e0       	ldi	r28, 0x00	; 0
-    3ee0:	d1 e0       	ldi	r29, 0x01	; 1
-
-      // While that is going on, read in page contents
-      bufPtr = buff;
-      do *bufPtr++ = getch();
-    3ee2:	58 d0       	rcall	.+176    	; 0x3f94 <getch>
-    3ee4:	89 93       	st	Y+, r24
-      while (--length);
-    3ee6:	0c 17       	cp	r16, r28
-    3ee8:	e1 f7       	brne	.-8      	; 0x3ee2 <main+0xe2>
-
-      // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
-      if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    3eea:	f0 e0       	ldi	r31, 0x00	; 0
-    3eec:	ef 16       	cp	r14, r31
-    3eee:	f8 e3       	ldi	r31, 0x38	; 56
-    3ef0:	ff 06       	cpc	r15, r31
-    3ef2:	18 f0       	brcs	.+6      	; 0x3efa <main+0xfa>
-    3ef4:	f7 01       	movw	r30, r14
-    3ef6:	d7 be       	out	0x37, r13	; 55
-    3ef8:	e8 95       	spm
-
-      // Read command terminator, start reply
-      verifySpace();
-    3efa:	5e d0       	rcall	.+188    	; 0x3fb8 <verifySpace>
-
-      // If only a partial page is to be programmed, the erase might not be complete.
-      // So check that here
-      boot_spm_busy_wait();
-    3efc:	07 b6       	in	r0, 0x37	; 55
-    3efe:	00 fc       	sbrc	r0, 0
-    3f00:	fd cf       	rjmp	.-6      	; 0x3efc <main+0xfc>
-    3f02:	a7 01       	movw	r20, r14
-    3f04:	a0 e0       	ldi	r26, 0x00	; 0
-    3f06:	b1 e0       	ldi	r27, 0x01	; 1
-      bufPtr = buff;
-      addrPtr = (uint16_t)(void*)address;
-      ch = SPM_PAGESIZE / 2;
-      do {
-        uint16_t a;
-        a = *bufPtr++;
-    3f08:	2c 91       	ld	r18, X
-    3f0a:	30 e0       	ldi	r19, 0x00	; 0
-        a |= (*bufPtr++) << 8;
-    3f0c:	11 96       	adiw	r26, 0x01	; 1
-    3f0e:	8c 91       	ld	r24, X
-    3f10:	11 97       	sbiw	r26, 0x01	; 1
-    3f12:	90 e0       	ldi	r25, 0x00	; 0
-    3f14:	98 2f       	mov	r25, r24
-    3f16:	88 27       	eor	r24, r24
-    3f18:	82 2b       	or	r24, r18
-    3f1a:	93 2b       	or	r25, r19
-# define UART_SRL UBRR3L
-# define UART_UDR UDR3
-#endif
-
-/* main program starts here */
-int main(void) {
-    3f1c:	12 96       	adiw	r26, 0x02	; 2
-      ch = SPM_PAGESIZE / 2;
-      do {
-        uint16_t a;
-        a = *bufPtr++;
-        a |= (*bufPtr++) << 8;
-        __boot_page_fill_short((uint16_t)(void*)addrPtr,a);
-    3f1e:	fa 01       	movw	r30, r20
-    3f20:	0c 01       	movw	r0, r24
-    3f22:	a7 be       	out	0x37, r10	; 55
-    3f24:	e8 95       	spm
-    3f26:	11 24       	eor	r1, r1
-        addrPtr += 2;
-    3f28:	4e 5f       	subi	r20, 0xFE	; 254
-    3f2a:	5f 4f       	sbci	r21, 0xFF	; 255
-      } while (--ch);
-    3f2c:	f1 e0       	ldi	r31, 0x01	; 1
-    3f2e:	a0 38       	cpi	r26, 0x80	; 128
-    3f30:	bf 07       	cpc	r27, r31
-    3f32:	51 f7       	brne	.-44     	; 0x3f08 <main+0x108>
-
-      // Write from programming buffer
-      __boot_page_write_short((uint16_t)(void*)address);
-    3f34:	f7 01       	movw	r30, r14
-    3f36:	c7 be       	out	0x37, r12	; 55
-    3f38:	e8 95       	spm
-      boot_spm_busy_wait();
-    3f3a:	07 b6       	in	r0, 0x37	; 55
-    3f3c:	00 fc       	sbrc	r0, 0
-    3f3e:	fd cf       	rjmp	.-6      	; 0x3f3a <main+0x13a>
-
-#if defined(RWWSRE)
-      // Reenable read access to flash
-      boot_rww_enable();
-    3f40:	b7 be       	out	0x37, r11	; 55
-    3f42:	e8 95       	spm
-    3f44:	1c c0       	rjmp	.+56     	; 0x3f7e <main+0x17e>
-#endif
-
-    }
-    /* Read memory block mode, length is big endian.  */
-    else if(ch == STK_READ_PAGE) {
-    3f46:	84 37       	cpi	r24, 0x74	; 116
-    3f48:	61 f4       	brne	.+24     	; 0x3f62 <main+0x162>
-      // READ PAGE - we only read flash
-      getch();			/* getlen() */
-    3f4a:	24 d0       	rcall	.+72     	; 0x3f94 <getch>
-      length = getch();
-    3f4c:	23 d0       	rcall	.+70     	; 0x3f94 <getch>
-    3f4e:	08 2f       	mov	r16, r24
-      getch();
-    3f50:	21 d0       	rcall	.+66     	; 0x3f94 <getch>
-
-      verifySpace();
-    3f52:	32 d0       	rcall	.+100    	; 0x3fb8 <verifySpace>
-        __asm__ ("elpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
-#else
-        // read a Flash byte and increment the address
-        __asm__ ("lpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
-#endif
-        putch(ch);
-    3f54:	f7 01       	movw	r30, r14
-    3f56:	85 91       	lpm	r24, Z+
-    3f58:	7f 01       	movw	r14, r30
-    3f5a:	14 d0       	rcall	.+40     	; 0x3f84 <putch>
-      } while (--length);
-    3f5c:	01 50       	subi	r16, 0x01	; 1
-    3f5e:	d1 f7       	brne	.-12     	; 0x3f54 <main+0x154>
-    3f60:	0e c0       	rjmp	.+28     	; 0x3f7e <main+0x17e>
-    }
-
-    /* Get device signature bytes  */
-    else if(ch == STK_READ_SIGN) {
-    3f62:	85 37       	cpi	r24, 0x75	; 117
-    3f64:	39 f4       	brne	.+14     	; 0x3f74 <main+0x174>
-      // READ SIGN - return what Avrdude wants to hear
-      verifySpace();
-    3f66:	28 d0       	rcall	.+80     	; 0x3fb8 <verifySpace>
-      putch(SIGNATURE_0);
-    3f68:	8e e1       	ldi	r24, 0x1E	; 30
-    3f6a:	0c d0       	rcall	.+24     	; 0x3f84 <putch>
-      putch(SIGNATURE_1);
-    3f6c:	84 e9       	ldi	r24, 0x94	; 148
-    3f6e:	0a d0       	rcall	.+20     	; 0x3f84 <putch>
-      putch(SIGNATURE_2);
-    3f70:	86 e0       	ldi	r24, 0x06	; 6
-    3f72:	84 cf       	rjmp	.-248    	; 0x3e7c <main+0x7c>
-    }
-    else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */
-    3f74:	81 35       	cpi	r24, 0x51	; 81
-    3f76:	11 f4       	brne	.+4      	; 0x3f7c <main+0x17c>
-      // Adaboot no-wait mod
-      watchdogConfig(WATCHDOG_16MS);
-    3f78:	88 e0       	ldi	r24, 0x08	; 8
-    3f7a:	18 d0       	rcall	.+48     	; 0x3fac <watchdogConfig>
-      verifySpace();
-    }
-    else {
-      // This covers the response to commands like STK_ENTER_PROGMODE
-      verifySpace();
-    3f7c:	1d d0       	rcall	.+58     	; 0x3fb8 <verifySpace>
-    }
-    putch(STK_OK);
-    3f7e:	80 e1       	ldi	r24, 0x10	; 16
-    3f80:	01 d0       	rcall	.+2      	; 0x3f84 <putch>
-    3f82:	6e cf       	rjmp	.-292    	; 0x3e60 <main+0x60>
-
-00003f84 <putch>:
-  }
-}
-
-void putch(char ch) {
-    3f84:	98 2f       	mov	r25, r24
-#ifndef SOFT_UART
-  while (!(UART_SRA & _BV(UDRE0)));
-    3f86:	80 91 c0 00 	lds	r24, 0x00C0
-    3f8a:	85 ff       	sbrs	r24, 5
-    3f8c:	fc cf       	rjmp	.-8      	; 0x3f86 <putch+0x2>
-  UART_UDR = ch;
-    3f8e:	90 93 c6 00 	sts	0x00C6, r25
-      [uartBit] "I" (UART_TX_BIT)
-    :
-      "r25"
-  );
-#endif
-}
-    3f92:	08 95       	ret
-
-00003f94 <getch>:
-      [uartBit] "I" (UART_RX_BIT)
-    :
-      "r25"
-);
-#else
-  while(!(UART_SRA & _BV(RXC0)))
-    3f94:	80 91 c0 00 	lds	r24, 0x00C0
-    3f98:	87 ff       	sbrs	r24, 7
-    3f9a:	fc cf       	rjmp	.-8      	; 0x3f94 <getch>
-    ;
-  if (!(UART_SRA & _BV(FE0))) {
-    3f9c:	80 91 c0 00 	lds	r24, 0x00C0
-    3fa0:	84 fd       	sbrc	r24, 4
-    3fa2:	01 c0       	rjmp	.+2      	; 0x3fa6 <getch+0x12>
-}
-#endif
-
-// Watchdog functions. These are only safe with interrupts turned off.
-void watchdogReset() {
-  __asm__ __volatile__ (
-    3fa4:	a8 95       	wdr
-       * don't care that an invalid char is returned...)
-       */
-    watchdogReset();
-  }
-  
-  ch = UART_UDR;
-    3fa6:	80 91 c6 00 	lds	r24, 0x00C6
-  LED_PIN |= _BV(LED);
-#endif
-#endif
-
-  return ch;
-}
-    3faa:	08 95       	ret
-
-00003fac <watchdogConfig>:
-    "wdr\n"
-  );
-}
-
-void watchdogConfig(uint8_t x) {
-  WDTCSR = _BV(WDCE) | _BV(WDE);
-    3fac:	e0 e6       	ldi	r30, 0x60	; 96
-    3fae:	f0 e0       	ldi	r31, 0x00	; 0
-    3fb0:	98 e1       	ldi	r25, 0x18	; 24
-    3fb2:	90 83       	st	Z, r25
-  WDTCSR = x;
-    3fb4:	80 83       	st	Z, r24
-}
-    3fb6:	08 95       	ret
-
-00003fb8 <verifySpace>:
-  do getch(); while (--count);
-  verifySpace();
-}
-
-void verifySpace() {
-  if (getch() != CRC_EOP) {
-    3fb8:	ed df       	rcall	.-38     	; 0x3f94 <getch>
-    3fba:	80 32       	cpi	r24, 0x20	; 32
-    3fbc:	19 f0       	breq	.+6      	; 0x3fc4 <verifySpace+0xc>
-    watchdogConfig(WATCHDOG_16MS);    // shorten WD timeout
-    3fbe:	88 e0       	ldi	r24, 0x08	; 8
-    3fc0:	f5 df       	rcall	.-22     	; 0x3fac <watchdogConfig>
-    3fc2:	ff cf       	rjmp	.-2      	; 0x3fc2 <verifySpace+0xa>
-    while (1)			      // and busy-loop so that WD causes
-      ;				      //  a reset and app start.
-  }
-  putch(STK_INSYNC);
-    3fc4:	84 e1       	ldi	r24, 0x14	; 20
-}
-    3fc6:	de cf       	rjmp	.-68     	; 0x3f84 <putch>
-
-00003fc8 <getNch>:
-    ::[count] "M" (UART_B_VALUE)
-  );
-}
-#endif
-
-void getNch(uint8_t count) {
-    3fc8:	1f 93       	push	r17
-    3fca:	18 2f       	mov	r17, r24
-  do getch(); while (--count);
-    3fcc:	e3 df       	rcall	.-58     	; 0x3f94 <getch>
-    3fce:	11 50       	subi	r17, 0x01	; 1
-    3fd0:	e9 f7       	brne	.-6      	; 0x3fcc <getNch+0x4>
-  verifySpace();
-    3fd2:	f2 df       	rcall	.-28     	; 0x3fb8 <verifySpace>
-}
-    3fd4:	1f 91       	pop	r17
-    3fd6:	08 95       	ret
-
-00003fd8 <appStart>:
-
-void appStart(uint8_t rstFlags) {
-  // 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" (rstFlags));
-    3fd8:	28 2e       	mov	r2, r24
-
-  watchdogConfig(WATCHDOG_OFF);
-    3fda:	80 e0       	ldi	r24, 0x00	; 0
-    3fdc:	e7 df       	rcall	.-50     	; 0x3fac <watchdogConfig>
-  __asm__ __volatile__ (
-    3fde:	ee 27       	eor	r30, r30
-    3fe0:	ff 27       	eor	r31, r31
-    3fe2:	09 94       	ijmp

+ 37 - 38
optiboot/bootloaders/optiboot/optiboot_luminet.hex

@@ -1,42 +1,41 @@
-:101D0000112484B714BE81FF26D185E08EBD8EE0FC
-:101D10000ED1D49AD29A86E023EC3FEF91E03DBDFC
+:101D0000112484B714BE81FF24D185E08EBD8EE0FE
+:101D10000CD1D49AD29A86E023EC3FEF91E03DBDFE
 :101D20002CBD9BB9589BFECFCC9AA8958150B9F792
 :101D3000EE24FF2493E0992EBB24B39485E0A82ED3
-:101D40000FE7D02E1EECC12EDFD0813471F4DCD031
-:101D5000082FF1D0023811F486E005C0013811F4E3
-:101D600084E001C083E0C1D0BDC0823411F484E1BD
-:101D700003C0853419F485E0E6D0B4C0853579F424
-:101D8000C3D0E82EFF24C0D0082F10E0102F00276A
-:101D90000E291F29000F111FCED07801A3C0863550
-:101DA00021F484E0D0D080E0DECF843609F05FC03B
-:101DB000ABD0AAD0182FA8D0C0E0D1E0A5D089938D
-:101DC0001C17E1F7F70197BEE895B5D007B600FC00
-:101DD000FDCFE114F10411F0A7012AC080910001A8
-:101DE0002091010130E0322F222790E0282B392B5F
-:101DF000309385012093840140910801809109016D
-:101E000090E0982F882750E0842B952B90938701A2
-:101E1000809386012450304020930801232F3327DC
-:101E200020930901D0920001C092010140E050E0EE
-:101E3000A0E0B1E02C9130E011968C91119790E0E8
-:101E4000982F8827822B932B1296FA010C01B7BE8C
-:101E5000E89511244E5F5F4FF1E0A034BF0751F7C2
-:101E6000F701A7BEE89507B600FCFDCF3BC084375D
-:101E700059F54AD049D0182F47D05DD0E701012F3E
-:101E8000209719F48091840114C0C130D10519F450
-:101E9000809185010EC0C830D10519F4809186016A
-:101EA00008C0C930D10519F48091870102C0FE0134
-:101EB000849121961AD0015019F70894E11CF11C65
-:101EC0001150E10EF11C0EC0853739F434D08EE18B
-:101ED0000CD083E90AD08CE046CF813511F488E03C
-:101EE00026D029D080E101D02FCF2AE030E08095A4
-:101EF000089410F4DA9802C0DA9A000014D013D0D3
-:101F000086952A95B1F7089529E030E0CB99FECF68
-:101F10000AD009D008D08894CB9908942A9511F05A
-:101F20008795F7CF08959EE09A95F1F7089598E187
-:101F300091BD81BD0895E8DF803219F088E0F7DFB8
-:101F4000FFCF84E1D2CF1F93182FDEDF1150E9F7C6
-:101F5000F2DF1F910895282E80E0E9DFE4E0FF27FB
-:021F60000994E2
-:021EFE000604D8
+:101D40000FE7D02E1EECC12EDDD0813461F4DAD045
+:101D5000082FEFD0023829F1013811F485E001C0D5
+:101D600083E0C1D0BDC0823411F484E103C0853466
+:101D700019F485E0E6D0B4C0853579F4C3D0E82EF7
+:101D8000FF24C0D0082F10E0102F00270E291F2994
+:101D9000000F111FCED07801A3C0863521F484E056
+:101DA000D0D080E0DECF843609F05FC0ABD0AAD0BF
+:101DB000182FA8D0C0E0D1E0A5D089931C17E1F777
+:101DC000F70197BEE895B5D007B600FCFDCFE1144A
+:101DD000F10411F0A7012AC08091000120910101B6
+:101DE00030E0322F222790E0282B392B30938501C9
+:101DF00020938401409108018091090190E0982F7F
+:101E0000882750E0842B952B90938701809386013F
+:101E10002450304020930801232F332720930901B9
+:101E2000D0920001C092010140E050E0A0E0B1E09A
+:101E30002C9130E011968C91119790E0982F882783
+:101E4000822B932B1296FA010C01B7BEE895112450
+:101E50004E5F5F4FF1E0A034BF0751F7F701A7BE17
+:101E6000E89507B600FCFDCF3BC0843759F54AD052
+:101E700049D0182F47D05DD0E701012F209719F4E2
+:101E80008091840114C0C130D10519F4809185017D
+:101E90000EC0C830D10519F48091860108C0C93040
+:101EA000D10519F48091870102C0FE018491219629
+:101EB0001AD0015019F70894E11CF11C1150E10EE1
+:101EC000F11C0EC0853739F434D08EE10CD083E993
+:101ED0000AD08CE046CF813511F488E026D029D095
+:101EE00080E101D031CF2AE030E08095089410F4F1
+:101EF000DA9802C0DA9A000014D013D086952A9599
+:101F0000B1F7089529E030E0CB99FECF0AD009D08F
+:101F100008D08894CB9908942A9511F08795F7CF2B
+:101F200008959EE09A95F1F7089598E191BD81BDDD
+:101F30000895E8DF803219F088E0F7DFFFCF84E111
+:101F4000D2CF1F93182FDEDF1150E9F7F2DF1F9178
+:0E1F50000895282E80E0E9DFE4E0FF270994E1
+:021EFE000005DD
 :0400000300001D00DC
 :00000001FF

+ 279 - 277
optiboot/bootloaders/optiboot/optiboot_luminet.lst

@@ -3,27 +3,27 @@ optiboot_luminet.elf:     file format elf32-avr
 
 Sections:
 Idx Name          Size      VMA       LMA       File off  Algn
-  0 .text         00000262  00001d00  00001d00  00000054  2**1
+  0 .text         0000025e  00001d00  00001d00  00000054  2**1
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
-  1 .version      00000002  00001efe  00001efe  000002b6  2**0
+  1 .version      00000002  00001efe  00001efe  000002b2  2**0
                   CONTENTS, READONLY
-  2 .debug_aranges 00000028  00000000  00000000  000002b8  2**0
+  2 .debug_aranges 00000028  00000000  00000000  000002b4  2**0
                   CONTENTS, READONLY, DEBUGGING
-  3 .debug_pubnames 0000006d  00000000  00000000  000002e0  2**0
+  3 .debug_pubnames 0000006d  00000000  00000000  000002dc  2**0
                   CONTENTS, READONLY, DEBUGGING
-  4 .debug_info   000002d2  00000000  00000000  0000034d  2**0
+  4 .debug_info   000002d2  00000000  00000000  00000349  2**0
                   CONTENTS, READONLY, DEBUGGING
-  5 .debug_abbrev 00000176  00000000  00000000  0000061f  2**0
+  5 .debug_abbrev 00000176  00000000  00000000  0000061b  2**0
                   CONTENTS, READONLY, DEBUGGING
-  6 .debug_line   000004c0  00000000  00000000  00000795  2**0
+  6 .debug_line   00000471  00000000  00000000  00000791  2**0
                   CONTENTS, READONLY, DEBUGGING
-  7 .debug_frame  00000090  00000000  00000000  00000c58  2**2
+  7 .debug_frame  00000090  00000000  00000000  00000c04  2**2
                   CONTENTS, READONLY, DEBUGGING
-  8 .debug_str    00000152  00000000  00000000  00000ce8  2**0
+  8 .debug_str    00000152  00000000  00000000  00000c94  2**0
                   CONTENTS, READONLY, DEBUGGING
-  9 .debug_loc    000002b4  00000000  00000000  00000e3a  2**0
+  9 .debug_loc    000002b4  00000000  00000000  00000de6  2**0
                   CONTENTS, READONLY, DEBUGGING
- 10 .debug_ranges 00000098  00000000  00000000  000010ee  2**0
+ 10 .debug_ranges 00000098  00000000  00000000  0000109a  2**0
                   CONTENTS, READONLY, DEBUGGING
 
 Disassembly of section .text:
@@ -36,7 +36,7 @@ Disassembly of section .text:
 /* main program starts here */
 int main(void) {
     1d00:	11 24       	eor	r1, r1
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__)
   SP=RAMEND;  // This is done by hardware reset
 #endif
 
@@ -47,7 +47,7 @@ int main(void) {
     1d04:	14 be       	out	0x34, r1	; 52
   if (!(ch & _BV(EXTRF))) appStart(ch);
     1d06:	81 ff       	sbrs	r24, 1
-    1d08:	26 d1       	rcall	.+588    	; 0x1f56 <appStart>
+    1d08:	24 d1       	rcall	.+584    	; 0x1f52 <appStart>
 
 #if LED_START_FLASHES > 0
   // Set up Timer 1 for timeout counter
@@ -61,11 +61,13 @@ int main(void) {
   // Set up watchdog to trigger after 500ms
   watchdogConfig(WATCHDOG_1S);
     1d0e:	8e e0       	ldi	r24, 0x0E	; 14
-    1d10:	0e d1       	rcall	.+540    	; 0x1f2e <watchdogConfig>
+    1d10:	0c d1       	rcall	.+536    	; 0x1f2a <watchdogConfig>
 
+#if (LED_START_FLASHES > 0) || defined(LED_DATA_FLASH)
   /* Set LED pin as output */
   LED_DDR |= _BV(LED);
     1d12:	d4 9a       	sbi	0x1a, 4	; 26
+#endif
 
 #ifdef SOFT_UART
   /* Set TX pin as output */
@@ -95,7 +97,7 @@ void flash_led(uint8_t count) {
     while(!(TIFR1 & _BV(TOV1)));
     1d24:	58 9b       	sbis	0x0b, 0	; 11
     1d26:	fe cf       	rjmp	.-4      	; 0x1d24 <main+0x24>
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__)  || defined (__AVR_ATmega32__)
     LED_PORT ^= _BV(LED);
 #else
     LED_PIN |= _BV(LED);
@@ -117,11 +119,11 @@ void watchdogReset() {
     1d2e:	b9 f7       	brne	.-18     	; 0x1d1e <main+0x1e>
     1d30:	ee 24       	eor	r14, r14
     1d32:	ff 24       	eor	r15, r15
-      do *bufPtr++ = getch();
-      while (--length);
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
     1d34:	93 e0       	ldi	r25, 0x03	; 3
     1d36:	99 2e       	mov	r9, r25
@@ -157,502 +159,502 @@ void watchdogReset() {
   for (;;) {
     /* get character from UART */
     ch = getch();
-    1d48:	df d0       	rcall	.+446    	; 0x1f08 <getch>
+    1d48:	dd d0       	rcall	.+442    	; 0x1f04 <getch>
 
     if(ch == STK_GET_PARAMETER) {
     1d4a:	81 34       	cpi	r24, 0x41	; 65
-    1d4c:	71 f4       	brne	.+28     	; 0x1d6a <main+0x6a>
+    1d4c:	61 f4       	brne	.+24     	; 0x1d66 <main+0x66>
       unsigned char which = getch();
-    1d4e:	dc d0       	rcall	.+440    	; 0x1f08 <getch>
+    1d4e:	da d0       	rcall	.+436    	; 0x1f04 <getch>
     1d50:	08 2f       	mov	r16, r24
       verifySpace();
-    1d52:	f1 d0       	rcall	.+482    	; 0x1f36 <verifySpace>
+    1d52:	ef d0       	rcall	.+478    	; 0x1f32 <verifySpace>
       if (which == 0x82) {
     1d54:	02 38       	cpi	r16, 0x82	; 130
-    1d56:	11 f4       	brne	.+4      	; 0x1d5c <main+0x5c>
+    1d56:	29 f1       	breq	.+74     	; 0x1da2 <main+0xa2>
 	/*
 	 * Send optiboot version as "minor SW version"
 	 */
 	putch(OPTIBOOT_MINVER);
-    1d58:	86 e0       	ldi	r24, 0x06	; 6
-    1d5a:	05 c0       	rjmp	.+10     	; 0x1d66 <main+0x66>
       } else if (which == 0x81) {
-    1d5c:	01 38       	cpi	r16, 0x81	; 129
-    1d5e:	11 f4       	brne	.+4      	; 0x1d64 <main+0x64>
+    1d58:	01 38       	cpi	r16, 0x81	; 129
+    1d5a:	11 f4       	brne	.+4      	; 0x1d60 <main+0x60>
 	  putch(OPTIBOOT_MAJVER);
-    1d60:	84 e0       	ldi	r24, 0x04	; 4
-    1d62:	01 c0       	rjmp	.+2      	; 0x1d66 <main+0x66>
+    1d5c:	85 e0       	ldi	r24, 0x05	; 5
+    1d5e:	01 c0       	rjmp	.+2      	; 0x1d62 <main+0x62>
       } else {
 	/*
 	 * GET PARAMETER returns a generic 0x03 reply for
          * other parameters - enough to keep Avrdude happy
 	 */
 	putch(0x03);
-    1d64:	83 e0       	ldi	r24, 0x03	; 3
-    1d66:	c1 d0       	rcall	.+386    	; 0x1eea <putch>
-    1d68:	bd c0       	rjmp	.+378    	; 0x1ee4 <main+0x1e4>
+    1d60:	83 e0       	ldi	r24, 0x03	; 3
+    1d62:	c1 d0       	rcall	.+386    	; 0x1ee6 <putch>
+    1d64:	bd c0       	rjmp	.+378    	; 0x1ee0 <main+0x1e0>
       }
     }
     else if(ch == STK_SET_DEVICE) {
-    1d6a:	82 34       	cpi	r24, 0x42	; 66
-    1d6c:	11 f4       	brne	.+4      	; 0x1d72 <main+0x72>
+    1d66:	82 34       	cpi	r24, 0x42	; 66
+    1d68:	11 f4       	brne	.+4      	; 0x1d6e <main+0x6e>
       // SET DEVICE is ignored
       getNch(20);
-    1d6e:	84 e1       	ldi	r24, 0x14	; 20
-    1d70:	03 c0       	rjmp	.+6      	; 0x1d78 <main+0x78>
+    1d6a:	84 e1       	ldi	r24, 0x14	; 20
+    1d6c:	03 c0       	rjmp	.+6      	; 0x1d74 <main+0x74>
     }
     else if(ch == STK_SET_DEVICE_EXT) {
-    1d72:	85 34       	cpi	r24, 0x45	; 69
-    1d74:	19 f4       	brne	.+6      	; 0x1d7c <main+0x7c>
+    1d6e:	85 34       	cpi	r24, 0x45	; 69
+    1d70:	19 f4       	brne	.+6      	; 0x1d78 <main+0x78>
       // SET DEVICE EXT is ignored
       getNch(5);
-    1d76:	85 e0       	ldi	r24, 0x05	; 5
-    1d78:	e6 d0       	rcall	.+460    	; 0x1f46 <getNch>
-    1d7a:	b4 c0       	rjmp	.+360    	; 0x1ee4 <main+0x1e4>
+    1d72:	85 e0       	ldi	r24, 0x05	; 5
+    1d74:	e6 d0       	rcall	.+460    	; 0x1f42 <getNch>
+    1d76:	b4 c0       	rjmp	.+360    	; 0x1ee0 <main+0x1e0>
     }
     else if(ch == STK_LOAD_ADDRESS) {
-    1d7c:	85 35       	cpi	r24, 0x55	; 85
-    1d7e:	79 f4       	brne	.+30     	; 0x1d9e <main+0x9e>
+    1d78:	85 35       	cpi	r24, 0x55	; 85
+    1d7a:	79 f4       	brne	.+30     	; 0x1d9a <main+0x9a>
       // LOAD ADDRESS
       uint16_t newAddress;
       newAddress = getch();
-    1d80:	c3 d0       	rcall	.+390    	; 0x1f08 <getch>
+    1d7c:	c3 d0       	rcall	.+390    	; 0x1f04 <getch>
       newAddress = (newAddress & 0xff) | (getch() << 8);
-    1d82:	e8 2e       	mov	r14, r24
-    1d84:	ff 24       	eor	r15, r15
-    1d86:	c0 d0       	rcall	.+384    	; 0x1f08 <getch>
-    1d88:	08 2f       	mov	r16, r24
-    1d8a:	10 e0       	ldi	r17, 0x00	; 0
-    1d8c:	10 2f       	mov	r17, r16
-    1d8e:	00 27       	eor	r16, r16
-    1d90:	0e 29       	or	r16, r14
-    1d92:	1f 29       	or	r17, r15
+    1d7e:	e8 2e       	mov	r14, r24
+    1d80:	ff 24       	eor	r15, r15
+    1d82:	c0 d0       	rcall	.+384    	; 0x1f04 <getch>
+    1d84:	08 2f       	mov	r16, r24
+    1d86:	10 e0       	ldi	r17, 0x00	; 0
+    1d88:	10 2f       	mov	r17, r16
+    1d8a:	00 27       	eor	r16, r16
+    1d8c:	0e 29       	or	r16, r14
+    1d8e:	1f 29       	or	r17, r15
 #ifdef RAMPZ
       // Transfer top bit to RAMPZ
       RAMPZ = (newAddress & 0x8000) ? 1 : 0;
 #endif
       newAddress += newAddress; // Convert from word address to byte address
-    1d94:	00 0f       	add	r16, r16
-    1d96:	11 1f       	adc	r17, r17
+    1d90:	00 0f       	add	r16, r16
+    1d92:	11 1f       	adc	r17, r17
       address = newAddress;
       verifySpace();
-    1d98:	ce d0       	rcall	.+412    	; 0x1f36 <verifySpace>
-    1d9a:	78 01       	movw	r14, r16
-    1d9c:	a3 c0       	rjmp	.+326    	; 0x1ee4 <main+0x1e4>
+    1d94:	ce d0       	rcall	.+412    	; 0x1f32 <verifySpace>
+    1d96:	78 01       	movw	r14, r16
+    1d98:	a3 c0       	rjmp	.+326    	; 0x1ee0 <main+0x1e0>
     }
     else if(ch == STK_UNIVERSAL) {
-    1d9e:	86 35       	cpi	r24, 0x56	; 86
-    1da0:	21 f4       	brne	.+8      	; 0x1daa <main+0xaa>
+    1d9a:	86 35       	cpi	r24, 0x56	; 86
+    1d9c:	21 f4       	brne	.+8      	; 0x1da6 <main+0xa6>
       // UNIVERSAL command is ignored
       getNch(4);
-    1da2:	84 e0       	ldi	r24, 0x04	; 4
-    1da4:	d0 d0       	rcall	.+416    	; 0x1f46 <getNch>
+    1d9e:	84 e0       	ldi	r24, 0x04	; 4
+    1da0:	d0 d0       	rcall	.+416    	; 0x1f42 <getNch>
       putch(0x00);
-    1da6:	80 e0       	ldi	r24, 0x00	; 0
-    1da8:	de cf       	rjmp	.-68     	; 0x1d66 <main+0x66>
+    1da2:	80 e0       	ldi	r24, 0x00	; 0
+    1da4:	de cf       	rjmp	.-68     	; 0x1d62 <main+0x62>
     }
     /* Write memory, length is big endian and is in bytes */
     else if(ch == STK_PROG_PAGE) {
-    1daa:	84 36       	cpi	r24, 0x64	; 100
-    1dac:	09 f0       	breq	.+2      	; 0x1db0 <main+0xb0>
-    1dae:	5f c0       	rjmp	.+190    	; 0x1e6e <main+0x16e>
+    1da6:	84 36       	cpi	r24, 0x64	; 100
+    1da8:	09 f0       	breq	.+2      	; 0x1dac <main+0xac>
+    1daa:	5f c0       	rjmp	.+190    	; 0x1e6a <main+0x16a>
       // PROGRAM PAGE - we support flash programming only, not EEPROM
       uint8_t *bufPtr;
       uint16_t addrPtr;
 
       getch();			/* getlen() */
-    1db0:	ab d0       	rcall	.+342    	; 0x1f08 <getch>
+    1dac:	ab d0       	rcall	.+342    	; 0x1f04 <getch>
       length = getch();
-    1db2:	aa d0       	rcall	.+340    	; 0x1f08 <getch>
-    1db4:	18 2f       	mov	r17, r24
+    1dae:	aa d0       	rcall	.+340    	; 0x1f04 <getch>
+    1db0:	18 2f       	mov	r17, r24
       getch();
-    1db6:	a8 d0       	rcall	.+336    	; 0x1f08 <getch>
-    1db8:	c0 e0       	ldi	r28, 0x00	; 0
-    1dba:	d1 e0       	ldi	r29, 0x01	; 1
+    1db2:	a8 d0       	rcall	.+336    	; 0x1f04 <getch>
+    1db4:	c0 e0       	ldi	r28, 0x00	; 0
+    1db6:	d1 e0       	ldi	r29, 0x01	; 1
       // If we are in RWW section, immediately start page erase
       if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
 
       // While that is going on, read in page contents
       bufPtr = buff;
       do *bufPtr++ = getch();
-    1dbc:	a5 d0       	rcall	.+330    	; 0x1f08 <getch>
-    1dbe:	89 93       	st	Y+, r24
+    1db8:	a5 d0       	rcall	.+330    	; 0x1f04 <getch>
+    1dba:	89 93       	st	Y+, r24
       while (--length);
-    1dc0:	1c 17       	cp	r17, r28
-    1dc2:	e1 f7       	brne	.-8      	; 0x1dbc <main+0xbc>
+    1dbc:	1c 17       	cp	r17, r28
+    1dbe:	e1 f7       	brne	.-8      	; 0x1db8 <main+0xb8>
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    1dc4:	f7 01       	movw	r30, r14
-    1dc6:	97 be       	out	0x37, r9	; 55
-    1dc8:	e8 95       	spm
+    1dc0:	f7 01       	movw	r30, r14
+    1dc2:	97 be       	out	0x37, r9	; 55
+    1dc4:	e8 95       	spm
 
       // Read command terminator, start reply
       verifySpace();
-    1dca:	b5 d0       	rcall	.+362    	; 0x1f36 <verifySpace>
+    1dc6:	b5 d0       	rcall	.+362    	; 0x1f32 <verifySpace>
 
       // If only a partial page is to be programmed, the erase might not be complete.
       // So check that here
       boot_spm_busy_wait();
-    1dcc:	07 b6       	in	r0, 0x37	; 55
-    1dce:	00 fc       	sbrc	r0, 0
-    1dd0:	fd cf       	rjmp	.-6      	; 0x1dcc <main+0xcc>
+    1dc8:	07 b6       	in	r0, 0x37	; 55
+    1dca:	00 fc       	sbrc	r0, 0
+    1dcc:	fd cf       	rjmp	.-6      	; 0x1dc8 <main+0xc8>
 
 #ifdef VIRTUAL_BOOT_PARTITION
       if ((uint16_t)(void*)address == 0) {
-    1dd2:	e1 14       	cp	r14, r1
-    1dd4:	f1 04       	cpc	r15, r1
-    1dd6:	11 f0       	breq	.+4      	; 0x1ddc <main+0xdc>
-    1dd8:	a7 01       	movw	r20, r14
-    1dda:	2a c0       	rjmp	.+84     	; 0x1e30 <main+0x130>
+    1dce:	e1 14       	cp	r14, r1
+    1dd0:	f1 04       	cpc	r15, r1
+    1dd2:	11 f0       	breq	.+4      	; 0x1dd8 <main+0xd8>
+    1dd4:	a7 01       	movw	r20, r14
+    1dd6:	2a c0       	rjmp	.+84     	; 0x1e2c <main+0x12c>
         // This is the reset vector page. We need to live-patch the code so the
         // bootloader runs.
         //
         // Move RESET vector to WDT vector
         uint16_t vect = buff[0] | (buff[1]<<8);
-    1ddc:	80 91 00 01 	lds	r24, 0x0100
-    1de0:	20 91 01 01 	lds	r18, 0x0101
-    1de4:	30 e0       	ldi	r19, 0x00	; 0
-    1de6:	32 2f       	mov	r19, r18
-    1de8:	22 27       	eor	r18, r18
-    1dea:	90 e0       	ldi	r25, 0x00	; 0
-    1dec:	28 2b       	or	r18, r24
-    1dee:	39 2b       	or	r19, r25
+    1dd8:	80 91 00 01 	lds	r24, 0x0100
+    1ddc:	20 91 01 01 	lds	r18, 0x0101
+    1de0:	30 e0       	ldi	r19, 0x00	; 0
+    1de2:	32 2f       	mov	r19, r18
+    1de4:	22 27       	eor	r18, r18
+    1de6:	90 e0       	ldi	r25, 0x00	; 0
+    1de8:	28 2b       	or	r18, r24
+    1dea:	39 2b       	or	r19, r25
         rstVect = vect;
-    1df0:	30 93 85 01 	sts	0x0185, r19
-    1df4:	20 93 84 01 	sts	0x0184, r18
+    1dec:	30 93 85 01 	sts	0x0185, r19
+    1df0:	20 93 84 01 	sts	0x0184, r18
         wdtVect = buff[8] | (buff[9]<<8);
-    1df8:	40 91 08 01 	lds	r20, 0x0108
-    1dfc:	80 91 09 01 	lds	r24, 0x0109
-    1e00:	90 e0       	ldi	r25, 0x00	; 0
-    1e02:	98 2f       	mov	r25, r24
-    1e04:	88 27       	eor	r24, r24
-    1e06:	50 e0       	ldi	r21, 0x00	; 0
-    1e08:	84 2b       	or	r24, r20
-    1e0a:	95 2b       	or	r25, r21
-    1e0c:	90 93 87 01 	sts	0x0187, r25
-    1e10:	80 93 86 01 	sts	0x0186, r24
+    1df4:	40 91 08 01 	lds	r20, 0x0108
+    1df8:	80 91 09 01 	lds	r24, 0x0109
+    1dfc:	90 e0       	ldi	r25, 0x00	; 0
+    1dfe:	98 2f       	mov	r25, r24
+    1e00:	88 27       	eor	r24, r24
+    1e02:	50 e0       	ldi	r21, 0x00	; 0
+    1e04:	84 2b       	or	r24, r20
+    1e06:	95 2b       	or	r25, r21
+    1e08:	90 93 87 01 	sts	0x0187, r25
+    1e0c:	80 93 86 01 	sts	0x0186, r24
         vect -= 4; // Instruction is a relative jump (rjmp), so recalculate.
-    1e14:	24 50       	subi	r18, 0x04	; 4
-    1e16:	30 40       	sbci	r19, 0x00	; 0
+    1e10:	24 50       	subi	r18, 0x04	; 4
+    1e12:	30 40       	sbci	r19, 0x00	; 0
         buff[8] = vect & 0xff;
-    1e18:	20 93 08 01 	sts	0x0108, r18
+    1e14:	20 93 08 01 	sts	0x0108, r18
         buff[9] = vect >> 8;
-    1e1c:	23 2f       	mov	r18, r19
-    1e1e:	33 27       	eor	r19, r19
-    1e20:	20 93 09 01 	sts	0x0109, r18
+    1e18:	23 2f       	mov	r18, r19
+    1e1a:	33 27       	eor	r19, r19
+    1e1c:	20 93 09 01 	sts	0x0109, r18
 
         // Add jump to bootloader at RESET vector
         buff[0] = 0x7f;
-    1e24:	d0 92 00 01 	sts	0x0100, r13
+    1e20:	d0 92 00 01 	sts	0x0100, r13
         buff[1] = 0xce; // rjmp 0x1d00 instruction
-    1e28:	c0 92 01 01 	sts	0x0101, r12
-    1e2c:	40 e0       	ldi	r20, 0x00	; 0
-    1e2e:	50 e0       	ldi	r21, 0x00	; 0
-    1e30:	a0 e0       	ldi	r26, 0x00	; 0
-    1e32:	b1 e0       	ldi	r27, 0x01	; 1
+    1e24:	c0 92 01 01 	sts	0x0101, r12
+    1e28:	40 e0       	ldi	r20, 0x00	; 0
+    1e2a:	50 e0       	ldi	r21, 0x00	; 0
+    1e2c:	a0 e0       	ldi	r26, 0x00	; 0
+    1e2e:	b1 e0       	ldi	r27, 0x01	; 1
       bufPtr = buff;
       addrPtr = (uint16_t)(void*)address;
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
-    1e34:	2c 91       	ld	r18, X
-    1e36:	30 e0       	ldi	r19, 0x00	; 0
+    1e30:	2c 91       	ld	r18, X
+    1e32:	30 e0       	ldi	r19, 0x00	; 0
         a |= (*bufPtr++) << 8;
-    1e38:	11 96       	adiw	r26, 0x01	; 1
-    1e3a:	8c 91       	ld	r24, X
-    1e3c:	11 97       	sbiw	r26, 0x01	; 1
-    1e3e:	90 e0       	ldi	r25, 0x00	; 0
-    1e40:	98 2f       	mov	r25, r24
-    1e42:	88 27       	eor	r24, r24
-    1e44:	82 2b       	or	r24, r18
-    1e46:	93 2b       	or	r25, r19
+    1e34:	11 96       	adiw	r26, 0x01	; 1
+    1e36:	8c 91       	ld	r24, X
+    1e38:	11 97       	sbiw	r26, 0x01	; 1
+    1e3a:	90 e0       	ldi	r25, 0x00	; 0
+    1e3c:	98 2f       	mov	r25, r24
+    1e3e:	88 27       	eor	r24, r24
+    1e40:	82 2b       	or	r24, r18
+    1e42:	93 2b       	or	r25, r19
 # define UART_SRL UBRR3L
 # define UART_UDR UDR3
 #endif
 
 /* main program starts here */
 int main(void) {
-    1e48:	12 96       	adiw	r26, 0x02	; 2
+    1e44:	12 96       	adiw	r26, 0x02	; 2
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
         a |= (*bufPtr++) << 8;
         __boot_page_fill_short((uint16_t)(void*)addrPtr,a);
-    1e4a:	fa 01       	movw	r30, r20
-    1e4c:	0c 01       	movw	r0, r24
-    1e4e:	b7 be       	out	0x37, r11	; 55
-    1e50:	e8 95       	spm
-    1e52:	11 24       	eor	r1, r1
+    1e46:	fa 01       	movw	r30, r20
+    1e48:	0c 01       	movw	r0, r24
+    1e4a:	b7 be       	out	0x37, r11	; 55
+    1e4c:	e8 95       	spm
+    1e4e:	11 24       	eor	r1, r1
         addrPtr += 2;
-    1e54:	4e 5f       	subi	r20, 0xFE	; 254
-    1e56:	5f 4f       	sbci	r21, 0xFF	; 255
+    1e50:	4e 5f       	subi	r20, 0xFE	; 254
+    1e52:	5f 4f       	sbci	r21, 0xFF	; 255
       } while (--ch);
-    1e58:	f1 e0       	ldi	r31, 0x01	; 1
-    1e5a:	a0 34       	cpi	r26, 0x40	; 64
-    1e5c:	bf 07       	cpc	r27, r31
-    1e5e:	51 f7       	brne	.-44     	; 0x1e34 <main+0x134>
+    1e54:	f1 e0       	ldi	r31, 0x01	; 1
+    1e56:	a0 34       	cpi	r26, 0x40	; 64
+    1e58:	bf 07       	cpc	r27, r31
+    1e5a:	51 f7       	brne	.-44     	; 0x1e30 <main+0x130>
 
       // Write from programming buffer
       __boot_page_write_short((uint16_t)(void*)address);
-    1e60:	f7 01       	movw	r30, r14
-    1e62:	a7 be       	out	0x37, r10	; 55
-    1e64:	e8 95       	spm
+    1e5c:	f7 01       	movw	r30, r14
+    1e5e:	a7 be       	out	0x37, r10	; 55
+    1e60:	e8 95       	spm
       boot_spm_busy_wait();
-    1e66:	07 b6       	in	r0, 0x37	; 55
-    1e68:	00 fc       	sbrc	r0, 0
-    1e6a:	fd cf       	rjmp	.-6      	; 0x1e66 <main+0x166>
-    1e6c:	3b c0       	rjmp	.+118    	; 0x1ee4 <main+0x1e4>
+    1e62:	07 b6       	in	r0, 0x37	; 55
+    1e64:	00 fc       	sbrc	r0, 0
+    1e66:	fd cf       	rjmp	.-6      	; 0x1e62 <main+0x162>
+    1e68:	3b c0       	rjmp	.+118    	; 0x1ee0 <main+0x1e0>
       boot_rww_enable();
 #endif
 
     }
     /* Read memory block mode, length is big endian.  */
     else if(ch == STK_READ_PAGE) {
-    1e6e:	84 37       	cpi	r24, 0x74	; 116
-    1e70:	59 f5       	brne	.+86     	; 0x1ec8 <main+0x1c8>
+    1e6a:	84 37       	cpi	r24, 0x74	; 116
+    1e6c:	59 f5       	brne	.+86     	; 0x1ec4 <main+0x1c4>
       // READ PAGE - we only read flash
       getch();			/* getlen() */
-    1e72:	4a d0       	rcall	.+148    	; 0x1f08 <getch>
+    1e6e:	4a d0       	rcall	.+148    	; 0x1f04 <getch>
       length = getch();
-    1e74:	49 d0       	rcall	.+146    	; 0x1f08 <getch>
-    1e76:	18 2f       	mov	r17, r24
+    1e70:	49 d0       	rcall	.+146    	; 0x1f04 <getch>
+    1e72:	18 2f       	mov	r17, r24
       getch();
-    1e78:	47 d0       	rcall	.+142    	; 0x1f08 <getch>
+    1e74:	47 d0       	rcall	.+142    	; 0x1f04 <getch>
 
       verifySpace();
-    1e7a:	5d d0       	rcall	.+186    	; 0x1f36 <verifySpace>
-    1e7c:	e7 01       	movw	r28, r14
-    1e7e:	01 2f       	mov	r16, r17
+    1e76:	5d d0       	rcall	.+186    	; 0x1f32 <verifySpace>
+    1e78:	e7 01       	movw	r28, r14
+    1e7a:	01 2f       	mov	r16, r17
       do {
 #ifdef VIRTUAL_BOOT_PARTITION
         // Undo vector patch in bottom page so verify passes
         if (address == 0)       ch=rstVect & 0xff;
-    1e80:	20 97       	sbiw	r28, 0x00	; 0
-    1e82:	19 f4       	brne	.+6      	; 0x1e8a <main+0x18a>
-    1e84:	80 91 84 01 	lds	r24, 0x0184
-    1e88:	14 c0       	rjmp	.+40     	; 0x1eb2 <main+0x1b2>
+    1e7c:	20 97       	sbiw	r28, 0x00	; 0
+    1e7e:	19 f4       	brne	.+6      	; 0x1e86 <main+0x186>
+    1e80:	80 91 84 01 	lds	r24, 0x0184
+    1e84:	14 c0       	rjmp	.+40     	; 0x1eae <main+0x1ae>
         else if (address == 1)  ch=rstVect >> 8;
-    1e8a:	c1 30       	cpi	r28, 0x01	; 1
-    1e8c:	d1 05       	cpc	r29, r1
-    1e8e:	19 f4       	brne	.+6      	; 0x1e96 <main+0x196>
-    1e90:	80 91 85 01 	lds	r24, 0x0185
-    1e94:	0e c0       	rjmp	.+28     	; 0x1eb2 <main+0x1b2>
+    1e86:	c1 30       	cpi	r28, 0x01	; 1
+    1e88:	d1 05       	cpc	r29, r1
+    1e8a:	19 f4       	brne	.+6      	; 0x1e92 <main+0x192>
+    1e8c:	80 91 85 01 	lds	r24, 0x0185
+    1e90:	0e c0       	rjmp	.+28     	; 0x1eae <main+0x1ae>
         else if (address == 8)  ch=wdtVect & 0xff;
-    1e96:	c8 30       	cpi	r28, 0x08	; 8
-    1e98:	d1 05       	cpc	r29, r1
-    1e9a:	19 f4       	brne	.+6      	; 0x1ea2 <main+0x1a2>
-    1e9c:	80 91 86 01 	lds	r24, 0x0186
-    1ea0:	08 c0       	rjmp	.+16     	; 0x1eb2 <main+0x1b2>
+    1e92:	c8 30       	cpi	r28, 0x08	; 8
+    1e94:	d1 05       	cpc	r29, r1
+    1e96:	19 f4       	brne	.+6      	; 0x1e9e <main+0x19e>
+    1e98:	80 91 86 01 	lds	r24, 0x0186
+    1e9c:	08 c0       	rjmp	.+16     	; 0x1eae <main+0x1ae>
         else if (address == 9) ch=wdtVect >> 8;
-    1ea2:	c9 30       	cpi	r28, 0x09	; 9
-    1ea4:	d1 05       	cpc	r29, r1
-    1ea6:	19 f4       	brne	.+6      	; 0x1eae <main+0x1ae>
-    1ea8:	80 91 87 01 	lds	r24, 0x0187
-    1eac:	02 c0       	rjmp	.+4      	; 0x1eb2 <main+0x1b2>
+    1e9e:	c9 30       	cpi	r28, 0x09	; 9
+    1ea0:	d1 05       	cpc	r29, r1
+    1ea2:	19 f4       	brne	.+6      	; 0x1eaa <main+0x1aa>
+    1ea4:	80 91 87 01 	lds	r24, 0x0187
+    1ea8:	02 c0       	rjmp	.+4      	; 0x1eae <main+0x1ae>
         else ch = pgm_read_byte_near(address);
-    1eae:	fe 01       	movw	r30, r28
-    1eb0:	84 91       	lpm	r24, Z+
+    1eaa:	fe 01       	movw	r30, r28
+    1eac:	84 91       	lpm	r24, Z+
         address++;
-    1eb2:	21 96       	adiw	r28, 0x01	; 1
+    1eae:	21 96       	adiw	r28, 0x01	; 1
         __asm__ ("elpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #else
         // read a Flash byte and increment the address
         __asm__ ("lpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #endif
         putch(ch);
-    1eb4:	1a d0       	rcall	.+52     	; 0x1eea <putch>
+    1eb0:	1a d0       	rcall	.+52     	; 0x1ee6 <putch>
       } while (--length);
-    1eb6:	01 50       	subi	r16, 0x01	; 1
-    1eb8:	19 f7       	brne	.-58     	; 0x1e80 <main+0x180>
+    1eb2:	01 50       	subi	r16, 0x01	; 1
+    1eb4:	19 f7       	brne	.-58     	; 0x1e7c <main+0x17c>
 # define UART_SRL UBRR3L
 # define UART_UDR UDR3
 #endif
 
 /* main program starts here */
 int main(void) {
-    1eba:	08 94       	sec
-    1ebc:	e1 1c       	adc	r14, r1
-    1ebe:	f1 1c       	adc	r15, r1
-    1ec0:	11 50       	subi	r17, 0x01	; 1
-    1ec2:	e1 0e       	add	r14, r17
-    1ec4:	f1 1c       	adc	r15, r1
-    1ec6:	0e c0       	rjmp	.+28     	; 0x1ee4 <main+0x1e4>
+    1eb6:	08 94       	sec
+    1eb8:	e1 1c       	adc	r14, r1
+    1eba:	f1 1c       	adc	r15, r1
+    1ebc:	11 50       	subi	r17, 0x01	; 1
+    1ebe:	e1 0e       	add	r14, r17
+    1ec0:	f1 1c       	adc	r15, r1
+    1ec2:	0e c0       	rjmp	.+28     	; 0x1ee0 <main+0x1e0>
         putch(ch);
       } while (--length);
     }
 
     /* Get device signature bytes  */
     else if(ch == STK_READ_SIGN) {
-    1ec8:	85 37       	cpi	r24, 0x75	; 117
-    1eca:	39 f4       	brne	.+14     	; 0x1eda <main+0x1da>
+    1ec4:	85 37       	cpi	r24, 0x75	; 117
+    1ec6:	39 f4       	brne	.+14     	; 0x1ed6 <main+0x1d6>
       // READ SIGN - return what Avrdude wants to hear
       verifySpace();
-    1ecc:	34 d0       	rcall	.+104    	; 0x1f36 <verifySpace>
+    1ec8:	34 d0       	rcall	.+104    	; 0x1f32 <verifySpace>
       putch(SIGNATURE_0);
-    1ece:	8e e1       	ldi	r24, 0x1E	; 30
-    1ed0:	0c d0       	rcall	.+24     	; 0x1eea <putch>
+    1eca:	8e e1       	ldi	r24, 0x1E	; 30
+    1ecc:	0c d0       	rcall	.+24     	; 0x1ee6 <putch>
       putch(SIGNATURE_1);
-    1ed2:	83 e9       	ldi	r24, 0x93	; 147
-    1ed4:	0a d0       	rcall	.+20     	; 0x1eea <putch>
+    1ece:	83 e9       	ldi	r24, 0x93	; 147
+    1ed0:	0a d0       	rcall	.+20     	; 0x1ee6 <putch>
       putch(SIGNATURE_2);
-    1ed6:	8c e0       	ldi	r24, 0x0C	; 12
-    1ed8:	46 cf       	rjmp	.-372    	; 0x1d66 <main+0x66>
+    1ed2:	8c e0       	ldi	r24, 0x0C	; 12
+    1ed4:	46 cf       	rjmp	.-372    	; 0x1d62 <main+0x62>
     }
     else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */
-    1eda:	81 35       	cpi	r24, 0x51	; 81
-    1edc:	11 f4       	brne	.+4      	; 0x1ee2 <main+0x1e2>
+    1ed6:	81 35       	cpi	r24, 0x51	; 81
+    1ed8:	11 f4       	brne	.+4      	; 0x1ede <main+0x1de>
       // Adaboot no-wait mod
       watchdogConfig(WATCHDOG_16MS);
-    1ede:	88 e0       	ldi	r24, 0x08	; 8
-    1ee0:	26 d0       	rcall	.+76     	; 0x1f2e <watchdogConfig>
+    1eda:	88 e0       	ldi	r24, 0x08	; 8
+    1edc:	26 d0       	rcall	.+76     	; 0x1f2a <watchdogConfig>
       verifySpace();
     }
     else {
       // This covers the response to commands like STK_ENTER_PROGMODE
       verifySpace();
-    1ee2:	29 d0       	rcall	.+82     	; 0x1f36 <verifySpace>
+    1ede:	29 d0       	rcall	.+82     	; 0x1f32 <verifySpace>
     }
     putch(STK_OK);
-    1ee4:	80 e1       	ldi	r24, 0x10	; 16
-    1ee6:	01 d0       	rcall	.+2      	; 0x1eea <putch>
-    1ee8:	2f cf       	rjmp	.-418    	; 0x1d48 <main+0x48>
+    1ee0:	80 e1       	ldi	r24, 0x10	; 16
+    1ee2:	01 d0       	rcall	.+2      	; 0x1ee6 <putch>
+    1ee4:	31 cf       	rjmp	.-414    	; 0x1d48 <main+0x48>
 
-00001eea <putch>:
+00001ee6 <putch>:
 void putch(char ch) {
 #ifndef SOFT_UART
   while (!(UART_SRA & _BV(UDRE0)));
   UART_UDR = ch;
 #else
   __asm__ __volatile__ (
-    1eea:	2a e0       	ldi	r18, 0x0A	; 10
-    1eec:	30 e0       	ldi	r19, 0x00	; 0
-    1eee:	80 95       	com	r24
-    1ef0:	08 94       	sec
-    1ef2:	10 f4       	brcc	.+4      	; 0x1ef8 <putch+0xe>
-    1ef4:	da 98       	cbi	0x1b, 2	; 27
-    1ef6:	02 c0       	rjmp	.+4      	; 0x1efc <putch+0x12>
-    1ef8:	da 9a       	sbi	0x1b, 2	; 27
-    1efa:	00 00       	nop
-    1efc:	14 d0       	rcall	.+40     	; 0x1f26 <uartDelay>
-    1efe:	13 d0       	rcall	.+38     	; 0x1f26 <uartDelay>
-    1f00:	86 95       	lsr	r24
-    1f02:	2a 95       	dec	r18
-    1f04:	b1 f7       	brne	.-20     	; 0x1ef2 <putch+0x8>
+    1ee6:	2a e0       	ldi	r18, 0x0A	; 10
+    1ee8:	30 e0       	ldi	r19, 0x00	; 0
+    1eea:	80 95       	com	r24
+    1eec:	08 94       	sec
+    1eee:	10 f4       	brcc	.+4      	; 0x1ef4 <putch+0xe>
+    1ef0:	da 98       	cbi	0x1b, 2	; 27
+    1ef2:	02 c0       	rjmp	.+4      	; 0x1ef8 <putch+0x12>
+    1ef4:	da 9a       	sbi	0x1b, 2	; 27
+    1ef6:	00 00       	nop
+    1ef8:	14 d0       	rcall	.+40     	; 0x1f22 <uartDelay>
+    1efa:	13 d0       	rcall	.+38     	; 0x1f22 <uartDelay>
+    1efc:	86 95       	lsr	r24
+    1efe:	2a 95       	dec	r18
+    1f00:	b1 f7       	brne	.-20     	; 0x1eee <putch+0x8>
       [uartBit] "I" (UART_TX_BIT)
     :
       "r25"
   );
 #endif
 }
-    1f06:	08 95       	ret
+    1f02:	08 95       	ret
 
-00001f08 <getch>:
+00001f04 <getch>:
   LED_PIN |= _BV(LED);
 #endif
 #endif
 
   return ch;
 }
-    1f08:	29 e0       	ldi	r18, 0x09	; 9
-    1f0a:	30 e0       	ldi	r19, 0x00	; 0
-    1f0c:	cb 99       	sbic	0x19, 3	; 25
-    1f0e:	fe cf       	rjmp	.-4      	; 0x1f0c <getch+0x4>
-    1f10:	0a d0       	rcall	.+20     	; 0x1f26 <uartDelay>
-    1f12:	09 d0       	rcall	.+18     	; 0x1f26 <uartDelay>
-    1f14:	08 d0       	rcall	.+16     	; 0x1f26 <uartDelay>
-    1f16:	88 94       	clc
-    1f18:	cb 99       	sbic	0x19, 3	; 25
-    1f1a:	08 94       	sec
-    1f1c:	2a 95       	dec	r18
-    1f1e:	11 f0       	breq	.+4      	; 0x1f24 <getch+0x1c>
-    1f20:	87 95       	ror	r24
-    1f22:	f7 cf       	rjmp	.-18     	; 0x1f12 <getch+0xa>
-    1f24:	08 95       	ret
-
-00001f26 <uartDelay>:
+    1f04:	29 e0       	ldi	r18, 0x09	; 9
+    1f06:	30 e0       	ldi	r19, 0x00	; 0
+    1f08:	cb 99       	sbic	0x19, 3	; 25
+    1f0a:	fe cf       	rjmp	.-4      	; 0x1f08 <getch+0x4>
+    1f0c:	0a d0       	rcall	.+20     	; 0x1f22 <uartDelay>
+    1f0e:	09 d0       	rcall	.+18     	; 0x1f22 <uartDelay>
+    1f10:	08 d0       	rcall	.+16     	; 0x1f22 <uartDelay>
+    1f12:	88 94       	clc
+    1f14:	cb 99       	sbic	0x19, 3	; 25
+    1f16:	08 94       	sec
+    1f18:	2a 95       	dec	r18
+    1f1a:	11 f0       	breq	.+4      	; 0x1f20 <getch+0x1c>
+    1f1c:	87 95       	ror	r24
+    1f1e:	f7 cf       	rjmp	.-18     	; 0x1f0e <getch+0xa>
+    1f20:	08 95       	ret
+
+00001f22 <uartDelay>:
 #if UART_B_VALUE > 255
 #error Baud rate too slow for soft UART
 #endif
 
 void uartDelay() {
   __asm__ __volatile__ (
-    1f26:	9e e0       	ldi	r25, 0x0E	; 14
-    1f28:	9a 95       	dec	r25
-    1f2a:	f1 f7       	brne	.-4      	; 0x1f28 <uartDelay+0x2>
-    1f2c:	08 95       	ret
+    1f22:	9e e0       	ldi	r25, 0x0E	; 14
+    1f24:	9a 95       	dec	r25
+    1f26:	f1 f7       	brne	.-4      	; 0x1f24 <uartDelay+0x2>
+    1f28:	08 95       	ret
 
-00001f2e <watchdogConfig>:
+00001f2a <watchdogConfig>:
     "wdr\n"
   );
 }
 
 void watchdogConfig(uint8_t x) {
   WDTCSR = _BV(WDCE) | _BV(WDE);
-    1f2e:	98 e1       	ldi	r25, 0x18	; 24
-    1f30:	91 bd       	out	0x21, r25	; 33
+    1f2a:	98 e1       	ldi	r25, 0x18	; 24
+    1f2c:	91 bd       	out	0x21, r25	; 33
   WDTCSR = x;
-    1f32:	81 bd       	out	0x21, r24	; 33
+    1f2e:	81 bd       	out	0x21, r24	; 33
 }
-    1f34:	08 95       	ret
+    1f30:	08 95       	ret
 
-00001f36 <verifySpace>:
+00001f32 <verifySpace>:
   do getch(); while (--count);
   verifySpace();
 }
 
 void verifySpace() {
   if (getch() != CRC_EOP) {
-    1f36:	e8 df       	rcall	.-48     	; 0x1f08 <getch>
-    1f38:	80 32       	cpi	r24, 0x20	; 32
-    1f3a:	19 f0       	breq	.+6      	; 0x1f42 <verifySpace+0xc>
+    1f32:	e8 df       	rcall	.-48     	; 0x1f04 <getch>
+    1f34:	80 32       	cpi	r24, 0x20	; 32
+    1f36:	19 f0       	breq	.+6      	; 0x1f3e <verifySpace+0xc>
     watchdogConfig(WATCHDOG_16MS);    // shorten WD timeout
-    1f3c:	88 e0       	ldi	r24, 0x08	; 8
-    1f3e:	f7 df       	rcall	.-18     	; 0x1f2e <watchdogConfig>
-    1f40:	ff cf       	rjmp	.-2      	; 0x1f40 <verifySpace+0xa>
+    1f38:	88 e0       	ldi	r24, 0x08	; 8
+    1f3a:	f7 df       	rcall	.-18     	; 0x1f2a <watchdogConfig>
+    1f3c:	ff cf       	rjmp	.-2      	; 0x1f3c <verifySpace+0xa>
     while (1)			      // and busy-loop so that WD causes
       ;				      //  a reset and app start.
   }
   putch(STK_INSYNC);
-    1f42:	84 e1       	ldi	r24, 0x14	; 20
+    1f3e:	84 e1       	ldi	r24, 0x14	; 20
 }
-    1f44:	d2 cf       	rjmp	.-92     	; 0x1eea <putch>
+    1f40:	d2 cf       	rjmp	.-92     	; 0x1ee6 <putch>
 
-00001f46 <getNch>:
+00001f42 <getNch>:
     ::[count] "M" (UART_B_VALUE)
   );
 }
 #endif
 
 void getNch(uint8_t count) {
-    1f46:	1f 93       	push	r17
-    1f48:	18 2f       	mov	r17, r24
+    1f42:	1f 93       	push	r17
+    1f44:	18 2f       	mov	r17, r24
   do getch(); while (--count);
-    1f4a:	de df       	rcall	.-68     	; 0x1f08 <getch>
-    1f4c:	11 50       	subi	r17, 0x01	; 1
-    1f4e:	e9 f7       	brne	.-6      	; 0x1f4a <getNch+0x4>
+    1f46:	de df       	rcall	.-68     	; 0x1f04 <getch>
+    1f48:	11 50       	subi	r17, 0x01	; 1
+    1f4a:	e9 f7       	brne	.-6      	; 0x1f46 <getNch+0x4>
   verifySpace();
-    1f50:	f2 df       	rcall	.-28     	; 0x1f36 <verifySpace>
+    1f4c:	f2 df       	rcall	.-28     	; 0x1f32 <verifySpace>
 }
-    1f52:	1f 91       	pop	r17
-    1f54:	08 95       	ret
+    1f4e:	1f 91       	pop	r17
+    1f50:	08 95       	ret
 
-00001f56 <appStart>:
+00001f52 <appStart>:
 
 void appStart(uint8_t rstFlags) {
   // 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" (rstFlags));
-    1f56:	28 2e       	mov	r2, r24
+    1f52:	28 2e       	mov	r2, r24
 
   watchdogConfig(WATCHDOG_OFF);
-    1f58:	80 e0       	ldi	r24, 0x00	; 0
-    1f5a:	e9 df       	rcall	.-46     	; 0x1f2e <watchdogConfig>
+    1f54:	80 e0       	ldi	r24, 0x00	; 0
+    1f56:	e9 df       	rcall	.-46     	; 0x1f2a <watchdogConfig>
   __asm__ __volatile__ (
-    1f5c:	e4 e0       	ldi	r30, 0x04	; 4
-    1f5e:	ff 27       	eor	r31, r31
-    1f60:	09 94       	ijmp
+    1f58:	e4 e0       	ldi	r30, 0x04	; 4
+    1f5a:	ff 27       	eor	r31, r31
+    1f5c:	09 94       	ijmp

+ 28 - 28
optiboot/bootloaders/optiboot/optiboot_pro_16MHz.hex

@@ -1,34 +1,34 @@
-:103E0000112484B714BE81FFE7D085E08093810040
+:103E0000112484B714BE81FFE6D085E08093810041
 :103E100082E08093C00088E18093C10086E08093B7
-:103E2000C20080E18093C4008EE0C0D0259A86E075
+:103E2000C20080E18093C4008EE0BFD0259A86E076
 :103E300020E33CEF91E0309385002093840096BB13
 :103E4000B09BFECF1D9AA8958150A9F7EE24FF24C0
 :103E5000AA24A394B5E0CB2EA1E1BA2EF3E0DF2E85
-:103E600099D0813469F496D0082FA6D0023809F48D
-:103E70007FC0013811F484E001C083E083D07FC0AB
-:103E8000823411F484E103C0853419F485E09CD0B8
-:103E900076C0853579F47ED0E82EFF247BD0082FBC
-:103EA00010E0102F00270E291F29000F111F84D0AA
-:103EB000780165C0863521F484E086D080E0DECFCD
-:103EC000843609F040C066D065D0082F63D080E00A
-:103ED000E81688E3F80618F4F701D7BEE895C0E0C5
-:103EE000D1E058D089930C17E1F7F0E0EF16F8E332
-:103EF000FF0618F0F701D7BEE8955ED007B600FCC4
-:103F0000FDCFA701A0E0B1E02C9130E011968C919B
-:103F1000119790E0982F8827822B932B1296FA0105
-:103F20000C01A7BEE89511244E5F5F4FF1E0A03869
-:103F3000BF0751F7F701C7BEE89507B600FCFDCFF4
-:103F4000B7BEE8951CC0843761F424D023D0082F75
-:103F500021D032D0F70185917F0114D00150D1F7E3
-:103F60000EC0853739F428D08EE10CD084E90AD010
-:103F700086E084CF813511F488E018D01DD080E12F
-:103F800001D06ECF982F8091C00085FFFCCF909319
-:103F9000C60008958091C00087FFFCCF8091C000CB
-:103FA00084FD01C0A8958091C6000895E0E6F0E088
-:103FB00098E1908380830895EDDF803219F088E0E6
-:103FC000F5DFFFCF84E1DECF1F93182FE3DF115021
-:103FD000E9F7F2DF1F910895282E80E0E7DFEE2752
-:043FE000FF2709941A
-:023FFE000604B7
+:103E600098D0813461F495D0082FA5D0023829F17B
+:103E7000013811F485E001C083E083D07FC0823433
+:103E800011F484E103C0853419F485E09CD076C038
+:103E9000853579F47ED0E82EFF247BD0082F10E002
+:103EA000102F00270E291F29000F111F84D0780121
+:103EB00065C0863521F484E086D080E0DECF84368C
+:103EC00009F040C066D065D0082F63D080E0E816C6
+:103ED00088E3F80618F4F701D7BEE895C0E0D1E012
+:103EE00058D089930C17E1F7F0E0EF16F8E3FF06DE
+:103EF00018F0F701D7BEE8955ED007B600FCFDCFFD
+:103F0000A701A0E0B1E02C9130E011968C911197BF
+:103F100090E0982F8827822B932B1296FA010C01A0
+:103F2000A7BEE89511244E5F5F4FF1E0A038BF07B0
+:103F300051F7F701C7BEE89507B600FCFDCFB7BE45
+:103F4000E8951CC0843761F424D023D0082F21D0F9
+:103F500032D0F70185917F0114D00150D1F70EC006
+:103F6000853739F428D08EE10CD084E90AD086E078
+:103F700084CF813511F488E018D01DD080E101D0C4
+:103F80006FCF982F8091C00085FFFCCF9093C60023
+:103F900008958091C00087FFFCCF8091C00084FD10
+:103FA00001C0A8958091C6000895E0E6F0E098E190
+:103FB000908380830895EDDF803219F088E0F5DF8B
+:103FC000FFCF84E1DECF1F93182FE3DF1150E9F715
+:103FD000F2DF1F910895282E80E0E7DFEE27FF270C
+:023FE000099442
+:023FFE000005BC
 :0400000300003E00BB
 :00000001FF

+ 214 - 212
optiboot/bootloaders/optiboot/optiboot_pro_16MHz.lst

@@ -1,29 +1,29 @@
 
-optiboot_pro_16MHz.elf:     file format elf32-avr
+optiboot_atmega168.elf:     file format elf32-avr
 
 Sections:
 Idx Name          Size      VMA       LMA       File off  Algn
-  0 .text         000001e4  00003e00  00003e00  00000054  2**1
+  0 .text         000001e2  00003e00  00003e00  00000054  2**1
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
-  1 .version      00000002  00003ffe  00003ffe  00000238  2**0
+  1 .version      00000002  00003ffe  00003ffe  00000236  2**0
                   CONTENTS, READONLY
-  2 .debug_aranges 00000028  00000000  00000000  0000023a  2**0
+  2 .debug_aranges 00000028  00000000  00000000  00000238  2**0
                   CONTENTS, READONLY, DEBUGGING
-  3 .debug_pubnames 0000005f  00000000  00000000  00000262  2**0
+  3 .debug_pubnames 0000005f  00000000  00000000  00000260  2**0
                   CONTENTS, READONLY, DEBUGGING
-  4 .debug_info   00000294  00000000  00000000  000002c1  2**0
+  4 .debug_info   00000294  00000000  00000000  000002bf  2**0
                   CONTENTS, READONLY, DEBUGGING
-  5 .debug_abbrev 0000016b  00000000  00000000  00000555  2**0
+  5 .debug_abbrev 0000016b  00000000  00000000  00000553  2**0
                   CONTENTS, READONLY, DEBUGGING
-  6 .debug_line   00000468  00000000  00000000  000006c0  2**0
+  6 .debug_line   00000421  00000000  00000000  000006be  2**0
                   CONTENTS, READONLY, DEBUGGING
-  7 .debug_frame  00000080  00000000  00000000  00000b28  2**2
+  7 .debug_frame  00000080  00000000  00000000  00000ae0  2**2
                   CONTENTS, READONLY, DEBUGGING
-  8 .debug_str    00000131  00000000  00000000  00000ba8  2**0
+  8 .debug_str    00000131  00000000  00000000  00000b60  2**0
                   CONTENTS, READONLY, DEBUGGING
-  9 .debug_loc    00000266  00000000  00000000  00000cd9  2**0
+  9 .debug_loc    00000266  00000000  00000000  00000c91  2**0
                   CONTENTS, READONLY, DEBUGGING
- 10 .debug_ranges 00000078  00000000  00000000  00000f3f  2**0
+ 10 .debug_ranges 00000078  00000000  00000000  00000ef7  2**0
                   CONTENTS, READONLY, DEBUGGING
 
 Disassembly of section .text:
@@ -36,7 +36,7 @@ Disassembly of section .text:
 /* main program starts here */
 int main(void) {
     3e00:	11 24       	eor	r1, r1
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__)
   SP=RAMEND;  // This is done by hardware reset
 #endif
 
@@ -47,7 +47,7 @@ int main(void) {
     3e04:	14 be       	out	0x34, r1	; 52
   if (!(ch & _BV(EXTRF))) appStart(ch);
     3e06:	81 ff       	sbrs	r24, 1
-    3e08:	e7 d0       	rcall	.+462    	; 0x3fd8 <appStart>
+    3e08:	e6 d0       	rcall	.+460    	; 0x3fd6 <appStart>
 
 #if LED_START_FLASHES > 0
   // Set up Timer 1 for timeout counter
@@ -77,8 +77,9 @@ int main(void) {
   // Set up watchdog to trigger after 500ms
   watchdogConfig(WATCHDOG_1S);
     3e28:	8e e0       	ldi	r24, 0x0E	; 14
-    3e2a:	c0 d0       	rcall	.+384    	; 0x3fac <watchdogConfig>
+    3e2a:	bf d0       	rcall	.+382    	; 0x3faa <watchdogConfig>
 
+#if (LED_START_FLASHES > 0) || defined(LED_DATA_FLASH)
   /* Set LED pin as output */
   LED_DDR |= _BV(LED);
     3e2c:	25 9a       	sbi	0x04, 5	; 4
@@ -106,7 +107,7 @@ void flash_led(uint8_t count) {
     while(!(TIFR1 & _BV(TOV1)));
     3e40:	b0 9b       	sbis	0x16, 0	; 22
     3e42:	fe cf       	rjmp	.-4      	; 0x3e40 <main+0x40>
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__)  || defined (__AVR_ATmega32__)
     LED_PORT ^= _BV(LED);
 #else
     LED_PIN |= _BV(LED);
@@ -150,11 +151,11 @@ void watchdogReset() {
       boot_rww_enable();
     3e58:	a1 e1       	ldi	r26, 0x11	; 17
     3e5a:	ba 2e       	mov	r11, r26
-      do *bufPtr++ = getch();
-      while (--length);
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
     3e5c:	f3 e0       	ldi	r31, 0x03	; 3
     3e5e:	df 2e       	mov	r13, r31
@@ -164,421 +165,422 @@ void watchdogReset() {
   for (;;) {
     /* get character from UART */
     ch = getch();
-    3e60:	99 d0       	rcall	.+306    	; 0x3f94 <getch>
+    3e60:	98 d0       	rcall	.+304    	; 0x3f92 <getch>
 
     if(ch == STK_GET_PARAMETER) {
     3e62:	81 34       	cpi	r24, 0x41	; 65
-    3e64:	69 f4       	brne	.+26     	; 0x3e80 <main+0x80>
+    3e64:	61 f4       	brne	.+24     	; 0x3e7e <main+0x7e>
       unsigned char which = getch();
-    3e66:	96 d0       	rcall	.+300    	; 0x3f94 <getch>
+    3e66:	95 d0       	rcall	.+298    	; 0x3f92 <getch>
     3e68:	08 2f       	mov	r16, r24
       verifySpace();
-    3e6a:	a6 d0       	rcall	.+332    	; 0x3fb8 <verifySpace>
+    3e6a:	a5 d0       	rcall	.+330    	; 0x3fb6 <verifySpace>
       if (which == 0x82) {
     3e6c:	02 38       	cpi	r16, 0x82	; 130
-    3e6e:	09 f4       	brne	.+2      	; 0x3e72 <main+0x72>
-    3e70:	7f c0       	rjmp	.+254    	; 0x3f70 <main+0x170>
+    3e6e:	29 f1       	breq	.+74     	; 0x3eba <main+0xba>
 	/*
 	 * Send optiboot version as "minor SW version"
 	 */
 	putch(OPTIBOOT_MINVER);
       } else if (which == 0x81) {
-    3e72:	01 38       	cpi	r16, 0x81	; 129
-    3e74:	11 f4       	brne	.+4      	; 0x3e7a <main+0x7a>
+    3e70:	01 38       	cpi	r16, 0x81	; 129
+    3e72:	11 f4       	brne	.+4      	; 0x3e78 <main+0x78>
 	  putch(OPTIBOOT_MAJVER);
-    3e76:	84 e0       	ldi	r24, 0x04	; 4
-    3e78:	01 c0       	rjmp	.+2      	; 0x3e7c <main+0x7c>
+    3e74:	85 e0       	ldi	r24, 0x05	; 5
+    3e76:	01 c0       	rjmp	.+2      	; 0x3e7a <main+0x7a>
       } else {
 	/*
 	 * GET PARAMETER returns a generic 0x03 reply for
          * other parameters - enough to keep Avrdude happy
 	 */
 	putch(0x03);
-    3e7a:	83 e0       	ldi	r24, 0x03	; 3
-    3e7c:	83 d0       	rcall	.+262    	; 0x3f84 <putch>
-    3e7e:	7f c0       	rjmp	.+254    	; 0x3f7e <main+0x17e>
+    3e78:	83 e0       	ldi	r24, 0x03	; 3
+    3e7a:	83 d0       	rcall	.+262    	; 0x3f82 <putch>
+    3e7c:	7f c0       	rjmp	.+254    	; 0x3f7c <main+0x17c>
       }
     }
     else if(ch == STK_SET_DEVICE) {
-    3e80:	82 34       	cpi	r24, 0x42	; 66
-    3e82:	11 f4       	brne	.+4      	; 0x3e88 <main+0x88>
+    3e7e:	82 34       	cpi	r24, 0x42	; 66
+    3e80:	11 f4       	brne	.+4      	; 0x3e86 <main+0x86>
       // SET DEVICE is ignored
       getNch(20);
-    3e84:	84 e1       	ldi	r24, 0x14	; 20
-    3e86:	03 c0       	rjmp	.+6      	; 0x3e8e <main+0x8e>
+    3e82:	84 e1       	ldi	r24, 0x14	; 20
+    3e84:	03 c0       	rjmp	.+6      	; 0x3e8c <main+0x8c>
     }
     else if(ch == STK_SET_DEVICE_EXT) {
-    3e88:	85 34       	cpi	r24, 0x45	; 69
-    3e8a:	19 f4       	brne	.+6      	; 0x3e92 <main+0x92>
+    3e86:	85 34       	cpi	r24, 0x45	; 69
+    3e88:	19 f4       	brne	.+6      	; 0x3e90 <main+0x90>
       // SET DEVICE EXT is ignored
       getNch(5);
-    3e8c:	85 e0       	ldi	r24, 0x05	; 5
-    3e8e:	9c d0       	rcall	.+312    	; 0x3fc8 <getNch>
-    3e90:	76 c0       	rjmp	.+236    	; 0x3f7e <main+0x17e>
+    3e8a:	85 e0       	ldi	r24, 0x05	; 5
+    3e8c:	9c d0       	rcall	.+312    	; 0x3fc6 <getNch>
+    3e8e:	76 c0       	rjmp	.+236    	; 0x3f7c <main+0x17c>
     }
     else if(ch == STK_LOAD_ADDRESS) {
-    3e92:	85 35       	cpi	r24, 0x55	; 85
-    3e94:	79 f4       	brne	.+30     	; 0x3eb4 <main+0xb4>
+    3e90:	85 35       	cpi	r24, 0x55	; 85
+    3e92:	79 f4       	brne	.+30     	; 0x3eb2 <main+0xb2>
       // LOAD ADDRESS
       uint16_t newAddress;
       newAddress = getch();
-    3e96:	7e d0       	rcall	.+252    	; 0x3f94 <getch>
+    3e94:	7e d0       	rcall	.+252    	; 0x3f92 <getch>
       newAddress = (newAddress & 0xff) | (getch() << 8);
-    3e98:	e8 2e       	mov	r14, r24
-    3e9a:	ff 24       	eor	r15, r15
-    3e9c:	7b d0       	rcall	.+246    	; 0x3f94 <getch>
-    3e9e:	08 2f       	mov	r16, r24
-    3ea0:	10 e0       	ldi	r17, 0x00	; 0
-    3ea2:	10 2f       	mov	r17, r16
-    3ea4:	00 27       	eor	r16, r16
-    3ea6:	0e 29       	or	r16, r14
-    3ea8:	1f 29       	or	r17, r15
+    3e96:	e8 2e       	mov	r14, r24
+    3e98:	ff 24       	eor	r15, r15
+    3e9a:	7b d0       	rcall	.+246    	; 0x3f92 <getch>
+    3e9c:	08 2f       	mov	r16, r24
+    3e9e:	10 e0       	ldi	r17, 0x00	; 0
+    3ea0:	10 2f       	mov	r17, r16
+    3ea2:	00 27       	eor	r16, r16
+    3ea4:	0e 29       	or	r16, r14
+    3ea6:	1f 29       	or	r17, r15
 #ifdef RAMPZ
       // Transfer top bit to RAMPZ
       RAMPZ = (newAddress & 0x8000) ? 1 : 0;
 #endif
       newAddress += newAddress; // Convert from word address to byte address
-    3eaa:	00 0f       	add	r16, r16
-    3eac:	11 1f       	adc	r17, r17
+    3ea8:	00 0f       	add	r16, r16
+    3eaa:	11 1f       	adc	r17, r17
       address = newAddress;
       verifySpace();
-    3eae:	84 d0       	rcall	.+264    	; 0x3fb8 <verifySpace>
-    3eb0:	78 01       	movw	r14, r16
-    3eb2:	65 c0       	rjmp	.+202    	; 0x3f7e <main+0x17e>
+    3eac:	84 d0       	rcall	.+264    	; 0x3fb6 <verifySpace>
+    3eae:	78 01       	movw	r14, r16
+    3eb0:	65 c0       	rjmp	.+202    	; 0x3f7c <main+0x17c>
     }
     else if(ch == STK_UNIVERSAL) {
-    3eb4:	86 35       	cpi	r24, 0x56	; 86
-    3eb6:	21 f4       	brne	.+8      	; 0x3ec0 <main+0xc0>
+    3eb2:	86 35       	cpi	r24, 0x56	; 86
+    3eb4:	21 f4       	brne	.+8      	; 0x3ebe <main+0xbe>
       // UNIVERSAL command is ignored
       getNch(4);
-    3eb8:	84 e0       	ldi	r24, 0x04	; 4
-    3eba:	86 d0       	rcall	.+268    	; 0x3fc8 <getNch>
+    3eb6:	84 e0       	ldi	r24, 0x04	; 4
+    3eb8:	86 d0       	rcall	.+268    	; 0x3fc6 <getNch>
       putch(0x00);
-    3ebc:	80 e0       	ldi	r24, 0x00	; 0
-    3ebe:	de cf       	rjmp	.-68     	; 0x3e7c <main+0x7c>
+    3eba:	80 e0       	ldi	r24, 0x00	; 0
+    3ebc:	de cf       	rjmp	.-68     	; 0x3e7a <main+0x7a>
     }
     /* Write memory, length is big endian and is in bytes */
     else if(ch == STK_PROG_PAGE) {
-    3ec0:	84 36       	cpi	r24, 0x64	; 100
-    3ec2:	09 f0       	breq	.+2      	; 0x3ec6 <main+0xc6>
-    3ec4:	40 c0       	rjmp	.+128    	; 0x3f46 <main+0x146>
+    3ebe:	84 36       	cpi	r24, 0x64	; 100
+    3ec0:	09 f0       	breq	.+2      	; 0x3ec4 <main+0xc4>
+    3ec2:	40 c0       	rjmp	.+128    	; 0x3f44 <main+0x144>
       // PROGRAM PAGE - we support flash programming only, not EEPROM
       uint8_t *bufPtr;
       uint16_t addrPtr;
 
       getch();			/* getlen() */
-    3ec6:	66 d0       	rcall	.+204    	; 0x3f94 <getch>
+    3ec4:	66 d0       	rcall	.+204    	; 0x3f92 <getch>
       length = getch();
-    3ec8:	65 d0       	rcall	.+202    	; 0x3f94 <getch>
-    3eca:	08 2f       	mov	r16, r24
+    3ec6:	65 d0       	rcall	.+202    	; 0x3f92 <getch>
+    3ec8:	08 2f       	mov	r16, r24
       getch();
-    3ecc:	63 d0       	rcall	.+198    	; 0x3f94 <getch>
+    3eca:	63 d0       	rcall	.+198    	; 0x3f92 <getch>
 
       // If we are in RWW section, immediately start page erase
       if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    3ece:	80 e0       	ldi	r24, 0x00	; 0
-    3ed0:	e8 16       	cp	r14, r24
-    3ed2:	88 e3       	ldi	r24, 0x38	; 56
-    3ed4:	f8 06       	cpc	r15, r24
-    3ed6:	18 f4       	brcc	.+6      	; 0x3ede <main+0xde>
-    3ed8:	f7 01       	movw	r30, r14
-    3eda:	d7 be       	out	0x37, r13	; 55
-    3edc:	e8 95       	spm
-    3ede:	c0 e0       	ldi	r28, 0x00	; 0
-    3ee0:	d1 e0       	ldi	r29, 0x01	; 1
+    3ecc:	80 e0       	ldi	r24, 0x00	; 0
+    3ece:	e8 16       	cp	r14, r24
+    3ed0:	88 e3       	ldi	r24, 0x38	; 56
+    3ed2:	f8 06       	cpc	r15, r24
+    3ed4:	18 f4       	brcc	.+6      	; 0x3edc <main+0xdc>
+    3ed6:	f7 01       	movw	r30, r14
+    3ed8:	d7 be       	out	0x37, r13	; 55
+    3eda:	e8 95       	spm
+    3edc:	c0 e0       	ldi	r28, 0x00	; 0
+    3ede:	d1 e0       	ldi	r29, 0x01	; 1
 
       // While that is going on, read in page contents
       bufPtr = buff;
       do *bufPtr++ = getch();
-    3ee2:	58 d0       	rcall	.+176    	; 0x3f94 <getch>
-    3ee4:	89 93       	st	Y+, r24
+    3ee0:	58 d0       	rcall	.+176    	; 0x3f92 <getch>
+    3ee2:	89 93       	st	Y+, r24
       while (--length);
-    3ee6:	0c 17       	cp	r16, r28
-    3ee8:	e1 f7       	brne	.-8      	; 0x3ee2 <main+0xe2>
+    3ee4:	0c 17       	cp	r16, r28
+    3ee6:	e1 f7       	brne	.-8      	; 0x3ee0 <main+0xe0>
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    3eea:	f0 e0       	ldi	r31, 0x00	; 0
-    3eec:	ef 16       	cp	r14, r31
-    3eee:	f8 e3       	ldi	r31, 0x38	; 56
-    3ef0:	ff 06       	cpc	r15, r31
-    3ef2:	18 f0       	brcs	.+6      	; 0x3efa <main+0xfa>
-    3ef4:	f7 01       	movw	r30, r14
-    3ef6:	d7 be       	out	0x37, r13	; 55
-    3ef8:	e8 95       	spm
+    3ee8:	f0 e0       	ldi	r31, 0x00	; 0
+    3eea:	ef 16       	cp	r14, r31
+    3eec:	f8 e3       	ldi	r31, 0x38	; 56
+    3eee:	ff 06       	cpc	r15, r31
+    3ef0:	18 f0       	brcs	.+6      	; 0x3ef8 <main+0xf8>
+    3ef2:	f7 01       	movw	r30, r14
+    3ef4:	d7 be       	out	0x37, r13	; 55
+    3ef6:	e8 95       	spm
 
       // Read command terminator, start reply
       verifySpace();
-    3efa:	5e d0       	rcall	.+188    	; 0x3fb8 <verifySpace>
+    3ef8:	5e d0       	rcall	.+188    	; 0x3fb6 <verifySpace>
 
       // If only a partial page is to be programmed, the erase might not be complete.
       // So check that here
       boot_spm_busy_wait();
-    3efc:	07 b6       	in	r0, 0x37	; 55
-    3efe:	00 fc       	sbrc	r0, 0
-    3f00:	fd cf       	rjmp	.-6      	; 0x3efc <main+0xfc>
-    3f02:	a7 01       	movw	r20, r14
-    3f04:	a0 e0       	ldi	r26, 0x00	; 0
-    3f06:	b1 e0       	ldi	r27, 0x01	; 1
+    3efa:	07 b6       	in	r0, 0x37	; 55
+    3efc:	00 fc       	sbrc	r0, 0
+    3efe:	fd cf       	rjmp	.-6      	; 0x3efa <main+0xfa>
+    3f00:	a7 01       	movw	r20, r14
+    3f02:	a0 e0       	ldi	r26, 0x00	; 0
+    3f04:	b1 e0       	ldi	r27, 0x01	; 1
       bufPtr = buff;
       addrPtr = (uint16_t)(void*)address;
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
-    3f08:	2c 91       	ld	r18, X
-    3f0a:	30 e0       	ldi	r19, 0x00	; 0
+    3f06:	2c 91       	ld	r18, X
+    3f08:	30 e0       	ldi	r19, 0x00	; 0
         a |= (*bufPtr++) << 8;
-    3f0c:	11 96       	adiw	r26, 0x01	; 1
-    3f0e:	8c 91       	ld	r24, X
-    3f10:	11 97       	sbiw	r26, 0x01	; 1
-    3f12:	90 e0       	ldi	r25, 0x00	; 0
-    3f14:	98 2f       	mov	r25, r24
-    3f16:	88 27       	eor	r24, r24
-    3f18:	82 2b       	or	r24, r18
-    3f1a:	93 2b       	or	r25, r19
+    3f0a:	11 96       	adiw	r26, 0x01	; 1
+    3f0c:	8c 91       	ld	r24, X
+    3f0e:	11 97       	sbiw	r26, 0x01	; 1
+    3f10:	90 e0       	ldi	r25, 0x00	; 0
+    3f12:	98 2f       	mov	r25, r24
+    3f14:	88 27       	eor	r24, r24
+    3f16:	82 2b       	or	r24, r18
+    3f18:	93 2b       	or	r25, r19
 # define UART_SRL UBRR3L
 # define UART_UDR UDR3
 #endif
 
 /* main program starts here */
 int main(void) {
-    3f1c:	12 96       	adiw	r26, 0x02	; 2
+    3f1a:	12 96       	adiw	r26, 0x02	; 2
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
         a |= (*bufPtr++) << 8;
         __boot_page_fill_short((uint16_t)(void*)addrPtr,a);
-    3f1e:	fa 01       	movw	r30, r20
-    3f20:	0c 01       	movw	r0, r24
-    3f22:	a7 be       	out	0x37, r10	; 55
-    3f24:	e8 95       	spm
-    3f26:	11 24       	eor	r1, r1
+    3f1c:	fa 01       	movw	r30, r20
+    3f1e:	0c 01       	movw	r0, r24
+    3f20:	a7 be       	out	0x37, r10	; 55
+    3f22:	e8 95       	spm
+    3f24:	11 24       	eor	r1, r1
         addrPtr += 2;
-    3f28:	4e 5f       	subi	r20, 0xFE	; 254
-    3f2a:	5f 4f       	sbci	r21, 0xFF	; 255
+    3f26:	4e 5f       	subi	r20, 0xFE	; 254
+    3f28:	5f 4f       	sbci	r21, 0xFF	; 255
       } while (--ch);
-    3f2c:	f1 e0       	ldi	r31, 0x01	; 1
-    3f2e:	a0 38       	cpi	r26, 0x80	; 128
-    3f30:	bf 07       	cpc	r27, r31
-    3f32:	51 f7       	brne	.-44     	; 0x3f08 <main+0x108>
+    3f2a:	f1 e0       	ldi	r31, 0x01	; 1
+    3f2c:	a0 38       	cpi	r26, 0x80	; 128
+    3f2e:	bf 07       	cpc	r27, r31
+    3f30:	51 f7       	brne	.-44     	; 0x3f06 <main+0x106>
 
       // Write from programming buffer
       __boot_page_write_short((uint16_t)(void*)address);
-    3f34:	f7 01       	movw	r30, r14
-    3f36:	c7 be       	out	0x37, r12	; 55
-    3f38:	e8 95       	spm
+    3f32:	f7 01       	movw	r30, r14
+    3f34:	c7 be       	out	0x37, r12	; 55
+    3f36:	e8 95       	spm
       boot_spm_busy_wait();
-    3f3a:	07 b6       	in	r0, 0x37	; 55
-    3f3c:	00 fc       	sbrc	r0, 0
-    3f3e:	fd cf       	rjmp	.-6      	; 0x3f3a <main+0x13a>
+    3f38:	07 b6       	in	r0, 0x37	; 55
+    3f3a:	00 fc       	sbrc	r0, 0
+    3f3c:	fd cf       	rjmp	.-6      	; 0x3f38 <main+0x138>
 
 #if defined(RWWSRE)
       // Reenable read access to flash
       boot_rww_enable();
-    3f40:	b7 be       	out	0x37, r11	; 55
-    3f42:	e8 95       	spm
-    3f44:	1c c0       	rjmp	.+56     	; 0x3f7e <main+0x17e>
+    3f3e:	b7 be       	out	0x37, r11	; 55
+    3f40:	e8 95       	spm
+    3f42:	1c c0       	rjmp	.+56     	; 0x3f7c <main+0x17c>
 #endif
 
     }
     /* Read memory block mode, length is big endian.  */
     else if(ch == STK_READ_PAGE) {
-    3f46:	84 37       	cpi	r24, 0x74	; 116
-    3f48:	61 f4       	brne	.+24     	; 0x3f62 <main+0x162>
+    3f44:	84 37       	cpi	r24, 0x74	; 116
+    3f46:	61 f4       	brne	.+24     	; 0x3f60 <main+0x160>
       // READ PAGE - we only read flash
       getch();			/* getlen() */
-    3f4a:	24 d0       	rcall	.+72     	; 0x3f94 <getch>
+    3f48:	24 d0       	rcall	.+72     	; 0x3f92 <getch>
       length = getch();
-    3f4c:	23 d0       	rcall	.+70     	; 0x3f94 <getch>
-    3f4e:	08 2f       	mov	r16, r24
+    3f4a:	23 d0       	rcall	.+70     	; 0x3f92 <getch>
+    3f4c:	08 2f       	mov	r16, r24
       getch();
-    3f50:	21 d0       	rcall	.+66     	; 0x3f94 <getch>
+    3f4e:	21 d0       	rcall	.+66     	; 0x3f92 <getch>
 
       verifySpace();
-    3f52:	32 d0       	rcall	.+100    	; 0x3fb8 <verifySpace>
+    3f50:	32 d0       	rcall	.+100    	; 0x3fb6 <verifySpace>
         __asm__ ("elpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #else
         // read a Flash byte and increment the address
         __asm__ ("lpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #endif
         putch(ch);
-    3f54:	f7 01       	movw	r30, r14
-    3f56:	85 91       	lpm	r24, Z+
-    3f58:	7f 01       	movw	r14, r30
-    3f5a:	14 d0       	rcall	.+40     	; 0x3f84 <putch>
+    3f52:	f7 01       	movw	r30, r14
+    3f54:	85 91       	lpm	r24, Z+
+    3f56:	7f 01       	movw	r14, r30
+    3f58:	14 d0       	rcall	.+40     	; 0x3f82 <putch>
       } while (--length);
-    3f5c:	01 50       	subi	r16, 0x01	; 1
-    3f5e:	d1 f7       	brne	.-12     	; 0x3f54 <main+0x154>
-    3f60:	0e c0       	rjmp	.+28     	; 0x3f7e <main+0x17e>
+    3f5a:	01 50       	subi	r16, 0x01	; 1
+    3f5c:	d1 f7       	brne	.-12     	; 0x3f52 <main+0x152>
+    3f5e:	0e c0       	rjmp	.+28     	; 0x3f7c <main+0x17c>
     }
 
     /* Get device signature bytes  */
     else if(ch == STK_READ_SIGN) {
-    3f62:	85 37       	cpi	r24, 0x75	; 117
-    3f64:	39 f4       	brne	.+14     	; 0x3f74 <main+0x174>
+    3f60:	85 37       	cpi	r24, 0x75	; 117
+    3f62:	39 f4       	brne	.+14     	; 0x3f72 <main+0x172>
       // READ SIGN - return what Avrdude wants to hear
       verifySpace();
-    3f66:	28 d0       	rcall	.+80     	; 0x3fb8 <verifySpace>
+    3f64:	28 d0       	rcall	.+80     	; 0x3fb6 <verifySpace>
       putch(SIGNATURE_0);
-    3f68:	8e e1       	ldi	r24, 0x1E	; 30
-    3f6a:	0c d0       	rcall	.+24     	; 0x3f84 <putch>
+    3f66:	8e e1       	ldi	r24, 0x1E	; 30
+    3f68:	0c d0       	rcall	.+24     	; 0x3f82 <putch>
       putch(SIGNATURE_1);
-    3f6c:	84 e9       	ldi	r24, 0x94	; 148
-    3f6e:	0a d0       	rcall	.+20     	; 0x3f84 <putch>
+    3f6a:	84 e9       	ldi	r24, 0x94	; 148
+    3f6c:	0a d0       	rcall	.+20     	; 0x3f82 <putch>
       putch(SIGNATURE_2);
-    3f70:	86 e0       	ldi	r24, 0x06	; 6
-    3f72:	84 cf       	rjmp	.-248    	; 0x3e7c <main+0x7c>
+    3f6e:	86 e0       	ldi	r24, 0x06	; 6
+    3f70:	84 cf       	rjmp	.-248    	; 0x3e7a <main+0x7a>
     }
     else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */
-    3f74:	81 35       	cpi	r24, 0x51	; 81
-    3f76:	11 f4       	brne	.+4      	; 0x3f7c <main+0x17c>
+    3f72:	81 35       	cpi	r24, 0x51	; 81
+    3f74:	11 f4       	brne	.+4      	; 0x3f7a <main+0x17a>
       // Adaboot no-wait mod
       watchdogConfig(WATCHDOG_16MS);
-    3f78:	88 e0       	ldi	r24, 0x08	; 8
-    3f7a:	18 d0       	rcall	.+48     	; 0x3fac <watchdogConfig>
+    3f76:	88 e0       	ldi	r24, 0x08	; 8
+    3f78:	18 d0       	rcall	.+48     	; 0x3faa <watchdogConfig>
       verifySpace();
     }
     else {
       // This covers the response to commands like STK_ENTER_PROGMODE
       verifySpace();
-    3f7c:	1d d0       	rcall	.+58     	; 0x3fb8 <verifySpace>
+    3f7a:	1d d0       	rcall	.+58     	; 0x3fb6 <verifySpace>
     }
     putch(STK_OK);
-    3f7e:	80 e1       	ldi	r24, 0x10	; 16
-    3f80:	01 d0       	rcall	.+2      	; 0x3f84 <putch>
-    3f82:	6e cf       	rjmp	.-292    	; 0x3e60 <main+0x60>
+    3f7c:	80 e1       	ldi	r24, 0x10	; 16
+    3f7e:	01 d0       	rcall	.+2      	; 0x3f82 <putch>
+    3f80:	6f cf       	rjmp	.-290    	; 0x3e60 <main+0x60>
 
-00003f84 <putch>:
+00003f82 <putch>:
   }
 }
 
 void putch(char ch) {
-    3f84:	98 2f       	mov	r25, r24
+    3f82:	98 2f       	mov	r25, r24
 #ifndef SOFT_UART
   while (!(UART_SRA & _BV(UDRE0)));
-    3f86:	80 91 c0 00 	lds	r24, 0x00C0
-    3f8a:	85 ff       	sbrs	r24, 5
-    3f8c:	fc cf       	rjmp	.-8      	; 0x3f86 <putch+0x2>
+    3f84:	80 91 c0 00 	lds	r24, 0x00C0
+    3f88:	85 ff       	sbrs	r24, 5
+    3f8a:	fc cf       	rjmp	.-8      	; 0x3f84 <putch+0x2>
   UART_UDR = ch;
-    3f8e:	90 93 c6 00 	sts	0x00C6, r25
+    3f8c:	90 93 c6 00 	sts	0x00C6, r25
       [uartBit] "I" (UART_TX_BIT)
     :
       "r25"
   );
 #endif
 }
-    3f92:	08 95       	ret
+    3f90:	08 95       	ret
 
-00003f94 <getch>:
+00003f92 <getch>:
       [uartBit] "I" (UART_RX_BIT)
     :
       "r25"
 );
 #else
   while(!(UART_SRA & _BV(RXC0)))
-    3f94:	80 91 c0 00 	lds	r24, 0x00C0
-    3f98:	87 ff       	sbrs	r24, 7
-    3f9a:	fc cf       	rjmp	.-8      	; 0x3f94 <getch>
+    3f92:	80 91 c0 00 	lds	r24, 0x00C0
+    3f96:	87 ff       	sbrs	r24, 7
+    3f98:	fc cf       	rjmp	.-8      	; 0x3f92 <getch>
     ;
   if (!(UART_SRA & _BV(FE0))) {
-    3f9c:	80 91 c0 00 	lds	r24, 0x00C0
-    3fa0:	84 fd       	sbrc	r24, 4
-    3fa2:	01 c0       	rjmp	.+2      	; 0x3fa6 <getch+0x12>
+    3f9a:	80 91 c0 00 	lds	r24, 0x00C0
+    3f9e:	84 fd       	sbrc	r24, 4
+    3fa0:	01 c0       	rjmp	.+2      	; 0x3fa4 <getch+0x12>
 }
 #endif
 
 // Watchdog functions. These are only safe with interrupts turned off.
 void watchdogReset() {
   __asm__ __volatile__ (
-    3fa4:	a8 95       	wdr
+    3fa2:	a8 95       	wdr
        * don't care that an invalid char is returned...)
        */
     watchdogReset();
   }
   
   ch = UART_UDR;
-    3fa6:	80 91 c6 00 	lds	r24, 0x00C6
+    3fa4:	80 91 c6 00 	lds	r24, 0x00C6
   LED_PIN |= _BV(LED);
 #endif
 #endif
 
   return ch;
 }
-    3faa:	08 95       	ret
+    3fa8:	08 95       	ret
 
-00003fac <watchdogConfig>:
+00003faa <watchdogConfig>:
     "wdr\n"
   );
 }
 
 void watchdogConfig(uint8_t x) {
   WDTCSR = _BV(WDCE) | _BV(WDE);
-    3fac:	e0 e6       	ldi	r30, 0x60	; 96
-    3fae:	f0 e0       	ldi	r31, 0x00	; 0
-    3fb0:	98 e1       	ldi	r25, 0x18	; 24
-    3fb2:	90 83       	st	Z, r25
+    3faa:	e0 e6       	ldi	r30, 0x60	; 96
+    3fac:	f0 e0       	ldi	r31, 0x00	; 0
+    3fae:	98 e1       	ldi	r25, 0x18	; 24
+    3fb0:	90 83       	st	Z, r25
   WDTCSR = x;
-    3fb4:	80 83       	st	Z, r24
+    3fb2:	80 83       	st	Z, r24
 }
-    3fb6:	08 95       	ret
+    3fb4:	08 95       	ret
 
-00003fb8 <verifySpace>:
+00003fb6 <verifySpace>:
   do getch(); while (--count);
   verifySpace();
 }
 
 void verifySpace() {
   if (getch() != CRC_EOP) {
-    3fb8:	ed df       	rcall	.-38     	; 0x3f94 <getch>
-    3fba:	80 32       	cpi	r24, 0x20	; 32
-    3fbc:	19 f0       	breq	.+6      	; 0x3fc4 <verifySpace+0xc>
+    3fb6:	ed df       	rcall	.-38     	; 0x3f92 <getch>
+    3fb8:	80 32       	cpi	r24, 0x20	; 32
+    3fba:	19 f0       	breq	.+6      	; 0x3fc2 <verifySpace+0xc>
     watchdogConfig(WATCHDOG_16MS);    // shorten WD timeout
-    3fbe:	88 e0       	ldi	r24, 0x08	; 8
-    3fc0:	f5 df       	rcall	.-22     	; 0x3fac <watchdogConfig>
-    3fc2:	ff cf       	rjmp	.-2      	; 0x3fc2 <verifySpace+0xa>
+    3fbc:	88 e0       	ldi	r24, 0x08	; 8
+    3fbe:	f5 df       	rcall	.-22     	; 0x3faa <watchdogConfig>
+    3fc0:	ff cf       	rjmp	.-2      	; 0x3fc0 <verifySpace+0xa>
     while (1)			      // and busy-loop so that WD causes
       ;				      //  a reset and app start.
   }
   putch(STK_INSYNC);
-    3fc4:	84 e1       	ldi	r24, 0x14	; 20
+    3fc2:	84 e1       	ldi	r24, 0x14	; 20
 }
-    3fc6:	de cf       	rjmp	.-68     	; 0x3f84 <putch>
+    3fc4:	de cf       	rjmp	.-68     	; 0x3f82 <putch>
 
-00003fc8 <getNch>:
+00003fc6 <getNch>:
     ::[count] "M" (UART_B_VALUE)
   );
 }
 #endif
 
 void getNch(uint8_t count) {
-    3fc8:	1f 93       	push	r17
-    3fca:	18 2f       	mov	r17, r24
+    3fc6:	1f 93       	push	r17
+    3fc8:	18 2f       	mov	r17, r24
   do getch(); while (--count);
-    3fcc:	e3 df       	rcall	.-58     	; 0x3f94 <getch>
-    3fce:	11 50       	subi	r17, 0x01	; 1
-    3fd0:	e9 f7       	brne	.-6      	; 0x3fcc <getNch+0x4>
+    3fca:	e3 df       	rcall	.-58     	; 0x3f92 <getch>
+    3fcc:	11 50       	subi	r17, 0x01	; 1
+    3fce:	e9 f7       	brne	.-6      	; 0x3fca <getNch+0x4>
   verifySpace();
-    3fd2:	f2 df       	rcall	.-28     	; 0x3fb8 <verifySpace>
+    3fd0:	f2 df       	rcall	.-28     	; 0x3fb6 <verifySpace>
 }
-    3fd4:	1f 91       	pop	r17
-    3fd6:	08 95       	ret
+    3fd2:	1f 91       	pop	r17
+    3fd4:	08 95       	ret
 
-00003fd8 <appStart>:
+00003fd6 <appStart>:
 
 void appStart(uint8_t rstFlags) {
   // 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" (rstFlags));
-    3fd8:	28 2e       	mov	r2, r24
+    3fd6:	28 2e       	mov	r2, r24
 
   watchdogConfig(WATCHDOG_OFF);
-    3fda:	80 e0       	ldi	r24, 0x00	; 0
-    3fdc:	e7 df       	rcall	.-50     	; 0x3fac <watchdogConfig>
+    3fd8:	80 e0       	ldi	r24, 0x00	; 0
+    3fda:	e7 df       	rcall	.-50     	; 0x3faa <watchdogConfig>
   __asm__ __volatile__ (
-    3fde:	ee 27       	eor	r30, r30
-    3fe0:	ff 27       	eor	r31, r31
-    3fe2:	09 94       	ijmp
+    3fdc:	ee 27       	eor	r30, r30
+    3fde:	ff 27       	eor	r31, r31
+    3fe0:	09 94       	ijmp

+ 28 - 28
optiboot/bootloaders/optiboot/optiboot_pro_20mhz.hex

@@ -1,34 +1,34 @@
-:103E0000112484B714BE81FFE7D085E08093810040
+:103E0000112484B714BE81FFE6D085E08093810041
 :103E100082E08093C00088E18093C10086E08093B7
-:103E2000C20085E18093C4008EE0C0D0259A86E070
+:103E2000C20085E18093C4008EE0BFD0259A86E071
 :103E30002CE33BEF91E0309385002093840096BB08
 :103E4000B09BFECF1D9AA8958150A9F7EE24FF24C0
 :103E5000AA24A394B5E0CB2EA1E1BA2EF3E0DF2E85
-:103E600099D0813469F496D0082FA6D0023809F48D
-:103E70007FC0013811F484E001C083E083D07FC0AB
-:103E8000823411F484E103C0853419F485E09CD0B8
-:103E900076C0853579F47ED0E82EFF247BD0082FBC
-:103EA00010E0102F00270E291F29000F111F84D0AA
-:103EB000780165C0863521F484E086D080E0DECFCD
-:103EC000843609F040C066D065D0082F63D080E00A
-:103ED000E81688E3F80618F4F701D7BEE895C0E0C5
-:103EE000D1E058D089930C17E1F7F0E0EF16F8E332
-:103EF000FF0618F0F701D7BEE8955ED007B600FCC4
-:103F0000FDCFA701A0E0B1E02C9130E011968C919B
-:103F1000119790E0982F8827822B932B1296FA0105
-:103F20000C01A7BEE89511244E5F5F4FF1E0A03869
-:103F3000BF0751F7F701C7BEE89507B600FCFDCFF4
-:103F4000B7BEE8951CC0843761F424D023D0082F75
-:103F500021D032D0F70185917F0114D00150D1F7E3
-:103F60000EC0853739F428D08EE10CD084E90AD010
-:103F700086E084CF813511F488E018D01DD080E12F
-:103F800001D06ECF982F8091C00085FFFCCF909319
-:103F9000C60008958091C00087FFFCCF8091C000CB
-:103FA00084FD01C0A8958091C6000895E0E6F0E088
-:103FB00098E1908380830895EDDF803219F088E0E6
-:103FC000F5DFFFCF84E1DECF1F93182FE3DF115021
-:103FD000E9F7F2DF1F910895282E80E0E7DFEE2752
-:043FE000FF2709941A
-:023FFE000604B7
+:103E600098D0813461F495D0082FA5D0023829F17B
+:103E7000013811F485E001C083E083D07FC0823433
+:103E800011F484E103C0853419F485E09CD076C038
+:103E9000853579F47ED0E82EFF247BD0082F10E002
+:103EA000102F00270E291F29000F111F84D0780121
+:103EB00065C0863521F484E086D080E0DECF84368C
+:103EC00009F040C066D065D0082F63D080E0E816C6
+:103ED00088E3F80618F4F701D7BEE895C0E0D1E012
+:103EE00058D089930C17E1F7F0E0EF16F8E3FF06DE
+:103EF00018F0F701D7BEE8955ED007B600FCFDCFFD
+:103F0000A701A0E0B1E02C9130E011968C911197BF
+:103F100090E0982F8827822B932B1296FA010C01A0
+:103F2000A7BEE89511244E5F5F4FF1E0A038BF07B0
+:103F300051F7F701C7BEE89507B600FCFDCFB7BE45
+:103F4000E8951CC0843761F424D023D0082F21D0F9
+:103F500032D0F70185917F0114D00150D1F70EC006
+:103F6000853739F428D08EE10CD084E90AD086E078
+:103F700084CF813511F488E018D01DD080E101D0C4
+:103F80006FCF982F8091C00085FFFCCF9093C60023
+:103F900008958091C00087FFFCCF8091C00084FD10
+:103FA00001C0A8958091C6000895E0E6F0E098E190
+:103FB000908380830895EDDF803219F088E0F5DF8B
+:103FC000FFCF84E1DECF1F93182FE3DF1150E9F715
+:103FD000F2DF1F910895282E80E0E7DFEE27FF270C
+:023FE000099442
+:023FFE000005BC
 :0400000300003E00BB
 :00000001FF

+ 214 - 212
optiboot/bootloaders/optiboot/optiboot_pro_20mhz.lst

@@ -1,29 +1,29 @@
 
-optiboot_pro_20mhz.elf:     file format elf32-avr
+optiboot_atmega168.elf:     file format elf32-avr
 
 Sections:
 Idx Name          Size      VMA       LMA       File off  Algn
-  0 .text         000001e4  00003e00  00003e00  00000054  2**1
+  0 .text         000001e2  00003e00  00003e00  00000054  2**1
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
-  1 .version      00000002  00003ffe  00003ffe  00000238  2**0
+  1 .version      00000002  00003ffe  00003ffe  00000236  2**0
                   CONTENTS, READONLY
-  2 .debug_aranges 00000028  00000000  00000000  0000023a  2**0
+  2 .debug_aranges 00000028  00000000  00000000  00000238  2**0
                   CONTENTS, READONLY, DEBUGGING
-  3 .debug_pubnames 0000005f  00000000  00000000  00000262  2**0
+  3 .debug_pubnames 0000005f  00000000  00000000  00000260  2**0
                   CONTENTS, READONLY, DEBUGGING
-  4 .debug_info   00000294  00000000  00000000  000002c1  2**0
+  4 .debug_info   00000294  00000000  00000000  000002bf  2**0
                   CONTENTS, READONLY, DEBUGGING
-  5 .debug_abbrev 0000016b  00000000  00000000  00000555  2**0
+  5 .debug_abbrev 0000016b  00000000  00000000  00000553  2**0
                   CONTENTS, READONLY, DEBUGGING
-  6 .debug_line   00000468  00000000  00000000  000006c0  2**0
+  6 .debug_line   00000421  00000000  00000000  000006be  2**0
                   CONTENTS, READONLY, DEBUGGING
-  7 .debug_frame  00000080  00000000  00000000  00000b28  2**2
+  7 .debug_frame  00000080  00000000  00000000  00000ae0  2**2
                   CONTENTS, READONLY, DEBUGGING
-  8 .debug_str    00000131  00000000  00000000  00000ba8  2**0
+  8 .debug_str    00000131  00000000  00000000  00000b60  2**0
                   CONTENTS, READONLY, DEBUGGING
-  9 .debug_loc    00000266  00000000  00000000  00000cd9  2**0
+  9 .debug_loc    00000266  00000000  00000000  00000c91  2**0
                   CONTENTS, READONLY, DEBUGGING
- 10 .debug_ranges 00000078  00000000  00000000  00000f3f  2**0
+ 10 .debug_ranges 00000078  00000000  00000000  00000ef7  2**0
                   CONTENTS, READONLY, DEBUGGING
 
 Disassembly of section .text:
@@ -36,7 +36,7 @@ Disassembly of section .text:
 /* main program starts here */
 int main(void) {
     3e00:	11 24       	eor	r1, r1
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__)
   SP=RAMEND;  // This is done by hardware reset
 #endif
 
@@ -47,7 +47,7 @@ int main(void) {
     3e04:	14 be       	out	0x34, r1	; 52
   if (!(ch & _BV(EXTRF))) appStart(ch);
     3e06:	81 ff       	sbrs	r24, 1
-    3e08:	e7 d0       	rcall	.+462    	; 0x3fd8 <appStart>
+    3e08:	e6 d0       	rcall	.+460    	; 0x3fd6 <appStart>
 
 #if LED_START_FLASHES > 0
   // Set up Timer 1 for timeout counter
@@ -77,8 +77,9 @@ int main(void) {
   // Set up watchdog to trigger after 500ms
   watchdogConfig(WATCHDOG_1S);
     3e28:	8e e0       	ldi	r24, 0x0E	; 14
-    3e2a:	c0 d0       	rcall	.+384    	; 0x3fac <watchdogConfig>
+    3e2a:	bf d0       	rcall	.+382    	; 0x3faa <watchdogConfig>
 
+#if (LED_START_FLASHES > 0) || defined(LED_DATA_FLASH)
   /* Set LED pin as output */
   LED_DDR |= _BV(LED);
     3e2c:	25 9a       	sbi	0x04, 5	; 4
@@ -106,7 +107,7 @@ void flash_led(uint8_t count) {
     while(!(TIFR1 & _BV(TOV1)));
     3e40:	b0 9b       	sbis	0x16, 0	; 22
     3e42:	fe cf       	rjmp	.-4      	; 0x3e40 <main+0x40>
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__)  || defined (__AVR_ATmega32__)
     LED_PORT ^= _BV(LED);
 #else
     LED_PIN |= _BV(LED);
@@ -150,11 +151,11 @@ void watchdogReset() {
       boot_rww_enable();
     3e58:	a1 e1       	ldi	r26, 0x11	; 17
     3e5a:	ba 2e       	mov	r11, r26
-      do *bufPtr++ = getch();
-      while (--length);
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
     3e5c:	f3 e0       	ldi	r31, 0x03	; 3
     3e5e:	df 2e       	mov	r13, r31
@@ -164,421 +165,422 @@ void watchdogReset() {
   for (;;) {
     /* get character from UART */
     ch = getch();
-    3e60:	99 d0       	rcall	.+306    	; 0x3f94 <getch>
+    3e60:	98 d0       	rcall	.+304    	; 0x3f92 <getch>
 
     if(ch == STK_GET_PARAMETER) {
     3e62:	81 34       	cpi	r24, 0x41	; 65
-    3e64:	69 f4       	brne	.+26     	; 0x3e80 <main+0x80>
+    3e64:	61 f4       	brne	.+24     	; 0x3e7e <main+0x7e>
       unsigned char which = getch();
-    3e66:	96 d0       	rcall	.+300    	; 0x3f94 <getch>
+    3e66:	95 d0       	rcall	.+298    	; 0x3f92 <getch>
     3e68:	08 2f       	mov	r16, r24
       verifySpace();
-    3e6a:	a6 d0       	rcall	.+332    	; 0x3fb8 <verifySpace>
+    3e6a:	a5 d0       	rcall	.+330    	; 0x3fb6 <verifySpace>
       if (which == 0x82) {
     3e6c:	02 38       	cpi	r16, 0x82	; 130
-    3e6e:	09 f4       	brne	.+2      	; 0x3e72 <main+0x72>
-    3e70:	7f c0       	rjmp	.+254    	; 0x3f70 <main+0x170>
+    3e6e:	29 f1       	breq	.+74     	; 0x3eba <main+0xba>
 	/*
 	 * Send optiboot version as "minor SW version"
 	 */
 	putch(OPTIBOOT_MINVER);
       } else if (which == 0x81) {
-    3e72:	01 38       	cpi	r16, 0x81	; 129
-    3e74:	11 f4       	brne	.+4      	; 0x3e7a <main+0x7a>
+    3e70:	01 38       	cpi	r16, 0x81	; 129
+    3e72:	11 f4       	brne	.+4      	; 0x3e78 <main+0x78>
 	  putch(OPTIBOOT_MAJVER);
-    3e76:	84 e0       	ldi	r24, 0x04	; 4
-    3e78:	01 c0       	rjmp	.+2      	; 0x3e7c <main+0x7c>
+    3e74:	85 e0       	ldi	r24, 0x05	; 5
+    3e76:	01 c0       	rjmp	.+2      	; 0x3e7a <main+0x7a>
       } else {
 	/*
 	 * GET PARAMETER returns a generic 0x03 reply for
          * other parameters - enough to keep Avrdude happy
 	 */
 	putch(0x03);
-    3e7a:	83 e0       	ldi	r24, 0x03	; 3
-    3e7c:	83 d0       	rcall	.+262    	; 0x3f84 <putch>
-    3e7e:	7f c0       	rjmp	.+254    	; 0x3f7e <main+0x17e>
+    3e78:	83 e0       	ldi	r24, 0x03	; 3
+    3e7a:	83 d0       	rcall	.+262    	; 0x3f82 <putch>
+    3e7c:	7f c0       	rjmp	.+254    	; 0x3f7c <main+0x17c>
       }
     }
     else if(ch == STK_SET_DEVICE) {
-    3e80:	82 34       	cpi	r24, 0x42	; 66
-    3e82:	11 f4       	brne	.+4      	; 0x3e88 <main+0x88>
+    3e7e:	82 34       	cpi	r24, 0x42	; 66
+    3e80:	11 f4       	brne	.+4      	; 0x3e86 <main+0x86>
       // SET DEVICE is ignored
       getNch(20);
-    3e84:	84 e1       	ldi	r24, 0x14	; 20
-    3e86:	03 c0       	rjmp	.+6      	; 0x3e8e <main+0x8e>
+    3e82:	84 e1       	ldi	r24, 0x14	; 20
+    3e84:	03 c0       	rjmp	.+6      	; 0x3e8c <main+0x8c>
     }
     else if(ch == STK_SET_DEVICE_EXT) {
-    3e88:	85 34       	cpi	r24, 0x45	; 69
-    3e8a:	19 f4       	brne	.+6      	; 0x3e92 <main+0x92>
+    3e86:	85 34       	cpi	r24, 0x45	; 69
+    3e88:	19 f4       	brne	.+6      	; 0x3e90 <main+0x90>
       // SET DEVICE EXT is ignored
       getNch(5);
-    3e8c:	85 e0       	ldi	r24, 0x05	; 5
-    3e8e:	9c d0       	rcall	.+312    	; 0x3fc8 <getNch>
-    3e90:	76 c0       	rjmp	.+236    	; 0x3f7e <main+0x17e>
+    3e8a:	85 e0       	ldi	r24, 0x05	; 5
+    3e8c:	9c d0       	rcall	.+312    	; 0x3fc6 <getNch>
+    3e8e:	76 c0       	rjmp	.+236    	; 0x3f7c <main+0x17c>
     }
     else if(ch == STK_LOAD_ADDRESS) {
-    3e92:	85 35       	cpi	r24, 0x55	; 85
-    3e94:	79 f4       	brne	.+30     	; 0x3eb4 <main+0xb4>
+    3e90:	85 35       	cpi	r24, 0x55	; 85
+    3e92:	79 f4       	brne	.+30     	; 0x3eb2 <main+0xb2>
       // LOAD ADDRESS
       uint16_t newAddress;
       newAddress = getch();
-    3e96:	7e d0       	rcall	.+252    	; 0x3f94 <getch>
+    3e94:	7e d0       	rcall	.+252    	; 0x3f92 <getch>
       newAddress = (newAddress & 0xff) | (getch() << 8);
-    3e98:	e8 2e       	mov	r14, r24
-    3e9a:	ff 24       	eor	r15, r15
-    3e9c:	7b d0       	rcall	.+246    	; 0x3f94 <getch>
-    3e9e:	08 2f       	mov	r16, r24
-    3ea0:	10 e0       	ldi	r17, 0x00	; 0
-    3ea2:	10 2f       	mov	r17, r16
-    3ea4:	00 27       	eor	r16, r16
-    3ea6:	0e 29       	or	r16, r14
-    3ea8:	1f 29       	or	r17, r15
+    3e96:	e8 2e       	mov	r14, r24
+    3e98:	ff 24       	eor	r15, r15
+    3e9a:	7b d0       	rcall	.+246    	; 0x3f92 <getch>
+    3e9c:	08 2f       	mov	r16, r24
+    3e9e:	10 e0       	ldi	r17, 0x00	; 0
+    3ea0:	10 2f       	mov	r17, r16
+    3ea2:	00 27       	eor	r16, r16
+    3ea4:	0e 29       	or	r16, r14
+    3ea6:	1f 29       	or	r17, r15
 #ifdef RAMPZ
       // Transfer top bit to RAMPZ
       RAMPZ = (newAddress & 0x8000) ? 1 : 0;
 #endif
       newAddress += newAddress; // Convert from word address to byte address
-    3eaa:	00 0f       	add	r16, r16
-    3eac:	11 1f       	adc	r17, r17
+    3ea8:	00 0f       	add	r16, r16
+    3eaa:	11 1f       	adc	r17, r17
       address = newAddress;
       verifySpace();
-    3eae:	84 d0       	rcall	.+264    	; 0x3fb8 <verifySpace>
-    3eb0:	78 01       	movw	r14, r16
-    3eb2:	65 c0       	rjmp	.+202    	; 0x3f7e <main+0x17e>
+    3eac:	84 d0       	rcall	.+264    	; 0x3fb6 <verifySpace>
+    3eae:	78 01       	movw	r14, r16
+    3eb0:	65 c0       	rjmp	.+202    	; 0x3f7c <main+0x17c>
     }
     else if(ch == STK_UNIVERSAL) {
-    3eb4:	86 35       	cpi	r24, 0x56	; 86
-    3eb6:	21 f4       	brne	.+8      	; 0x3ec0 <main+0xc0>
+    3eb2:	86 35       	cpi	r24, 0x56	; 86
+    3eb4:	21 f4       	brne	.+8      	; 0x3ebe <main+0xbe>
       // UNIVERSAL command is ignored
       getNch(4);
-    3eb8:	84 e0       	ldi	r24, 0x04	; 4
-    3eba:	86 d0       	rcall	.+268    	; 0x3fc8 <getNch>
+    3eb6:	84 e0       	ldi	r24, 0x04	; 4
+    3eb8:	86 d0       	rcall	.+268    	; 0x3fc6 <getNch>
       putch(0x00);
-    3ebc:	80 e0       	ldi	r24, 0x00	; 0
-    3ebe:	de cf       	rjmp	.-68     	; 0x3e7c <main+0x7c>
+    3eba:	80 e0       	ldi	r24, 0x00	; 0
+    3ebc:	de cf       	rjmp	.-68     	; 0x3e7a <main+0x7a>
     }
     /* Write memory, length is big endian and is in bytes */
     else if(ch == STK_PROG_PAGE) {
-    3ec0:	84 36       	cpi	r24, 0x64	; 100
-    3ec2:	09 f0       	breq	.+2      	; 0x3ec6 <main+0xc6>
-    3ec4:	40 c0       	rjmp	.+128    	; 0x3f46 <main+0x146>
+    3ebe:	84 36       	cpi	r24, 0x64	; 100
+    3ec0:	09 f0       	breq	.+2      	; 0x3ec4 <main+0xc4>
+    3ec2:	40 c0       	rjmp	.+128    	; 0x3f44 <main+0x144>
       // PROGRAM PAGE - we support flash programming only, not EEPROM
       uint8_t *bufPtr;
       uint16_t addrPtr;
 
       getch();			/* getlen() */
-    3ec6:	66 d0       	rcall	.+204    	; 0x3f94 <getch>
+    3ec4:	66 d0       	rcall	.+204    	; 0x3f92 <getch>
       length = getch();
-    3ec8:	65 d0       	rcall	.+202    	; 0x3f94 <getch>
-    3eca:	08 2f       	mov	r16, r24
+    3ec6:	65 d0       	rcall	.+202    	; 0x3f92 <getch>
+    3ec8:	08 2f       	mov	r16, r24
       getch();
-    3ecc:	63 d0       	rcall	.+198    	; 0x3f94 <getch>
+    3eca:	63 d0       	rcall	.+198    	; 0x3f92 <getch>
 
       // If we are in RWW section, immediately start page erase
       if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    3ece:	80 e0       	ldi	r24, 0x00	; 0
-    3ed0:	e8 16       	cp	r14, r24
-    3ed2:	88 e3       	ldi	r24, 0x38	; 56
-    3ed4:	f8 06       	cpc	r15, r24
-    3ed6:	18 f4       	brcc	.+6      	; 0x3ede <main+0xde>
-    3ed8:	f7 01       	movw	r30, r14
-    3eda:	d7 be       	out	0x37, r13	; 55
-    3edc:	e8 95       	spm
-    3ede:	c0 e0       	ldi	r28, 0x00	; 0
-    3ee0:	d1 e0       	ldi	r29, 0x01	; 1
+    3ecc:	80 e0       	ldi	r24, 0x00	; 0
+    3ece:	e8 16       	cp	r14, r24
+    3ed0:	88 e3       	ldi	r24, 0x38	; 56
+    3ed2:	f8 06       	cpc	r15, r24
+    3ed4:	18 f4       	brcc	.+6      	; 0x3edc <main+0xdc>
+    3ed6:	f7 01       	movw	r30, r14
+    3ed8:	d7 be       	out	0x37, r13	; 55
+    3eda:	e8 95       	spm
+    3edc:	c0 e0       	ldi	r28, 0x00	; 0
+    3ede:	d1 e0       	ldi	r29, 0x01	; 1
 
       // While that is going on, read in page contents
       bufPtr = buff;
       do *bufPtr++ = getch();
-    3ee2:	58 d0       	rcall	.+176    	; 0x3f94 <getch>
-    3ee4:	89 93       	st	Y+, r24
+    3ee0:	58 d0       	rcall	.+176    	; 0x3f92 <getch>
+    3ee2:	89 93       	st	Y+, r24
       while (--length);
-    3ee6:	0c 17       	cp	r16, r28
-    3ee8:	e1 f7       	brne	.-8      	; 0x3ee2 <main+0xe2>
+    3ee4:	0c 17       	cp	r16, r28
+    3ee6:	e1 f7       	brne	.-8      	; 0x3ee0 <main+0xe0>
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    3eea:	f0 e0       	ldi	r31, 0x00	; 0
-    3eec:	ef 16       	cp	r14, r31
-    3eee:	f8 e3       	ldi	r31, 0x38	; 56
-    3ef0:	ff 06       	cpc	r15, r31
-    3ef2:	18 f0       	brcs	.+6      	; 0x3efa <main+0xfa>
-    3ef4:	f7 01       	movw	r30, r14
-    3ef6:	d7 be       	out	0x37, r13	; 55
-    3ef8:	e8 95       	spm
+    3ee8:	f0 e0       	ldi	r31, 0x00	; 0
+    3eea:	ef 16       	cp	r14, r31
+    3eec:	f8 e3       	ldi	r31, 0x38	; 56
+    3eee:	ff 06       	cpc	r15, r31
+    3ef0:	18 f0       	brcs	.+6      	; 0x3ef8 <main+0xf8>
+    3ef2:	f7 01       	movw	r30, r14
+    3ef4:	d7 be       	out	0x37, r13	; 55
+    3ef6:	e8 95       	spm
 
       // Read command terminator, start reply
       verifySpace();
-    3efa:	5e d0       	rcall	.+188    	; 0x3fb8 <verifySpace>
+    3ef8:	5e d0       	rcall	.+188    	; 0x3fb6 <verifySpace>
 
       // If only a partial page is to be programmed, the erase might not be complete.
       // So check that here
       boot_spm_busy_wait();
-    3efc:	07 b6       	in	r0, 0x37	; 55
-    3efe:	00 fc       	sbrc	r0, 0
-    3f00:	fd cf       	rjmp	.-6      	; 0x3efc <main+0xfc>
-    3f02:	a7 01       	movw	r20, r14
-    3f04:	a0 e0       	ldi	r26, 0x00	; 0
-    3f06:	b1 e0       	ldi	r27, 0x01	; 1
+    3efa:	07 b6       	in	r0, 0x37	; 55
+    3efc:	00 fc       	sbrc	r0, 0
+    3efe:	fd cf       	rjmp	.-6      	; 0x3efa <main+0xfa>
+    3f00:	a7 01       	movw	r20, r14
+    3f02:	a0 e0       	ldi	r26, 0x00	; 0
+    3f04:	b1 e0       	ldi	r27, 0x01	; 1
       bufPtr = buff;
       addrPtr = (uint16_t)(void*)address;
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
-    3f08:	2c 91       	ld	r18, X
-    3f0a:	30 e0       	ldi	r19, 0x00	; 0
+    3f06:	2c 91       	ld	r18, X
+    3f08:	30 e0       	ldi	r19, 0x00	; 0
         a |= (*bufPtr++) << 8;
-    3f0c:	11 96       	adiw	r26, 0x01	; 1
-    3f0e:	8c 91       	ld	r24, X
-    3f10:	11 97       	sbiw	r26, 0x01	; 1
-    3f12:	90 e0       	ldi	r25, 0x00	; 0
-    3f14:	98 2f       	mov	r25, r24
-    3f16:	88 27       	eor	r24, r24
-    3f18:	82 2b       	or	r24, r18
-    3f1a:	93 2b       	or	r25, r19
+    3f0a:	11 96       	adiw	r26, 0x01	; 1
+    3f0c:	8c 91       	ld	r24, X
+    3f0e:	11 97       	sbiw	r26, 0x01	; 1
+    3f10:	90 e0       	ldi	r25, 0x00	; 0
+    3f12:	98 2f       	mov	r25, r24
+    3f14:	88 27       	eor	r24, r24
+    3f16:	82 2b       	or	r24, r18
+    3f18:	93 2b       	or	r25, r19
 # define UART_SRL UBRR3L
 # define UART_UDR UDR3
 #endif
 
 /* main program starts here */
 int main(void) {
-    3f1c:	12 96       	adiw	r26, 0x02	; 2
+    3f1a:	12 96       	adiw	r26, 0x02	; 2
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
         a |= (*bufPtr++) << 8;
         __boot_page_fill_short((uint16_t)(void*)addrPtr,a);
-    3f1e:	fa 01       	movw	r30, r20
-    3f20:	0c 01       	movw	r0, r24
-    3f22:	a7 be       	out	0x37, r10	; 55
-    3f24:	e8 95       	spm
-    3f26:	11 24       	eor	r1, r1
+    3f1c:	fa 01       	movw	r30, r20
+    3f1e:	0c 01       	movw	r0, r24
+    3f20:	a7 be       	out	0x37, r10	; 55
+    3f22:	e8 95       	spm
+    3f24:	11 24       	eor	r1, r1
         addrPtr += 2;
-    3f28:	4e 5f       	subi	r20, 0xFE	; 254
-    3f2a:	5f 4f       	sbci	r21, 0xFF	; 255
+    3f26:	4e 5f       	subi	r20, 0xFE	; 254
+    3f28:	5f 4f       	sbci	r21, 0xFF	; 255
       } while (--ch);
-    3f2c:	f1 e0       	ldi	r31, 0x01	; 1
-    3f2e:	a0 38       	cpi	r26, 0x80	; 128
-    3f30:	bf 07       	cpc	r27, r31
-    3f32:	51 f7       	brne	.-44     	; 0x3f08 <main+0x108>
+    3f2a:	f1 e0       	ldi	r31, 0x01	; 1
+    3f2c:	a0 38       	cpi	r26, 0x80	; 128
+    3f2e:	bf 07       	cpc	r27, r31
+    3f30:	51 f7       	brne	.-44     	; 0x3f06 <main+0x106>
 
       // Write from programming buffer
       __boot_page_write_short((uint16_t)(void*)address);
-    3f34:	f7 01       	movw	r30, r14
-    3f36:	c7 be       	out	0x37, r12	; 55
-    3f38:	e8 95       	spm
+    3f32:	f7 01       	movw	r30, r14
+    3f34:	c7 be       	out	0x37, r12	; 55
+    3f36:	e8 95       	spm
       boot_spm_busy_wait();
-    3f3a:	07 b6       	in	r0, 0x37	; 55
-    3f3c:	00 fc       	sbrc	r0, 0
-    3f3e:	fd cf       	rjmp	.-6      	; 0x3f3a <main+0x13a>
+    3f38:	07 b6       	in	r0, 0x37	; 55
+    3f3a:	00 fc       	sbrc	r0, 0
+    3f3c:	fd cf       	rjmp	.-6      	; 0x3f38 <main+0x138>
 
 #if defined(RWWSRE)
       // Reenable read access to flash
       boot_rww_enable();
-    3f40:	b7 be       	out	0x37, r11	; 55
-    3f42:	e8 95       	spm
-    3f44:	1c c0       	rjmp	.+56     	; 0x3f7e <main+0x17e>
+    3f3e:	b7 be       	out	0x37, r11	; 55
+    3f40:	e8 95       	spm
+    3f42:	1c c0       	rjmp	.+56     	; 0x3f7c <main+0x17c>
 #endif
 
     }
     /* Read memory block mode, length is big endian.  */
     else if(ch == STK_READ_PAGE) {
-    3f46:	84 37       	cpi	r24, 0x74	; 116
-    3f48:	61 f4       	brne	.+24     	; 0x3f62 <main+0x162>
+    3f44:	84 37       	cpi	r24, 0x74	; 116
+    3f46:	61 f4       	brne	.+24     	; 0x3f60 <main+0x160>
       // READ PAGE - we only read flash
       getch();			/* getlen() */
-    3f4a:	24 d0       	rcall	.+72     	; 0x3f94 <getch>
+    3f48:	24 d0       	rcall	.+72     	; 0x3f92 <getch>
       length = getch();
-    3f4c:	23 d0       	rcall	.+70     	; 0x3f94 <getch>
-    3f4e:	08 2f       	mov	r16, r24
+    3f4a:	23 d0       	rcall	.+70     	; 0x3f92 <getch>
+    3f4c:	08 2f       	mov	r16, r24
       getch();
-    3f50:	21 d0       	rcall	.+66     	; 0x3f94 <getch>
+    3f4e:	21 d0       	rcall	.+66     	; 0x3f92 <getch>
 
       verifySpace();
-    3f52:	32 d0       	rcall	.+100    	; 0x3fb8 <verifySpace>
+    3f50:	32 d0       	rcall	.+100    	; 0x3fb6 <verifySpace>
         __asm__ ("elpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #else
         // read a Flash byte and increment the address
         __asm__ ("lpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #endif
         putch(ch);
-    3f54:	f7 01       	movw	r30, r14
-    3f56:	85 91       	lpm	r24, Z+
-    3f58:	7f 01       	movw	r14, r30
-    3f5a:	14 d0       	rcall	.+40     	; 0x3f84 <putch>
+    3f52:	f7 01       	movw	r30, r14
+    3f54:	85 91       	lpm	r24, Z+
+    3f56:	7f 01       	movw	r14, r30
+    3f58:	14 d0       	rcall	.+40     	; 0x3f82 <putch>
       } while (--length);
-    3f5c:	01 50       	subi	r16, 0x01	; 1
-    3f5e:	d1 f7       	brne	.-12     	; 0x3f54 <main+0x154>
-    3f60:	0e c0       	rjmp	.+28     	; 0x3f7e <main+0x17e>
+    3f5a:	01 50       	subi	r16, 0x01	; 1
+    3f5c:	d1 f7       	brne	.-12     	; 0x3f52 <main+0x152>
+    3f5e:	0e c0       	rjmp	.+28     	; 0x3f7c <main+0x17c>
     }
 
     /* Get device signature bytes  */
     else if(ch == STK_READ_SIGN) {
-    3f62:	85 37       	cpi	r24, 0x75	; 117
-    3f64:	39 f4       	brne	.+14     	; 0x3f74 <main+0x174>
+    3f60:	85 37       	cpi	r24, 0x75	; 117
+    3f62:	39 f4       	brne	.+14     	; 0x3f72 <main+0x172>
       // READ SIGN - return what Avrdude wants to hear
       verifySpace();
-    3f66:	28 d0       	rcall	.+80     	; 0x3fb8 <verifySpace>
+    3f64:	28 d0       	rcall	.+80     	; 0x3fb6 <verifySpace>
       putch(SIGNATURE_0);
-    3f68:	8e e1       	ldi	r24, 0x1E	; 30
-    3f6a:	0c d0       	rcall	.+24     	; 0x3f84 <putch>
+    3f66:	8e e1       	ldi	r24, 0x1E	; 30
+    3f68:	0c d0       	rcall	.+24     	; 0x3f82 <putch>
       putch(SIGNATURE_1);
-    3f6c:	84 e9       	ldi	r24, 0x94	; 148
-    3f6e:	0a d0       	rcall	.+20     	; 0x3f84 <putch>
+    3f6a:	84 e9       	ldi	r24, 0x94	; 148
+    3f6c:	0a d0       	rcall	.+20     	; 0x3f82 <putch>
       putch(SIGNATURE_2);
-    3f70:	86 e0       	ldi	r24, 0x06	; 6
-    3f72:	84 cf       	rjmp	.-248    	; 0x3e7c <main+0x7c>
+    3f6e:	86 e0       	ldi	r24, 0x06	; 6
+    3f70:	84 cf       	rjmp	.-248    	; 0x3e7a <main+0x7a>
     }
     else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */
-    3f74:	81 35       	cpi	r24, 0x51	; 81
-    3f76:	11 f4       	brne	.+4      	; 0x3f7c <main+0x17c>
+    3f72:	81 35       	cpi	r24, 0x51	; 81
+    3f74:	11 f4       	brne	.+4      	; 0x3f7a <main+0x17a>
       // Adaboot no-wait mod
       watchdogConfig(WATCHDOG_16MS);
-    3f78:	88 e0       	ldi	r24, 0x08	; 8
-    3f7a:	18 d0       	rcall	.+48     	; 0x3fac <watchdogConfig>
+    3f76:	88 e0       	ldi	r24, 0x08	; 8
+    3f78:	18 d0       	rcall	.+48     	; 0x3faa <watchdogConfig>
       verifySpace();
     }
     else {
       // This covers the response to commands like STK_ENTER_PROGMODE
       verifySpace();
-    3f7c:	1d d0       	rcall	.+58     	; 0x3fb8 <verifySpace>
+    3f7a:	1d d0       	rcall	.+58     	; 0x3fb6 <verifySpace>
     }
     putch(STK_OK);
-    3f7e:	80 e1       	ldi	r24, 0x10	; 16
-    3f80:	01 d0       	rcall	.+2      	; 0x3f84 <putch>
-    3f82:	6e cf       	rjmp	.-292    	; 0x3e60 <main+0x60>
+    3f7c:	80 e1       	ldi	r24, 0x10	; 16
+    3f7e:	01 d0       	rcall	.+2      	; 0x3f82 <putch>
+    3f80:	6f cf       	rjmp	.-290    	; 0x3e60 <main+0x60>
 
-00003f84 <putch>:
+00003f82 <putch>:
   }
 }
 
 void putch(char ch) {
-    3f84:	98 2f       	mov	r25, r24
+    3f82:	98 2f       	mov	r25, r24
 #ifndef SOFT_UART
   while (!(UART_SRA & _BV(UDRE0)));
-    3f86:	80 91 c0 00 	lds	r24, 0x00C0
-    3f8a:	85 ff       	sbrs	r24, 5
-    3f8c:	fc cf       	rjmp	.-8      	; 0x3f86 <putch+0x2>
+    3f84:	80 91 c0 00 	lds	r24, 0x00C0
+    3f88:	85 ff       	sbrs	r24, 5
+    3f8a:	fc cf       	rjmp	.-8      	; 0x3f84 <putch+0x2>
   UART_UDR = ch;
-    3f8e:	90 93 c6 00 	sts	0x00C6, r25
+    3f8c:	90 93 c6 00 	sts	0x00C6, r25
       [uartBit] "I" (UART_TX_BIT)
     :
       "r25"
   );
 #endif
 }
-    3f92:	08 95       	ret
+    3f90:	08 95       	ret
 
-00003f94 <getch>:
+00003f92 <getch>:
       [uartBit] "I" (UART_RX_BIT)
     :
       "r25"
 );
 #else
   while(!(UART_SRA & _BV(RXC0)))
-    3f94:	80 91 c0 00 	lds	r24, 0x00C0
-    3f98:	87 ff       	sbrs	r24, 7
-    3f9a:	fc cf       	rjmp	.-8      	; 0x3f94 <getch>
+    3f92:	80 91 c0 00 	lds	r24, 0x00C0
+    3f96:	87 ff       	sbrs	r24, 7
+    3f98:	fc cf       	rjmp	.-8      	; 0x3f92 <getch>
     ;
   if (!(UART_SRA & _BV(FE0))) {
-    3f9c:	80 91 c0 00 	lds	r24, 0x00C0
-    3fa0:	84 fd       	sbrc	r24, 4
-    3fa2:	01 c0       	rjmp	.+2      	; 0x3fa6 <getch+0x12>
+    3f9a:	80 91 c0 00 	lds	r24, 0x00C0
+    3f9e:	84 fd       	sbrc	r24, 4
+    3fa0:	01 c0       	rjmp	.+2      	; 0x3fa4 <getch+0x12>
 }
 #endif
 
 // Watchdog functions. These are only safe with interrupts turned off.
 void watchdogReset() {
   __asm__ __volatile__ (
-    3fa4:	a8 95       	wdr
+    3fa2:	a8 95       	wdr
        * don't care that an invalid char is returned...)
        */
     watchdogReset();
   }
   
   ch = UART_UDR;
-    3fa6:	80 91 c6 00 	lds	r24, 0x00C6
+    3fa4:	80 91 c6 00 	lds	r24, 0x00C6
   LED_PIN |= _BV(LED);
 #endif
 #endif
 
   return ch;
 }
-    3faa:	08 95       	ret
+    3fa8:	08 95       	ret
 
-00003fac <watchdogConfig>:
+00003faa <watchdogConfig>:
     "wdr\n"
   );
 }
 
 void watchdogConfig(uint8_t x) {
   WDTCSR = _BV(WDCE) | _BV(WDE);
-    3fac:	e0 e6       	ldi	r30, 0x60	; 96
-    3fae:	f0 e0       	ldi	r31, 0x00	; 0
-    3fb0:	98 e1       	ldi	r25, 0x18	; 24
-    3fb2:	90 83       	st	Z, r25
+    3faa:	e0 e6       	ldi	r30, 0x60	; 96
+    3fac:	f0 e0       	ldi	r31, 0x00	; 0
+    3fae:	98 e1       	ldi	r25, 0x18	; 24
+    3fb0:	90 83       	st	Z, r25
   WDTCSR = x;
-    3fb4:	80 83       	st	Z, r24
+    3fb2:	80 83       	st	Z, r24
 }
-    3fb6:	08 95       	ret
+    3fb4:	08 95       	ret
 
-00003fb8 <verifySpace>:
+00003fb6 <verifySpace>:
   do getch(); while (--count);
   verifySpace();
 }
 
 void verifySpace() {
   if (getch() != CRC_EOP) {
-    3fb8:	ed df       	rcall	.-38     	; 0x3f94 <getch>
-    3fba:	80 32       	cpi	r24, 0x20	; 32
-    3fbc:	19 f0       	breq	.+6      	; 0x3fc4 <verifySpace+0xc>
+    3fb6:	ed df       	rcall	.-38     	; 0x3f92 <getch>
+    3fb8:	80 32       	cpi	r24, 0x20	; 32
+    3fba:	19 f0       	breq	.+6      	; 0x3fc2 <verifySpace+0xc>
     watchdogConfig(WATCHDOG_16MS);    // shorten WD timeout
-    3fbe:	88 e0       	ldi	r24, 0x08	; 8
-    3fc0:	f5 df       	rcall	.-22     	; 0x3fac <watchdogConfig>
-    3fc2:	ff cf       	rjmp	.-2      	; 0x3fc2 <verifySpace+0xa>
+    3fbc:	88 e0       	ldi	r24, 0x08	; 8
+    3fbe:	f5 df       	rcall	.-22     	; 0x3faa <watchdogConfig>
+    3fc0:	ff cf       	rjmp	.-2      	; 0x3fc0 <verifySpace+0xa>
     while (1)			      // and busy-loop so that WD causes
       ;				      //  a reset and app start.
   }
   putch(STK_INSYNC);
-    3fc4:	84 e1       	ldi	r24, 0x14	; 20
+    3fc2:	84 e1       	ldi	r24, 0x14	; 20
 }
-    3fc6:	de cf       	rjmp	.-68     	; 0x3f84 <putch>
+    3fc4:	de cf       	rjmp	.-68     	; 0x3f82 <putch>
 
-00003fc8 <getNch>:
+00003fc6 <getNch>:
     ::[count] "M" (UART_B_VALUE)
   );
 }
 #endif
 
 void getNch(uint8_t count) {
-    3fc8:	1f 93       	push	r17
-    3fca:	18 2f       	mov	r17, r24
+    3fc6:	1f 93       	push	r17
+    3fc8:	18 2f       	mov	r17, r24
   do getch(); while (--count);
-    3fcc:	e3 df       	rcall	.-58     	; 0x3f94 <getch>
-    3fce:	11 50       	subi	r17, 0x01	; 1
-    3fd0:	e9 f7       	brne	.-6      	; 0x3fcc <getNch+0x4>
+    3fca:	e3 df       	rcall	.-58     	; 0x3f92 <getch>
+    3fcc:	11 50       	subi	r17, 0x01	; 1
+    3fce:	e9 f7       	brne	.-6      	; 0x3fca <getNch+0x4>
   verifySpace();
-    3fd2:	f2 df       	rcall	.-28     	; 0x3fb8 <verifySpace>
+    3fd0:	f2 df       	rcall	.-28     	; 0x3fb6 <verifySpace>
 }
-    3fd4:	1f 91       	pop	r17
-    3fd6:	08 95       	ret
+    3fd2:	1f 91       	pop	r17
+    3fd4:	08 95       	ret
 
-00003fd8 <appStart>:
+00003fd6 <appStart>:
 
 void appStart(uint8_t rstFlags) {
   // 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" (rstFlags));
-    3fd8:	28 2e       	mov	r2, r24
+    3fd6:	28 2e       	mov	r2, r24
 
   watchdogConfig(WATCHDOG_OFF);
-    3fda:	80 e0       	ldi	r24, 0x00	; 0
-    3fdc:	e7 df       	rcall	.-50     	; 0x3fac <watchdogConfig>
+    3fd8:	80 e0       	ldi	r24, 0x00	; 0
+    3fda:	e7 df       	rcall	.-50     	; 0x3faa <watchdogConfig>
   __asm__ __volatile__ (
-    3fde:	ee 27       	eor	r30, r30
-    3fe0:	ff 27       	eor	r31, r31
-    3fe2:	09 94       	ijmp
+    3fdc:	ee 27       	eor	r30, r30
+    3fde:	ff 27       	eor	r31, r31
+    3fe0:	09 94       	ijmp

+ 28 - 28
optiboot/bootloaders/optiboot/optiboot_pro_8MHz.hex

@@ -1,34 +1,34 @@
-:103E0000112484B714BE81FFE7D085E08093810040
+:103E0000112484B714BE81FFE6D085E08093810041
 :103E100082E08093C00088E18093C10086E08093B7
-:103E2000C20088E08093C4008EE0C0D0259A86E06E
+:103E2000C20088E08093C4008EE0BFD0259A86E06F
 :103E300028E13EEF91E0309385002093840096BB0B
 :103E4000B09BFECF1D9AA8958150A9F7EE24FF24C0
 :103E5000AA24A394B5E0CB2EA1E1BA2EF3E0DF2E85
-:103E600099D0813469F496D0082FA6D0023809F48D
-:103E70007FC0013811F484E001C083E083D07FC0AB
-:103E8000823411F484E103C0853419F485E09CD0B8
-:103E900076C0853579F47ED0E82EFF247BD0082FBC
-:103EA00010E0102F00270E291F29000F111F84D0AA
-:103EB000780165C0863521F484E086D080E0DECFCD
-:103EC000843609F040C066D065D0082F63D080E00A
-:103ED000E81688E3F80618F4F701D7BEE895C0E0C5
-:103EE000D1E058D089930C17E1F7F0E0EF16F8E332
-:103EF000FF0618F0F701D7BEE8955ED007B600FCC4
-:103F0000FDCFA701A0E0B1E02C9130E011968C919B
-:103F1000119790E0982F8827822B932B1296FA0105
-:103F20000C01A7BEE89511244E5F5F4FF1E0A03869
-:103F3000BF0751F7F701C7BEE89507B600FCFDCFF4
-:103F4000B7BEE8951CC0843761F424D023D0082F75
-:103F500021D032D0F70185917F0114D00150D1F7E3
-:103F60000EC0853739F428D08EE10CD084E90AD010
-:103F700086E084CF813511F488E018D01DD080E12F
-:103F800001D06ECF982F8091C00085FFFCCF909319
-:103F9000C60008958091C00087FFFCCF8091C000CB
-:103FA00084FD01C0A8958091C6000895E0E6F0E088
-:103FB00098E1908380830895EDDF803219F088E0E6
-:103FC000F5DFFFCF84E1DECF1F93182FE3DF115021
-:103FD000E9F7F2DF1F910895282E80E0E7DFEE2752
-:043FE000FF2709941A
-:023FFE000604B7
+:103E600098D0813461F495D0082FA5D0023829F17B
+:103E7000013811F485E001C083E083D07FC0823433
+:103E800011F484E103C0853419F485E09CD076C038
+:103E9000853579F47ED0E82EFF247BD0082F10E002
+:103EA000102F00270E291F29000F111F84D0780121
+:103EB00065C0863521F484E086D080E0DECF84368C
+:103EC00009F040C066D065D0082F63D080E0E816C6
+:103ED00088E3F80618F4F701D7BEE895C0E0D1E012
+:103EE00058D089930C17E1F7F0E0EF16F8E3FF06DE
+:103EF00018F0F701D7BEE8955ED007B600FCFDCFFD
+:103F0000A701A0E0B1E02C9130E011968C911197BF
+:103F100090E0982F8827822B932B1296FA010C01A0
+:103F2000A7BEE89511244E5F5F4FF1E0A038BF07B0
+:103F300051F7F701C7BEE89507B600FCFDCFB7BE45
+:103F4000E8951CC0843761F424D023D0082F21D0F9
+:103F500032D0F70185917F0114D00150D1F70EC006
+:103F6000853739F428D08EE10CD084E90AD086E078
+:103F700084CF813511F488E018D01DD080E101D0C4
+:103F80006FCF982F8091C00085FFFCCF9093C60023
+:103F900008958091C00087FFFCCF8091C00084FD10
+:103FA00001C0A8958091C6000895E0E6F0E098E190
+:103FB000908380830895EDDF803219F088E0F5DF8B
+:103FC000FFCF84E1DECF1F93182FE3DF1150E9F715
+:103FD000F2DF1F910895282E80E0E7DFEE27FF270C
+:023FE000099442
+:023FFE000005BC
 :0400000300003E00BB
 :00000001FF

+ 214 - 212
optiboot/bootloaders/optiboot/optiboot_pro_8MHz.lst

@@ -1,29 +1,29 @@
 
-optiboot_pro_8MHz.elf:     file format elf32-avr
+optiboot_atmega168.elf:     file format elf32-avr
 
 Sections:
 Idx Name          Size      VMA       LMA       File off  Algn
-  0 .text         000001e4  00003e00  00003e00  00000054  2**1
+  0 .text         000001e2  00003e00  00003e00  00000054  2**1
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
-  1 .version      00000002  00003ffe  00003ffe  00000238  2**0
+  1 .version      00000002  00003ffe  00003ffe  00000236  2**0
                   CONTENTS, READONLY
-  2 .debug_aranges 00000028  00000000  00000000  0000023a  2**0
+  2 .debug_aranges 00000028  00000000  00000000  00000238  2**0
                   CONTENTS, READONLY, DEBUGGING
-  3 .debug_pubnames 0000005f  00000000  00000000  00000262  2**0
+  3 .debug_pubnames 0000005f  00000000  00000000  00000260  2**0
                   CONTENTS, READONLY, DEBUGGING
-  4 .debug_info   00000294  00000000  00000000  000002c1  2**0
+  4 .debug_info   00000294  00000000  00000000  000002bf  2**0
                   CONTENTS, READONLY, DEBUGGING
-  5 .debug_abbrev 0000016b  00000000  00000000  00000555  2**0
+  5 .debug_abbrev 0000016b  00000000  00000000  00000553  2**0
                   CONTENTS, READONLY, DEBUGGING
-  6 .debug_line   00000468  00000000  00000000  000006c0  2**0
+  6 .debug_line   00000421  00000000  00000000  000006be  2**0
                   CONTENTS, READONLY, DEBUGGING
-  7 .debug_frame  00000080  00000000  00000000  00000b28  2**2
+  7 .debug_frame  00000080  00000000  00000000  00000ae0  2**2
                   CONTENTS, READONLY, DEBUGGING
-  8 .debug_str    00000131  00000000  00000000  00000ba8  2**0
+  8 .debug_str    00000131  00000000  00000000  00000b60  2**0
                   CONTENTS, READONLY, DEBUGGING
-  9 .debug_loc    00000266  00000000  00000000  00000cd9  2**0
+  9 .debug_loc    00000266  00000000  00000000  00000c91  2**0
                   CONTENTS, READONLY, DEBUGGING
- 10 .debug_ranges 00000078  00000000  00000000  00000f3f  2**0
+ 10 .debug_ranges 00000078  00000000  00000000  00000ef7  2**0
                   CONTENTS, READONLY, DEBUGGING
 
 Disassembly of section .text:
@@ -36,7 +36,7 @@ Disassembly of section .text:
 /* main program starts here */
 int main(void) {
     3e00:	11 24       	eor	r1, r1
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__) || defined (__AVR_ATmega32__)
   SP=RAMEND;  // This is done by hardware reset
 #endif
 
@@ -47,7 +47,7 @@ int main(void) {
     3e04:	14 be       	out	0x34, r1	; 52
   if (!(ch & _BV(EXTRF))) appStart(ch);
     3e06:	81 ff       	sbrs	r24, 1
-    3e08:	e7 d0       	rcall	.+462    	; 0x3fd8 <appStart>
+    3e08:	e6 d0       	rcall	.+460    	; 0x3fd6 <appStart>
 
 #if LED_START_FLASHES > 0
   // Set up Timer 1 for timeout counter
@@ -77,8 +77,9 @@ int main(void) {
   // Set up watchdog to trigger after 500ms
   watchdogConfig(WATCHDOG_1S);
     3e28:	8e e0       	ldi	r24, 0x0E	; 14
-    3e2a:	c0 d0       	rcall	.+384    	; 0x3fac <watchdogConfig>
+    3e2a:	bf d0       	rcall	.+382    	; 0x3faa <watchdogConfig>
 
+#if (LED_START_FLASHES > 0) || defined(LED_DATA_FLASH)
   /* Set LED pin as output */
   LED_DDR |= _BV(LED);
     3e2c:	25 9a       	sbi	0x04, 5	; 4
@@ -106,7 +107,7 @@ void flash_led(uint8_t count) {
     while(!(TIFR1 & _BV(TOV1)));
     3e40:	b0 9b       	sbis	0x16, 0	; 22
     3e42:	fe cf       	rjmp	.-4      	; 0x3e40 <main+0x40>
-#ifdef __AVR_ATmega8__
+#if defined(__AVR_ATmega8__)  || defined (__AVR_ATmega32__)
     LED_PORT ^= _BV(LED);
 #else
     LED_PIN |= _BV(LED);
@@ -150,11 +151,11 @@ void watchdogReset() {
       boot_rww_enable();
     3e58:	a1 e1       	ldi	r26, 0x11	; 17
     3e5a:	ba 2e       	mov	r11, r26
-      do *bufPtr++ = getch();
-      while (--length);
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
     3e5c:	f3 e0       	ldi	r31, 0x03	; 3
     3e5e:	df 2e       	mov	r13, r31
@@ -164,421 +165,422 @@ void watchdogReset() {
   for (;;) {
     /* get character from UART */
     ch = getch();
-    3e60:	99 d0       	rcall	.+306    	; 0x3f94 <getch>
+    3e60:	98 d0       	rcall	.+304    	; 0x3f92 <getch>
 
     if(ch == STK_GET_PARAMETER) {
     3e62:	81 34       	cpi	r24, 0x41	; 65
-    3e64:	69 f4       	brne	.+26     	; 0x3e80 <main+0x80>
+    3e64:	61 f4       	brne	.+24     	; 0x3e7e <main+0x7e>
       unsigned char which = getch();
-    3e66:	96 d0       	rcall	.+300    	; 0x3f94 <getch>
+    3e66:	95 d0       	rcall	.+298    	; 0x3f92 <getch>
     3e68:	08 2f       	mov	r16, r24
       verifySpace();
-    3e6a:	a6 d0       	rcall	.+332    	; 0x3fb8 <verifySpace>
+    3e6a:	a5 d0       	rcall	.+330    	; 0x3fb6 <verifySpace>
       if (which == 0x82) {
     3e6c:	02 38       	cpi	r16, 0x82	; 130
-    3e6e:	09 f4       	brne	.+2      	; 0x3e72 <main+0x72>
-    3e70:	7f c0       	rjmp	.+254    	; 0x3f70 <main+0x170>
+    3e6e:	29 f1       	breq	.+74     	; 0x3eba <main+0xba>
 	/*
 	 * Send optiboot version as "minor SW version"
 	 */
 	putch(OPTIBOOT_MINVER);
       } else if (which == 0x81) {
-    3e72:	01 38       	cpi	r16, 0x81	; 129
-    3e74:	11 f4       	brne	.+4      	; 0x3e7a <main+0x7a>
+    3e70:	01 38       	cpi	r16, 0x81	; 129
+    3e72:	11 f4       	brne	.+4      	; 0x3e78 <main+0x78>
 	  putch(OPTIBOOT_MAJVER);
-    3e76:	84 e0       	ldi	r24, 0x04	; 4
-    3e78:	01 c0       	rjmp	.+2      	; 0x3e7c <main+0x7c>
+    3e74:	85 e0       	ldi	r24, 0x05	; 5
+    3e76:	01 c0       	rjmp	.+2      	; 0x3e7a <main+0x7a>
       } else {
 	/*
 	 * GET PARAMETER returns a generic 0x03 reply for
          * other parameters - enough to keep Avrdude happy
 	 */
 	putch(0x03);
-    3e7a:	83 e0       	ldi	r24, 0x03	; 3
-    3e7c:	83 d0       	rcall	.+262    	; 0x3f84 <putch>
-    3e7e:	7f c0       	rjmp	.+254    	; 0x3f7e <main+0x17e>
+    3e78:	83 e0       	ldi	r24, 0x03	; 3
+    3e7a:	83 d0       	rcall	.+262    	; 0x3f82 <putch>
+    3e7c:	7f c0       	rjmp	.+254    	; 0x3f7c <main+0x17c>
       }
     }
     else if(ch == STK_SET_DEVICE) {
-    3e80:	82 34       	cpi	r24, 0x42	; 66
-    3e82:	11 f4       	brne	.+4      	; 0x3e88 <main+0x88>
+    3e7e:	82 34       	cpi	r24, 0x42	; 66
+    3e80:	11 f4       	brne	.+4      	; 0x3e86 <main+0x86>
       // SET DEVICE is ignored
       getNch(20);
-    3e84:	84 e1       	ldi	r24, 0x14	; 20
-    3e86:	03 c0       	rjmp	.+6      	; 0x3e8e <main+0x8e>
+    3e82:	84 e1       	ldi	r24, 0x14	; 20
+    3e84:	03 c0       	rjmp	.+6      	; 0x3e8c <main+0x8c>
     }
     else if(ch == STK_SET_DEVICE_EXT) {
-    3e88:	85 34       	cpi	r24, 0x45	; 69
-    3e8a:	19 f4       	brne	.+6      	; 0x3e92 <main+0x92>
+    3e86:	85 34       	cpi	r24, 0x45	; 69
+    3e88:	19 f4       	brne	.+6      	; 0x3e90 <main+0x90>
       // SET DEVICE EXT is ignored
       getNch(5);
-    3e8c:	85 e0       	ldi	r24, 0x05	; 5
-    3e8e:	9c d0       	rcall	.+312    	; 0x3fc8 <getNch>
-    3e90:	76 c0       	rjmp	.+236    	; 0x3f7e <main+0x17e>
+    3e8a:	85 e0       	ldi	r24, 0x05	; 5
+    3e8c:	9c d0       	rcall	.+312    	; 0x3fc6 <getNch>
+    3e8e:	76 c0       	rjmp	.+236    	; 0x3f7c <main+0x17c>
     }
     else if(ch == STK_LOAD_ADDRESS) {
-    3e92:	85 35       	cpi	r24, 0x55	; 85
-    3e94:	79 f4       	brne	.+30     	; 0x3eb4 <main+0xb4>
+    3e90:	85 35       	cpi	r24, 0x55	; 85
+    3e92:	79 f4       	brne	.+30     	; 0x3eb2 <main+0xb2>
       // LOAD ADDRESS
       uint16_t newAddress;
       newAddress = getch();
-    3e96:	7e d0       	rcall	.+252    	; 0x3f94 <getch>
+    3e94:	7e d0       	rcall	.+252    	; 0x3f92 <getch>
       newAddress = (newAddress & 0xff) | (getch() << 8);
-    3e98:	e8 2e       	mov	r14, r24
-    3e9a:	ff 24       	eor	r15, r15
-    3e9c:	7b d0       	rcall	.+246    	; 0x3f94 <getch>
-    3e9e:	08 2f       	mov	r16, r24
-    3ea0:	10 e0       	ldi	r17, 0x00	; 0
-    3ea2:	10 2f       	mov	r17, r16
-    3ea4:	00 27       	eor	r16, r16
-    3ea6:	0e 29       	or	r16, r14
-    3ea8:	1f 29       	or	r17, r15
+    3e96:	e8 2e       	mov	r14, r24
+    3e98:	ff 24       	eor	r15, r15
+    3e9a:	7b d0       	rcall	.+246    	; 0x3f92 <getch>
+    3e9c:	08 2f       	mov	r16, r24
+    3e9e:	10 e0       	ldi	r17, 0x00	; 0
+    3ea0:	10 2f       	mov	r17, r16
+    3ea2:	00 27       	eor	r16, r16
+    3ea4:	0e 29       	or	r16, r14
+    3ea6:	1f 29       	or	r17, r15
 #ifdef RAMPZ
       // Transfer top bit to RAMPZ
       RAMPZ = (newAddress & 0x8000) ? 1 : 0;
 #endif
       newAddress += newAddress; // Convert from word address to byte address
-    3eaa:	00 0f       	add	r16, r16
-    3eac:	11 1f       	adc	r17, r17
+    3ea8:	00 0f       	add	r16, r16
+    3eaa:	11 1f       	adc	r17, r17
       address = newAddress;
       verifySpace();
-    3eae:	84 d0       	rcall	.+264    	; 0x3fb8 <verifySpace>
-    3eb0:	78 01       	movw	r14, r16
-    3eb2:	65 c0       	rjmp	.+202    	; 0x3f7e <main+0x17e>
+    3eac:	84 d0       	rcall	.+264    	; 0x3fb6 <verifySpace>
+    3eae:	78 01       	movw	r14, r16
+    3eb0:	65 c0       	rjmp	.+202    	; 0x3f7c <main+0x17c>
     }
     else if(ch == STK_UNIVERSAL) {
-    3eb4:	86 35       	cpi	r24, 0x56	; 86
-    3eb6:	21 f4       	brne	.+8      	; 0x3ec0 <main+0xc0>
+    3eb2:	86 35       	cpi	r24, 0x56	; 86
+    3eb4:	21 f4       	brne	.+8      	; 0x3ebe <main+0xbe>
       // UNIVERSAL command is ignored
       getNch(4);
-    3eb8:	84 e0       	ldi	r24, 0x04	; 4
-    3eba:	86 d0       	rcall	.+268    	; 0x3fc8 <getNch>
+    3eb6:	84 e0       	ldi	r24, 0x04	; 4
+    3eb8:	86 d0       	rcall	.+268    	; 0x3fc6 <getNch>
       putch(0x00);
-    3ebc:	80 e0       	ldi	r24, 0x00	; 0
-    3ebe:	de cf       	rjmp	.-68     	; 0x3e7c <main+0x7c>
+    3eba:	80 e0       	ldi	r24, 0x00	; 0
+    3ebc:	de cf       	rjmp	.-68     	; 0x3e7a <main+0x7a>
     }
     /* Write memory, length is big endian and is in bytes */
     else if(ch == STK_PROG_PAGE) {
-    3ec0:	84 36       	cpi	r24, 0x64	; 100
-    3ec2:	09 f0       	breq	.+2      	; 0x3ec6 <main+0xc6>
-    3ec4:	40 c0       	rjmp	.+128    	; 0x3f46 <main+0x146>
+    3ebe:	84 36       	cpi	r24, 0x64	; 100
+    3ec0:	09 f0       	breq	.+2      	; 0x3ec4 <main+0xc4>
+    3ec2:	40 c0       	rjmp	.+128    	; 0x3f44 <main+0x144>
       // PROGRAM PAGE - we support flash programming only, not EEPROM
       uint8_t *bufPtr;
       uint16_t addrPtr;
 
       getch();			/* getlen() */
-    3ec6:	66 d0       	rcall	.+204    	; 0x3f94 <getch>
+    3ec4:	66 d0       	rcall	.+204    	; 0x3f92 <getch>
       length = getch();
-    3ec8:	65 d0       	rcall	.+202    	; 0x3f94 <getch>
-    3eca:	08 2f       	mov	r16, r24
+    3ec6:	65 d0       	rcall	.+202    	; 0x3f92 <getch>
+    3ec8:	08 2f       	mov	r16, r24
       getch();
-    3ecc:	63 d0       	rcall	.+198    	; 0x3f94 <getch>
+    3eca:	63 d0       	rcall	.+198    	; 0x3f92 <getch>
 
       // If we are in RWW section, immediately start page erase
       if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    3ece:	80 e0       	ldi	r24, 0x00	; 0
-    3ed0:	e8 16       	cp	r14, r24
-    3ed2:	88 e3       	ldi	r24, 0x38	; 56
-    3ed4:	f8 06       	cpc	r15, r24
-    3ed6:	18 f4       	brcc	.+6      	; 0x3ede <main+0xde>
-    3ed8:	f7 01       	movw	r30, r14
-    3eda:	d7 be       	out	0x37, r13	; 55
-    3edc:	e8 95       	spm
-    3ede:	c0 e0       	ldi	r28, 0x00	; 0
-    3ee0:	d1 e0       	ldi	r29, 0x01	; 1
+    3ecc:	80 e0       	ldi	r24, 0x00	; 0
+    3ece:	e8 16       	cp	r14, r24
+    3ed0:	88 e3       	ldi	r24, 0x38	; 56
+    3ed2:	f8 06       	cpc	r15, r24
+    3ed4:	18 f4       	brcc	.+6      	; 0x3edc <main+0xdc>
+    3ed6:	f7 01       	movw	r30, r14
+    3ed8:	d7 be       	out	0x37, r13	; 55
+    3eda:	e8 95       	spm
+    3edc:	c0 e0       	ldi	r28, 0x00	; 0
+    3ede:	d1 e0       	ldi	r29, 0x01	; 1
 
       // While that is going on, read in page contents
       bufPtr = buff;
       do *bufPtr++ = getch();
-    3ee2:	58 d0       	rcall	.+176    	; 0x3f94 <getch>
-    3ee4:	89 93       	st	Y+, r24
+    3ee0:	58 d0       	rcall	.+176    	; 0x3f92 <getch>
+    3ee2:	89 93       	st	Y+, r24
       while (--length);
-    3ee6:	0c 17       	cp	r16, r28
-    3ee8:	e1 f7       	brne	.-8      	; 0x3ee2 <main+0xe2>
+    3ee4:	0c 17       	cp	r16, r28
+    3ee6:	e1 f7       	brne	.-8      	; 0x3ee0 <main+0xe0>
 
       // If we are in NRWW section, page erase has to be delayed until now.
-      // Todo: Take RAMPZ into account
+      // Todo: Take RAMPZ into account (not doing so just means that we will
+      //  treat the top of both "pages" of flash as NRWW, for a slight speed
+      //  decrease, so fixing this is not urgent.)
       if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
-    3eea:	f0 e0       	ldi	r31, 0x00	; 0
-    3eec:	ef 16       	cp	r14, r31
-    3eee:	f8 e3       	ldi	r31, 0x38	; 56
-    3ef0:	ff 06       	cpc	r15, r31
-    3ef2:	18 f0       	brcs	.+6      	; 0x3efa <main+0xfa>
-    3ef4:	f7 01       	movw	r30, r14
-    3ef6:	d7 be       	out	0x37, r13	; 55
-    3ef8:	e8 95       	spm
+    3ee8:	f0 e0       	ldi	r31, 0x00	; 0
+    3eea:	ef 16       	cp	r14, r31
+    3eec:	f8 e3       	ldi	r31, 0x38	; 56
+    3eee:	ff 06       	cpc	r15, r31
+    3ef0:	18 f0       	brcs	.+6      	; 0x3ef8 <main+0xf8>
+    3ef2:	f7 01       	movw	r30, r14
+    3ef4:	d7 be       	out	0x37, r13	; 55
+    3ef6:	e8 95       	spm
 
       // Read command terminator, start reply
       verifySpace();
-    3efa:	5e d0       	rcall	.+188    	; 0x3fb8 <verifySpace>
+    3ef8:	5e d0       	rcall	.+188    	; 0x3fb6 <verifySpace>
 
       // If only a partial page is to be programmed, the erase might not be complete.
       // So check that here
       boot_spm_busy_wait();
-    3efc:	07 b6       	in	r0, 0x37	; 55
-    3efe:	00 fc       	sbrc	r0, 0
-    3f00:	fd cf       	rjmp	.-6      	; 0x3efc <main+0xfc>
-    3f02:	a7 01       	movw	r20, r14
-    3f04:	a0 e0       	ldi	r26, 0x00	; 0
-    3f06:	b1 e0       	ldi	r27, 0x01	; 1
+    3efa:	07 b6       	in	r0, 0x37	; 55
+    3efc:	00 fc       	sbrc	r0, 0
+    3efe:	fd cf       	rjmp	.-6      	; 0x3efa <main+0xfa>
+    3f00:	a7 01       	movw	r20, r14
+    3f02:	a0 e0       	ldi	r26, 0x00	; 0
+    3f04:	b1 e0       	ldi	r27, 0x01	; 1
       bufPtr = buff;
       addrPtr = (uint16_t)(void*)address;
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
-    3f08:	2c 91       	ld	r18, X
-    3f0a:	30 e0       	ldi	r19, 0x00	; 0
+    3f06:	2c 91       	ld	r18, X
+    3f08:	30 e0       	ldi	r19, 0x00	; 0
         a |= (*bufPtr++) << 8;
-    3f0c:	11 96       	adiw	r26, 0x01	; 1
-    3f0e:	8c 91       	ld	r24, X
-    3f10:	11 97       	sbiw	r26, 0x01	; 1
-    3f12:	90 e0       	ldi	r25, 0x00	; 0
-    3f14:	98 2f       	mov	r25, r24
-    3f16:	88 27       	eor	r24, r24
-    3f18:	82 2b       	or	r24, r18
-    3f1a:	93 2b       	or	r25, r19
+    3f0a:	11 96       	adiw	r26, 0x01	; 1
+    3f0c:	8c 91       	ld	r24, X
+    3f0e:	11 97       	sbiw	r26, 0x01	; 1
+    3f10:	90 e0       	ldi	r25, 0x00	; 0
+    3f12:	98 2f       	mov	r25, r24
+    3f14:	88 27       	eor	r24, r24
+    3f16:	82 2b       	or	r24, r18
+    3f18:	93 2b       	or	r25, r19
 # define UART_SRL UBRR3L
 # define UART_UDR UDR3
 #endif
 
 /* main program starts here */
 int main(void) {
-    3f1c:	12 96       	adiw	r26, 0x02	; 2
+    3f1a:	12 96       	adiw	r26, 0x02	; 2
       ch = SPM_PAGESIZE / 2;
       do {
         uint16_t a;
         a = *bufPtr++;
         a |= (*bufPtr++) << 8;
         __boot_page_fill_short((uint16_t)(void*)addrPtr,a);
-    3f1e:	fa 01       	movw	r30, r20
-    3f20:	0c 01       	movw	r0, r24
-    3f22:	a7 be       	out	0x37, r10	; 55
-    3f24:	e8 95       	spm
-    3f26:	11 24       	eor	r1, r1
+    3f1c:	fa 01       	movw	r30, r20
+    3f1e:	0c 01       	movw	r0, r24
+    3f20:	a7 be       	out	0x37, r10	; 55
+    3f22:	e8 95       	spm
+    3f24:	11 24       	eor	r1, r1
         addrPtr += 2;
-    3f28:	4e 5f       	subi	r20, 0xFE	; 254
-    3f2a:	5f 4f       	sbci	r21, 0xFF	; 255
+    3f26:	4e 5f       	subi	r20, 0xFE	; 254
+    3f28:	5f 4f       	sbci	r21, 0xFF	; 255
       } while (--ch);
-    3f2c:	f1 e0       	ldi	r31, 0x01	; 1
-    3f2e:	a0 38       	cpi	r26, 0x80	; 128
-    3f30:	bf 07       	cpc	r27, r31
-    3f32:	51 f7       	brne	.-44     	; 0x3f08 <main+0x108>
+    3f2a:	f1 e0       	ldi	r31, 0x01	; 1
+    3f2c:	a0 38       	cpi	r26, 0x80	; 128
+    3f2e:	bf 07       	cpc	r27, r31
+    3f30:	51 f7       	brne	.-44     	; 0x3f06 <main+0x106>
 
       // Write from programming buffer
       __boot_page_write_short((uint16_t)(void*)address);
-    3f34:	f7 01       	movw	r30, r14
-    3f36:	c7 be       	out	0x37, r12	; 55
-    3f38:	e8 95       	spm
+    3f32:	f7 01       	movw	r30, r14
+    3f34:	c7 be       	out	0x37, r12	; 55
+    3f36:	e8 95       	spm
       boot_spm_busy_wait();
-    3f3a:	07 b6       	in	r0, 0x37	; 55
-    3f3c:	00 fc       	sbrc	r0, 0
-    3f3e:	fd cf       	rjmp	.-6      	; 0x3f3a <main+0x13a>
+    3f38:	07 b6       	in	r0, 0x37	; 55
+    3f3a:	00 fc       	sbrc	r0, 0
+    3f3c:	fd cf       	rjmp	.-6      	; 0x3f38 <main+0x138>
 
 #if defined(RWWSRE)
       // Reenable read access to flash
       boot_rww_enable();
-    3f40:	b7 be       	out	0x37, r11	; 55
-    3f42:	e8 95       	spm
-    3f44:	1c c0       	rjmp	.+56     	; 0x3f7e <main+0x17e>
+    3f3e:	b7 be       	out	0x37, r11	; 55
+    3f40:	e8 95       	spm
+    3f42:	1c c0       	rjmp	.+56     	; 0x3f7c <main+0x17c>
 #endif
 
     }
     /* Read memory block mode, length is big endian.  */
     else if(ch == STK_READ_PAGE) {
-    3f46:	84 37       	cpi	r24, 0x74	; 116
-    3f48:	61 f4       	brne	.+24     	; 0x3f62 <main+0x162>
+    3f44:	84 37       	cpi	r24, 0x74	; 116
+    3f46:	61 f4       	brne	.+24     	; 0x3f60 <main+0x160>
       // READ PAGE - we only read flash
       getch();			/* getlen() */
-    3f4a:	24 d0       	rcall	.+72     	; 0x3f94 <getch>
+    3f48:	24 d0       	rcall	.+72     	; 0x3f92 <getch>
       length = getch();
-    3f4c:	23 d0       	rcall	.+70     	; 0x3f94 <getch>
-    3f4e:	08 2f       	mov	r16, r24
+    3f4a:	23 d0       	rcall	.+70     	; 0x3f92 <getch>
+    3f4c:	08 2f       	mov	r16, r24
       getch();
-    3f50:	21 d0       	rcall	.+66     	; 0x3f94 <getch>
+    3f4e:	21 d0       	rcall	.+66     	; 0x3f92 <getch>
 
       verifySpace();
-    3f52:	32 d0       	rcall	.+100    	; 0x3fb8 <verifySpace>
+    3f50:	32 d0       	rcall	.+100    	; 0x3fb6 <verifySpace>
         __asm__ ("elpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #else
         // read a Flash byte and increment the address
         __asm__ ("lpm %0,Z+\n" : "=r" (ch), "=z" (address): "1" (address));
 #endif
         putch(ch);
-    3f54:	f7 01       	movw	r30, r14
-    3f56:	85 91       	lpm	r24, Z+
-    3f58:	7f 01       	movw	r14, r30
-    3f5a:	14 d0       	rcall	.+40     	; 0x3f84 <putch>
+    3f52:	f7 01       	movw	r30, r14
+    3f54:	85 91       	lpm	r24, Z+
+    3f56:	7f 01       	movw	r14, r30
+    3f58:	14 d0       	rcall	.+40     	; 0x3f82 <putch>
       } while (--length);
-    3f5c:	01 50       	subi	r16, 0x01	; 1
-    3f5e:	d1 f7       	brne	.-12     	; 0x3f54 <main+0x154>
-    3f60:	0e c0       	rjmp	.+28     	; 0x3f7e <main+0x17e>
+    3f5a:	01 50       	subi	r16, 0x01	; 1
+    3f5c:	d1 f7       	brne	.-12     	; 0x3f52 <main+0x152>
+    3f5e:	0e c0       	rjmp	.+28     	; 0x3f7c <main+0x17c>
     }
 
     /* Get device signature bytes  */
     else if(ch == STK_READ_SIGN) {
-    3f62:	85 37       	cpi	r24, 0x75	; 117
-    3f64:	39 f4       	brne	.+14     	; 0x3f74 <main+0x174>
+    3f60:	85 37       	cpi	r24, 0x75	; 117
+    3f62:	39 f4       	brne	.+14     	; 0x3f72 <main+0x172>
       // READ SIGN - return what Avrdude wants to hear
       verifySpace();
-    3f66:	28 d0       	rcall	.+80     	; 0x3fb8 <verifySpace>
+    3f64:	28 d0       	rcall	.+80     	; 0x3fb6 <verifySpace>
       putch(SIGNATURE_0);
-    3f68:	8e e1       	ldi	r24, 0x1E	; 30
-    3f6a:	0c d0       	rcall	.+24     	; 0x3f84 <putch>
+    3f66:	8e e1       	ldi	r24, 0x1E	; 30
+    3f68:	0c d0       	rcall	.+24     	; 0x3f82 <putch>
       putch(SIGNATURE_1);
-    3f6c:	84 e9       	ldi	r24, 0x94	; 148
-    3f6e:	0a d0       	rcall	.+20     	; 0x3f84 <putch>
+    3f6a:	84 e9       	ldi	r24, 0x94	; 148
+    3f6c:	0a d0       	rcall	.+20     	; 0x3f82 <putch>
       putch(SIGNATURE_2);
-    3f70:	86 e0       	ldi	r24, 0x06	; 6
-    3f72:	84 cf       	rjmp	.-248    	; 0x3e7c <main+0x7c>
+    3f6e:	86 e0       	ldi	r24, 0x06	; 6
+    3f70:	84 cf       	rjmp	.-248    	; 0x3e7a <main+0x7a>
     }
     else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */
-    3f74:	81 35       	cpi	r24, 0x51	; 81
-    3f76:	11 f4       	brne	.+4      	; 0x3f7c <main+0x17c>
+    3f72:	81 35       	cpi	r24, 0x51	; 81
+    3f74:	11 f4       	brne	.+4      	; 0x3f7a <main+0x17a>
       // Adaboot no-wait mod
       watchdogConfig(WATCHDOG_16MS);
-    3f78:	88 e0       	ldi	r24, 0x08	; 8
-    3f7a:	18 d0       	rcall	.+48     	; 0x3fac <watchdogConfig>
+    3f76:	88 e0       	ldi	r24, 0x08	; 8
+    3f78:	18 d0       	rcall	.+48     	; 0x3faa <watchdogConfig>
       verifySpace();
     }
     else {
       // This covers the response to commands like STK_ENTER_PROGMODE
       verifySpace();
-    3f7c:	1d d0       	rcall	.+58     	; 0x3fb8 <verifySpace>
+    3f7a:	1d d0       	rcall	.+58     	; 0x3fb6 <verifySpace>
     }
     putch(STK_OK);
-    3f7e:	80 e1       	ldi	r24, 0x10	; 16
-    3f80:	01 d0       	rcall	.+2      	; 0x3f84 <putch>
-    3f82:	6e cf       	rjmp	.-292    	; 0x3e60 <main+0x60>
+    3f7c:	80 e1       	ldi	r24, 0x10	; 16
+    3f7e:	01 d0       	rcall	.+2      	; 0x3f82 <putch>
+    3f80:	6f cf       	rjmp	.-290    	; 0x3e60 <main+0x60>
 
-00003f84 <putch>:
+00003f82 <putch>:
   }
 }
 
 void putch(char ch) {
-    3f84:	98 2f       	mov	r25, r24
+    3f82:	98 2f       	mov	r25, r24
 #ifndef SOFT_UART
   while (!(UART_SRA & _BV(UDRE0)));
-    3f86:	80 91 c0 00 	lds	r24, 0x00C0
-    3f8a:	85 ff       	sbrs	r24, 5
-    3f8c:	fc cf       	rjmp	.-8      	; 0x3f86 <putch+0x2>
+    3f84:	80 91 c0 00 	lds	r24, 0x00C0
+    3f88:	85 ff       	sbrs	r24, 5
+    3f8a:	fc cf       	rjmp	.-8      	; 0x3f84 <putch+0x2>
   UART_UDR = ch;
-    3f8e:	90 93 c6 00 	sts	0x00C6, r25
+    3f8c:	90 93 c6 00 	sts	0x00C6, r25
       [uartBit] "I" (UART_TX_BIT)
     :
       "r25"
   );
 #endif
 }
-    3f92:	08 95       	ret
+    3f90:	08 95       	ret
 
-00003f94 <getch>:
+00003f92 <getch>:
       [uartBit] "I" (UART_RX_BIT)
     :
       "r25"
 );
 #else
   while(!(UART_SRA & _BV(RXC0)))
-    3f94:	80 91 c0 00 	lds	r24, 0x00C0
-    3f98:	87 ff       	sbrs	r24, 7
-    3f9a:	fc cf       	rjmp	.-8      	; 0x3f94 <getch>
+    3f92:	80 91 c0 00 	lds	r24, 0x00C0
+    3f96:	87 ff       	sbrs	r24, 7
+    3f98:	fc cf       	rjmp	.-8      	; 0x3f92 <getch>
     ;
   if (!(UART_SRA & _BV(FE0))) {
-    3f9c:	80 91 c0 00 	lds	r24, 0x00C0
-    3fa0:	84 fd       	sbrc	r24, 4
-    3fa2:	01 c0       	rjmp	.+2      	; 0x3fa6 <getch+0x12>
+    3f9a:	80 91 c0 00 	lds	r24, 0x00C0
+    3f9e:	84 fd       	sbrc	r24, 4
+    3fa0:	01 c0       	rjmp	.+2      	; 0x3fa4 <getch+0x12>
 }
 #endif
 
 // Watchdog functions. These are only safe with interrupts turned off.
 void watchdogReset() {
   __asm__ __volatile__ (
-    3fa4:	a8 95       	wdr
+    3fa2:	a8 95       	wdr
        * don't care that an invalid char is returned...)
        */
     watchdogReset();
   }
   
   ch = UART_UDR;
-    3fa6:	80 91 c6 00 	lds	r24, 0x00C6
+    3fa4:	80 91 c6 00 	lds	r24, 0x00C6
   LED_PIN |= _BV(LED);
 #endif
 #endif
 
   return ch;
 }
-    3faa:	08 95       	ret
+    3fa8:	08 95       	ret
 
-00003fac <watchdogConfig>:
+00003faa <watchdogConfig>:
     "wdr\n"
   );
 }
 
 void watchdogConfig(uint8_t x) {
   WDTCSR = _BV(WDCE) | _BV(WDE);
-    3fac:	e0 e6       	ldi	r30, 0x60	; 96
-    3fae:	f0 e0       	ldi	r31, 0x00	; 0
-    3fb0:	98 e1       	ldi	r25, 0x18	; 24
-    3fb2:	90 83       	st	Z, r25
+    3faa:	e0 e6       	ldi	r30, 0x60	; 96
+    3fac:	f0 e0       	ldi	r31, 0x00	; 0
+    3fae:	98 e1       	ldi	r25, 0x18	; 24
+    3fb0:	90 83       	st	Z, r25
   WDTCSR = x;
-    3fb4:	80 83       	st	Z, r24
+    3fb2:	80 83       	st	Z, r24
 }
-    3fb6:	08 95       	ret
+    3fb4:	08 95       	ret
 
-00003fb8 <verifySpace>:
+00003fb6 <verifySpace>:
   do getch(); while (--count);
   verifySpace();
 }
 
 void verifySpace() {
   if (getch() != CRC_EOP) {
-    3fb8:	ed df       	rcall	.-38     	; 0x3f94 <getch>
-    3fba:	80 32       	cpi	r24, 0x20	; 32
-    3fbc:	19 f0       	breq	.+6      	; 0x3fc4 <verifySpace+0xc>
+    3fb6:	ed df       	rcall	.-38     	; 0x3f92 <getch>
+    3fb8:	80 32       	cpi	r24, 0x20	; 32
+    3fba:	19 f0       	breq	.+6      	; 0x3fc2 <verifySpace+0xc>
     watchdogConfig(WATCHDOG_16MS);    // shorten WD timeout
-    3fbe:	88 e0       	ldi	r24, 0x08	; 8
-    3fc0:	f5 df       	rcall	.-22     	; 0x3fac <watchdogConfig>
-    3fc2:	ff cf       	rjmp	.-2      	; 0x3fc2 <verifySpace+0xa>
+    3fbc:	88 e0       	ldi	r24, 0x08	; 8
+    3fbe:	f5 df       	rcall	.-22     	; 0x3faa <watchdogConfig>
+    3fc0:	ff cf       	rjmp	.-2      	; 0x3fc0 <verifySpace+0xa>
     while (1)			      // and busy-loop so that WD causes
       ;				      //  a reset and app start.
   }
   putch(STK_INSYNC);
-    3fc4:	84 e1       	ldi	r24, 0x14	; 20
+    3fc2:	84 e1       	ldi	r24, 0x14	; 20
 }
-    3fc6:	de cf       	rjmp	.-68     	; 0x3f84 <putch>
+    3fc4:	de cf       	rjmp	.-68     	; 0x3f82 <putch>
 
-00003fc8 <getNch>:
+00003fc6 <getNch>:
     ::[count] "M" (UART_B_VALUE)
   );
 }
 #endif
 
 void getNch(uint8_t count) {
-    3fc8:	1f 93       	push	r17
-    3fca:	18 2f       	mov	r17, r24
+    3fc6:	1f 93       	push	r17
+    3fc8:	18 2f       	mov	r17, r24
   do getch(); while (--count);
-    3fcc:	e3 df       	rcall	.-58     	; 0x3f94 <getch>
-    3fce:	11 50       	subi	r17, 0x01	; 1
-    3fd0:	e9 f7       	brne	.-6      	; 0x3fcc <getNch+0x4>
+    3fca:	e3 df       	rcall	.-58     	; 0x3f92 <getch>
+    3fcc:	11 50       	subi	r17, 0x01	; 1
+    3fce:	e9 f7       	brne	.-6      	; 0x3fca <getNch+0x4>
   verifySpace();
-    3fd2:	f2 df       	rcall	.-28     	; 0x3fb8 <verifySpace>
+    3fd0:	f2 df       	rcall	.-28     	; 0x3fb6 <verifySpace>
 }
-    3fd4:	1f 91       	pop	r17
-    3fd6:	08 95       	ret
+    3fd2:	1f 91       	pop	r17
+    3fd4:	08 95       	ret
 
-00003fd8 <appStart>:
+00003fd6 <appStart>:
 
 void appStart(uint8_t rstFlags) {
   // 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" (rstFlags));
-    3fd8:	28 2e       	mov	r2, r24
+    3fd6:	28 2e       	mov	r2, r24
 
   watchdogConfig(WATCHDOG_OFF);
-    3fda:	80 e0       	ldi	r24, 0x00	; 0
-    3fdc:	e7 df       	rcall	.-50     	; 0x3fac <watchdogConfig>
+    3fd8:	80 e0       	ldi	r24, 0x00	; 0
+    3fda:	e7 df       	rcall	.-50     	; 0x3faa <watchdogConfig>
   __asm__ __volatile__ (
-    3fde:	ee 27       	eor	r30, r30
-    3fe0:	ff 27       	eor	r31, r31
-    3fe2:	09 94       	ijmp
+    3fdc:	ee 27       	eor	r30, r30
+    3fde:	ff 27       	eor	r31, r31
+    3fe0:	09 94       	ijmp