From bac72096b31cb5f7b063c3ae00dca237376995b5 Mon Sep 17 00:00:00 2001 From: WestfW Date: Thu, 9 Jun 2011 22:36:05 -0700 Subject: Makefile modification to allow building optiboot in more environments. Allows building within the Arduino Source tree, and within the Arduino IDE tree, as well as using CrossPack on Mac. Adds README.TXT to track arduino-specific changes (and documents the new build options.) This addresses Arduino issue: http://code.google.com/p/arduino/issues/detail?id=487 And optiboot issue http://code.google.com/p/optiboot/issues/detail?id=1 (which can be thought of as a subset of the Arduno issue.) Note that the binaries produced after these Makefile changes (using any of the compile environments) are identical to those produced by the crosspack-20100115 environment on a Mac. --- bootloaders/optiboot/optiboot_atmega328.lst | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'bootloaders/optiboot/optiboot_atmega328.lst') diff --git a/bootloaders/optiboot/optiboot_atmega328.lst b/bootloaders/optiboot/optiboot_atmega328.lst index dd879dc..104799f 100644 --- a/bootloaders/optiboot/optiboot_atmega328.lst +++ b/bootloaders/optiboot/optiboot_atmega328.lst @@ -13,15 +13,15 @@ Idx Name Size VMA LMA File off Algn CONTENTS, READONLY, DEBUGGING 4 .debug_abbrev 00000196 00000000 00000000 0000053d 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_line 000003db 00000000 00000000 000006d3 2**0 + 5 .debug_line 0000043f 00000000 00000000 000006d3 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_frame 00000090 00000000 00000000 00000ab0 2**2 + 6 .debug_frame 00000090 00000000 00000000 00000b14 2**2 CONTENTS, READONLY, DEBUGGING - 7 .debug_str 00000124 00000000 00000000 00000b40 2**0 + 7 .debug_str 00000136 00000000 00000000 00000ba4 2**0 CONTENTS, READONLY, DEBUGGING - 8 .debug_loc 000001d1 00000000 00000000 00000c64 2**0 + 8 .debug_loc 000001d1 00000000 00000000 00000cda 2**0 CONTENTS, READONLY, DEBUGGING - 9 .debug_ranges 00000068 00000000 00000000 00000e35 2**0 + 9 .debug_ranges 00000068 00000000 00000000 00000eab 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: @@ -153,7 +153,7 @@ void watchdogReset() { // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy getNch(1); 7e5e: 81 e0 ldi r24, 0x01 ; 1 - 7e60: be d0 rcall .+380 ; 0x7fde + 7e60: be d0 rcall .+380 ; 0x7fde putch(0x03); 7e62: 83 e0 ldi r24, 0x03 ; 3 7e64: 24 c0 rjmp .+72 ; 0x7eae @@ -172,7 +172,7 @@ void watchdogReset() { // SET DEVICE EXT is ignored getNch(5); 7e72: 85 e0 ldi r24, 0x05 ; 5 - 7e74: b4 d0 rcall .+360 ; 0x7fde + 7e74: b4 d0 rcall .+360 ; 0x7fde 7e76: 8a c0 rjmp .+276 ; 0x7f8c } else if(ch == STK_LOAD_ADDRESS) { @@ -206,7 +206,7 @@ void watchdogReset() { // UNIVERSAL command is ignored getNch(4); 7ea8: 84 e0 ldi r24, 0x04 ; 4 - 7eaa: 99 d0 rcall .+306 ; 0x7fde + 7eaa: 99 d0 rcall .+306 ; 0x7fde putch(0x00); 7eac: 80 e0 ldi r24, 0x00 ; 0 7eae: 71 d0 rcall .+226 ; 0x7f92 @@ -503,6 +503,8 @@ void verifySpace() { 7fda: 84 e1 ldi r24, 0x14 ; 20 } 7fdc: da cf rjmp .-76 ; 0x7f92 + +00007fde : ::[count] "M" (UART_B_VALUE) ); } @@ -511,12 +513,10 @@ void verifySpace() { void getNch(uint8_t count) { 7fde: 1f 93 push r17 7fe0: 18 2f mov r17, r24 - -00007fe2 : do getch(); while (--count); 7fe2: df df rcall .-66 ; 0x7fa2 7fe4: 11 50 subi r17, 0x01 ; 1 - 7fe6: e9 f7 brne .-6 ; 0x7fe2 + 7fe6: e9 f7 brne .-6 ; 0x7fe2 verifySpace(); 7fe8: f4 df rcall .-24 ; 0x7fd2 } -- cgit v1.2.3-18-g5258 From 4f44d2893a506ee3924785c91a5f8983c013150c Mon Sep 17 00:00:00 2001 From: WestfW Date: Fri, 10 Jun 2011 16:17:13 -0700 Subject: This is a relatively significant edit that brings the Arduino copy of optiboot up-to-date with the optiboot source repository as of Jun-2011 (the last changes made in the optiboot repository were in Oct-2010) This adds support for several plaforms, fixes the "30k bug", and refactors the source to have separate stk500.h, boot.h, and pin_defs.h These are the arduino opticode issues fixed: http://code.google.com/p/arduino/issues/detail?id=380 optiboot has problems upload sketches bigger than 30 KB http://code.google.com/p/arduino/issues/detail?id=556 update optiboot to the point of the latest optiboot project sources. These are issues that had been solved in the optiboot source aready: http://code.google.com/p/arduino/issues/detail?id=364 optiboot leaves timer1 configured when starting app, breaks PWM on pin 9 and 10. (fixed with a workaround in arduino core.) aka http://code.google.com/p/optiboot/source/detail?r=c778fbe72df6ac13ef730c25283358c3c970f73e Support for ATmega8 and mega88. Fix fuse settings for mega168 _ISP targets Additional new platforms (mega, sanguino) http://code.google.com/p/optiboot/issues/detail?id=26 Set R1 to 0 (already in arduino code) http://code.google.com/p/optiboot/issues/detail?id=36&can=1 Fails to build correctly for mega88 After this commit, the only differences between the Arduino optiboot.c and the optiboot repository optiboot.c are cosmetic. --- bootloaders/optiboot/optiboot_atmega328.lst | 486 +++++++++++++++------------- 1 file changed, 258 insertions(+), 228 deletions(-) (limited to 'bootloaders/optiboot/optiboot_atmega328.lst') diff --git a/bootloaders/optiboot/optiboot_atmega328.lst b/bootloaders/optiboot/optiboot_atmega328.lst index 104799f..1af4a3c 100644 --- a/bootloaders/optiboot/optiboot_atmega328.lst +++ b/bootloaders/optiboot/optiboot_atmega328.lst @@ -3,74 +3,79 @@ optiboot_atmega328.elf: file format elf32-avr Sections: Idx Name Size VMA LMA File off Algn - 0 .text 000001ee 00007e00 00007e00 00000054 2**1 + 0 .text 000001fc 00007e00 00007e00 00000054 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE - 1 .debug_aranges 00000028 00000000 00000000 00000242 2**0 + 1 .debug_aranges 00000028 00000000 00000000 00000250 2**0 CONTENTS, READONLY, DEBUGGING - 2 .debug_pubnames 0000006a 00000000 00000000 0000026a 2**0 + 2 .debug_pubnames 0000006a 00000000 00000000 00000278 2**0 CONTENTS, READONLY, DEBUGGING - 3 .debug_info 00000269 00000000 00000000 000002d4 2**0 + 3 .debug_info 00000284 00000000 00000000 000002e2 2**0 CONTENTS, READONLY, DEBUGGING - 4 .debug_abbrev 00000196 00000000 00000000 0000053d 2**0 + 4 .debug_abbrev 000001ae 00000000 00000000 00000566 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_line 0000043f 00000000 00000000 000006d3 2**0 + 5 .debug_line 00000450 00000000 00000000 00000714 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_frame 00000090 00000000 00000000 00000b14 2**2 + 6 .debug_frame 00000090 00000000 00000000 00000b64 2**2 CONTENTS, READONLY, DEBUGGING - 7 .debug_str 00000136 00000000 00000000 00000ba4 2**0 + 7 .debug_str 00000141 00000000 00000000 00000bf4 2**0 CONTENTS, READONLY, DEBUGGING - 8 .debug_loc 000001d1 00000000 00000000 00000cda 2**0 + 8 .debug_loc 000001e1 00000000 00000000 00000d35 2**0 CONTENTS, READONLY, DEBUGGING - 9 .debug_ranges 00000068 00000000 00000000 00000eab 2**0 + 9 .debug_ranges 00000068 00000000 00000000 00000f16 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: 00007e00
: -#ifdef VIRTUAL_BOOT_PARTITION -#define rstVect (*(uint16_t*)(0x204)) -#define wdtVect (*(uint16_t*)(0x206)) +#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) { 7e00: 11 24 eor r1, r1 +#ifdef __AVR_ATmega8__ + SP=RAMEND; // This is done by hardware reset +#endif - uint8_t ch; + // Adaboot no-wait mod + ch = MCUSR; + 7e02: 84 b7 in r24, 0x34 ; 52 + MCUSR = 0; + 7e04: 14 be out 0x34, r1 ; 52 + if (!(ch & _BV(EXTRF))) appStart(); + 7e06: 81 ff sbrs r24, 1 + 7e08: e6 d0 rcall .+460 ; 0x7fd6 #if LED_START_FLASHES > 0 // Set up Timer 1 for timeout counter TCCR1B = _BV(CS12) | _BV(CS10); // div 1024 - 7e02: 85 e0 ldi r24, 0x05 ; 5 - 7e04: 80 93 81 00 sts 0x0081, r24 -#endif -#ifndef SOFT_UART + 7e0a: 85 e0 ldi r24, 0x05 ; 5 + 7e0c: 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 UCSR0A = _BV(U2X0); //Double speed mode USART0 - 7e08: 82 e0 ldi r24, 0x02 ; 2 - 7e0a: 80 93 c0 00 sts 0x00C0, r24 + 7e10: 82 e0 ldi r24, 0x02 ; 2 + 7e12: 80 93 c0 00 sts 0x00C0, r24 UCSR0B = _BV(RXEN0) | _BV(TXEN0); - 7e0e: 88 e1 ldi r24, 0x18 ; 24 - 7e10: 80 93 c1 00 sts 0x00C1, r24 + 7e16: 88 e1 ldi r24, 0x18 ; 24 + 7e18: 80 93 c1 00 sts 0x00C1, r24 UCSR0C = _BV(UCSZ00) | _BV(UCSZ01); - 7e14: 86 e0 ldi r24, 0x06 ; 6 - 7e16: 80 93 c2 00 sts 0x00C2, r24 + 7e1c: 86 e0 ldi r24, 0x06 ; 6 + 7e1e: 80 93 c2 00 sts 0x00C2, r24 UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); - 7e1a: 80 e1 ldi r24, 0x10 ; 16 - 7e1c: 80 93 c4 00 sts 0x00C4, r24 + 7e22: 80 e1 ldi r24, 0x10 ; 16 + 7e24: 80 93 c4 00 sts 0x00C4, r24 +#endif #endif - - // Adaboot no-wait mod - ch = MCUSR; - 7e20: 84 b7 in r24, 0x34 ; 52 - MCUSR = 0; - 7e22: 14 be out 0x34, r1 ; 52 - if (!(ch & _BV(EXTRF))) appStart(); - 7e24: 81 ff sbrs r24, 1 - 7e26: d0 d0 rcall .+416 ; 0x7fc8 // Set up watchdog to trigger after 500ms - watchdogConfig(WATCHDOG_500MS); - 7e28: 8d e0 ldi r24, 0x0D ; 13 - 7e2a: c8 d0 rcall .+400 ; 0x7fbc + watchdogConfig(WATCHDOG_1S); + 7e28: 8e e0 ldi r24, 0x0E ; 14 + 7e2a: cf d0 rcall .+414 ; 0x7fca /* Set LED pin as output */ LED_DDR |= _BV(LED); @@ -99,6 +104,9 @@ void flash_led(uint8_t count) { while(!(TIFR1 & _BV(TOV1))); 7e40: b0 9b sbis 0x16, 0 ; 22 7e42: fe cf rjmp .-4 ; 0x7e40 +#ifdef __AVR_ATmega8__ + LED_PORT ^= _BV(LED); +#else LED_PIN |= _BV(LED); 7e44: 1d 9a sbi 0x03, 5 ; 3 return getch(); @@ -108,10 +116,10 @@ void flash_led(uint8_t count) { void watchdogReset() { __asm__ __volatile__ ( 7e46: a8 95 wdr - TCNT1 = -(F_CPU/(1024*16)); - TIFR1 = _BV(TOV1); - while(!(TIFR1 & _BV(TOV1))); + LED_PORT ^= _BV(LED); +#else LED_PIN |= _BV(LED); +#endif watchdogReset(); } while (--count); 7e48: 81 50 subi r24, 0x01 ; 1 @@ -124,12 +132,12 @@ void watchdogReset() { getNch(1); 7e4c: dd 24 eor r13, r13 7e4e: d3 94 inc r13 - boot_page_fill((uint16_t)(void*)addrPtr,a); + __boot_page_fill_short((uint16_t)(void*)addrPtr,a); addrPtr += 2; } while (--ch); // Write from programming buffer - boot_page_write((uint16_t)(void*)address); + __boot_page_write_short((uint16_t)(void*)address); 7e50: a5 e0 ldi r26, 0x05 ; 5 7e52: ea 2e mov r14, r26 boot_spm_busy_wait(); @@ -145,7 +153,7 @@ void watchdogReset() { for (;;) { /* get character from UART */ ch = getch(); - 7e58: a4 d0 rcall .+328 ; 0x7fa2 + 7e58: ab d0 rcall .+342 ; 0x7fb0 if(ch == STK_GET_PARAMETER) { 7e5a: 81 34 cpi r24, 0x41 ; 65 @@ -153,10 +161,10 @@ void watchdogReset() { // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy getNch(1); 7e5e: 81 e0 ldi r24, 0x01 ; 1 - 7e60: be d0 rcall .+380 ; 0x7fde + 7e60: c5 d0 rcall .+394 ; 0x7fec putch(0x03); 7e62: 83 e0 ldi r24, 0x03 ; 3 - 7e64: 24 c0 rjmp .+72 ; 0x7eae + 7e64: 20 c0 rjmp .+64 ; 0x7ea6 } else if(ch == STK_SET_DEVICE) { 7e66: 82 34 cpi r24, 0x42 ; 66 @@ -172,353 +180,375 @@ void watchdogReset() { // SET DEVICE EXT is ignored getNch(5); 7e72: 85 e0 ldi r24, 0x05 ; 5 - 7e74: b4 d0 rcall .+360 ; 0x7fde - 7e76: 8a c0 rjmp .+276 ; 0x7f8c + 7e74: bb d0 rcall .+374 ; 0x7fec + 7e76: 91 c0 rjmp .+290 ; 0x7f9a } else if(ch == STK_LOAD_ADDRESS) { 7e78: 85 35 cpi r24, 0x55 ; 85 - 7e7a: a1 f4 brne .+40 ; 0x7ea4 + 7e7a: 81 f4 brne .+32 ; 0x7e9c // LOAD ADDRESS - address = getch(); - 7e7c: 92 d0 rcall .+292 ; 0x7fa2 + uint16_t newAddress; + newAddress = getch(); + 7e7c: 99 d0 rcall .+306 ; 0x7fb0 + newAddress = (newAddress & 0xff) | (getch() << 8); 7e7e: 08 2f mov r16, r24 7e80: 10 e0 ldi r17, 0x00 ; 0 - 7e82: 10 93 01 02 sts 0x0201, r17 - 7e86: 00 93 00 02 sts 0x0200, r16 - address = (address & 0xff) | (getch() << 8); - 7e8a: 8b d0 rcall .+278 ; 0x7fa2 - 7e8c: 90 e0 ldi r25, 0x00 ; 0 - 7e8e: 98 2f mov r25, r24 - 7e90: 88 27 eor r24, r24 - 7e92: 80 2b or r24, r16 - 7e94: 91 2b or r25, r17 - address += address; // Convert from word address to byte address - 7e96: 88 0f add r24, r24 - 7e98: 99 1f adc r25, r25 - 7e9a: 90 93 01 02 sts 0x0201, r25 - 7e9e: 80 93 00 02 sts 0x0200, r24 - 7ea2: 73 c0 rjmp .+230 ; 0x7f8a + 7e82: 96 d0 rcall .+300 ; 0x7fb0 + 7e84: 90 e0 ldi r25, 0x00 ; 0 + 7e86: 98 2f mov r25, r24 + 7e88: 88 27 eor r24, r24 + 7e8a: 80 2b or r24, r16 + 7e8c: 91 2b or r25, r17 +#ifdef RAMPZ + // Transfer top bit to RAMPZ + RAMPZ = (newAddress & 0x8000) ? 1 : 0; +#endif + newAddress += newAddress; // Convert from word address to byte address + 7e8e: 88 0f add r24, r24 + 7e90: 99 1f adc r25, r25 + address = newAddress; + 7e92: 90 93 01 02 sts 0x0201, r25 + 7e96: 80 93 00 02 sts 0x0200, r24 + 7e9a: 7e c0 rjmp .+252 ; 0x7f98 verifySpace(); } else if(ch == STK_UNIVERSAL) { - 7ea4: 86 35 cpi r24, 0x56 ; 86 - 7ea6: 29 f4 brne .+10 ; 0x7eb2 + 7e9c: 86 35 cpi r24, 0x56 ; 86 + 7e9e: 29 f4 brne .+10 ; 0x7eaa // UNIVERSAL command is ignored getNch(4); - 7ea8: 84 e0 ldi r24, 0x04 ; 4 - 7eaa: 99 d0 rcall .+306 ; 0x7fde + 7ea0: 84 e0 ldi r24, 0x04 ; 4 + 7ea2: a4 d0 rcall .+328 ; 0x7fec putch(0x00); - 7eac: 80 e0 ldi r24, 0x00 ; 0 - 7eae: 71 d0 rcall .+226 ; 0x7f92 - 7eb0: 6d c0 rjmp .+218 ; 0x7f8c + 7ea4: 80 e0 ldi r24, 0x00 ; 0 + 7ea6: 7c d0 rcall .+248 ; 0x7fa0 + 7ea8: 78 c0 rjmp .+240 ; 0x7f9a } - /* Write memory, length is big endian and is in bytes */ + /* Write memory, length is big endian and is in bytes */ else if(ch == STK_PROG_PAGE) { - 7eb2: 84 36 cpi r24, 0x64 ; 100 - 7eb4: 09 f0 breq .+2 ; 0x7eb8 - 7eb6: 43 c0 rjmp .+134 ; 0x7f3e + 7eaa: 84 36 cpi r24, 0x64 ; 100 + 7eac: 09 f0 breq .+2 ; 0x7eb0 + 7eae: 4e c0 rjmp .+156 ; 0x7f4c // PROGRAM PAGE - we support flash programming only, not EEPROM uint8_t *bufPtr; uint16_t addrPtr; getLen(); - 7eb8: 7c d0 rcall .+248 ; 0x7fb2 - - // Immediately start page erase - this will 4.5ms - boot_page_erase((uint16_t)(void*)address); - 7eba: e0 91 00 02 lds r30, 0x0200 - 7ebe: f0 91 01 02 lds r31, 0x0201 + 7eb0: 87 d0 rcall .+270 ; 0x7fc0 + + // If we are in RWW section, immediately start page erase + if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address); + 7eb2: e0 91 00 02 lds r30, 0x0200 + 7eb6: f0 91 01 02 lds r31, 0x0201 + 7eba: 80 e7 ldi r24, 0x70 ; 112 + 7ebc: e0 30 cpi r30, 0x00 ; 0 + 7ebe: f8 07 cpc r31, r24 + 7ec0: 18 f4 brcc .+6 ; 0x7ec8 7ec2: 83 e0 ldi r24, 0x03 ; 3 - 7ec4: 80 93 57 00 sts 0x0057, r24 - 7ec8: e8 95 spm - 7eca: c0 e0 ldi r28, 0x00 ; 0 - 7ecc: d1 e0 ldi r29, 0x01 ; 1 - + 7ec4: 87 bf out 0x37, r24 ; 55 + 7ec6: e8 95 spm + 7ec8: c0 e0 ldi r28, 0x00 ; 0 + 7eca: d1 e0 ldi r29, 0x01 ; 1 + // While that is going on, read in page contents bufPtr = buff; do *bufPtr++ = getch(); - 7ece: 69 d0 rcall .+210 ; 0x7fa2 - 7ed0: 89 93 st Y+, r24 + 7ecc: 71 d0 rcall .+226 ; 0x7fb0 + 7ece: 89 93 st Y+, r24 while (--length); - 7ed2: 80 91 02 02 lds r24, 0x0202 - 7ed6: 81 50 subi r24, 0x01 ; 1 - 7ed8: 80 93 02 02 sts 0x0202, r24 - 7edc: 88 23 and r24, r24 - 7ede: b9 f7 brne .-18 ; 0x7ece + 7ed0: 80 91 02 02 lds r24, 0x0202 + 7ed4: 81 50 subi r24, 0x01 ; 1 + 7ed6: 80 93 02 02 sts 0x0202, r24 + 7eda: 88 23 and r24, r24 + 7edc: b9 f7 brne .-18 ; 0x7ecc + + // 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); + 7ede: e0 91 00 02 lds r30, 0x0200 + 7ee2: f0 91 01 02 lds r31, 0x0201 + 7ee6: 80 e7 ldi r24, 0x70 ; 112 + 7ee8: e0 30 cpi r30, 0x00 ; 0 + 7eea: f8 07 cpc r31, r24 + 7eec: 18 f0 brcs .+6 ; 0x7ef4 + 7eee: 83 e0 ldi r24, 0x03 ; 3 + 7ef0: 87 bf out 0x37, r24 ; 55 + 7ef2: e8 95 spm // Read command terminator, start reply verifySpace(); - 7ee0: 78 d0 rcall .+240 ; 0x7fd2 + 7ef4: 75 d0 rcall .+234 ; 0x7fe0 // If only a partial page is to be programmed, the erase might not be complete. // So check that here boot_spm_busy_wait(); - 7ee2: 07 b6 in r0, 0x37 ; 55 - 7ee4: 00 fc sbrc r0, 0 - 7ee6: fd cf rjmp .-6 ; 0x7ee2 + 7ef6: 07 b6 in r0, 0x37 ; 55 + 7ef8: 00 fc sbrc r0, 0 + 7efa: fd cf rjmp .-6 ; 0x7ef6 } #endif // Copy buffer into programming buffer bufPtr = buff; addrPtr = (uint16_t)(void*)address; - 7ee8: 40 91 00 02 lds r20, 0x0200 - 7eec: 50 91 01 02 lds r21, 0x0201 - 7ef0: a0 e0 ldi r26, 0x00 ; 0 - 7ef2: b1 e0 ldi r27, 0x01 ; 1 + 7efc: 40 91 00 02 lds r20, 0x0200 + 7f00: 50 91 01 02 lds r21, 0x0201 + 7f04: a0 e0 ldi r26, 0x00 ; 0 + 7f06: b1 e0 ldi r27, 0x01 ; 1 ch = SPM_PAGESIZE / 2; do { uint16_t a; a = *bufPtr++; - 7ef4: 2c 91 ld r18, X - 7ef6: 30 e0 ldi r19, 0x00 ; 0 + 7f08: 2c 91 ld r18, X + 7f0a: 30 e0 ldi r19, 0x00 ; 0 a |= (*bufPtr++) << 8; - 7ef8: 11 96 adiw r26, 0x01 ; 1 - 7efa: 8c 91 ld r24, X - 7efc: 11 97 sbiw r26, 0x01 ; 1 - 7efe: 90 e0 ldi r25, 0x00 ; 0 - 7f00: 98 2f mov r25, r24 - 7f02: 88 27 eor r24, r24 - 7f04: 82 2b or r24, r18 - 7f06: 93 2b or r25, r19 -#ifdef VIRTUAL_BOOT_PARTITION -#define rstVect (*(uint16_t*)(0x204)) -#define wdtVect (*(uint16_t*)(0x206)) + 7f0c: 11 96 adiw r26, 0x01 ; 1 + 7f0e: 8c 91 ld r24, X + 7f10: 11 97 sbiw r26, 0x01 ; 1 + 7f12: 90 e0 ldi r25, 0x00 ; 0 + 7f14: 98 2f mov r25, r24 + 7f16: 88 27 eor r24, r24 + 7f18: 82 2b or r24, r18 + 7f1a: 93 2b or r25, r19 +#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) { - 7f08: 12 96 adiw r26, 0x02 ; 2 + 7f1c: 12 96 adiw r26, 0x02 ; 2 ch = SPM_PAGESIZE / 2; do { uint16_t a; a = *bufPtr++; a |= (*bufPtr++) << 8; - boot_page_fill((uint16_t)(void*)addrPtr,a); - 7f0a: fa 01 movw r30, r20 - 7f0c: 0c 01 movw r0, r24 - 7f0e: d0 92 57 00 sts 0x0057, r13 - 7f12: e8 95 spm - 7f14: 11 24 eor r1, r1 + __boot_page_fill_short((uint16_t)(void*)addrPtr,a); + 7f1e: fa 01 movw r30, r20 + 7f20: 0c 01 movw r0, r24 + 7f22: d7 be out 0x37, r13 ; 55 + 7f24: e8 95 spm + 7f26: 11 24 eor r1, r1 addrPtr += 2; - 7f16: 4e 5f subi r20, 0xFE ; 254 - 7f18: 5f 4f sbci r21, 0xFF ; 255 + 7f28: 4e 5f subi r20, 0xFE ; 254 + 7f2a: 5f 4f sbci r21, 0xFF ; 255 } while (--ch); - 7f1a: f1 e0 ldi r31, 0x01 ; 1 - 7f1c: a0 38 cpi r26, 0x80 ; 128 - 7f1e: bf 07 cpc r27, r31 - 7f20: 49 f7 brne .-46 ; 0x7ef4 + 7f2c: f1 e0 ldi r31, 0x01 ; 1 + 7f2e: a0 38 cpi r26, 0x80 ; 128 + 7f30: bf 07 cpc r27, r31 + 7f32: 51 f7 brne .-44 ; 0x7f08 // Write from programming buffer - boot_page_write((uint16_t)(void*)address); - 7f22: e0 91 00 02 lds r30, 0x0200 - 7f26: f0 91 01 02 lds r31, 0x0201 - 7f2a: e0 92 57 00 sts 0x0057, r14 - 7f2e: e8 95 spm + __boot_page_write_short((uint16_t)(void*)address); + 7f34: e0 91 00 02 lds r30, 0x0200 + 7f38: f0 91 01 02 lds r31, 0x0201 + 7f3c: e7 be out 0x37, r14 ; 55 + 7f3e: e8 95 spm boot_spm_busy_wait(); - 7f30: 07 b6 in r0, 0x37 ; 55 - 7f32: 00 fc sbrc r0, 0 - 7f34: fd cf rjmp .-6 ; 0x7f30 + 7f40: 07 b6 in r0, 0x37 ; 55 + 7f42: 00 fc sbrc r0, 0 + 7f44: fd cf rjmp .-6 ; 0x7f40 #if defined(RWWSRE) // Reenable read access to flash boot_rww_enable(); - 7f36: f0 92 57 00 sts 0x0057, r15 - 7f3a: e8 95 spm - 7f3c: 27 c0 rjmp .+78 ; 0x7f8c + 7f46: f7 be out 0x37, r15 ; 55 + 7f48: e8 95 spm + 7f4a: 27 c0 rjmp .+78 ; 0x7f9a #endif } /* Read memory block mode, length is big endian. */ else if(ch == STK_READ_PAGE) { - 7f3e: 84 37 cpi r24, 0x74 ; 116 - 7f40: b9 f4 brne .+46 ; 0x7f70 + 7f4c: 84 37 cpi r24, 0x74 ; 116 + 7f4e: b9 f4 brne .+46 ; 0x7f7e // READ PAGE - we only read flash getLen(); - 7f42: 37 d0 rcall .+110 ; 0x7fb2 + 7f50: 37 d0 rcall .+110 ; 0x7fc0 verifySpace(); - 7f44: 46 d0 rcall .+140 ; 0x7fd2 - else ch = pgm_read_byte_near(address); + 7f52: 46 d0 rcall .+140 ; 0x7fe0 + putch(result); address++; - putch(ch); - } while (--length); + } + while (--length); #else do putch(pgm_read_byte_near(address++)); - 7f46: e0 91 00 02 lds r30, 0x0200 - 7f4a: f0 91 01 02 lds r31, 0x0201 - 7f4e: 31 96 adiw r30, 0x01 ; 1 - 7f50: f0 93 01 02 sts 0x0201, r31 - 7f54: e0 93 00 02 sts 0x0200, r30 - 7f58: 31 97 sbiw r30, 0x01 ; 1 - 7f5a: e4 91 lpm r30, Z+ - 7f5c: 8e 2f mov r24, r30 - 7f5e: 19 d0 rcall .+50 ; 0x7f92 + 7f54: e0 91 00 02 lds r30, 0x0200 + 7f58: f0 91 01 02 lds r31, 0x0201 + 7f5c: 31 96 adiw r30, 0x01 ; 1 + 7f5e: f0 93 01 02 sts 0x0201, r31 + 7f62: e0 93 00 02 sts 0x0200, r30 + 7f66: 31 97 sbiw r30, 0x01 ; 1 + 7f68: e4 91 lpm r30, Z+ + 7f6a: 8e 2f mov r24, r30 + 7f6c: 19 d0 rcall .+50 ; 0x7fa0 while (--length); - 7f60: 80 91 02 02 lds r24, 0x0202 - 7f64: 81 50 subi r24, 0x01 ; 1 - 7f66: 80 93 02 02 sts 0x0202, r24 - 7f6a: 88 23 and r24, r24 - 7f6c: 61 f7 brne .-40 ; 0x7f46 - 7f6e: 0e c0 rjmp .+28 ; 0x7f8c + 7f6e: 80 91 02 02 lds r24, 0x0202 + 7f72: 81 50 subi r24, 0x01 ; 1 + 7f74: 80 93 02 02 sts 0x0202, r24 + 7f78: 88 23 and r24, r24 + 7f7a: 61 f7 brne .-40 ; 0x7f54 + 7f7c: 0e c0 rjmp .+28 ; 0x7f9a +#endif #endif } /* Get device signature bytes */ else if(ch == STK_READ_SIGN) { - 7f70: 85 37 cpi r24, 0x75 ; 117 - 7f72: 39 f4 brne .+14 ; 0x7f82 + 7f7e: 85 37 cpi r24, 0x75 ; 117 + 7f80: 39 f4 brne .+14 ; 0x7f90 // READ SIGN - return what Avrdude wants to hear verifySpace(); - 7f74: 2e d0 rcall .+92 ; 0x7fd2 + 7f82: 2e d0 rcall .+92 ; 0x7fe0 putch(SIGNATURE_0); - 7f76: 8e e1 ldi r24, 0x1E ; 30 - 7f78: 0c d0 rcall .+24 ; 0x7f92 + 7f84: 8e e1 ldi r24, 0x1E ; 30 + 7f86: 0c d0 rcall .+24 ; 0x7fa0 putch(SIGNATURE_1); - 7f7a: 85 e9 ldi r24, 0x95 ; 149 - 7f7c: 0a d0 rcall .+20 ; 0x7f92 + 7f88: 85 e9 ldi r24, 0x95 ; 149 + 7f8a: 0a d0 rcall .+20 ; 0x7fa0 putch(SIGNATURE_2); - 7f7e: 8f e0 ldi r24, 0x0F ; 15 - 7f80: 96 cf rjmp .-212 ; 0x7eae + 7f8c: 8f e0 ldi r24, 0x0F ; 15 + 7f8e: 8b cf rjmp .-234 ; 0x7ea6 } else if (ch == 'Q') { - 7f82: 81 35 cpi r24, 0x51 ; 81 - 7f84: 11 f4 brne .+4 ; 0x7f8a + 7f90: 81 35 cpi r24, 0x51 ; 81 + 7f92: 11 f4 brne .+4 ; 0x7f98 // Adaboot no-wait mod watchdogConfig(WATCHDOG_16MS); - 7f86: 88 e0 ldi r24, 0x08 ; 8 - 7f88: 19 d0 rcall .+50 ; 0x7fbc + 7f94: 88 e0 ldi r24, 0x08 ; 8 + 7f96: 19 d0 rcall .+50 ; 0x7fca verifySpace(); } else { // This covers the response to commands like STK_ENTER_PROGMODE verifySpace(); - 7f8a: 23 d0 rcall .+70 ; 0x7fd2 + 7f98: 23 d0 rcall .+70 ; 0x7fe0 } putch(STK_OK); - 7f8c: 80 e1 ldi r24, 0x10 ; 16 - 7f8e: 01 d0 rcall .+2 ; 0x7f92 - 7f90: 63 cf rjmp .-314 ; 0x7e58 + 7f9a: 80 e1 ldi r24, 0x10 ; 16 + 7f9c: 01 d0 rcall .+2 ; 0x7fa0 + 7f9e: 5c cf rjmp .-328 ; 0x7e58 -00007f92 : +00007fa0 : } } void putch(char ch) { - 7f92: 98 2f mov r25, r24 + 7fa0: 98 2f mov r25, r24 #ifndef SOFT_UART while (!(UCSR0A & _BV(UDRE0))); - 7f94: 80 91 c0 00 lds r24, 0x00C0 - 7f98: 85 ff sbrs r24, 5 - 7f9a: fc cf rjmp .-8 ; 0x7f94 + 7fa2: 80 91 c0 00 lds r24, 0x00C0 + 7fa6: 85 ff sbrs r24, 5 + 7fa8: fc cf rjmp .-8 ; 0x7fa2 UDR0 = ch; - 7f9c: 90 93 c6 00 sts 0x00C6, r25 + 7faa: 90 93 c6 00 sts 0x00C6, r25 [uartBit] "I" (UART_TX_BIT) : "r25" ); #endif } - 7fa0: 08 95 ret + 7fae: 08 95 ret -00007fa2 : +00007fb0 : return getch(); } // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( - 7fa2: a8 95 wdr + 7fb0: a8 95 wdr [uartBit] "I" (UART_RX_BIT) : "r25" ); #else while(!(UCSR0A & _BV(RXC0))); - 7fa4: 80 91 c0 00 lds r24, 0x00C0 - 7fa8: 87 ff sbrs r24, 7 - 7faa: fc cf rjmp .-8 ; 0x7fa4 + 7fb2: 80 91 c0 00 lds r24, 0x00C0 + 7fb6: 87 ff sbrs r24, 7 + 7fb8: fc cf rjmp .-8 ; 0x7fb2 ch = UDR0; - 7fac: 80 91 c6 00 lds r24, 0x00C6 -#ifdef LED_DATA_FLASH + 7fba: 80 91 c6 00 lds r24, 0x00C6 LED_PIN |= _BV(LED); +#endif #endif return ch; } - 7fb0: 08 95 ret + 7fbe: 08 95 ret -00007fb2 : +00007fc0 : } while (--count); } #endif uint8_t getLen() { getch(); - 7fb2: f7 df rcall .-18 ; 0x7fa2 + 7fc0: f7 df rcall .-18 ; 0x7fb0 length = getch(); - 7fb4: f6 df rcall .-20 ; 0x7fa2 - 7fb6: 80 93 02 02 sts 0x0202, r24 + 7fc2: f6 df rcall .-20 ; 0x7fb0 + 7fc4: 80 93 02 02 sts 0x0202, r24 return getch(); } - 7fba: f3 cf rjmp .-26 ; 0x7fa2 + 7fc8: f3 cf rjmp .-26 ; 0x7fb0 -00007fbc : +00007fca : "wdr\n" ); } void watchdogConfig(uint8_t x) { WDTCSR = _BV(WDCE) | _BV(WDE); - 7fbc: e0 e6 ldi r30, 0x60 ; 96 - 7fbe: f0 e0 ldi r31, 0x00 ; 0 - 7fc0: 98 e1 ldi r25, 0x18 ; 24 - 7fc2: 90 83 st Z, r25 + 7fca: e0 e6 ldi r30, 0x60 ; 96 + 7fcc: f0 e0 ldi r31, 0x00 ; 0 + 7fce: 98 e1 ldi r25, 0x18 ; 24 + 7fd0: 90 83 st Z, r25 WDTCSR = x; - 7fc4: 80 83 st Z, r24 + 7fd2: 80 83 st Z, r24 } - 7fc6: 08 95 ret + 7fd4: 08 95 ret -00007fc8 : +00007fd6 : void appStart() { watchdogConfig(WATCHDOG_OFF); - 7fc8: 80 e0 ldi r24, 0x00 ; 0 - 7fca: f8 df rcall .-16 ; 0x7fbc + 7fd6: 80 e0 ldi r24, 0x00 ; 0 + 7fd8: f8 df rcall .-16 ; 0x7fca __asm__ __volatile__ ( - 7fcc: ee 27 eor r30, r30 - 7fce: ff 27 eor r31, r31 - 7fd0: 09 94 ijmp + 7fda: ee 27 eor r30, r30 + 7fdc: ff 27 eor r31, r31 + 7fde: 09 94 ijmp -00007fd2 : +00007fe0 : do getch(); while (--count); verifySpace(); } void verifySpace() { if (getch() != CRC_EOP) appStart(); - 7fd2: e7 df rcall .-50 ; 0x7fa2 - 7fd4: 80 32 cpi r24, 0x20 ; 32 - 7fd6: 09 f0 breq .+2 ; 0x7fda - 7fd8: f7 df rcall .-18 ; 0x7fc8 + 7fe0: e7 df rcall .-50 ; 0x7fb0 + 7fe2: 80 32 cpi r24, 0x20 ; 32 + 7fe4: 09 f0 breq .+2 ; 0x7fe8 + 7fe6: f7 df rcall .-18 ; 0x7fd6 putch(STK_INSYNC); - 7fda: 84 e1 ldi r24, 0x14 ; 20 + 7fe8: 84 e1 ldi r24, 0x14 ; 20 } - 7fdc: da cf rjmp .-76 ; 0x7f92 + 7fea: da cf rjmp .-76 ; 0x7fa0 -00007fde : +00007fec : ::[count] "M" (UART_B_VALUE) ); } #endif void getNch(uint8_t count) { - 7fde: 1f 93 push r17 - 7fe0: 18 2f mov r17, r24 + 7fec: 1f 93 push r17 + 7fee: 18 2f mov r17, r24 do getch(); while (--count); - 7fe2: df df rcall .-66 ; 0x7fa2 - 7fe4: 11 50 subi r17, 0x01 ; 1 - 7fe6: e9 f7 brne .-6 ; 0x7fe2 + 7ff0: df df rcall .-66 ; 0x7fb0 + 7ff2: 11 50 subi r17, 0x01 ; 1 + 7ff4: e9 f7 brne .-6 ; 0x7ff0 verifySpace(); - 7fe8: f4 df rcall .-24 ; 0x7fd2 + 7ff6: f4 df rcall .-24 ; 0x7fe0 } - 7fea: 1f 91 pop r17 - 7fec: 08 95 ret + 7ff8: 1f 91 pop r17 + 7ffa: 08 95 ret -- cgit v1.2.3-18-g5258 From 2a83ee55b38c81df04d7d3b83d6bf68ed72936e4 Mon Sep 17 00:00:00 2001 From: WestfW Date: Fri, 10 Jun 2011 17:47:47 -0700 Subject: Add a version number to the optiboot source and binary. http://code.google.com/p/arduino/issues/detail?id=554 end of flash memory where they can be read (at least in theory) by device programmers, hex-file examination, or application programs. This is done by putting the version number in a separate section (".version"), and using linker/objcopy magic to locate that section as appropriate for the target chip. (See http://lists.gnu.org/archive/html/avr-gcc-list/2011-02/msg00016.html for some discussion on the details.) Start the version at 4.1 (the last "packaged" version of optiboot was called version 3, so the "top of source" would be 4.0, and adding the version number makes 4.1) Refactor LDSECTION in the Makefile to LDSECTIONS so that multiple section start addresses can be defined. Change the _isp makefile definitions to make the bootloader section readable (but not writable) by the application section. (This would need to be done elsewhere as well to handle all bootloader programming techniques. Notably Arduino's boards.txt Note that this change does not change the "code" portion of optiboot at all. The only diffs in the .hex files are the added version word at the end of flash memory. --- bootloaders/optiboot/optiboot_atmega328.lst | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'bootloaders/optiboot/optiboot_atmega328.lst') diff --git a/bootloaders/optiboot/optiboot_atmega328.lst b/bootloaders/optiboot/optiboot_atmega328.lst index 1af4a3c..0da8aaf 100644 --- a/bootloaders/optiboot/optiboot_atmega328.lst +++ b/bootloaders/optiboot/optiboot_atmega328.lst @@ -5,23 +5,25 @@ Sections: Idx Name Size VMA LMA File off Algn 0 .text 000001fc 00007e00 00007e00 00000054 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE - 1 .debug_aranges 00000028 00000000 00000000 00000250 2**0 + 1 .version 00000002 00007ffe 00007ffe 00000250 2**0 + CONTENTS, READONLY + 2 .debug_aranges 00000028 00000000 00000000 00000252 2**0 CONTENTS, READONLY, DEBUGGING - 2 .debug_pubnames 0000006a 00000000 00000000 00000278 2**0 + 3 .debug_pubnames 0000006a 00000000 00000000 0000027a 2**0 CONTENTS, READONLY, DEBUGGING - 3 .debug_info 00000284 00000000 00000000 000002e2 2**0 + 4 .debug_info 00000285 00000000 00000000 000002e4 2**0 CONTENTS, READONLY, DEBUGGING - 4 .debug_abbrev 000001ae 00000000 00000000 00000566 2**0 + 5 .debug_abbrev 0000019f 00000000 00000000 00000569 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_line 00000450 00000000 00000000 00000714 2**0 + 6 .debug_line 00000453 00000000 00000000 00000708 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_frame 00000090 00000000 00000000 00000b64 2**2 + 7 .debug_frame 00000090 00000000 00000000 00000b5c 2**2 CONTENTS, READONLY, DEBUGGING - 7 .debug_str 00000141 00000000 00000000 00000bf4 2**0 + 8 .debug_str 00000141 00000000 00000000 00000bec 2**0 CONTENTS, READONLY, DEBUGGING - 8 .debug_loc 000001e1 00000000 00000000 00000d35 2**0 + 9 .debug_loc 000001e1 00000000 00000000 00000d2d 2**0 CONTENTS, READONLY, DEBUGGING - 9 .debug_ranges 00000068 00000000 00000000 00000f16 2**0 + 10 .debug_ranges 00000068 00000000 00000000 00000f0e 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: @@ -135,7 +137,7 @@ void watchdogReset() { __boot_page_fill_short((uint16_t)(void*)addrPtr,a); addrPtr += 2; } while (--ch); - + // Write from programming buffer __boot_page_write_short((uint16_t)(void*)address); 7e50: a5 e0 ldi r26, 0x05 ; 5 @@ -249,7 +251,7 @@ void watchdogReset() { 7ec6: e8 95 spm 7ec8: c0 e0 ldi r28, 0x00 ; 0 7eca: d1 e0 ldi r29, 0x01 ; 1 - + // While that is going on, read in page contents bufPtr = buff; do *bufPtr++ = getch(); @@ -278,7 +280,7 @@ void watchdogReset() { // Read command terminator, start reply verifySpace(); 7ef4: 75 d0 rcall .+234 ; 0x7fe0 - + // If only a partial page is to be programmed, the erase might not be complete. // So check that here boot_spm_busy_wait(); @@ -336,7 +338,7 @@ int main(void) { 7f2e: a0 38 cpi r26, 0x80 ; 128 7f30: bf 07 cpc r27, r31 7f32: 51 f7 brne .-44 ; 0x7f08 - + // Write from programming buffer __boot_page_write_short((uint16_t)(void*)address); 7f34: e0 91 00 02 lds r30, 0x0200 -- cgit v1.2.3-18-g5258 From a78553bd13fb9cbb03b574b363c8f68a7289dc11 Mon Sep 17 00:00:00 2001 From: WestfW Date: Fri, 10 Jun 2011 23:02:25 -0700 Subject: Shrink code by using registers for variables "length" and "address" http://code.google.com/p/optiboot/issues/detail?id=33 Fix high-value watchdog timeouts on ATmega8 http://code.google.com/p/optiboot/issues/detail?id=38 Change "start app on bad commands" code to start the app via the watchdog timer, so that the app is always started with the chip in fully reset state. http://code.google.com/p/optiboot/issues/detail?id=37 --- bootloaders/optiboot/optiboot_atmega328.lst | 439 ++++++++++++++-------------- 1 file changed, 222 insertions(+), 217 deletions(-) (limited to 'bootloaders/optiboot/optiboot_atmega328.lst') diff --git a/bootloaders/optiboot/optiboot_atmega328.lst b/bootloaders/optiboot/optiboot_atmega328.lst index 0da8aaf..7876b96 100644 --- a/bootloaders/optiboot/optiboot_atmega328.lst +++ b/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 000001fc 00007e00 00007e00 00000054 2**1 + 0 .text 000001da 00007e00 00007e00 00000054 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE - 1 .version 00000002 00007ffe 00007ffe 00000250 2**0 + 1 .version 00000002 00007ffe 00007ffe 0000022e 2**0 CONTENTS, READONLY - 2 .debug_aranges 00000028 00000000 00000000 00000252 2**0 + 2 .debug_aranges 00000028 00000000 00000000 00000230 2**0 CONTENTS, READONLY, DEBUGGING - 3 .debug_pubnames 0000006a 00000000 00000000 0000027a 2**0 + 3 .debug_pubnames 0000005f 00000000 00000000 00000258 2**0 CONTENTS, READONLY, DEBUGGING - 4 .debug_info 00000285 00000000 00000000 000002e4 2**0 + 4 .debug_info 0000028c 00000000 00000000 000002b7 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_abbrev 0000019f 00000000 00000000 00000569 2**0 + 5 .debug_abbrev 00000199 00000000 00000000 00000543 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_line 00000453 00000000 00000000 00000708 2**0 + 6 .debug_line 00000456 00000000 00000000 000006dc 2**0 CONTENTS, READONLY, DEBUGGING - 7 .debug_frame 00000090 00000000 00000000 00000b5c 2**2 + 7 .debug_frame 00000080 00000000 00000000 00000b34 2**2 CONTENTS, READONLY, DEBUGGING - 8 .debug_str 00000141 00000000 00000000 00000bec 2**0 + 8 .debug_str 00000149 00000000 00000000 00000bb4 2**0 CONTENTS, READONLY, DEBUGGING - 9 .debug_loc 000001e1 00000000 00000000 00000d2d 2**0 + 9 .debug_loc 0000027e 00000000 00000000 00000cfd 2**0 CONTENTS, READONLY, DEBUGGING - 10 .debug_ranges 00000068 00000000 00000000 00000f0e 2**0 + 10 .debug_ranges 00000060 00000000 00000000 00000f7b 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: @@ -47,7 +47,7 @@ int main(void) { 7e04: 14 be out 0x34, r1 ; 52 if (!(ch & _BV(EXTRF))) appStart(); 7e06: 81 ff sbrs r24, 1 - 7e08: e6 d0 rcall .+460 ; 0x7fd6 + 7e08: e3 d0 rcall .+454 ; 0x7fd0 #if LED_START_FLASHES > 0 // Set up Timer 1 for timeout counter @@ -77,7 +77,7 @@ int main(void) { // Set up watchdog to trigger after 500ms watchdogConfig(WATCHDOG_1S); 7e28: 8e e0 ldi r24, 0x0E ; 14 - 7e2a: cf d0 rcall .+414 ; 0x7fca + 7e2a: bc d0 rcall .+376 ; 0x7fa4 /* Set LED pin as output */ LED_DDR |= _BV(LED); @@ -111,8 +111,8 @@ void flash_led(uint8_t count) { #else LED_PIN |= _BV(LED); 7e44: 1d 9a sbi 0x03, 5 ; 3 - return getch(); } +#endif // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { @@ -132,8 +132,8 @@ void watchdogReset() { if(ch == STK_GET_PARAMETER) { // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy getNch(1); - 7e4c: dd 24 eor r13, r13 - 7e4e: d3 94 inc r13 + 7e4c: 99 24 eor r9, r9 + 7e4e: 93 94 inc r9 __boot_page_fill_short((uint16_t)(void*)addrPtr,a); addrPtr += 2; } while (--ch); @@ -141,21 +141,21 @@ void watchdogReset() { // Write from programming buffer __boot_page_write_short((uint16_t)(void*)address); 7e50: a5 e0 ldi r26, 0x05 ; 5 - 7e52: ea 2e mov r14, r26 + 7e52: aa 2e mov r10, r26 boot_spm_busy_wait(); #if defined(RWWSRE) // Reenable read access to flash boot_rww_enable(); 7e54: f1 e1 ldi r31, 0x11 ; 17 - 7e56: ff 2e mov r15, r31 + 7e56: bf 2e mov r11, r31 #endif /* Forever loop */ for (;;) { /* get character from UART */ ch = getch(); - 7e58: ab d0 rcall .+342 ; 0x7fb0 + 7e58: 9d d0 rcall .+314 ; 0x7f94 if(ch == STK_GET_PARAMETER) { 7e5a: 81 34 cpi r24, 0x41 ; 65 @@ -163,10 +163,10 @@ void watchdogReset() { // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy getNch(1); 7e5e: 81 e0 ldi r24, 0x01 ; 1 - 7e60: c5 d0 rcall .+394 ; 0x7fec + 7e60: af d0 rcall .+350 ; 0x7fc0 putch(0x03); 7e62: 83 e0 ldi r24, 0x03 ; 3 - 7e64: 20 c0 rjmp .+64 ; 0x7ea6 + 7e64: 1f c0 rjmp .+62 ; 0x7ea4 } else if(ch == STK_SET_DEVICE) { 7e66: 82 34 cpi r24, 0x42 ; 66 @@ -182,71 +182,77 @@ void watchdogReset() { // SET DEVICE EXT is ignored getNch(5); 7e72: 85 e0 ldi r24, 0x05 ; 5 - 7e74: bb d0 rcall .+374 ; 0x7fec - 7e76: 91 c0 rjmp .+290 ; 0x7f9a + 7e74: a5 d0 rcall .+330 ; 0x7fc0 + 7e76: 83 c0 rjmp .+262 ; 0x7f7e } else if(ch == STK_LOAD_ADDRESS) { 7e78: 85 35 cpi r24, 0x55 ; 85 - 7e7a: 81 f4 brne .+32 ; 0x7e9c + 7e7a: 79 f4 brne .+30 ; 0x7e9a // LOAD ADDRESS uint16_t newAddress; newAddress = getch(); - 7e7c: 99 d0 rcall .+306 ; 0x7fb0 + 7e7c: 8b d0 rcall .+278 ; 0x7f94 newAddress = (newAddress & 0xff) | (getch() << 8); - 7e7e: 08 2f mov r16, r24 - 7e80: 10 e0 ldi r17, 0x00 ; 0 - 7e82: 96 d0 rcall .+300 ; 0x7fb0 - 7e84: 90 e0 ldi r25, 0x00 ; 0 - 7e86: 98 2f mov r25, r24 - 7e88: 88 27 eor r24, r24 - 7e8a: 80 2b or r24, r16 - 7e8c: 91 2b or r25, r17 + 7e7e: e8 2e mov r14, r24 + 7e80: ff 24 eor r15, r15 + 7e82: 88 d0 rcall .+272 ; 0x7f94 + 7e84: 08 2f mov r16, r24 + 7e86: 10 e0 ldi r17, 0x00 ; 0 + 7e88: 10 2f mov r17, r16 + 7e8a: 00 27 eor r16, r16 + 7e8c: 0e 29 or r16, r14 + 7e8e: 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 - 7e8e: 88 0f add r24, r24 - 7e90: 99 1f adc r25, r25 + 7e90: 00 0f add r16, r16 + 7e92: 11 1f adc r17, r17 address = newAddress; - 7e92: 90 93 01 02 sts 0x0201, r25 - 7e96: 80 93 00 02 sts 0x0200, r24 - 7e9a: 7e c0 rjmp .+252 ; 0x7f98 verifySpace(); + 7e94: 8d d0 rcall .+282 ; 0x7fb0 + 7e96: 68 01 movw r12, r16 + 7e98: 72 c0 rjmp .+228 ; 0x7f7e } else if(ch == STK_UNIVERSAL) { - 7e9c: 86 35 cpi r24, 0x56 ; 86 - 7e9e: 29 f4 brne .+10 ; 0x7eaa + 7e9a: 86 35 cpi r24, 0x56 ; 86 + 7e9c: 29 f4 brne .+10 ; 0x7ea8 // UNIVERSAL command is ignored getNch(4); - 7ea0: 84 e0 ldi r24, 0x04 ; 4 - 7ea2: a4 d0 rcall .+328 ; 0x7fec + 7e9e: 84 e0 ldi r24, 0x04 ; 4 + 7ea0: 8f d0 rcall .+286 ; 0x7fc0 putch(0x00); - 7ea4: 80 e0 ldi r24, 0x00 ; 0 - 7ea6: 7c d0 rcall .+248 ; 0x7fa0 - 7ea8: 78 c0 rjmp .+240 ; 0x7f9a + 7ea2: 80 e0 ldi r24, 0x00 ; 0 + 7ea4: 6f d0 rcall .+222 ; 0x7f84 + 7ea6: 6b c0 rjmp .+214 ; 0x7f7e } /* Write memory, length is big endian and is in bytes */ else if(ch == STK_PROG_PAGE) { - 7eaa: 84 36 cpi r24, 0x64 ; 100 - 7eac: 09 f0 breq .+2 ; 0x7eb0 - 7eae: 4e c0 rjmp .+156 ; 0x7f4c + 7ea8: 84 36 cpi r24, 0x64 ; 100 + 7eaa: 09 f0 breq .+2 ; 0x7eae + 7eac: 42 c0 rjmp .+132 ; 0x7f32 // PROGRAM PAGE - we support flash programming only, not EEPROM uint8_t *bufPtr; uint16_t addrPtr; - getLen(); - 7eb0: 87 d0 rcall .+270 ; 0x7fc0 + getch(); /* getlen() */ + 7eae: 72 d0 rcall .+228 ; 0x7f94 + length = getch(); + 7eb0: 71 d0 rcall .+226 ; 0x7f94 + 7eb2: 08 2f mov r16, r24 + getch(); + 7eb4: 6f d0 rcall .+222 ; 0x7f94 // If we are in RWW section, immediately start page erase if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address); - 7eb2: e0 91 00 02 lds r30, 0x0200 - 7eb6: f0 91 01 02 lds r31, 0x0201 + 7eb6: 80 e0 ldi r24, 0x00 ; 0 + 7eb8: c8 16 cp r12, r24 7eba: 80 e7 ldi r24, 0x70 ; 112 - 7ebc: e0 30 cpi r30, 0x00 ; 0 - 7ebe: f8 07 cpc r31, r24 - 7ec0: 18 f4 brcc .+6 ; 0x7ec8 - 7ec2: 83 e0 ldi r24, 0x03 ; 3 + 7ebc: d8 06 cpc r13, r24 + 7ebe: 20 f4 brcc .+8 ; 0x7ec8 + 7ec0: 83 e0 ldi r24, 0x03 ; 3 + 7ec2: f6 01 movw r30, r12 7ec4: 87 bf out 0x37, r24 ; 55 7ec6: e8 95 spm 7ec8: c0 e0 ldi r28, 0x00 ; 0 @@ -255,302 +261,301 @@ void watchdogReset() { // While that is going on, read in page contents bufPtr = buff; do *bufPtr++ = getch(); - 7ecc: 71 d0 rcall .+226 ; 0x7fb0 + 7ecc: 63 d0 rcall .+198 ; 0x7f94 7ece: 89 93 st Y+, r24 while (--length); - 7ed0: 80 91 02 02 lds r24, 0x0202 - 7ed4: 81 50 subi r24, 0x01 ; 1 - 7ed6: 80 93 02 02 sts 0x0202, r24 - 7eda: 88 23 and r24, r24 - 7edc: b9 f7 brne .-18 ; 0x7ecc + 7ed0: 0c 17 cp r16, r28 + 7ed2: e1 f7 brne .-8 ; 0x7ecc // 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); - 7ede: e0 91 00 02 lds r30, 0x0200 - 7ee2: f0 91 01 02 lds r31, 0x0201 - 7ee6: 80 e7 ldi r24, 0x70 ; 112 - 7ee8: e0 30 cpi r30, 0x00 ; 0 - 7eea: f8 07 cpc r31, r24 - 7eec: 18 f0 brcs .+6 ; 0x7ef4 - 7eee: 83 e0 ldi r24, 0x03 ; 3 - 7ef0: 87 bf out 0x37, r24 ; 55 - 7ef2: e8 95 spm + 7ed4: f0 e0 ldi r31, 0x00 ; 0 + 7ed6: cf 16 cp r12, r31 + 7ed8: f0 e7 ldi r31, 0x70 ; 112 + 7eda: df 06 cpc r13, r31 + 7edc: 20 f0 brcs .+8 ; 0x7ee6 + 7ede: 83 e0 ldi r24, 0x03 ; 3 + 7ee0: f6 01 movw r30, r12 + 7ee2: 87 bf out 0x37, r24 ; 55 + 7ee4: e8 95 spm // Read command terminator, start reply verifySpace(); - 7ef4: 75 d0 rcall .+234 ; 0x7fe0 + 7ee6: 64 d0 rcall .+200 ; 0x7fb0 // If only a partial page is to be programmed, the erase might not be complete. // So check that here boot_spm_busy_wait(); - 7ef6: 07 b6 in r0, 0x37 ; 55 - 7ef8: 00 fc sbrc r0, 0 - 7efa: fd cf rjmp .-6 ; 0x7ef6 - } -#endif - - // Copy buffer into programming buffer + 7ee8: 07 b6 in r0, 0x37 ; 55 + 7eea: 00 fc sbrc r0, 0 + 7eec: fd cf rjmp .-6 ; 0x7ee8 + 7eee: a6 01 movw r20, r12 + 7ef0: a0 e0 ldi r26, 0x00 ; 0 + 7ef2: b1 e0 ldi r27, 0x01 ; 1 bufPtr = buff; addrPtr = (uint16_t)(void*)address; - 7efc: 40 91 00 02 lds r20, 0x0200 - 7f00: 50 91 01 02 lds r21, 0x0201 - 7f04: a0 e0 ldi r26, 0x00 ; 0 - 7f06: b1 e0 ldi r27, 0x01 ; 1 ch = SPM_PAGESIZE / 2; do { uint16_t a; a = *bufPtr++; - 7f08: 2c 91 ld r18, X - 7f0a: 30 e0 ldi r19, 0x00 ; 0 + 7ef4: 2c 91 ld r18, X + 7ef6: 30 e0 ldi r19, 0x00 ; 0 a |= (*bufPtr++) << 8; - 7f0c: 11 96 adiw r26, 0x01 ; 1 - 7f0e: 8c 91 ld r24, X - 7f10: 11 97 sbiw r26, 0x01 ; 1 - 7f12: 90 e0 ldi r25, 0x00 ; 0 - 7f14: 98 2f mov r25, r24 - 7f16: 88 27 eor r24, r24 - 7f18: 82 2b or r24, r18 - 7f1a: 93 2b or r25, r19 + 7ef8: 11 96 adiw r26, 0x01 ; 1 + 7efa: 8c 91 ld r24, X + 7efc: 11 97 sbiw r26, 0x01 ; 1 + 7efe: 90 e0 ldi r25, 0x00 ; 0 + 7f00: 98 2f mov r25, r24 + 7f02: 88 27 eor r24, r24 + 7f04: 82 2b or r24, r18 + 7f06: 93 2b or r25, r19 #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) { - 7f1c: 12 96 adiw r26, 0x02 ; 2 + 7f08: 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); - 7f1e: fa 01 movw r30, r20 - 7f20: 0c 01 movw r0, r24 - 7f22: d7 be out 0x37, r13 ; 55 - 7f24: e8 95 spm - 7f26: 11 24 eor r1, r1 + 7f0a: fa 01 movw r30, r20 + 7f0c: 0c 01 movw r0, r24 + 7f0e: 97 be out 0x37, r9 ; 55 + 7f10: e8 95 spm + 7f12: 11 24 eor r1, r1 addrPtr += 2; - 7f28: 4e 5f subi r20, 0xFE ; 254 - 7f2a: 5f 4f sbci r21, 0xFF ; 255 + 7f14: 4e 5f subi r20, 0xFE ; 254 + 7f16: 5f 4f sbci r21, 0xFF ; 255 } while (--ch); - 7f2c: f1 e0 ldi r31, 0x01 ; 1 - 7f2e: a0 38 cpi r26, 0x80 ; 128 - 7f30: bf 07 cpc r27, r31 - 7f32: 51 f7 brne .-44 ; 0x7f08 + 7f18: f1 e0 ldi r31, 0x01 ; 1 + 7f1a: a0 38 cpi r26, 0x80 ; 128 + 7f1c: bf 07 cpc r27, r31 + 7f1e: 51 f7 brne .-44 ; 0x7ef4 // Write from programming buffer __boot_page_write_short((uint16_t)(void*)address); - 7f34: e0 91 00 02 lds r30, 0x0200 - 7f38: f0 91 01 02 lds r31, 0x0201 - 7f3c: e7 be out 0x37, r14 ; 55 - 7f3e: e8 95 spm + 7f20: f6 01 movw r30, r12 + 7f22: a7 be out 0x37, r10 ; 55 + 7f24: e8 95 spm boot_spm_busy_wait(); - 7f40: 07 b6 in r0, 0x37 ; 55 - 7f42: 00 fc sbrc r0, 0 - 7f44: fd cf rjmp .-6 ; 0x7f40 + 7f26: 07 b6 in r0, 0x37 ; 55 + 7f28: 00 fc sbrc r0, 0 + 7f2a: fd cf rjmp .-6 ; 0x7f26 #if defined(RWWSRE) // Reenable read access to flash boot_rww_enable(); - 7f46: f7 be out 0x37, r15 ; 55 - 7f48: e8 95 spm - 7f4a: 27 c0 rjmp .+78 ; 0x7f9a + 7f2c: b7 be out 0x37, r11 ; 55 + 7f2e: e8 95 spm + 7f30: 26 c0 rjmp .+76 ; 0x7f7e #endif } /* Read memory block mode, length is big endian. */ else if(ch == STK_READ_PAGE) { - 7f4c: 84 37 cpi r24, 0x74 ; 116 - 7f4e: b9 f4 brne .+46 ; 0x7f7e + 7f32: 84 37 cpi r24, 0x74 ; 116 + 7f34: b1 f4 brne .+44 ; 0x7f62 // READ PAGE - we only read flash - getLen(); - 7f50: 37 d0 rcall .+110 ; 0x7fc0 + getch(); /* getlen() */ + 7f36: 2e d0 rcall .+92 ; 0x7f94 + length = getch(); + 7f38: 2d d0 rcall .+90 ; 0x7f94 + 7f3a: f8 2e mov r15, r24 + getch(); + 7f3c: 2b d0 rcall .+86 ; 0x7f94 + verifySpace(); - 7f52: 46 d0 rcall .+140 ; 0x7fe0 + 7f3e: 38 d0 rcall .+112 ; 0x7fb0 + 7f40: f6 01 movw r30, r12 + 7f42: ef 2c mov r14, r15 putch(result); address++; } while (--length); #else do putch(pgm_read_byte_near(address++)); - 7f54: e0 91 00 02 lds r30, 0x0200 - 7f58: f0 91 01 02 lds r31, 0x0201 - 7f5c: 31 96 adiw r30, 0x01 ; 1 - 7f5e: f0 93 01 02 sts 0x0201, r31 - 7f62: e0 93 00 02 sts 0x0200, r30 - 7f66: 31 97 sbiw r30, 0x01 ; 1 - 7f68: e4 91 lpm r30, Z+ - 7f6a: 8e 2f mov r24, r30 - 7f6c: 19 d0 rcall .+50 ; 0x7fa0 + 7f44: 8f 01 movw r16, r30 + 7f46: 0f 5f subi r16, 0xFF ; 255 + 7f48: 1f 4f sbci r17, 0xFF ; 255 + 7f4a: 84 91 lpm r24, Z+ + 7f4c: 1b d0 rcall .+54 ; 0x7f84 while (--length); - 7f6e: 80 91 02 02 lds r24, 0x0202 - 7f72: 81 50 subi r24, 0x01 ; 1 - 7f74: 80 93 02 02 sts 0x0202, r24 - 7f78: 88 23 and r24, r24 - 7f7a: 61 f7 brne .-40 ; 0x7f54 - 7f7c: 0e c0 rjmp .+28 ; 0x7f9a + 7f4e: ea 94 dec r14 + 7f50: f8 01 movw r30, r16 + 7f52: c1 f7 brne .-16 ; 0x7f44 +#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) { + 7f54: 08 94 sec + 7f56: c1 1c adc r12, r1 + 7f58: d1 1c adc r13, r1 + 7f5a: fa 94 dec r15 + 7f5c: cf 0c add r12, r15 + 7f5e: d1 1c adc r13, r1 + 7f60: 0e c0 rjmp .+28 ; 0x7f7e #endif #endif } /* Get device signature bytes */ else if(ch == STK_READ_SIGN) { - 7f7e: 85 37 cpi r24, 0x75 ; 117 - 7f80: 39 f4 brne .+14 ; 0x7f90 + 7f62: 85 37 cpi r24, 0x75 ; 117 + 7f64: 39 f4 brne .+14 ; 0x7f74 // READ SIGN - return what Avrdude wants to hear verifySpace(); - 7f82: 2e d0 rcall .+92 ; 0x7fe0 + 7f66: 24 d0 rcall .+72 ; 0x7fb0 putch(SIGNATURE_0); - 7f84: 8e e1 ldi r24, 0x1E ; 30 - 7f86: 0c d0 rcall .+24 ; 0x7fa0 + 7f68: 8e e1 ldi r24, 0x1E ; 30 + 7f6a: 0c d0 rcall .+24 ; 0x7f84 putch(SIGNATURE_1); - 7f88: 85 e9 ldi r24, 0x95 ; 149 - 7f8a: 0a d0 rcall .+20 ; 0x7fa0 + 7f6c: 85 e9 ldi r24, 0x95 ; 149 + 7f6e: 0a d0 rcall .+20 ; 0x7f84 putch(SIGNATURE_2); - 7f8c: 8f e0 ldi r24, 0x0F ; 15 - 7f8e: 8b cf rjmp .-234 ; 0x7ea6 + 7f70: 8f e0 ldi r24, 0x0F ; 15 + 7f72: 98 cf rjmp .-208 ; 0x7ea4 } else if (ch == 'Q') { - 7f90: 81 35 cpi r24, 0x51 ; 81 - 7f92: 11 f4 brne .+4 ; 0x7f98 + 7f74: 81 35 cpi r24, 0x51 ; 81 + 7f76: 11 f4 brne .+4 ; 0x7f7c // Adaboot no-wait mod watchdogConfig(WATCHDOG_16MS); - 7f94: 88 e0 ldi r24, 0x08 ; 8 - 7f96: 19 d0 rcall .+50 ; 0x7fca + 7f78: 88 e0 ldi r24, 0x08 ; 8 + 7f7a: 14 d0 rcall .+40 ; 0x7fa4 verifySpace(); } else { // This covers the response to commands like STK_ENTER_PROGMODE verifySpace(); - 7f98: 23 d0 rcall .+70 ; 0x7fe0 + 7f7c: 19 d0 rcall .+50 ; 0x7fb0 } putch(STK_OK); - 7f9a: 80 e1 ldi r24, 0x10 ; 16 - 7f9c: 01 d0 rcall .+2 ; 0x7fa0 - 7f9e: 5c cf rjmp .-328 ; 0x7e58 + 7f7e: 80 e1 ldi r24, 0x10 ; 16 + 7f80: 01 d0 rcall .+2 ; 0x7f84 + 7f82: 6a cf rjmp .-300 ; 0x7e58 -00007fa0 : +00007f84 : } } void putch(char ch) { - 7fa0: 98 2f mov r25, r24 + 7f84: 98 2f mov r25, r24 #ifndef SOFT_UART while (!(UCSR0A & _BV(UDRE0))); - 7fa2: 80 91 c0 00 lds r24, 0x00C0 - 7fa6: 85 ff sbrs r24, 5 - 7fa8: fc cf rjmp .-8 ; 0x7fa2 + 7f86: 80 91 c0 00 lds r24, 0x00C0 + 7f8a: 85 ff sbrs r24, 5 + 7f8c: fc cf rjmp .-8 ; 0x7f86 UDR0 = ch; - 7faa: 90 93 c6 00 sts 0x00C6, r25 + 7f8e: 90 93 c6 00 sts 0x00C6, r25 [uartBit] "I" (UART_TX_BIT) : "r25" ); #endif } - 7fae: 08 95 ret + 7f92: 08 95 ret -00007fb0 : - return getch(); +00007f94 : } +#endif // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( - 7fb0: a8 95 wdr + 7f94: a8 95 wdr [uartBit] "I" (UART_RX_BIT) : "r25" ); #else while(!(UCSR0A & _BV(RXC0))); - 7fb2: 80 91 c0 00 lds r24, 0x00C0 - 7fb6: 87 ff sbrs r24, 7 - 7fb8: fc cf rjmp .-8 ; 0x7fb2 + 7f96: 80 91 c0 00 lds r24, 0x00C0 + 7f9a: 87 ff sbrs r24, 7 + 7f9c: fc cf rjmp .-8 ; 0x7f96 ch = UDR0; - 7fba: 80 91 c6 00 lds r24, 0x00C6 + 7f9e: 80 91 c6 00 lds r24, 0x00C6 LED_PIN |= _BV(LED); #endif #endif return ch; } - 7fbe: 08 95 ret - -00007fc0 : - } while (--count); -} -#endif - -uint8_t getLen() { - getch(); - 7fc0: f7 df rcall .-18 ; 0x7fb0 - length = getch(); - 7fc2: f6 df rcall .-20 ; 0x7fb0 - 7fc4: 80 93 02 02 sts 0x0202, r24 - return getch(); -} - 7fc8: f3 cf rjmp .-26 ; 0x7fb0 + 7fa2: 08 95 ret -00007fca : +00007fa4 : "wdr\n" ); } void watchdogConfig(uint8_t x) { WDTCSR = _BV(WDCE) | _BV(WDE); - 7fca: e0 e6 ldi r30, 0x60 ; 96 - 7fcc: f0 e0 ldi r31, 0x00 ; 0 - 7fce: 98 e1 ldi r25, 0x18 ; 24 - 7fd0: 90 83 st Z, r25 + 7fa4: e0 e6 ldi r30, 0x60 ; 96 + 7fa6: f0 e0 ldi r31, 0x00 ; 0 + 7fa8: 98 e1 ldi r25, 0x18 ; 24 + 7faa: 90 83 st Z, r25 WDTCSR = x; - 7fd2: 80 83 st Z, r24 + 7fac: 80 83 st Z, r24 } - 7fd4: 08 95 ret - -00007fd6 : - -void appStart() { - watchdogConfig(WATCHDOG_OFF); - 7fd6: 80 e0 ldi r24, 0x00 ; 0 - 7fd8: f8 df rcall .-16 ; 0x7fca - __asm__ __volatile__ ( - 7fda: ee 27 eor r30, r30 - 7fdc: ff 27 eor r31, r31 - 7fde: 09 94 ijmp + 7fae: 08 95 ret -00007fe0 : +00007fb0 : do getch(); while (--count); verifySpace(); } void verifySpace() { - if (getch() != CRC_EOP) appStart(); - 7fe0: e7 df rcall .-50 ; 0x7fb0 - 7fe2: 80 32 cpi r24, 0x20 ; 32 - 7fe4: 09 f0 breq .+2 ; 0x7fe8 - 7fe6: f7 df rcall .-18 ; 0x7fd6 + if (getch() != CRC_EOP) { + 7fb0: f1 df rcall .-30 ; 0x7f94 + 7fb2: 80 32 cpi r24, 0x20 ; 32 + 7fb4: 19 f0 breq .+6 ; 0x7fbc + watchdogConfig(WATCHDOG_16MS); // shorten WD timeout + 7fb6: 88 e0 ldi r24, 0x08 ; 8 + 7fb8: f5 df rcall .-22 ; 0x7fa4 + 7fba: ff cf rjmp .-2 ; 0x7fba + while (1) // and busy-loop so that WD causes + ; // a reset and app start. + } putch(STK_INSYNC); - 7fe8: 84 e1 ldi r24, 0x14 ; 20 + 7fbc: 84 e1 ldi r24, 0x14 ; 20 } - 7fea: da cf rjmp .-76 ; 0x7fa0 + 7fbe: e2 cf rjmp .-60 ; 0x7f84 -00007fec : +00007fc0 : ::[count] "M" (UART_B_VALUE) ); } #endif void getNch(uint8_t count) { - 7fec: 1f 93 push r17 - 7fee: 18 2f mov r17, r24 + 7fc0: 1f 93 push r17 + 7fc2: 18 2f mov r17, r24 do getch(); while (--count); - 7ff0: df df rcall .-66 ; 0x7fb0 - 7ff2: 11 50 subi r17, 0x01 ; 1 - 7ff4: e9 f7 brne .-6 ; 0x7ff0 + 7fc4: e7 df rcall .-50 ; 0x7f94 + 7fc6: 11 50 subi r17, 0x01 ; 1 + 7fc8: e9 f7 brne .-6 ; 0x7fc4 verifySpace(); - 7ff6: f4 df rcall .-24 ; 0x7fe0 + 7fca: f2 df rcall .-28 ; 0x7fb0 +} + 7fcc: 1f 91 pop r17 + 7fce: 08 95 ret + +00007fd0 : + WDTCSR = _BV(WDCE) | _BV(WDE); + WDTCSR = x; } - 7ff8: 1f 91 pop r17 - 7ffa: 08 95 ret + +void appStart() { + watchdogConfig(WATCHDOG_OFF); + 7fd0: 80 e0 ldi r24, 0x00 ; 0 + 7fd2: e8 df rcall .-48 ; 0x7fa4 + __asm__ __volatile__ ( + 7fd4: ee 27 eor r30, r30 + 7fd6: ff 27 eor r31, r31 + 7fd8: 09 94 ijmp -- cgit v1.2.3-18-g5258 From 738e5ca709769e6b42d0ae93285435aeaa459a56 Mon Sep 17 00:00:00 2001 From: WestfW Date: Sat, 11 Jun 2011 03:15:33 -0700 Subject: Fix errors in LDSECTIONS refactoring (found during atmega8 testing.) --- bootloaders/optiboot/optiboot_atmega328.lst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'bootloaders/optiboot/optiboot_atmega328.lst') diff --git a/bootloaders/optiboot/optiboot_atmega328.lst b/bootloaders/optiboot/optiboot_atmega328.lst index 7876b96..89577f6 100644 --- a/bootloaders/optiboot/optiboot_atmega328.lst +++ b/bootloaders/optiboot/optiboot_atmega328.lst @@ -11,19 +11,19 @@ Idx Name Size VMA LMA File off Algn CONTENTS, READONLY, DEBUGGING 3 .debug_pubnames 0000005f 00000000 00000000 00000258 2**0 CONTENTS, READONLY, DEBUGGING - 4 .debug_info 0000028c 00000000 00000000 000002b7 2**0 + 4 .debug_info 0000028d 00000000 00000000 000002b7 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_abbrev 00000199 00000000 00000000 00000543 2**0 + 5 .debug_abbrev 0000018a 00000000 00000000 00000544 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_line 00000456 00000000 00000000 000006dc 2**0 + 6 .debug_line 00000456 00000000 00000000 000006ce 2**0 CONTENTS, READONLY, DEBUGGING - 7 .debug_frame 00000080 00000000 00000000 00000b34 2**2 + 7 .debug_frame 00000080 00000000 00000000 00000b24 2**2 CONTENTS, READONLY, DEBUGGING - 8 .debug_str 00000149 00000000 00000000 00000bb4 2**0 + 8 .debug_str 00000149 00000000 00000000 00000ba4 2**0 CONTENTS, READONLY, DEBUGGING - 9 .debug_loc 0000027e 00000000 00000000 00000cfd 2**0 + 9 .debug_loc 0000027e 00000000 00000000 00000ced 2**0 CONTENTS, READONLY, DEBUGGING - 10 .debug_ranges 00000060 00000000 00000000 00000f7b 2**0 + 10 .debug_ranges 00000060 00000000 00000000 00000f6b 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: -- cgit v1.2.3-18-g5258 From a0d00b4d86cfbd5cb508eda69997175fab39e725 Mon Sep 17 00:00:00 2001 From: WestfW Date: Mon, 13 Jun 2011 19:07:07 -0700 Subject: http://code.google.com/p/arduino/issues/detail?id=368 Optiboot does not support ArduinoasISP programmer. When avrdude runs and talks to an arduino running ArduinoISP, it needs the optiboot (entered due to auto-reset) to abort and start the ArduinoISP "application" when it sees communications at the wrong serial speed. Unfortunately, optiboot treats all unrecognized command characters as "no-ops" and responds/loops for more commands, leading to a nice loop that never gets to the sketch. This patch causes characters received with Framing errors (the most likely error for speed mis-matches) to NOT reset the watchdog timer (normally done in getch()), which will cause the application to start if it continues for "a while." (tested. Works! Running ArduinoISP at speeds as high as 57600 still causes the bootloader to start the sketch (although it fails later on for other reasons.)) --- bootloaders/optiboot/optiboot_atmega328.lst | 140 +++++++++++++++------------- 1 file changed, 75 insertions(+), 65 deletions(-) (limited to 'bootloaders/optiboot/optiboot_atmega328.lst') diff --git a/bootloaders/optiboot/optiboot_atmega328.lst b/bootloaders/optiboot/optiboot_atmega328.lst index 89577f6..db45462 100644 --- a/bootloaders/optiboot/optiboot_atmega328.lst +++ b/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 000001da 00007e00 00007e00 00000054 2**1 + 0 .text 000001e2 00007e00 00007e00 00000054 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE - 1 .version 00000002 00007ffe 00007ffe 0000022e 2**0 + 1 .version 00000002 00007ffe 00007ffe 00000236 2**0 CONTENTS, READONLY - 2 .debug_aranges 00000028 00000000 00000000 00000230 2**0 + 2 .debug_aranges 00000028 00000000 00000000 00000238 2**0 CONTENTS, READONLY, DEBUGGING - 3 .debug_pubnames 0000005f 00000000 00000000 00000258 2**0 + 3 .debug_pubnames 0000005f 00000000 00000000 00000260 2**0 CONTENTS, READONLY, DEBUGGING - 4 .debug_info 0000028d 00000000 00000000 000002b7 2**0 + 4 .debug_info 0000028e 00000000 00000000 000002bf 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_abbrev 0000018a 00000000 00000000 00000544 2**0 + 5 .debug_abbrev 00000171 00000000 00000000 0000054d 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_line 00000456 00000000 00000000 000006ce 2**0 + 6 .debug_line 0000045e 00000000 00000000 000006be 2**0 CONTENTS, READONLY, DEBUGGING - 7 .debug_frame 00000080 00000000 00000000 00000b24 2**2 + 7 .debug_frame 00000080 00000000 00000000 00000b1c 2**2 CONTENTS, READONLY, DEBUGGING - 8 .debug_str 00000149 00000000 00000000 00000ba4 2**0 + 8 .debug_str 00000149 00000000 00000000 00000b9c 2**0 CONTENTS, READONLY, DEBUGGING - 9 .debug_loc 0000027e 00000000 00000000 00000ced 2**0 + 9 .debug_loc 0000027e 00000000 00000000 00000ce5 2**0 CONTENTS, READONLY, DEBUGGING - 10 .debug_ranges 00000060 00000000 00000000 00000f6b 2**0 + 10 .debug_ranges 00000060 00000000 00000000 00000f63 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: @@ -47,7 +47,7 @@ int main(void) { 7e04: 14 be out 0x34, r1 ; 52 if (!(ch & _BV(EXTRF))) appStart(); 7e06: 81 ff sbrs r24, 1 - 7e08: e3 d0 rcall .+454 ; 0x7fd0 + 7e08: e7 d0 rcall .+462 ; 0x7fd8 #if LED_START_FLASHES > 0 // Set up Timer 1 for timeout counter @@ -77,7 +77,7 @@ int main(void) { // Set up watchdog to trigger after 500ms watchdogConfig(WATCHDOG_1S); 7e28: 8e e0 ldi r24, 0x0E ; 14 - 7e2a: bc d0 rcall .+376 ; 0x7fa4 + 7e2a: c0 d0 rcall .+384 ; 0x7fac /* Set LED pin as output */ LED_DDR |= _BV(LED); @@ -163,7 +163,7 @@ void watchdogReset() { // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy getNch(1); 7e5e: 81 e0 ldi r24, 0x01 ; 1 - 7e60: af d0 rcall .+350 ; 0x7fc0 + 7e60: b3 d0 rcall .+358 ; 0x7fc8 putch(0x03); 7e62: 83 e0 ldi r24, 0x03 ; 3 7e64: 1f c0 rjmp .+62 ; 0x7ea4 @@ -182,7 +182,7 @@ void watchdogReset() { // SET DEVICE EXT is ignored getNch(5); 7e72: 85 e0 ldi r24, 0x05 ; 5 - 7e74: a5 d0 rcall .+330 ; 0x7fc0 + 7e74: a9 d0 rcall .+338 ; 0x7fc8 7e76: 83 c0 rjmp .+262 ; 0x7f7e } else if(ch == STK_LOAD_ADDRESS) { @@ -211,7 +211,7 @@ void watchdogReset() { 7e92: 11 1f adc r17, r17 address = newAddress; verifySpace(); - 7e94: 8d d0 rcall .+282 ; 0x7fb0 + 7e94: 91 d0 rcall .+290 ; 0x7fb8 7e96: 68 01 movw r12, r16 7e98: 72 c0 rjmp .+228 ; 0x7f7e } @@ -221,7 +221,7 @@ void watchdogReset() { // UNIVERSAL command is ignored getNch(4); 7e9e: 84 e0 ldi r24, 0x04 ; 4 - 7ea0: 8f d0 rcall .+286 ; 0x7fc0 + 7ea0: 93 d0 rcall .+294 ; 0x7fc8 putch(0x00); 7ea2: 80 e0 ldi r24, 0x00 ; 0 7ea4: 6f d0 rcall .+222 ; 0x7f84 @@ -282,7 +282,7 @@ void watchdogReset() { // Read command terminator, start reply verifySpace(); - 7ee6: 64 d0 rcall .+200 ; 0x7fb0 + 7ee6: 68 d0 rcall .+208 ; 0x7fb8 // If only a partial page is to be programmed, the erase might not be complete. // So check that here @@ -370,7 +370,7 @@ int main(void) { 7f3c: 2b d0 rcall .+86 ; 0x7f94 verifySpace(); - 7f3e: 38 d0 rcall .+112 ; 0x7fb0 + 7f3e: 3c d0 rcall .+120 ; 0x7fb8 7f40: f6 01 movw r30, r12 7f42: ef 2c mov r14, r15 putch(result); @@ -411,7 +411,7 @@ int main(void) { 7f64: 39 f4 brne .+14 ; 0x7f74 // READ SIGN - return what Avrdude wants to hear verifySpace(); - 7f66: 24 d0 rcall .+72 ; 0x7fb0 + 7f66: 28 d0 rcall .+80 ; 0x7fb8 putch(SIGNATURE_0); 7f68: 8e e1 ldi r24, 0x1E ; 30 7f6a: 0c d0 rcall .+24 ; 0x7f84 @@ -428,13 +428,13 @@ int main(void) { // Adaboot no-wait mod watchdogConfig(WATCHDOG_16MS); 7f78: 88 e0 ldi r24, 0x08 ; 8 - 7f7a: 14 d0 rcall .+40 ; 0x7fa4 + 7f7a: 18 d0 rcall .+48 ; 0x7fac verifySpace(); } else { // This covers the response to commands like STK_ENTER_PROGMODE verifySpace(); - 7f7c: 19 d0 rcall .+50 ; 0x7fb0 + 7f7c: 1d d0 rcall .+58 ; 0x7fb8 } putch(STK_OK); 7f7e: 80 e1 ldi r24, 0x10 ; 16 @@ -463,99 +463,109 @@ void putch(char ch) { 7f92: 08 95 ret 00007f94 : + [uartBit] "I" (UART_RX_BIT) + : + "r25" +); +#else + while(!(UCSR0A & _BV(RXC0))) + 7f94: 80 91 c0 00 lds r24, 0x00C0 + 7f98: 87 ff sbrs r24, 7 + 7f9a: fc cf rjmp .-8 ; 0x7f94 + ; + if (!(UCSR0A & _BV(FE0))) { + 7f9c: 80 91 c0 00 lds r24, 0x00C0 + 7fa0: 84 fd sbrc r24, 4 + 7fa2: 01 c0 rjmp .+2 ; 0x7fa6 } #endif // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( - 7f94: a8 95 wdr - [uartBit] "I" (UART_RX_BIT) - : - "r25" -); -#else - while(!(UCSR0A & _BV(RXC0))); - 7f96: 80 91 c0 00 lds r24, 0x00C0 - 7f9a: 87 ff sbrs r24, 7 - 7f9c: fc cf rjmp .-8 ; 0x7f96 + 7fa4: a8 95 wdr + * don't care that an invalid char is returned...) + */ + watchdogReset(); + } + ch = UDR0; - 7f9e: 80 91 c6 00 lds r24, 0x00C6 + 7fa6: 80 91 c6 00 lds r24, 0x00C6 LED_PIN |= _BV(LED); #endif #endif return ch; } - 7fa2: 08 95 ret + 7faa: 08 95 ret -00007fa4 : +00007fac : "wdr\n" ); } void watchdogConfig(uint8_t x) { WDTCSR = _BV(WDCE) | _BV(WDE); - 7fa4: e0 e6 ldi r30, 0x60 ; 96 - 7fa6: f0 e0 ldi r31, 0x00 ; 0 - 7fa8: 98 e1 ldi r25, 0x18 ; 24 - 7faa: 90 83 st Z, r25 + 7fac: e0 e6 ldi r30, 0x60 ; 96 + 7fae: f0 e0 ldi r31, 0x00 ; 0 + 7fb0: 98 e1 ldi r25, 0x18 ; 24 + 7fb2: 90 83 st Z, r25 WDTCSR = x; - 7fac: 80 83 st Z, r24 + 7fb4: 80 83 st Z, r24 } - 7fae: 08 95 ret + 7fb6: 08 95 ret -00007fb0 : +00007fb8 : do getch(); while (--count); verifySpace(); } void verifySpace() { if (getch() != CRC_EOP) { - 7fb0: f1 df rcall .-30 ; 0x7f94 - 7fb2: 80 32 cpi r24, 0x20 ; 32 - 7fb4: 19 f0 breq .+6 ; 0x7fbc + 7fb8: ed df rcall .-38 ; 0x7f94 + 7fba: 80 32 cpi r24, 0x20 ; 32 + 7fbc: 19 f0 breq .+6 ; 0x7fc4 watchdogConfig(WATCHDOG_16MS); // shorten WD timeout - 7fb6: 88 e0 ldi r24, 0x08 ; 8 - 7fb8: f5 df rcall .-22 ; 0x7fa4 - 7fba: ff cf rjmp .-2 ; 0x7fba + 7fbe: 88 e0 ldi r24, 0x08 ; 8 + 7fc0: f5 df rcall .-22 ; 0x7fac + 7fc2: ff cf rjmp .-2 ; 0x7fc2 while (1) // and busy-loop so that WD causes ; // a reset and app start. } putch(STK_INSYNC); - 7fbc: 84 e1 ldi r24, 0x14 ; 20 + 7fc4: 84 e1 ldi r24, 0x14 ; 20 } - 7fbe: e2 cf rjmp .-60 ; 0x7f84 + 7fc6: de cf rjmp .-68 ; 0x7f84 -00007fc0 : +00007fc8 : ::[count] "M" (UART_B_VALUE) ); } #endif void getNch(uint8_t count) { - 7fc0: 1f 93 push r17 - 7fc2: 18 2f mov r17, r24 + 7fc8: 1f 93 push r17 + 7fca: 18 2f mov r17, r24 do getch(); while (--count); - 7fc4: e7 df rcall .-50 ; 0x7f94 - 7fc6: 11 50 subi r17, 0x01 ; 1 - 7fc8: e9 f7 brne .-6 ; 0x7fc4 + 7fcc: e3 df rcall .-58 ; 0x7f94 + 7fce: 11 50 subi r17, 0x01 ; 1 + 7fd0: e9 f7 brne .-6 ; 0x7fcc verifySpace(); - 7fca: f2 df rcall .-28 ; 0x7fb0 + 7fd2: f2 df rcall .-28 ; 0x7fb8 } - 7fcc: 1f 91 pop r17 - 7fce: 08 95 ret + 7fd4: 1f 91 pop r17 + 7fd6: 08 95 ret -00007fd0 : +00007fd8 : WDTCSR = _BV(WDCE) | _BV(WDE); WDTCSR = x; } void appStart() { watchdogConfig(WATCHDOG_OFF); - 7fd0: 80 e0 ldi r24, 0x00 ; 0 - 7fd2: e8 df rcall .-48 ; 0x7fa4 + 7fd8: 80 e0 ldi r24, 0x00 ; 0 + 7fda: e8 df rcall .-48 ; 0x7fac __asm__ __volatile__ ( - 7fd4: ee 27 eor r30, r30 - 7fd6: ff 27 eor r31, r31 - 7fd8: 09 94 ijmp + 7fdc: ee 27 eor r30, r30 + 7fde: ff 27 eor r31, r31 + 7fe0: 09 94 ijmp -- cgit v1.2.3-18-g5258 From 1f01799bbfd17eb04ec6322a123d6d26b21b09a0 Mon Sep 17 00:00:00 2001 From: WestfW Date: Tue, 14 Jun 2011 10:24:27 -0700 Subject: Allow the READ PARAMETER command to return our version number. (significant size impact: 14 bytes!) Initialized "address" to eliminate compiler warning (4 bytes!) Add "atmega168" as a more accurate target name than "diecimila" (keep diecimila as well for backward compatibility) Reduce the .hex and .lst targets that are stored in source control to the three basics: atmega8, atmega168, atmega328. The other targets remain in the makefile and makeall, but will need to be built from source if wanted. Which should be less of a problem now that the source is buildable without installing crosspack. --- bootloaders/optiboot/optiboot_atmega328.lst | 479 +++++++++++++++------------- 1 file changed, 253 insertions(+), 226 deletions(-) (limited to 'bootloaders/optiboot/optiboot_atmega328.lst') diff --git a/bootloaders/optiboot/optiboot_atmega328.lst b/bootloaders/optiboot/optiboot_atmega328.lst index db45462..d9dd4cc 100644 --- a/bootloaders/optiboot/optiboot_atmega328.lst +++ b/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 000001e2 00007e00 00007e00 00000054 2**1 + 0 .text 000001f4 00007e00 00007e00 00000054 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE - 1 .version 00000002 00007ffe 00007ffe 00000236 2**0 + 1 .version 00000002 00007ffe 00007ffe 00000248 2**0 CONTENTS, READONLY - 2 .debug_aranges 00000028 00000000 00000000 00000238 2**0 + 2 .debug_aranges 00000028 00000000 00000000 0000024a 2**0 CONTENTS, READONLY, DEBUGGING - 3 .debug_pubnames 0000005f 00000000 00000000 00000260 2**0 + 3 .debug_pubnames 0000005f 00000000 00000000 00000272 2**0 CONTENTS, READONLY, DEBUGGING - 4 .debug_info 0000028e 00000000 00000000 000002bf 2**0 + 4 .debug_info 000002a8 00000000 00000000 000002d1 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_abbrev 00000171 00000000 00000000 0000054d 2**0 + 5 .debug_abbrev 00000178 00000000 00000000 00000579 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_line 0000045e 00000000 00000000 000006be 2**0 + 6 .debug_line 00000488 00000000 00000000 000006f1 2**0 CONTENTS, READONLY, DEBUGGING - 7 .debug_frame 00000080 00000000 00000000 00000b1c 2**2 + 7 .debug_frame 00000080 00000000 00000000 00000b7c 2**2 CONTENTS, READONLY, DEBUGGING - 8 .debug_str 00000149 00000000 00000000 00000b9c 2**0 + 8 .debug_str 0000014f 00000000 00000000 00000bfc 2**0 CONTENTS, READONLY, DEBUGGING - 9 .debug_loc 0000027e 00000000 00000000 00000ce5 2**0 + 9 .debug_loc 000002d8 00000000 00000000 00000d4b 2**0 CONTENTS, READONLY, DEBUGGING - 10 .debug_ranges 00000060 00000000 00000000 00000f63 2**0 + 10 .debug_ranges 00000078 00000000 00000000 00001023 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: @@ -47,7 +47,7 @@ int main(void) { 7e04: 14 be out 0x34, r1 ; 52 if (!(ch & _BV(EXTRF))) appStart(); 7e06: 81 ff sbrs r24, 1 - 7e08: e7 d0 rcall .+462 ; 0x7fd8 + 7e08: f0 d0 rcall .+480 ; 0x7fea #if LED_START_FLASHES > 0 // Set up Timer 1 for timeout counter @@ -77,7 +77,7 @@ int main(void) { // Set up watchdog to trigger after 500ms watchdogConfig(WATCHDOG_1S); 7e28: 8e e0 ldi r24, 0x0E ; 14 - 7e2a: c0 d0 rcall .+384 ; 0x7fac + 7e2a: c9 d0 rcall .+402 ; 0x7fbe /* Set LED pin as output */ LED_DDR |= _BV(LED); @@ -126,446 +126,473 @@ void watchdogReset() { } while (--count); 7e48: 81 50 subi r24, 0x01 ; 1 7e4a: a9 f7 brne .-22 ; 0x7e36 - /* get character from UART */ - ch = getch(); - - if(ch == STK_GET_PARAMETER) { - // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy - getNch(1); - 7e4c: 99 24 eor r9, r9 - 7e4e: 93 94 inc r9 + 7e4c: cc 24 eor r12, r12 + 7e4e: dd 24 eor r13, r13 + ch = SPM_PAGESIZE / 2; + do { + uint16_t a; + a = *bufPtr++; + a |= (*bufPtr++) << 8; __boot_page_fill_short((uint16_t)(void*)addrPtr,a); + 7e50: 88 24 eor r8, r8 + 7e52: 83 94 inc r8 addrPtr += 2; } while (--ch); // Write from programming buffer __boot_page_write_short((uint16_t)(void*)address); - 7e50: a5 e0 ldi r26, 0x05 ; 5 - 7e52: aa 2e mov r10, r26 + 7e54: b5 e0 ldi r27, 0x05 ; 5 + 7e56: ab 2e mov r10, r27 boot_spm_busy_wait(); #if defined(RWWSRE) // Reenable read access to flash boot_rww_enable(); - 7e54: f1 e1 ldi r31, 0x11 ; 17 - 7e56: bf 2e mov r11, r31 + 7e58: a1 e1 ldi r26, 0x11 ; 17 + 7e5a: 9a 2e mov r9, 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); + 7e5c: f3 e0 ldi r31, 0x03 ; 3 + 7e5e: bf 2e mov r11, r31 #endif /* Forever loop */ for (;;) { /* get character from UART */ ch = getch(); - 7e58: 9d d0 rcall .+314 ; 0x7f94 + 7e60: a2 d0 rcall .+324 ; 0x7fa6 if(ch == STK_GET_PARAMETER) { - 7e5a: 81 34 cpi r24, 0x41 ; 65 - 7e5c: 21 f4 brne .+8 ; 0x7e66 - // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy - getNch(1); - 7e5e: 81 e0 ldi r24, 0x01 ; 1 - 7e60: b3 d0 rcall .+358 ; 0x7fc8 - putch(0x03); - 7e62: 83 e0 ldi r24, 0x03 ; 3 - 7e64: 1f c0 rjmp .+62 ; 0x7ea4 + 7e62: 81 34 cpi r24, 0x41 ; 65 + 7e64: 61 f4 brne .+24 ; 0x7e7e + unsigned char which = getch(); + 7e66: 9f d0 rcall .+318 ; 0x7fa6 + 7e68: 08 2f mov r16, r24 + verifySpace(); + 7e6a: af d0 rcall .+350 ; 0x7fca + if (which == 0x82) { + 7e6c: 02 38 cpi r16, 0x82 ; 130 + 7e6e: 11 f0 breq .+4 ; 0x7e74 + /* + * Send optiboot version as "minor SW version" + */ + putch(OPTIBOOT_MINVER); + } else if (which == 0x81) { + 7e70: 01 38 cpi r16, 0x81 ; 129 + 7e72: 11 f4 brne .+4 ; 0x7e78 + putch(OPTIBOOT_MAJVER); + 7e74: 84 e0 ldi r24, 0x04 ; 4 + 7e76: 01 c0 rjmp .+2 ; 0x7e7a + } else { + /* + * GET PARAMETER returns a generic 0x03 reply for + * other parameters - enough to keep Avrdude happy + */ + putch(0x03); + 7e78: 83 e0 ldi r24, 0x03 ; 3 + 7e7a: 8d d0 rcall .+282 ; 0x7f96 + 7e7c: 89 c0 rjmp .+274 ; 0x7f90 + } } else if(ch == STK_SET_DEVICE) { - 7e66: 82 34 cpi r24, 0x42 ; 66 - 7e68: 11 f4 brne .+4 ; 0x7e6e + 7e7e: 82 34 cpi r24, 0x42 ; 66 + 7e80: 11 f4 brne .+4 ; 0x7e86 // SET DEVICE is ignored getNch(20); - 7e6a: 84 e1 ldi r24, 0x14 ; 20 - 7e6c: 03 c0 rjmp .+6 ; 0x7e74 + 7e82: 84 e1 ldi r24, 0x14 ; 20 + 7e84: 03 c0 rjmp .+6 ; 0x7e8c } else if(ch == STK_SET_DEVICE_EXT) { - 7e6e: 85 34 cpi r24, 0x45 ; 69 - 7e70: 19 f4 brne .+6 ; 0x7e78 + 7e86: 85 34 cpi r24, 0x45 ; 69 + 7e88: 19 f4 brne .+6 ; 0x7e90 // SET DEVICE EXT is ignored getNch(5); - 7e72: 85 e0 ldi r24, 0x05 ; 5 - 7e74: a9 d0 rcall .+338 ; 0x7fc8 - 7e76: 83 c0 rjmp .+262 ; 0x7f7e + 7e8a: 85 e0 ldi r24, 0x05 ; 5 + 7e8c: a6 d0 rcall .+332 ; 0x7fda + 7e8e: 80 c0 rjmp .+256 ; 0x7f90 } else if(ch == STK_LOAD_ADDRESS) { - 7e78: 85 35 cpi r24, 0x55 ; 85 - 7e7a: 79 f4 brne .+30 ; 0x7e9a + 7e90: 85 35 cpi r24, 0x55 ; 85 + 7e92: 79 f4 brne .+30 ; 0x7eb2 // LOAD ADDRESS uint16_t newAddress; newAddress = getch(); - 7e7c: 8b d0 rcall .+278 ; 0x7f94 + 7e94: 88 d0 rcall .+272 ; 0x7fa6 newAddress = (newAddress & 0xff) | (getch() << 8); - 7e7e: e8 2e mov r14, r24 - 7e80: ff 24 eor r15, r15 - 7e82: 88 d0 rcall .+272 ; 0x7f94 - 7e84: 08 2f mov r16, r24 - 7e86: 10 e0 ldi r17, 0x00 ; 0 - 7e88: 10 2f mov r17, r16 - 7e8a: 00 27 eor r16, r16 - 7e8c: 0e 29 or r16, r14 - 7e8e: 1f 29 or r17, r15 + 7e96: e8 2e mov r14, r24 + 7e98: ff 24 eor r15, r15 + 7e9a: 85 d0 rcall .+266 ; 0x7fa6 + 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 - 7e90: 00 0f add r16, r16 - 7e92: 11 1f adc r17, r17 + 7ea8: 00 0f add r16, r16 + 7eaa: 11 1f adc r17, r17 address = newAddress; verifySpace(); - 7e94: 91 d0 rcall .+290 ; 0x7fb8 - 7e96: 68 01 movw r12, r16 - 7e98: 72 c0 rjmp .+228 ; 0x7f7e + 7eac: 8e d0 rcall .+284 ; 0x7fca + 7eae: 68 01 movw r12, r16 + 7eb0: 6f c0 rjmp .+222 ; 0x7f90 } else if(ch == STK_UNIVERSAL) { - 7e9a: 86 35 cpi r24, 0x56 ; 86 - 7e9c: 29 f4 brne .+10 ; 0x7ea8 + 7eb2: 86 35 cpi r24, 0x56 ; 86 + 7eb4: 21 f4 brne .+8 ; 0x7ebe // UNIVERSAL command is ignored getNch(4); - 7e9e: 84 e0 ldi r24, 0x04 ; 4 - 7ea0: 93 d0 rcall .+294 ; 0x7fc8 + 7eb6: 84 e0 ldi r24, 0x04 ; 4 + 7eb8: 90 d0 rcall .+288 ; 0x7fda putch(0x00); - 7ea2: 80 e0 ldi r24, 0x00 ; 0 - 7ea4: 6f d0 rcall .+222 ; 0x7f84 - 7ea6: 6b c0 rjmp .+214 ; 0x7f7e + 7eba: 80 e0 ldi r24, 0x00 ; 0 + 7ebc: de cf rjmp .-68 ; 0x7e7a } /* Write memory, length is big endian and is in bytes */ else if(ch == STK_PROG_PAGE) { - 7ea8: 84 36 cpi r24, 0x64 ; 100 - 7eaa: 09 f0 breq .+2 ; 0x7eae - 7eac: 42 c0 rjmp .+132 ; 0x7f32 + 7ebe: 84 36 cpi r24, 0x64 ; 100 + 7ec0: 09 f0 breq .+2 ; 0x7ec4 + 7ec2: 40 c0 rjmp .+128 ; 0x7f44 // PROGRAM PAGE - we support flash programming only, not EEPROM uint8_t *bufPtr; uint16_t addrPtr; getch(); /* getlen() */ - 7eae: 72 d0 rcall .+228 ; 0x7f94 + 7ec4: 70 d0 rcall .+224 ; 0x7fa6 length = getch(); - 7eb0: 71 d0 rcall .+226 ; 0x7f94 - 7eb2: 08 2f mov r16, r24 + 7ec6: 6f d0 rcall .+222 ; 0x7fa6 + 7ec8: 08 2f mov r16, r24 getch(); - 7eb4: 6f d0 rcall .+222 ; 0x7f94 + 7eca: 6d d0 rcall .+218 ; 0x7fa6 // If we are in RWW section, immediately start page erase if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address); - 7eb6: 80 e0 ldi r24, 0x00 ; 0 - 7eb8: c8 16 cp r12, r24 - 7eba: 80 e7 ldi r24, 0x70 ; 112 - 7ebc: d8 06 cpc r13, r24 - 7ebe: 20 f4 brcc .+8 ; 0x7ec8 - 7ec0: 83 e0 ldi r24, 0x03 ; 3 - 7ec2: f6 01 movw r30, r12 - 7ec4: 87 bf out 0x37, r24 ; 55 - 7ec6: e8 95 spm - 7ec8: c0 e0 ldi r28, 0x00 ; 0 - 7eca: d1 e0 ldi r29, 0x01 ; 1 + 7ecc: 80 e0 ldi r24, 0x00 ; 0 + 7ece: c8 16 cp r12, r24 + 7ed0: 80 e7 ldi r24, 0x70 ; 112 + 7ed2: d8 06 cpc r13, r24 + 7ed4: 18 f4 brcc .+6 ; 0x7edc + 7ed6: f6 01 movw r30, r12 + 7ed8: b7 be out 0x37, r11 ; 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(); - 7ecc: 63 d0 rcall .+198 ; 0x7f94 - 7ece: 89 93 st Y+, r24 + 7ee0: 62 d0 rcall .+196 ; 0x7fa6 + 7ee2: 89 93 st Y+, r24 while (--length); - 7ed0: 0c 17 cp r16, r28 - 7ed2: e1 f7 brne .-8 ; 0x7ecc + 7ee4: 0c 17 cp r16, r28 + 7ee6: e1 f7 brne .-8 ; 0x7ee0 // 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); - 7ed4: f0 e0 ldi r31, 0x00 ; 0 - 7ed6: cf 16 cp r12, r31 - 7ed8: f0 e7 ldi r31, 0x70 ; 112 - 7eda: df 06 cpc r13, r31 - 7edc: 20 f0 brcs .+8 ; 0x7ee6 - 7ede: 83 e0 ldi r24, 0x03 ; 3 - 7ee0: f6 01 movw r30, r12 - 7ee2: 87 bf out 0x37, r24 ; 55 - 7ee4: e8 95 spm + 7ee8: f0 e0 ldi r31, 0x00 ; 0 + 7eea: cf 16 cp r12, r31 + 7eec: f0 e7 ldi r31, 0x70 ; 112 + 7eee: df 06 cpc r13, r31 + 7ef0: 18 f0 brcs .+6 ; 0x7ef8 + 7ef2: f6 01 movw r30, r12 + 7ef4: b7 be out 0x37, r11 ; 55 + 7ef6: e8 95 spm // Read command terminator, start reply verifySpace(); - 7ee6: 68 d0 rcall .+208 ; 0x7fb8 + 7ef8: 68 d0 rcall .+208 ; 0x7fca // If only a partial page is to be programmed, the erase might not be complete. // So check that here boot_spm_busy_wait(); - 7ee8: 07 b6 in r0, 0x37 ; 55 - 7eea: 00 fc sbrc r0, 0 - 7eec: fd cf rjmp .-6 ; 0x7ee8 - 7eee: a6 01 movw r20, r12 - 7ef0: a0 e0 ldi r26, 0x00 ; 0 - 7ef2: 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 + 7f00: a6 01 movw r20, r12 + 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++; - 7ef4: 2c 91 ld r18, X - 7ef6: 30 e0 ldi r19, 0x00 ; 0 + 7f06: 2c 91 ld r18, X + 7f08: 30 e0 ldi r19, 0x00 ; 0 a |= (*bufPtr++) << 8; - 7ef8: 11 96 adiw r26, 0x01 ; 1 - 7efa: 8c 91 ld r24, X - 7efc: 11 97 sbiw r26, 0x01 ; 1 - 7efe: 90 e0 ldi r25, 0x00 ; 0 - 7f00: 98 2f mov r25, r24 - 7f02: 88 27 eor r24, r24 - 7f04: 82 2b or r24, r18 - 7f06: 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 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) { - 7f08: 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); - 7f0a: fa 01 movw r30, r20 - 7f0c: 0c 01 movw r0, r24 - 7f0e: 97 be out 0x37, r9 ; 55 - 7f10: e8 95 spm - 7f12: 11 24 eor r1, r1 + 7f1c: fa 01 movw r30, r20 + 7f1e: 0c 01 movw r0, r24 + 7f20: 87 be out 0x37, r8 ; 55 + 7f22: e8 95 spm + 7f24: 11 24 eor r1, r1 addrPtr += 2; - 7f14: 4e 5f subi r20, 0xFE ; 254 - 7f16: 5f 4f sbci r21, 0xFF ; 255 + 7f26: 4e 5f subi r20, 0xFE ; 254 + 7f28: 5f 4f sbci r21, 0xFF ; 255 } while (--ch); - 7f18: f1 e0 ldi r31, 0x01 ; 1 - 7f1a: a0 38 cpi r26, 0x80 ; 128 - 7f1c: bf 07 cpc r27, r31 - 7f1e: 51 f7 brne .-44 ; 0x7ef4 + 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 // Write from programming buffer __boot_page_write_short((uint16_t)(void*)address); - 7f20: f6 01 movw r30, r12 - 7f22: a7 be out 0x37, r10 ; 55 - 7f24: e8 95 spm + 7f32: f6 01 movw r30, r12 + 7f34: a7 be out 0x37, r10 ; 55 + 7f36: e8 95 spm boot_spm_busy_wait(); - 7f26: 07 b6 in r0, 0x37 ; 55 - 7f28: 00 fc sbrc r0, 0 - 7f2a: fd cf rjmp .-6 ; 0x7f26 + 7f38: 07 b6 in r0, 0x37 ; 55 + 7f3a: 00 fc sbrc r0, 0 + 7f3c: fd cf rjmp .-6 ; 0x7f38 #if defined(RWWSRE) // Reenable read access to flash boot_rww_enable(); - 7f2c: b7 be out 0x37, r11 ; 55 - 7f2e: e8 95 spm - 7f30: 26 c0 rjmp .+76 ; 0x7f7e + 7f3e: 97 be out 0x37, r9 ; 55 + 7f40: e8 95 spm + 7f42: 26 c0 rjmp .+76 ; 0x7f90 #endif } /* Read memory block mode, length is big endian. */ else if(ch == STK_READ_PAGE) { - 7f32: 84 37 cpi r24, 0x74 ; 116 - 7f34: b1 f4 brne .+44 ; 0x7f62 + 7f44: 84 37 cpi r24, 0x74 ; 116 + 7f46: b1 f4 brne .+44 ; 0x7f74 // READ PAGE - we only read flash getch(); /* getlen() */ - 7f36: 2e d0 rcall .+92 ; 0x7f94 + 7f48: 2e d0 rcall .+92 ; 0x7fa6 length = getch(); - 7f38: 2d d0 rcall .+90 ; 0x7f94 - 7f3a: f8 2e mov r15, r24 + 7f4a: 2d d0 rcall .+90 ; 0x7fa6 + 7f4c: f8 2e mov r15, r24 getch(); - 7f3c: 2b d0 rcall .+86 ; 0x7f94 + 7f4e: 2b d0 rcall .+86 ; 0x7fa6 verifySpace(); - 7f3e: 3c d0 rcall .+120 ; 0x7fb8 - 7f40: f6 01 movw r30, r12 - 7f42: ef 2c mov r14, r15 + 7f50: 3c d0 rcall .+120 ; 0x7fca + 7f52: f6 01 movw r30, r12 + 7f54: ef 2c mov r14, r15 putch(result); address++; } while (--length); #else do putch(pgm_read_byte_near(address++)); - 7f44: 8f 01 movw r16, r30 - 7f46: 0f 5f subi r16, 0xFF ; 255 - 7f48: 1f 4f sbci r17, 0xFF ; 255 - 7f4a: 84 91 lpm r24, Z+ - 7f4c: 1b d0 rcall .+54 ; 0x7f84 + 7f56: 8f 01 movw r16, r30 + 7f58: 0f 5f subi r16, 0xFF ; 255 + 7f5a: 1f 4f sbci r17, 0xFF ; 255 + 7f5c: 84 91 lpm r24, Z+ + 7f5e: 1b d0 rcall .+54 ; 0x7f96 while (--length); - 7f4e: ea 94 dec r14 - 7f50: f8 01 movw r30, r16 - 7f52: c1 f7 brne .-16 ; 0x7f44 + 7f60: ea 94 dec r14 + 7f62: f8 01 movw r30, r16 + 7f64: c1 f7 brne .-16 ; 0x7f56 #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) { - 7f54: 08 94 sec - 7f56: c1 1c adc r12, r1 - 7f58: d1 1c adc r13, r1 - 7f5a: fa 94 dec r15 - 7f5c: cf 0c add r12, r15 - 7f5e: d1 1c adc r13, r1 - 7f60: 0e c0 rjmp .+28 ; 0x7f7e + 7f66: 08 94 sec + 7f68: c1 1c adc r12, r1 + 7f6a: d1 1c adc r13, r1 + 7f6c: fa 94 dec r15 + 7f6e: cf 0c add r12, r15 + 7f70: d1 1c adc r13, r1 + 7f72: 0e c0 rjmp .+28 ; 0x7f90 #endif #endif } /* Get device signature bytes */ else if(ch == STK_READ_SIGN) { - 7f62: 85 37 cpi r24, 0x75 ; 117 - 7f64: 39 f4 brne .+14 ; 0x7f74 + 7f74: 85 37 cpi r24, 0x75 ; 117 + 7f76: 39 f4 brne .+14 ; 0x7f86 // READ SIGN - return what Avrdude wants to hear verifySpace(); - 7f66: 28 d0 rcall .+80 ; 0x7fb8 + 7f78: 28 d0 rcall .+80 ; 0x7fca putch(SIGNATURE_0); - 7f68: 8e e1 ldi r24, 0x1E ; 30 - 7f6a: 0c d0 rcall .+24 ; 0x7f84 + 7f7a: 8e e1 ldi r24, 0x1E ; 30 + 7f7c: 0c d0 rcall .+24 ; 0x7f96 putch(SIGNATURE_1); - 7f6c: 85 e9 ldi r24, 0x95 ; 149 - 7f6e: 0a d0 rcall .+20 ; 0x7f84 + 7f7e: 85 e9 ldi r24, 0x95 ; 149 + 7f80: 0a d0 rcall .+20 ; 0x7f96 putch(SIGNATURE_2); - 7f70: 8f e0 ldi r24, 0x0F ; 15 - 7f72: 98 cf rjmp .-208 ; 0x7ea4 + 7f82: 8f e0 ldi r24, 0x0F ; 15 + 7f84: 7a cf rjmp .-268 ; 0x7e7a } else if (ch == 'Q') { - 7f74: 81 35 cpi r24, 0x51 ; 81 - 7f76: 11 f4 brne .+4 ; 0x7f7c + 7f86: 81 35 cpi r24, 0x51 ; 81 + 7f88: 11 f4 brne .+4 ; 0x7f8e // Adaboot no-wait mod watchdogConfig(WATCHDOG_16MS); - 7f78: 88 e0 ldi r24, 0x08 ; 8 - 7f7a: 18 d0 rcall .+48 ; 0x7fac + 7f8a: 88 e0 ldi r24, 0x08 ; 8 + 7f8c: 18 d0 rcall .+48 ; 0x7fbe verifySpace(); } else { // This covers the response to commands like STK_ENTER_PROGMODE verifySpace(); - 7f7c: 1d d0 rcall .+58 ; 0x7fb8 + 7f8e: 1d d0 rcall .+58 ; 0x7fca } putch(STK_OK); - 7f7e: 80 e1 ldi r24, 0x10 ; 16 - 7f80: 01 d0 rcall .+2 ; 0x7f84 - 7f82: 6a cf rjmp .-300 ; 0x7e58 + 7f90: 80 e1 ldi r24, 0x10 ; 16 + 7f92: 01 d0 rcall .+2 ; 0x7f96 + 7f94: 65 cf rjmp .-310 ; 0x7e60 -00007f84 : +00007f96 : } } void putch(char ch) { - 7f84: 98 2f mov r25, r24 + 7f96: 98 2f mov r25, r24 #ifndef SOFT_UART while (!(UCSR0A & _BV(UDRE0))); - 7f86: 80 91 c0 00 lds r24, 0x00C0 - 7f8a: 85 ff sbrs r24, 5 - 7f8c: fc cf rjmp .-8 ; 0x7f86 + 7f98: 80 91 c0 00 lds r24, 0x00C0 + 7f9c: 85 ff sbrs r24, 5 + 7f9e: fc cf rjmp .-8 ; 0x7f98 UDR0 = ch; - 7f8e: 90 93 c6 00 sts 0x00C6, r25 + 7fa0: 90 93 c6 00 sts 0x00C6, r25 [uartBit] "I" (UART_TX_BIT) : "r25" ); #endif } - 7f92: 08 95 ret + 7fa4: 08 95 ret -00007f94 : +00007fa6 : [uartBit] "I" (UART_RX_BIT) : "r25" ); #else while(!(UCSR0A & _BV(RXC0))) - 7f94: 80 91 c0 00 lds r24, 0x00C0 - 7f98: 87 ff sbrs r24, 7 - 7f9a: fc cf rjmp .-8 ; 0x7f94 + 7fa6: 80 91 c0 00 lds r24, 0x00C0 + 7faa: 87 ff sbrs r24, 7 + 7fac: fc cf rjmp .-8 ; 0x7fa6 ; if (!(UCSR0A & _BV(FE0))) { - 7f9c: 80 91 c0 00 lds r24, 0x00C0 - 7fa0: 84 fd sbrc r24, 4 - 7fa2: 01 c0 rjmp .+2 ; 0x7fa6 + 7fae: 80 91 c0 00 lds r24, 0x00C0 + 7fb2: 84 fd sbrc r24, 4 + 7fb4: 01 c0 rjmp .+2 ; 0x7fb8 } #endif // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( - 7fa4: a8 95 wdr + 7fb6: a8 95 wdr * don't care that an invalid char is returned...) */ watchdogReset(); } ch = UDR0; - 7fa6: 80 91 c6 00 lds r24, 0x00C6 + 7fb8: 80 91 c6 00 lds r24, 0x00C6 LED_PIN |= _BV(LED); #endif #endif return ch; } - 7faa: 08 95 ret + 7fbc: 08 95 ret -00007fac : +00007fbe : "wdr\n" ); } void watchdogConfig(uint8_t x) { WDTCSR = _BV(WDCE) | _BV(WDE); - 7fac: e0 e6 ldi r30, 0x60 ; 96 - 7fae: f0 e0 ldi r31, 0x00 ; 0 - 7fb0: 98 e1 ldi r25, 0x18 ; 24 - 7fb2: 90 83 st Z, r25 + 7fbe: e0 e6 ldi r30, 0x60 ; 96 + 7fc0: f0 e0 ldi r31, 0x00 ; 0 + 7fc2: 98 e1 ldi r25, 0x18 ; 24 + 7fc4: 90 83 st Z, r25 WDTCSR = x; - 7fb4: 80 83 st Z, r24 + 7fc6: 80 83 st Z, r24 } - 7fb6: 08 95 ret + 7fc8: 08 95 ret -00007fb8 : +00007fca : do getch(); while (--count); verifySpace(); } void verifySpace() { if (getch() != CRC_EOP) { - 7fb8: ed df rcall .-38 ; 0x7f94 - 7fba: 80 32 cpi r24, 0x20 ; 32 - 7fbc: 19 f0 breq .+6 ; 0x7fc4 + 7fca: ed df rcall .-38 ; 0x7fa6 + 7fcc: 80 32 cpi r24, 0x20 ; 32 + 7fce: 19 f0 breq .+6 ; 0x7fd6 watchdogConfig(WATCHDOG_16MS); // shorten WD timeout - 7fbe: 88 e0 ldi r24, 0x08 ; 8 - 7fc0: f5 df rcall .-22 ; 0x7fac - 7fc2: ff cf rjmp .-2 ; 0x7fc2 + 7fd0: 88 e0 ldi r24, 0x08 ; 8 + 7fd2: f5 df rcall .-22 ; 0x7fbe + 7fd4: ff cf rjmp .-2 ; 0x7fd4 while (1) // and busy-loop so that WD causes ; // a reset and app start. } putch(STK_INSYNC); - 7fc4: 84 e1 ldi r24, 0x14 ; 20 + 7fd6: 84 e1 ldi r24, 0x14 ; 20 } - 7fc6: de cf rjmp .-68 ; 0x7f84 + 7fd8: de cf rjmp .-68 ; 0x7f96 -00007fc8 : +00007fda : ::[count] "M" (UART_B_VALUE) ); } #endif void getNch(uint8_t count) { - 7fc8: 1f 93 push r17 - 7fca: 18 2f mov r17, r24 + 7fda: 1f 93 push r17 + 7fdc: 18 2f mov r17, r24 do getch(); while (--count); - 7fcc: e3 df rcall .-58 ; 0x7f94 - 7fce: 11 50 subi r17, 0x01 ; 1 - 7fd0: e9 f7 brne .-6 ; 0x7fcc + 7fde: e3 df rcall .-58 ; 0x7fa6 + 7fe0: 11 50 subi r17, 0x01 ; 1 + 7fe2: e9 f7 brne .-6 ; 0x7fde verifySpace(); - 7fd2: f2 df rcall .-28 ; 0x7fb8 + 7fe4: f2 df rcall .-28 ; 0x7fca } - 7fd4: 1f 91 pop r17 - 7fd6: 08 95 ret + 7fe6: 1f 91 pop r17 + 7fe8: 08 95 ret -00007fd8 : +00007fea : WDTCSR = _BV(WDCE) | _BV(WDE); WDTCSR = x; } void appStart() { watchdogConfig(WATCHDOG_OFF); - 7fd8: 80 e0 ldi r24, 0x00 ; 0 - 7fda: e8 df rcall .-48 ; 0x7fac + 7fea: 80 e0 ldi r24, 0x00 ; 0 + 7fec: e8 df rcall .-48 ; 0x7fbe __asm__ __volatile__ ( - 7fdc: ee 27 eor r30, r30 - 7fde: ff 27 eor r31, r31 - 7fe0: 09 94 ijmp + 7fee: ee 27 eor r30, r30 + 7ff0: ff 27 eor r31, r31 + 7ff2: 09 94 ijmp -- cgit v1.2.3-18-g5258