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_pro_8MHz.lst | 539 +++++++++++++++-------------- 1 file changed, 280 insertions(+), 259 deletions(-) (limited to 'bootloaders/optiboot/optiboot_pro_8MHz.lst') diff --git a/bootloaders/optiboot/optiboot_pro_8MHz.lst b/bootloaders/optiboot/optiboot_pro_8MHz.lst index 94603e2..25a4bd2 100644 --- a/bootloaders/optiboot/optiboot_pro_8MHz.lst +++ b/bootloaders/optiboot/optiboot_pro_8MHz.lst @@ -7,452 +7,473 @@ Idx Name Size VMA LMA File off Algn CONTENTS, ALLOC, LOAD, READONLY, CODE 1 .debug_aranges 00000028 00000000 00000000 00000250 2**0 CONTENTS, READONLY, DEBUGGING - 2 .debug_pubnames 00000078 00000000 00000000 00000278 2**0 + 2 .debug_pubnames 0000006a 00000000 00000000 00000278 2**0 CONTENTS, READONLY, DEBUGGING - 3 .debug_info 00000277 00000000 00000000 000002f0 2**0 + 3 .debug_info 00000284 00000000 00000000 000002e2 2**0 CONTENTS, READONLY, DEBUGGING - 4 .debug_abbrev 00000194 00000000 00000000 00000567 2**0 + 4 .debug_abbrev 000001ae 00000000 00000000 00000566 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_line 000003bb 00000000 00000000 000006fb 2**0 + 5 .debug_line 00000450 00000000 00000000 00000714 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_frame 000000a0 00000000 00000000 00000ab8 2**2 + 6 .debug_frame 00000090 00000000 00000000 00000b64 2**2 CONTENTS, READONLY, DEBUGGING - 7 .debug_str 0000013f 00000000 00000000 00000b58 2**0 + 7 .debug_str 00000141 00000000 00000000 00000bf4 2**0 CONTENTS, READONLY, DEBUGGING - 8 .debug_loc 000001a0 00000000 00000000 00000c97 2**0 + 8 .debug_loc 000001e1 00000000 00000000 00000d35 2**0 CONTENTS, READONLY, DEBUGGING - 9 .debug_ranges 00000070 00000000 00000000 00000e37 2**0 + 9 .debug_ranges 00000068 00000000 00000000 00000f16 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: 00003e00
: -#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) { - 3e00: 85 e0 ldi r24, 0x05 ; 5 - 3e02: 80 93 81 00 sts 0x0081, r24 - UCSR0C = _BV(UCSZ00) | _BV(UCSZ01); - UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); + 3e00: 11 24 eor r1, r1 +#ifdef __AVR_ATmega8__ + SP=RAMEND; // This is done by hardware reset #endif // Adaboot no-wait mod ch = MCUSR; - 3e06: 84 b7 in r24, 0x34 ; 52 + 3e02: 84 b7 in r24, 0x34 ; 52 MCUSR = 0; - 3e08: 14 be out 0x34, r1 ; 52 + 3e04: 14 be out 0x34, r1 ; 52 if (!(ch & _BV(EXTRF))) appStart(); - 3e0a: 81 ff sbrs r24, 1 - 3e0c: e4 d0 rcall .+456 ; 0x3fd6 + 3e06: 81 ff sbrs r24, 1 + 3e08: e6 d0 rcall .+460 ; 0x3fd6 + +#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 + UCSR0A = _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); + 3e16: 88 e1 ldi r24, 0x18 ; 24 + 3e18: 80 93 c1 00 sts 0x00C1, r24 + UCSR0C = _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 ); + 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_500MS); - 3e0e: 8d e0 ldi r24, 0x0D ; 13 - 3e10: dc d0 rcall .+440 ; 0x3fca + watchdogConfig(WATCHDOG_1S); + 3e28: 8e e0 ldi r24, 0x0E ; 14 + 3e2a: cf d0 rcall .+414 ; 0x3fca /* Set LED pin as output */ LED_DDR |= _BV(LED); - 3e12: 25 9a sbi 0x04, 5 ; 4 - -#ifdef SOFT_UART - /* Set TX pin as output */ - UART_DDR |= _BV(UART_TX_BIT); - 3e14: 51 9a sbi 0x0a, 1 ; 10 - 3e16: 86 e0 ldi r24, 0x06 ; 6 + 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)); - 3e18: 28 e1 ldi r18, 0x18 ; 24 - 3e1a: 3e ef ldi r19, 0xFE ; 254 + 3e30: 28 e1 ldi r18, 0x18 ; 24 + 3e32: 3e ef ldi r19, 0xFE ; 254 TIFR1 = _BV(TOV1); - 3e1c: 91 e0 ldi r25, 0x01 ; 1 + 3e34: 91 e0 ldi r25, 0x01 ; 1 } #if LED_START_FLASHES > 0 void flash_led(uint8_t count) { do { TCNT1 = -(F_CPU/(1024*16)); - 3e1e: 30 93 85 00 sts 0x0085, r19 - 3e22: 20 93 84 00 sts 0x0084, r18 + 3e36: 30 93 85 00 sts 0x0085, r19 + 3e3a: 20 93 84 00 sts 0x0084, r18 TIFR1 = _BV(TOV1); - 3e26: 96 bb out 0x16, r25 ; 22 + 3e3e: 96 bb out 0x16, r25 ; 22 while(!(TIFR1 & _BV(TOV1))); - 3e28: b0 9b sbis 0x16, 0 ; 22 - 3e2a: fe cf rjmp .-4 ; 0x3e28 + 3e40: b0 9b sbis 0x16, 0 ; 22 + 3e42: fe cf rjmp .-4 ; 0x3e40 +#ifdef __AVR_ATmega8__ + LED_PORT ^= _BV(LED); +#else LED_PIN |= _BV(LED); - 3e2c: 1d 9a sbi 0x03, 5 ; 3 + 3e44: 1d 9a sbi 0x03, 5 ; 3 return getch(); } // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( - 3e2e: a8 95 wdr - TCNT1 = -(F_CPU/(1024*16)); - TIFR1 = _BV(TOV1); - while(!(TIFR1 & _BV(TOV1))); + 3e46: a8 95 wdr + LED_PORT ^= _BV(LED); +#else LED_PIN |= _BV(LED); +#endif watchdogReset(); } while (--count); - 3e30: 81 50 subi r24, 0x01 ; 1 - 3e32: a9 f7 brne .-22 ; 0x3e1e + 3e48: 81 50 subi r24, 0x01 ; 1 + 3e4a: a9 f7 brne .-22 ; 0x3e36 /* 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); - 3e34: dd 24 eor r13, r13 - 3e36: d3 94 inc r13 - boot_page_fill((uint16_t)(void*)addrPtr,a); + 3e4c: dd 24 eor r13, r13 + 3e4e: d3 94 inc r13 + __boot_page_fill_short((uint16_t)(void*)addrPtr,a); addrPtr += 2; } while (--ch); // Write from programming buffer - boot_page_write((uint16_t)(void*)address); - 3e38: a5 e0 ldi r26, 0x05 ; 5 - 3e3a: ea 2e mov r14, r26 + __boot_page_write_short((uint16_t)(void*)address); + 3e50: a5 e0 ldi r26, 0x05 ; 5 + 3e52: ea 2e mov r14, r26 boot_spm_busy_wait(); #if defined(RWWSRE) // Reenable read access to flash boot_rww_enable(); - 3e3c: f1 e1 ldi r31, 0x11 ; 17 - 3e3e: ff 2e mov r15, r31 + 3e54: f1 e1 ldi r31, 0x11 ; 17 + 3e56: ff 2e mov r15, r31 #endif /* Forever loop */ for (;;) { /* get character from UART */ ch = getch(); - 3e40: ab d0 rcall .+342 ; 0x3f98 + 3e58: ab d0 rcall .+342 ; 0x3fb0 if(ch == STK_GET_PARAMETER) { - 3e42: 81 34 cpi r24, 0x41 ; 65 - 3e44: 21 f4 brne .+8 ; 0x3e4e + 3e5a: 81 34 cpi r24, 0x41 ; 65 + 3e5c: 21 f4 brne .+8 ; 0x3e66 // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy getNch(1); - 3e46: 81 e0 ldi r24, 0x01 ; 1 - 3e48: d1 d0 rcall .+418 ; 0x3fec + 3e5e: 81 e0 ldi r24, 0x01 ; 1 + 3e60: c5 d0 rcall .+394 ; 0x3fec putch(0x03); - 3e4a: 83 e0 ldi r24, 0x03 ; 3 - 3e4c: 24 c0 rjmp .+72 ; 0x3e96 + 3e62: 83 e0 ldi r24, 0x03 ; 3 + 3e64: 20 c0 rjmp .+64 ; 0x3ea6 } else if(ch == STK_SET_DEVICE) { - 3e4e: 82 34 cpi r24, 0x42 ; 66 - 3e50: 11 f4 brne .+4 ; 0x3e56 + 3e66: 82 34 cpi r24, 0x42 ; 66 + 3e68: 11 f4 brne .+4 ; 0x3e6e // SET DEVICE is ignored getNch(20); - 3e52: 84 e1 ldi r24, 0x14 ; 20 - 3e54: 03 c0 rjmp .+6 ; 0x3e5c + 3e6a: 84 e1 ldi r24, 0x14 ; 20 + 3e6c: 03 c0 rjmp .+6 ; 0x3e74 } else if(ch == STK_SET_DEVICE_EXT) { - 3e56: 85 34 cpi r24, 0x45 ; 69 - 3e58: 19 f4 brne .+6 ; 0x3e60 + 3e6e: 85 34 cpi r24, 0x45 ; 69 + 3e70: 19 f4 brne .+6 ; 0x3e78 // SET DEVICE EXT is ignored getNch(5); - 3e5a: 85 e0 ldi r24, 0x05 ; 5 - 3e5c: c7 d0 rcall .+398 ; 0x3fec - 3e5e: 8a c0 rjmp .+276 ; 0x3f74 + 3e72: 85 e0 ldi r24, 0x05 ; 5 + 3e74: bb d0 rcall .+374 ; 0x3fec + 3e76: 91 c0 rjmp .+290 ; 0x3f9a } else if(ch == STK_LOAD_ADDRESS) { - 3e60: 85 35 cpi r24, 0x55 ; 85 - 3e62: a1 f4 brne .+40 ; 0x3e8c + 3e78: 85 35 cpi r24, 0x55 ; 85 + 3e7a: 81 f4 brne .+32 ; 0x3e9c // LOAD ADDRESS - address = getch(); - 3e64: 99 d0 rcall .+306 ; 0x3f98 - 3e66: 08 2f mov r16, r24 - 3e68: 10 e0 ldi r17, 0x00 ; 0 - 3e6a: 10 93 01 02 sts 0x0201, r17 - 3e6e: 00 93 00 02 sts 0x0200, r16 - address = (address & 0xff) | (getch() << 8); - 3e72: 92 d0 rcall .+292 ; 0x3f98 - 3e74: 90 e0 ldi r25, 0x00 ; 0 - 3e76: 98 2f mov r25, r24 - 3e78: 88 27 eor r24, r24 - 3e7a: 80 2b or r24, r16 - 3e7c: 91 2b or r25, r17 - address += address; // Convert from word address to byte address - 3e7e: 88 0f add r24, r24 - 3e80: 99 1f adc r25, r25 - 3e82: 90 93 01 02 sts 0x0201, r25 - 3e86: 80 93 00 02 sts 0x0200, r24 - 3e8a: 73 c0 rjmp .+230 ; 0x3f72 + uint16_t newAddress; + newAddress = getch(); + 3e7c: 99 d0 rcall .+306 ; 0x3fb0 + newAddress = (newAddress & 0xff) | (getch() << 8); + 3e7e: 08 2f mov r16, r24 + 3e80: 10 e0 ldi r17, 0x00 ; 0 + 3e82: 96 d0 rcall .+300 ; 0x3fb0 + 3e84: 90 e0 ldi r25, 0x00 ; 0 + 3e86: 98 2f mov r25, r24 + 3e88: 88 27 eor r24, r24 + 3e8a: 80 2b or r24, r16 + 3e8c: 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 + 3e8e: 88 0f add r24, r24 + 3e90: 99 1f adc r25, r25 + address = newAddress; + 3e92: 90 93 01 02 sts 0x0201, r25 + 3e96: 80 93 00 02 sts 0x0200, r24 + 3e9a: 7e c0 rjmp .+252 ; 0x3f98 verifySpace(); } else if(ch == STK_UNIVERSAL) { - 3e8c: 86 35 cpi r24, 0x56 ; 86 - 3e8e: 29 f4 brne .+10 ; 0x3e9a + 3e9c: 86 35 cpi r24, 0x56 ; 86 + 3e9e: 29 f4 brne .+10 ; 0x3eaa // UNIVERSAL command is ignored getNch(4); - 3e90: 84 e0 ldi r24, 0x04 ; 4 - 3e92: ac d0 rcall .+344 ; 0x3fec + 3ea0: 84 e0 ldi r24, 0x04 ; 4 + 3ea2: a4 d0 rcall .+328 ; 0x3fec putch(0x00); - 3e94: 80 e0 ldi r24, 0x00 ; 0 - 3e96: 71 d0 rcall .+226 ; 0x3f7a - 3e98: 6d c0 rjmp .+218 ; 0x3f74 + 3ea4: 80 e0 ldi r24, 0x00 ; 0 + 3ea6: 7c d0 rcall .+248 ; 0x3fa0 + 3ea8: 78 c0 rjmp .+240 ; 0x3f9a } - /* 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) { - 3e9a: 84 36 cpi r24, 0x64 ; 100 - 3e9c: 09 f0 breq .+2 ; 0x3ea0 - 3e9e: 43 c0 rjmp .+134 ; 0x3f26 + 3eaa: 84 36 cpi r24, 0x64 ; 100 + 3eac: 09 f0 breq .+2 ; 0x3eb0 + 3eae: 4e c0 rjmp .+156 ; 0x3f4c // PROGRAM PAGE - we support flash programming only, not EEPROM uint8_t *bufPtr; uint16_t addrPtr; getLen(); - 3ea0: 8f d0 rcall .+286 ; 0x3fc0 - - // Immediately start page erase - this will 4.5ms - boot_page_erase((uint16_t)(void*)address); - 3ea2: e0 91 00 02 lds r30, 0x0200 - 3ea6: f0 91 01 02 lds r31, 0x0201 - 3eaa: 83 e0 ldi r24, 0x03 ; 3 - 3eac: 80 93 57 00 sts 0x0057, r24 - 3eb0: e8 95 spm - 3eb2: c0 e0 ldi r28, 0x00 ; 0 - 3eb4: d1 e0 ldi r29, 0x01 ; 1 - + 3eb0: 87 d0 rcall .+270 ; 0x3fc0 + + // If we are in RWW section, immediately start page erase + if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address); + 3eb2: e0 91 00 02 lds r30, 0x0200 + 3eb6: f0 91 01 02 lds r31, 0x0201 + 3eba: 88 e3 ldi r24, 0x38 ; 56 + 3ebc: e0 30 cpi r30, 0x00 ; 0 + 3ebe: f8 07 cpc r31, r24 + 3ec0: 18 f4 brcc .+6 ; 0x3ec8 + 3ec2: 83 e0 ldi r24, 0x03 ; 3 + 3ec4: 87 bf out 0x37, r24 ; 55 + 3ec6: e8 95 spm + 3ec8: c0 e0 ldi r28, 0x00 ; 0 + 3eca: d1 e0 ldi r29, 0x01 ; 1 + // While that is going on, read in page contents bufPtr = buff; do *bufPtr++ = getch(); - 3eb6: 70 d0 rcall .+224 ; 0x3f98 - 3eb8: 89 93 st Y+, r24 + 3ecc: 71 d0 rcall .+226 ; 0x3fb0 + 3ece: 89 93 st Y+, r24 while (--length); - 3eba: 80 91 02 02 lds r24, 0x0202 - 3ebe: 81 50 subi r24, 0x01 ; 1 - 3ec0: 80 93 02 02 sts 0x0202, r24 - 3ec4: 88 23 and r24, r24 - 3ec6: b9 f7 brne .-18 ; 0x3eb6 + 3ed0: 80 91 02 02 lds r24, 0x0202 + 3ed4: 81 50 subi r24, 0x01 ; 1 + 3ed6: 80 93 02 02 sts 0x0202, r24 + 3eda: 88 23 and r24, r24 + 3edc: b9 f7 brne .-18 ; 0x3ecc + + // 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); + 3ede: e0 91 00 02 lds r30, 0x0200 + 3ee2: f0 91 01 02 lds r31, 0x0201 + 3ee6: 88 e3 ldi r24, 0x38 ; 56 + 3ee8: e0 30 cpi r30, 0x00 ; 0 + 3eea: f8 07 cpc r31, r24 + 3eec: 18 f0 brcs .+6 ; 0x3ef4 + 3eee: 83 e0 ldi r24, 0x03 ; 3 + 3ef0: 87 bf out 0x37, r24 ; 55 + 3ef2: e8 95 spm // Read command terminator, start reply verifySpace(); - 3ec8: 8b d0 rcall .+278 ; 0x3fe0 + 3ef4: 75 d0 rcall .+234 ; 0x3fe0 // If only a partial page is to be programmed, the erase might not be complete. // So check that here boot_spm_busy_wait(); - 3eca: 07 b6 in r0, 0x37 ; 55 - 3ecc: 00 fc sbrc r0, 0 - 3ece: fd cf rjmp .-6 ; 0x3eca + 3ef6: 07 b6 in r0, 0x37 ; 55 + 3ef8: 00 fc sbrc r0, 0 + 3efa: fd cf rjmp .-6 ; 0x3ef6 } #endif // Copy buffer into programming buffer bufPtr = buff; addrPtr = (uint16_t)(void*)address; - 3ed0: 40 91 00 02 lds r20, 0x0200 - 3ed4: 50 91 01 02 lds r21, 0x0201 - 3ed8: a0 e0 ldi r26, 0x00 ; 0 - 3eda: b1 e0 ldi r27, 0x01 ; 1 + 3efc: 40 91 00 02 lds r20, 0x0200 + 3f00: 50 91 01 02 lds r21, 0x0201 + 3f04: a0 e0 ldi r26, 0x00 ; 0 + 3f06: b1 e0 ldi r27, 0x01 ; 1 ch = SPM_PAGESIZE / 2; do { uint16_t a; a = *bufPtr++; - 3edc: 2c 91 ld r18, X - 3ede: 30 e0 ldi r19, 0x00 ; 0 + 3f08: 2c 91 ld r18, X + 3f0a: 30 e0 ldi r19, 0x00 ; 0 a |= (*bufPtr++) << 8; - 3ee0: 11 96 adiw r26, 0x01 ; 1 - 3ee2: 8c 91 ld r24, X - 3ee4: 11 97 sbiw r26, 0x01 ; 1 - 3ee6: 90 e0 ldi r25, 0x00 ; 0 - 3ee8: 98 2f mov r25, r24 - 3eea: 88 27 eor r24, r24 - 3eec: 82 2b or r24, r18 - 3eee: 93 2b or r25, r19 -#ifdef VIRTUAL_BOOT_PARTITION -#define rstVect (*(uint16_t*)(0x204)) -#define wdtVect (*(uint16_t*)(0x206)) + 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 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) { - 3ef0: 12 96 adiw r26, 0x02 ; 2 + 3f1c: 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); - 3ef2: fa 01 movw r30, r20 - 3ef4: 0c 01 movw r0, r24 - 3ef6: d0 92 57 00 sts 0x0057, r13 - 3efa: e8 95 spm - 3efc: 11 24 eor r1, r1 + __boot_page_fill_short((uint16_t)(void*)addrPtr,a); + 3f1e: fa 01 movw r30, r20 + 3f20: 0c 01 movw r0, r24 + 3f22: d7 be out 0x37, r13 ; 55 + 3f24: e8 95 spm + 3f26: 11 24 eor r1, r1 addrPtr += 2; - 3efe: 4e 5f subi r20, 0xFE ; 254 - 3f00: 5f 4f sbci r21, 0xFF ; 255 + 3f28: 4e 5f subi r20, 0xFE ; 254 + 3f2a: 5f 4f sbci r21, 0xFF ; 255 } while (--ch); - 3f02: f1 e0 ldi r31, 0x01 ; 1 - 3f04: a0 38 cpi r26, 0x80 ; 128 - 3f06: bf 07 cpc r27, r31 - 3f08: 49 f7 brne .-46 ; 0x3edc + 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 // Write from programming buffer - boot_page_write((uint16_t)(void*)address); - 3f0a: e0 91 00 02 lds r30, 0x0200 - 3f0e: f0 91 01 02 lds r31, 0x0201 - 3f12: e0 92 57 00 sts 0x0057, r14 - 3f16: e8 95 spm + __boot_page_write_short((uint16_t)(void*)address); + 3f34: e0 91 00 02 lds r30, 0x0200 + 3f38: f0 91 01 02 lds r31, 0x0201 + 3f3c: e7 be out 0x37, r14 ; 55 + 3f3e: e8 95 spm boot_spm_busy_wait(); - 3f18: 07 b6 in r0, 0x37 ; 55 - 3f1a: 00 fc sbrc r0, 0 - 3f1c: fd cf rjmp .-6 ; 0x3f18 + 3f40: 07 b6 in r0, 0x37 ; 55 + 3f42: 00 fc sbrc r0, 0 + 3f44: fd cf rjmp .-6 ; 0x3f40 #if defined(RWWSRE) // Reenable read access to flash boot_rww_enable(); - 3f1e: f0 92 57 00 sts 0x0057, r15 - 3f22: e8 95 spm - 3f24: 27 c0 rjmp .+78 ; 0x3f74 + 3f46: f7 be out 0x37, r15 ; 55 + 3f48: e8 95 spm + 3f4a: 27 c0 rjmp .+78 ; 0x3f9a #endif } /* Read memory block mode, length is big endian. */ else if(ch == STK_READ_PAGE) { - 3f26: 84 37 cpi r24, 0x74 ; 116 - 3f28: b9 f4 brne .+46 ; 0x3f58 + 3f4c: 84 37 cpi r24, 0x74 ; 116 + 3f4e: b9 f4 brne .+46 ; 0x3f7e // READ PAGE - we only read flash getLen(); - 3f2a: 4a d0 rcall .+148 ; 0x3fc0 + 3f50: 37 d0 rcall .+110 ; 0x3fc0 verifySpace(); - 3f2c: 59 d0 rcall .+178 ; 0x3fe0 - else ch = pgm_read_byte_near(address); + 3f52: 46 d0 rcall .+140 ; 0x3fe0 + putch(result); address++; - putch(ch); - } while (--length); + } + while (--length); #else do putch(pgm_read_byte_near(address++)); - 3f2e: e0 91 00 02 lds r30, 0x0200 - 3f32: f0 91 01 02 lds r31, 0x0201 - 3f36: 31 96 adiw r30, 0x01 ; 1 - 3f38: f0 93 01 02 sts 0x0201, r31 - 3f3c: e0 93 00 02 sts 0x0200, r30 - 3f40: 31 97 sbiw r30, 0x01 ; 1 - 3f42: e4 91 lpm r30, Z+ - 3f44: 8e 2f mov r24, r30 - 3f46: 19 d0 rcall .+50 ; 0x3f7a + 3f54: e0 91 00 02 lds r30, 0x0200 + 3f58: f0 91 01 02 lds r31, 0x0201 + 3f5c: 31 96 adiw r30, 0x01 ; 1 + 3f5e: f0 93 01 02 sts 0x0201, r31 + 3f62: e0 93 00 02 sts 0x0200, r30 + 3f66: 31 97 sbiw r30, 0x01 ; 1 + 3f68: e4 91 lpm r30, Z+ + 3f6a: 8e 2f mov r24, r30 + 3f6c: 19 d0 rcall .+50 ; 0x3fa0 while (--length); - 3f48: 80 91 02 02 lds r24, 0x0202 - 3f4c: 81 50 subi r24, 0x01 ; 1 - 3f4e: 80 93 02 02 sts 0x0202, r24 - 3f52: 88 23 and r24, r24 - 3f54: 61 f7 brne .-40 ; 0x3f2e - 3f56: 0e c0 rjmp .+28 ; 0x3f74 + 3f6e: 80 91 02 02 lds r24, 0x0202 + 3f72: 81 50 subi r24, 0x01 ; 1 + 3f74: 80 93 02 02 sts 0x0202, r24 + 3f78: 88 23 and r24, r24 + 3f7a: 61 f7 brne .-40 ; 0x3f54 + 3f7c: 0e c0 rjmp .+28 ; 0x3f9a +#endif #endif } /* Get device signature bytes */ else if(ch == STK_READ_SIGN) { - 3f58: 85 37 cpi r24, 0x75 ; 117 - 3f5a: 39 f4 brne .+14 ; 0x3f6a + 3f7e: 85 37 cpi r24, 0x75 ; 117 + 3f80: 39 f4 brne .+14 ; 0x3f90 // READ SIGN - return what Avrdude wants to hear verifySpace(); - 3f5c: 41 d0 rcall .+130 ; 0x3fe0 + 3f82: 2e d0 rcall .+92 ; 0x3fe0 putch(SIGNATURE_0); - 3f5e: 8e e1 ldi r24, 0x1E ; 30 - 3f60: 0c d0 rcall .+24 ; 0x3f7a + 3f84: 8e e1 ldi r24, 0x1E ; 30 + 3f86: 0c d0 rcall .+24 ; 0x3fa0 putch(SIGNATURE_1); - 3f62: 84 e9 ldi r24, 0x94 ; 148 - 3f64: 0a d0 rcall .+20 ; 0x3f7a + 3f88: 84 e9 ldi r24, 0x94 ; 148 + 3f8a: 0a d0 rcall .+20 ; 0x3fa0 putch(SIGNATURE_2); - 3f66: 86 e0 ldi r24, 0x06 ; 6 - 3f68: 96 cf rjmp .-212 ; 0x3e96 + 3f8c: 86 e0 ldi r24, 0x06 ; 6 + 3f8e: 8b cf rjmp .-234 ; 0x3ea6 } else if (ch == 'Q') { - 3f6a: 81 35 cpi r24, 0x51 ; 81 - 3f6c: 11 f4 brne .+4 ; 0x3f72 + 3f90: 81 35 cpi r24, 0x51 ; 81 + 3f92: 11 f4 brne .+4 ; 0x3f98 // Adaboot no-wait mod watchdogConfig(WATCHDOG_16MS); - 3f6e: 88 e0 ldi r24, 0x08 ; 8 - 3f70: 2c d0 rcall .+88 ; 0x3fca + 3f94: 88 e0 ldi r24, 0x08 ; 8 + 3f96: 19 d0 rcall .+50 ; 0x3fca verifySpace(); } else { // This covers the response to commands like STK_ENTER_PROGMODE verifySpace(); - 3f72: 36 d0 rcall .+108 ; 0x3fe0 + 3f98: 23 d0 rcall .+70 ; 0x3fe0 } putch(STK_OK); - 3f74: 80 e1 ldi r24, 0x10 ; 16 - 3f76: 01 d0 rcall .+2 ; 0x3f7a - 3f78: 63 cf rjmp .-314 ; 0x3e40 + 3f9a: 80 e1 ldi r24, 0x10 ; 16 + 3f9c: 01 d0 rcall .+2 ; 0x3fa0 + 3f9e: 5c cf rjmp .-328 ; 0x3e58 + +00003fa0 : + } +} -00003f7a : void putch(char ch) { + 3fa0: 98 2f mov r25, r24 #ifndef SOFT_UART while (!(UCSR0A & _BV(UDRE0))); + 3fa2: 80 91 c0 00 lds r24, 0x00C0 + 3fa6: 85 ff sbrs r24, 5 + 3fa8: fc cf rjmp .-8 ; 0x3fa2 UDR0 = ch; -#else - __asm__ __volatile__ ( - 3f7a: 2a e0 ldi r18, 0x0A ; 10 - 3f7c: 30 e0 ldi r19, 0x00 ; 0 - 3f7e: 80 95 com r24 - 3f80: 08 94 sec - 3f82: 10 f4 brcc .+4 ; 0x3f88 - 3f84: 59 98 cbi 0x0b, 1 ; 11 - 3f86: 02 c0 rjmp .+4 ; 0x3f8c - 3f88: 59 9a sbi 0x0b, 1 ; 11 - 3f8a: 00 00 nop - 3f8c: 15 d0 rcall .+42 ; 0x3fb8 - 3f8e: 14 d0 rcall .+40 ; 0x3fb8 - 3f90: 86 95 lsr r24 - 3f92: 2a 95 dec r18 - 3f94: b1 f7 brne .-20 ; 0x3f82 + 3faa: 90 93 c6 00 sts 0x00C6, r25 [uartBit] "I" (UART_TX_BIT) : "r25" ); #endif } - 3f96: 08 95 ret + 3fae: 08 95 ret -00003f98 : +00003fb0 : return getch(); } // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( - 3f98: a8 95 wdr -#ifdef LED_DATA_FLASH + 3fb0: a8 95 wdr + [uartBit] "I" (UART_RX_BIT) + : + "r25" +); +#else + while(!(UCSR0A & _BV(RXC0))); + 3fb2: 80 91 c0 00 lds r24, 0x00C0 + 3fb6: 87 ff sbrs r24, 7 + 3fb8: fc cf rjmp .-8 ; 0x3fb2 + ch = UDR0; + 3fba: 80 91 c6 00 lds r24, 0x00C6 LED_PIN |= _BV(LED); +#endif #endif return ch; } - 3f9a: 29 e0 ldi r18, 0x09 ; 9 - 3f9c: 30 e0 ldi r19, 0x00 ; 0 - 3f9e: 48 99 sbic 0x09, 0 ; 9 - 3fa0: fe cf rjmp .-4 ; 0x3f9e - 3fa2: 0a d0 rcall .+20 ; 0x3fb8 - 3fa4: 09 d0 rcall .+18 ; 0x3fb8 - 3fa6: 08 d0 rcall .+16 ; 0x3fb8 - 3fa8: 88 94 clc - 3faa: 48 99 sbic 0x09, 0 ; 9 - 3fac: 08 94 sec - 3fae: 2a 95 dec r18 - 3fb0: 11 f0 breq .+4 ; 0x3fb6 - 3fb2: 87 95 ror r24 - 3fb4: f7 cf rjmp .-18 ; 0x3fa4 - 3fb6: 08 95 ret - -00003fb8 : -#if UART_B_VALUE > 255 -#error Baud rate too slow for soft UART -#endif - -void uartDelay() { - __asm__ __volatile__ ( - 3fb8: 98 e0 ldi r25, 0x08 ; 8 - 3fba: 9a 95 dec r25 - 3fbc: f1 f7 brne .-4 ; 0x3fba 3fbe: 08 95 ret 00003fc0 : @@ -462,13 +483,13 @@ void uartDelay() { uint8_t getLen() { getch(); - 3fc0: eb df rcall .-42 ; 0x3f98 + 3fc0: f7 df rcall .-18 ; 0x3fb0 length = getch(); - 3fc2: ea df rcall .-44 ; 0x3f98 + 3fc2: f6 df rcall .-20 ; 0x3fb0 3fc4: 80 93 02 02 sts 0x0202, r24 return getch(); } - 3fc8: e7 cf rjmp .-50 ; 0x3f98 + 3fc8: f3 cf rjmp .-26 ; 0x3fb0 00003fca : "wdr\n" @@ -504,14 +525,16 @@ void appStart() { void verifySpace() { if (getch() != CRC_EOP) appStart(); - 3fe0: db df rcall .-74 ; 0x3f98 + 3fe0: e7 df rcall .-50 ; 0x3fb0 3fe2: 80 32 cpi r24, 0x20 ; 32 3fe4: 09 f0 breq .+2 ; 0x3fe8 3fe6: f7 df rcall .-18 ; 0x3fd6 putch(STK_INSYNC); 3fe8: 84 e1 ldi r24, 0x14 ; 20 } - 3fea: c7 cf rjmp .-114 ; 0x3f7a + 3fea: da cf rjmp .-76 ; 0x3fa0 + +00003fec : ::[count] "M" (UART_B_VALUE) ); } @@ -520,12 +543,10 @@ void verifySpace() { void getNch(uint8_t count) { 3fec: 1f 93 push r17 3fee: 18 2f mov r17, r24 - -00003ff0 : do getch(); while (--count); - 3ff0: d3 df rcall .-90 ; 0x3f98 + 3ff0: df df rcall .-66 ; 0x3fb0 3ff2: 11 50 subi r17, 0x01 ; 1 - 3ff4: e9 f7 brne .-6 ; 0x3ff0 + 3ff4: e9 f7 brne .-6 ; 0x3ff0 verifySpace(); 3ff6: f4 df rcall .-24 ; 0x3fe0 } -- 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_pro_8MHz.lst | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'bootloaders/optiboot/optiboot_pro_8MHz.lst') diff --git a/bootloaders/optiboot/optiboot_pro_8MHz.lst b/bootloaders/optiboot/optiboot_pro_8MHz.lst index 25a4bd2..23d5e1a 100644 --- a/bootloaders/optiboot/optiboot_pro_8MHz.lst +++ b/bootloaders/optiboot/optiboot_pro_8MHz.lst @@ -5,23 +5,25 @@ Sections: Idx Name Size VMA LMA File off Algn 0 .text 000001fc 00003e00 00003e00 00000054 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE - 1 .debug_aranges 00000028 00000000 00000000 00000250 2**0 + 1 .version 00000002 00003ffe 00003ffe 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); 3e50: a5 e0 ldi r26, 0x05 ; 5 @@ -249,7 +251,7 @@ void watchdogReset() { 3ec6: e8 95 spm 3ec8: c0 e0 ldi r28, 0x00 ; 0 3eca: 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(); 3ef4: 75 d0 rcall .+234 ; 0x3fe0 - + // 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) { 3f2e: a0 38 cpi r26, 0x80 ; 128 3f30: bf 07 cpc r27, r31 3f32: 51 f7 brne .-44 ; 0x3f08 - + // Write from programming buffer __boot_page_write_short((uint16_t)(void*)address); 3f34: 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_pro_8MHz.lst | 439 +++++++++++++++-------------- 1 file changed, 222 insertions(+), 217 deletions(-) (limited to 'bootloaders/optiboot/optiboot_pro_8MHz.lst') diff --git a/bootloaders/optiboot/optiboot_pro_8MHz.lst b/bootloaders/optiboot/optiboot_pro_8MHz.lst index 23d5e1a..d3d760e 100644 --- a/bootloaders/optiboot/optiboot_pro_8MHz.lst +++ b/bootloaders/optiboot/optiboot_pro_8MHz.lst @@ -3,27 +3,27 @@ optiboot_pro_8MHz.elf: file format elf32-avr Sections: Idx Name Size VMA LMA File off Algn - 0 .text 000001fc 00003e00 00003e00 00000054 2**1 + 0 .text 000001da 00003e00 00003e00 00000054 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE - 1 .version 00000002 00003ffe 00003ffe 00000250 2**0 + 1 .version 00000002 00003ffe 00003ffe 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) { 3e04: 14 be out 0x34, r1 ; 52 if (!(ch & _BV(EXTRF))) appStart(); 3e06: 81 ff sbrs r24, 1 - 3e08: e6 d0 rcall .+460 ; 0x3fd6 + 3e08: e3 d0 rcall .+454 ; 0x3fd0 #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); 3e28: 8e e0 ldi r24, 0x0E ; 14 - 3e2a: cf d0 rcall .+414 ; 0x3fca + 3e2a: bc d0 rcall .+376 ; 0x3fa4 /* Set LED pin as output */ LED_DDR |= _BV(LED); @@ -111,8 +111,8 @@ void flash_led(uint8_t count) { #else LED_PIN |= _BV(LED); 3e44: 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); - 3e4c: dd 24 eor r13, r13 - 3e4e: d3 94 inc r13 + 3e4c: 99 24 eor r9, r9 + 3e4e: 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); 3e50: a5 e0 ldi r26, 0x05 ; 5 - 3e52: ea 2e mov r14, r26 + 3e52: aa 2e mov r10, r26 boot_spm_busy_wait(); #if defined(RWWSRE) // Reenable read access to flash boot_rww_enable(); 3e54: f1 e1 ldi r31, 0x11 ; 17 - 3e56: ff 2e mov r15, r31 + 3e56: bf 2e mov r11, r31 #endif /* Forever loop */ for (;;) { /* get character from UART */ ch = getch(); - 3e58: ab d0 rcall .+342 ; 0x3fb0 + 3e58: 9d d0 rcall .+314 ; 0x3f94 if(ch == STK_GET_PARAMETER) { 3e5a: 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); 3e5e: 81 e0 ldi r24, 0x01 ; 1 - 3e60: c5 d0 rcall .+394 ; 0x3fec + 3e60: af d0 rcall .+350 ; 0x3fc0 putch(0x03); 3e62: 83 e0 ldi r24, 0x03 ; 3 - 3e64: 20 c0 rjmp .+64 ; 0x3ea6 + 3e64: 1f c0 rjmp .+62 ; 0x3ea4 } else if(ch == STK_SET_DEVICE) { 3e66: 82 34 cpi r24, 0x42 ; 66 @@ -182,71 +182,77 @@ void watchdogReset() { // SET DEVICE EXT is ignored getNch(5); 3e72: 85 e0 ldi r24, 0x05 ; 5 - 3e74: bb d0 rcall .+374 ; 0x3fec - 3e76: 91 c0 rjmp .+290 ; 0x3f9a + 3e74: a5 d0 rcall .+330 ; 0x3fc0 + 3e76: 83 c0 rjmp .+262 ; 0x3f7e } else if(ch == STK_LOAD_ADDRESS) { 3e78: 85 35 cpi r24, 0x55 ; 85 - 3e7a: 81 f4 brne .+32 ; 0x3e9c + 3e7a: 79 f4 brne .+30 ; 0x3e9a // LOAD ADDRESS uint16_t newAddress; newAddress = getch(); - 3e7c: 99 d0 rcall .+306 ; 0x3fb0 + 3e7c: 8b d0 rcall .+278 ; 0x3f94 newAddress = (newAddress & 0xff) | (getch() << 8); - 3e7e: 08 2f mov r16, r24 - 3e80: 10 e0 ldi r17, 0x00 ; 0 - 3e82: 96 d0 rcall .+300 ; 0x3fb0 - 3e84: 90 e0 ldi r25, 0x00 ; 0 - 3e86: 98 2f mov r25, r24 - 3e88: 88 27 eor r24, r24 - 3e8a: 80 2b or r24, r16 - 3e8c: 91 2b or r25, r17 + 3e7e: e8 2e mov r14, r24 + 3e80: ff 24 eor r15, r15 + 3e82: 88 d0 rcall .+272 ; 0x3f94 + 3e84: 08 2f mov r16, r24 + 3e86: 10 e0 ldi r17, 0x00 ; 0 + 3e88: 10 2f mov r17, r16 + 3e8a: 00 27 eor r16, r16 + 3e8c: 0e 29 or r16, r14 + 3e8e: 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 - 3e8e: 88 0f add r24, r24 - 3e90: 99 1f adc r25, r25 + 3e90: 00 0f add r16, r16 + 3e92: 11 1f adc r17, r17 address = newAddress; - 3e92: 90 93 01 02 sts 0x0201, r25 - 3e96: 80 93 00 02 sts 0x0200, r24 - 3e9a: 7e c0 rjmp .+252 ; 0x3f98 verifySpace(); + 3e94: 8d d0 rcall .+282 ; 0x3fb0 + 3e96: 68 01 movw r12, r16 + 3e98: 72 c0 rjmp .+228 ; 0x3f7e } else if(ch == STK_UNIVERSAL) { - 3e9c: 86 35 cpi r24, 0x56 ; 86 - 3e9e: 29 f4 brne .+10 ; 0x3eaa + 3e9a: 86 35 cpi r24, 0x56 ; 86 + 3e9c: 29 f4 brne .+10 ; 0x3ea8 // UNIVERSAL command is ignored getNch(4); - 3ea0: 84 e0 ldi r24, 0x04 ; 4 - 3ea2: a4 d0 rcall .+328 ; 0x3fec + 3e9e: 84 e0 ldi r24, 0x04 ; 4 + 3ea0: 8f d0 rcall .+286 ; 0x3fc0 putch(0x00); - 3ea4: 80 e0 ldi r24, 0x00 ; 0 - 3ea6: 7c d0 rcall .+248 ; 0x3fa0 - 3ea8: 78 c0 rjmp .+240 ; 0x3f9a + 3ea2: 80 e0 ldi r24, 0x00 ; 0 + 3ea4: 6f d0 rcall .+222 ; 0x3f84 + 3ea6: 6b c0 rjmp .+214 ; 0x3f7e } /* Write memory, length is big endian and is in bytes */ else if(ch == STK_PROG_PAGE) { - 3eaa: 84 36 cpi r24, 0x64 ; 100 - 3eac: 09 f0 breq .+2 ; 0x3eb0 - 3eae: 4e c0 rjmp .+156 ; 0x3f4c + 3ea8: 84 36 cpi r24, 0x64 ; 100 + 3eaa: 09 f0 breq .+2 ; 0x3eae + 3eac: 42 c0 rjmp .+132 ; 0x3f32 // PROGRAM PAGE - we support flash programming only, not EEPROM uint8_t *bufPtr; uint16_t addrPtr; - getLen(); - 3eb0: 87 d0 rcall .+270 ; 0x3fc0 + getch(); /* getlen() */ + 3eae: 72 d0 rcall .+228 ; 0x3f94 + length = getch(); + 3eb0: 71 d0 rcall .+226 ; 0x3f94 + 3eb2: 08 2f mov r16, r24 + getch(); + 3eb4: 6f d0 rcall .+222 ; 0x3f94 // If we are in RWW section, immediately start page erase if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address); - 3eb2: e0 91 00 02 lds r30, 0x0200 - 3eb6: f0 91 01 02 lds r31, 0x0201 + 3eb6: 80 e0 ldi r24, 0x00 ; 0 + 3eb8: c8 16 cp r12, r24 3eba: 88 e3 ldi r24, 0x38 ; 56 - 3ebc: e0 30 cpi r30, 0x00 ; 0 - 3ebe: f8 07 cpc r31, r24 - 3ec0: 18 f4 brcc .+6 ; 0x3ec8 - 3ec2: 83 e0 ldi r24, 0x03 ; 3 + 3ebc: d8 06 cpc r13, r24 + 3ebe: 20 f4 brcc .+8 ; 0x3ec8 + 3ec0: 83 e0 ldi r24, 0x03 ; 3 + 3ec2: f6 01 movw r30, r12 3ec4: 87 bf out 0x37, r24 ; 55 3ec6: e8 95 spm 3ec8: 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(); - 3ecc: 71 d0 rcall .+226 ; 0x3fb0 + 3ecc: 63 d0 rcall .+198 ; 0x3f94 3ece: 89 93 st Y+, r24 while (--length); - 3ed0: 80 91 02 02 lds r24, 0x0202 - 3ed4: 81 50 subi r24, 0x01 ; 1 - 3ed6: 80 93 02 02 sts 0x0202, r24 - 3eda: 88 23 and r24, r24 - 3edc: b9 f7 brne .-18 ; 0x3ecc + 3ed0: 0c 17 cp r16, r28 + 3ed2: e1 f7 brne .-8 ; 0x3ecc // 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); - 3ede: e0 91 00 02 lds r30, 0x0200 - 3ee2: f0 91 01 02 lds r31, 0x0201 - 3ee6: 88 e3 ldi r24, 0x38 ; 56 - 3ee8: e0 30 cpi r30, 0x00 ; 0 - 3eea: f8 07 cpc r31, r24 - 3eec: 18 f0 brcs .+6 ; 0x3ef4 - 3eee: 83 e0 ldi r24, 0x03 ; 3 - 3ef0: 87 bf out 0x37, r24 ; 55 - 3ef2: e8 95 spm + 3ed4: f0 e0 ldi r31, 0x00 ; 0 + 3ed6: cf 16 cp r12, r31 + 3ed8: f8 e3 ldi r31, 0x38 ; 56 + 3eda: df 06 cpc r13, r31 + 3edc: 20 f0 brcs .+8 ; 0x3ee6 + 3ede: 83 e0 ldi r24, 0x03 ; 3 + 3ee0: f6 01 movw r30, r12 + 3ee2: 87 bf out 0x37, r24 ; 55 + 3ee4: e8 95 spm // Read command terminator, start reply verifySpace(); - 3ef4: 75 d0 rcall .+234 ; 0x3fe0 + 3ee6: 64 d0 rcall .+200 ; 0x3fb0 // If only a partial page is to be programmed, the erase might not be complete. // So check that here boot_spm_busy_wait(); - 3ef6: 07 b6 in r0, 0x37 ; 55 - 3ef8: 00 fc sbrc r0, 0 - 3efa: fd cf rjmp .-6 ; 0x3ef6 - } -#endif - - // Copy buffer into programming buffer + 3ee8: 07 b6 in r0, 0x37 ; 55 + 3eea: 00 fc sbrc r0, 0 + 3eec: fd cf rjmp .-6 ; 0x3ee8 + 3eee: a6 01 movw r20, r12 + 3ef0: a0 e0 ldi r26, 0x00 ; 0 + 3ef2: b1 e0 ldi r27, 0x01 ; 1 bufPtr = buff; addrPtr = (uint16_t)(void*)address; - 3efc: 40 91 00 02 lds r20, 0x0200 - 3f00: 50 91 01 02 lds r21, 0x0201 - 3f04: a0 e0 ldi r26, 0x00 ; 0 - 3f06: b1 e0 ldi r27, 0x01 ; 1 ch = SPM_PAGESIZE / 2; do { uint16_t a; a = *bufPtr++; - 3f08: 2c 91 ld r18, X - 3f0a: 30 e0 ldi r19, 0x00 ; 0 + 3ef4: 2c 91 ld r18, X + 3ef6: 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 + 3ef8: 11 96 adiw r26, 0x01 ; 1 + 3efa: 8c 91 ld r24, X + 3efc: 11 97 sbiw r26, 0x01 ; 1 + 3efe: 90 e0 ldi r25, 0x00 ; 0 + 3f00: 98 2f mov r25, r24 + 3f02: 88 27 eor r24, r24 + 3f04: 82 2b or r24, r18 + 3f06: 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) { - 3f1c: 12 96 adiw r26, 0x02 ; 2 + 3f08: 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: d7 be out 0x37, r13 ; 55 - 3f24: e8 95 spm - 3f26: 11 24 eor r1, r1 + 3f0a: fa 01 movw r30, r20 + 3f0c: 0c 01 movw r0, r24 + 3f0e: 97 be out 0x37, r9 ; 55 + 3f10: e8 95 spm + 3f12: 11 24 eor r1, r1 addrPtr += 2; - 3f28: 4e 5f subi r20, 0xFE ; 254 - 3f2a: 5f 4f sbci r21, 0xFF ; 255 + 3f14: 4e 5f subi r20, 0xFE ; 254 + 3f16: 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 + 3f18: f1 e0 ldi r31, 0x01 ; 1 + 3f1a: a0 38 cpi r26, 0x80 ; 128 + 3f1c: bf 07 cpc r27, r31 + 3f1e: 51 f7 brne .-44 ; 0x3ef4 // Write from programming buffer __boot_page_write_short((uint16_t)(void*)address); - 3f34: e0 91 00 02 lds r30, 0x0200 - 3f38: f0 91 01 02 lds r31, 0x0201 - 3f3c: e7 be out 0x37, r14 ; 55 - 3f3e: e8 95 spm + 3f20: f6 01 movw r30, r12 + 3f22: a7 be out 0x37, r10 ; 55 + 3f24: e8 95 spm boot_spm_busy_wait(); - 3f40: 07 b6 in r0, 0x37 ; 55 - 3f42: 00 fc sbrc r0, 0 - 3f44: fd cf rjmp .-6 ; 0x3f40 + 3f26: 07 b6 in r0, 0x37 ; 55 + 3f28: 00 fc sbrc r0, 0 + 3f2a: fd cf rjmp .-6 ; 0x3f26 #if defined(RWWSRE) // Reenable read access to flash boot_rww_enable(); - 3f46: f7 be out 0x37, r15 ; 55 - 3f48: e8 95 spm - 3f4a: 27 c0 rjmp .+78 ; 0x3f9a + 3f2c: b7 be out 0x37, r11 ; 55 + 3f2e: e8 95 spm + 3f30: 26 c0 rjmp .+76 ; 0x3f7e #endif } /* Read memory block mode, length is big endian. */ else if(ch == STK_READ_PAGE) { - 3f4c: 84 37 cpi r24, 0x74 ; 116 - 3f4e: b9 f4 brne .+46 ; 0x3f7e + 3f32: 84 37 cpi r24, 0x74 ; 116 + 3f34: b1 f4 brne .+44 ; 0x3f62 // READ PAGE - we only read flash - getLen(); - 3f50: 37 d0 rcall .+110 ; 0x3fc0 + getch(); /* getlen() */ + 3f36: 2e d0 rcall .+92 ; 0x3f94 + length = getch(); + 3f38: 2d d0 rcall .+90 ; 0x3f94 + 3f3a: f8 2e mov r15, r24 + getch(); + 3f3c: 2b d0 rcall .+86 ; 0x3f94 + verifySpace(); - 3f52: 46 d0 rcall .+140 ; 0x3fe0 + 3f3e: 38 d0 rcall .+112 ; 0x3fb0 + 3f40: f6 01 movw r30, r12 + 3f42: ef 2c mov r14, r15 putch(result); address++; } while (--length); #else do putch(pgm_read_byte_near(address++)); - 3f54: e0 91 00 02 lds r30, 0x0200 - 3f58: f0 91 01 02 lds r31, 0x0201 - 3f5c: 31 96 adiw r30, 0x01 ; 1 - 3f5e: f0 93 01 02 sts 0x0201, r31 - 3f62: e0 93 00 02 sts 0x0200, r30 - 3f66: 31 97 sbiw r30, 0x01 ; 1 - 3f68: e4 91 lpm r30, Z+ - 3f6a: 8e 2f mov r24, r30 - 3f6c: 19 d0 rcall .+50 ; 0x3fa0 + 3f44: 8f 01 movw r16, r30 + 3f46: 0f 5f subi r16, 0xFF ; 255 + 3f48: 1f 4f sbci r17, 0xFF ; 255 + 3f4a: 84 91 lpm r24, Z+ + 3f4c: 1b d0 rcall .+54 ; 0x3f84 while (--length); - 3f6e: 80 91 02 02 lds r24, 0x0202 - 3f72: 81 50 subi r24, 0x01 ; 1 - 3f74: 80 93 02 02 sts 0x0202, r24 - 3f78: 88 23 and r24, r24 - 3f7a: 61 f7 brne .-40 ; 0x3f54 - 3f7c: 0e c0 rjmp .+28 ; 0x3f9a + 3f4e: ea 94 dec r14 + 3f50: f8 01 movw r30, r16 + 3f52: c1 f7 brne .-16 ; 0x3f44 +#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) { + 3f54: 08 94 sec + 3f56: c1 1c adc r12, r1 + 3f58: d1 1c adc r13, r1 + 3f5a: fa 94 dec r15 + 3f5c: cf 0c add r12, r15 + 3f5e: d1 1c adc r13, r1 + 3f60: 0e c0 rjmp .+28 ; 0x3f7e #endif #endif } /* Get device signature bytes */ else if(ch == STK_READ_SIGN) { - 3f7e: 85 37 cpi r24, 0x75 ; 117 - 3f80: 39 f4 brne .+14 ; 0x3f90 + 3f62: 85 37 cpi r24, 0x75 ; 117 + 3f64: 39 f4 brne .+14 ; 0x3f74 // READ SIGN - return what Avrdude wants to hear verifySpace(); - 3f82: 2e d0 rcall .+92 ; 0x3fe0 + 3f66: 24 d0 rcall .+72 ; 0x3fb0 putch(SIGNATURE_0); - 3f84: 8e e1 ldi r24, 0x1E ; 30 - 3f86: 0c d0 rcall .+24 ; 0x3fa0 + 3f68: 8e e1 ldi r24, 0x1E ; 30 + 3f6a: 0c d0 rcall .+24 ; 0x3f84 putch(SIGNATURE_1); - 3f88: 84 e9 ldi r24, 0x94 ; 148 - 3f8a: 0a d0 rcall .+20 ; 0x3fa0 + 3f6c: 84 e9 ldi r24, 0x94 ; 148 + 3f6e: 0a d0 rcall .+20 ; 0x3f84 putch(SIGNATURE_2); - 3f8c: 86 e0 ldi r24, 0x06 ; 6 - 3f8e: 8b cf rjmp .-234 ; 0x3ea6 + 3f70: 86 e0 ldi r24, 0x06 ; 6 + 3f72: 98 cf rjmp .-208 ; 0x3ea4 } else if (ch == 'Q') { - 3f90: 81 35 cpi r24, 0x51 ; 81 - 3f92: 11 f4 brne .+4 ; 0x3f98 + 3f74: 81 35 cpi r24, 0x51 ; 81 + 3f76: 11 f4 brne .+4 ; 0x3f7c // Adaboot no-wait mod watchdogConfig(WATCHDOG_16MS); - 3f94: 88 e0 ldi r24, 0x08 ; 8 - 3f96: 19 d0 rcall .+50 ; 0x3fca + 3f78: 88 e0 ldi r24, 0x08 ; 8 + 3f7a: 14 d0 rcall .+40 ; 0x3fa4 verifySpace(); } else { // This covers the response to commands like STK_ENTER_PROGMODE verifySpace(); - 3f98: 23 d0 rcall .+70 ; 0x3fe0 + 3f7c: 19 d0 rcall .+50 ; 0x3fb0 } putch(STK_OK); - 3f9a: 80 e1 ldi r24, 0x10 ; 16 - 3f9c: 01 d0 rcall .+2 ; 0x3fa0 - 3f9e: 5c cf rjmp .-328 ; 0x3e58 + 3f7e: 80 e1 ldi r24, 0x10 ; 16 + 3f80: 01 d0 rcall .+2 ; 0x3f84 + 3f82: 6a cf rjmp .-300 ; 0x3e58 -00003fa0 : +00003f84 : } } void putch(char ch) { - 3fa0: 98 2f mov r25, r24 + 3f84: 98 2f mov r25, r24 #ifndef SOFT_UART while (!(UCSR0A & _BV(UDRE0))); - 3fa2: 80 91 c0 00 lds r24, 0x00C0 - 3fa6: 85 ff sbrs r24, 5 - 3fa8: fc cf rjmp .-8 ; 0x3fa2 + 3f86: 80 91 c0 00 lds r24, 0x00C0 + 3f8a: 85 ff sbrs r24, 5 + 3f8c: fc cf rjmp .-8 ; 0x3f86 UDR0 = ch; - 3faa: 90 93 c6 00 sts 0x00C6, r25 + 3f8e: 90 93 c6 00 sts 0x00C6, r25 [uartBit] "I" (UART_TX_BIT) : "r25" ); #endif } - 3fae: 08 95 ret + 3f92: 08 95 ret -00003fb0 : - return getch(); +00003f94 : } +#endif // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( - 3fb0: a8 95 wdr + 3f94: a8 95 wdr [uartBit] "I" (UART_RX_BIT) : "r25" ); #else while(!(UCSR0A & _BV(RXC0))); - 3fb2: 80 91 c0 00 lds r24, 0x00C0 - 3fb6: 87 ff sbrs r24, 7 - 3fb8: fc cf rjmp .-8 ; 0x3fb2 + 3f96: 80 91 c0 00 lds r24, 0x00C0 + 3f9a: 87 ff sbrs r24, 7 + 3f9c: fc cf rjmp .-8 ; 0x3f96 ch = UDR0; - 3fba: 80 91 c6 00 lds r24, 0x00C6 + 3f9e: 80 91 c6 00 lds r24, 0x00C6 LED_PIN |= _BV(LED); #endif #endif return ch; } - 3fbe: 08 95 ret - -00003fc0 : - } while (--count); -} -#endif - -uint8_t getLen() { - getch(); - 3fc0: f7 df rcall .-18 ; 0x3fb0 - length = getch(); - 3fc2: f6 df rcall .-20 ; 0x3fb0 - 3fc4: 80 93 02 02 sts 0x0202, r24 - return getch(); -} - 3fc8: f3 cf rjmp .-26 ; 0x3fb0 + 3fa2: 08 95 ret -00003fca : +00003fa4 : "wdr\n" ); } void watchdogConfig(uint8_t x) { WDTCSR = _BV(WDCE) | _BV(WDE); - 3fca: e0 e6 ldi r30, 0x60 ; 96 - 3fcc: f0 e0 ldi r31, 0x00 ; 0 - 3fce: 98 e1 ldi r25, 0x18 ; 24 - 3fd0: 90 83 st Z, r25 + 3fa4: e0 e6 ldi r30, 0x60 ; 96 + 3fa6: f0 e0 ldi r31, 0x00 ; 0 + 3fa8: 98 e1 ldi r25, 0x18 ; 24 + 3faa: 90 83 st Z, r25 WDTCSR = x; - 3fd2: 80 83 st Z, r24 + 3fac: 80 83 st Z, r24 } - 3fd4: 08 95 ret - -00003fd6 : - -void appStart() { - watchdogConfig(WATCHDOG_OFF); - 3fd6: 80 e0 ldi r24, 0x00 ; 0 - 3fd8: f8 df rcall .-16 ; 0x3fca - __asm__ __volatile__ ( - 3fda: ee 27 eor r30, r30 - 3fdc: ff 27 eor r31, r31 - 3fde: 09 94 ijmp + 3fae: 08 95 ret -00003fe0 : +00003fb0 : do getch(); while (--count); verifySpace(); } void verifySpace() { - if (getch() != CRC_EOP) appStart(); - 3fe0: e7 df rcall .-50 ; 0x3fb0 - 3fe2: 80 32 cpi r24, 0x20 ; 32 - 3fe4: 09 f0 breq .+2 ; 0x3fe8 - 3fe6: f7 df rcall .-18 ; 0x3fd6 + if (getch() != CRC_EOP) { + 3fb0: f1 df rcall .-30 ; 0x3f94 + 3fb2: 80 32 cpi r24, 0x20 ; 32 + 3fb4: 19 f0 breq .+6 ; 0x3fbc + watchdogConfig(WATCHDOG_16MS); // shorten WD timeout + 3fb6: 88 e0 ldi r24, 0x08 ; 8 + 3fb8: f5 df rcall .-22 ; 0x3fa4 + 3fba: ff cf rjmp .-2 ; 0x3fba + while (1) // and busy-loop so that WD causes + ; // a reset and app start. + } putch(STK_INSYNC); - 3fe8: 84 e1 ldi r24, 0x14 ; 20 + 3fbc: 84 e1 ldi r24, 0x14 ; 20 } - 3fea: da cf rjmp .-76 ; 0x3fa0 + 3fbe: e2 cf rjmp .-60 ; 0x3f84 -00003fec : +00003fc0 : ::[count] "M" (UART_B_VALUE) ); } #endif void getNch(uint8_t count) { - 3fec: 1f 93 push r17 - 3fee: 18 2f mov r17, r24 + 3fc0: 1f 93 push r17 + 3fc2: 18 2f mov r17, r24 do getch(); while (--count); - 3ff0: df df rcall .-66 ; 0x3fb0 - 3ff2: 11 50 subi r17, 0x01 ; 1 - 3ff4: e9 f7 brne .-6 ; 0x3ff0 + 3fc4: e7 df rcall .-50 ; 0x3f94 + 3fc6: 11 50 subi r17, 0x01 ; 1 + 3fc8: e9 f7 brne .-6 ; 0x3fc4 verifySpace(); - 3ff6: f4 df rcall .-24 ; 0x3fe0 + 3fca: f2 df rcall .-28 ; 0x3fb0 +} + 3fcc: 1f 91 pop r17 + 3fce: 08 95 ret + +00003fd0 : + WDTCSR = _BV(WDCE) | _BV(WDE); + WDTCSR = x; } - 3ff8: 1f 91 pop r17 - 3ffa: 08 95 ret + +void appStart() { + watchdogConfig(WATCHDOG_OFF); + 3fd0: 80 e0 ldi r24, 0x00 ; 0 + 3fd2: e8 df rcall .-48 ; 0x3fa4 + __asm__ __volatile__ ( + 3fd4: ee 27 eor r30, r30 + 3fd6: ff 27 eor r31, r31 + 3fd8: 09 94 ijmp -- cgit v1.2.3-18-g5258 From 5c27dd97a0df974fa7f42b08d8eba6bf1fd50cb8 Mon Sep 17 00:00:00 2001 From: WestfW Date: Sat, 11 Jun 2011 03:17:38 -0700 Subject: (make sure .hex and .lst are updated as well.) --- bootloaders/optiboot/optiboot_pro_8MHz.lst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'bootloaders/optiboot/optiboot_pro_8MHz.lst') diff --git a/bootloaders/optiboot/optiboot_pro_8MHz.lst b/bootloaders/optiboot/optiboot_pro_8MHz.lst index d3d760e..6c117ca 100644 --- a/bootloaders/optiboot/optiboot_pro_8MHz.lst +++ b/bootloaders/optiboot/optiboot_pro_8MHz.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_pro_8MHz.lst | 140 +++++++++++++++-------------- 1 file changed, 75 insertions(+), 65 deletions(-) (limited to 'bootloaders/optiboot/optiboot_pro_8MHz.lst') diff --git a/bootloaders/optiboot/optiboot_pro_8MHz.lst b/bootloaders/optiboot/optiboot_pro_8MHz.lst index 6c117ca..1fb903c 100644 --- a/bootloaders/optiboot/optiboot_pro_8MHz.lst +++ b/bootloaders/optiboot/optiboot_pro_8MHz.lst @@ -3,27 +3,27 @@ optiboot_pro_8MHz.elf: file format elf32-avr Sections: Idx Name Size VMA LMA File off Algn - 0 .text 000001da 00003e00 00003e00 00000054 2**1 + 0 .text 000001e2 00003e00 00003e00 00000054 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE - 1 .version 00000002 00003ffe 00003ffe 0000022e 2**0 + 1 .version 00000002 00003ffe 00003ffe 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) { 3e04: 14 be out 0x34, r1 ; 52 if (!(ch & _BV(EXTRF))) appStart(); 3e06: 81 ff sbrs r24, 1 - 3e08: e3 d0 rcall .+454 ; 0x3fd0 + 3e08: e7 d0 rcall .+462 ; 0x3fd8 #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); 3e28: 8e e0 ldi r24, 0x0E ; 14 - 3e2a: bc d0 rcall .+376 ; 0x3fa4 + 3e2a: c0 d0 rcall .+384 ; 0x3fac /* 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); 3e5e: 81 e0 ldi r24, 0x01 ; 1 - 3e60: af d0 rcall .+350 ; 0x3fc0 + 3e60: b3 d0 rcall .+358 ; 0x3fc8 putch(0x03); 3e62: 83 e0 ldi r24, 0x03 ; 3 3e64: 1f c0 rjmp .+62 ; 0x3ea4 @@ -182,7 +182,7 @@ void watchdogReset() { // SET DEVICE EXT is ignored getNch(5); 3e72: 85 e0 ldi r24, 0x05 ; 5 - 3e74: a5 d0 rcall .+330 ; 0x3fc0 + 3e74: a9 d0 rcall .+338 ; 0x3fc8 3e76: 83 c0 rjmp .+262 ; 0x3f7e } else if(ch == STK_LOAD_ADDRESS) { @@ -211,7 +211,7 @@ void watchdogReset() { 3e92: 11 1f adc r17, r17 address = newAddress; verifySpace(); - 3e94: 8d d0 rcall .+282 ; 0x3fb0 + 3e94: 91 d0 rcall .+290 ; 0x3fb8 3e96: 68 01 movw r12, r16 3e98: 72 c0 rjmp .+228 ; 0x3f7e } @@ -221,7 +221,7 @@ void watchdogReset() { // UNIVERSAL command is ignored getNch(4); 3e9e: 84 e0 ldi r24, 0x04 ; 4 - 3ea0: 8f d0 rcall .+286 ; 0x3fc0 + 3ea0: 93 d0 rcall .+294 ; 0x3fc8 putch(0x00); 3ea2: 80 e0 ldi r24, 0x00 ; 0 3ea4: 6f d0 rcall .+222 ; 0x3f84 @@ -282,7 +282,7 @@ void watchdogReset() { // Read command terminator, start reply verifySpace(); - 3ee6: 64 d0 rcall .+200 ; 0x3fb0 + 3ee6: 68 d0 rcall .+208 ; 0x3fb8 // 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) { 3f3c: 2b d0 rcall .+86 ; 0x3f94 verifySpace(); - 3f3e: 38 d0 rcall .+112 ; 0x3fb0 + 3f3e: 3c d0 rcall .+120 ; 0x3fb8 3f40: f6 01 movw r30, r12 3f42: ef 2c mov r14, r15 putch(result); @@ -411,7 +411,7 @@ int main(void) { 3f64: 39 f4 brne .+14 ; 0x3f74 // READ SIGN - return what Avrdude wants to hear verifySpace(); - 3f66: 24 d0 rcall .+72 ; 0x3fb0 + 3f66: 28 d0 rcall .+80 ; 0x3fb8 putch(SIGNATURE_0); 3f68: 8e e1 ldi r24, 0x1E ; 30 3f6a: 0c d0 rcall .+24 ; 0x3f84 @@ -428,13 +428,13 @@ int main(void) { // Adaboot no-wait mod watchdogConfig(WATCHDOG_16MS); 3f78: 88 e0 ldi r24, 0x08 ; 8 - 3f7a: 14 d0 rcall .+40 ; 0x3fa4 + 3f7a: 18 d0 rcall .+48 ; 0x3fac verifySpace(); } else { // This covers the response to commands like STK_ENTER_PROGMODE verifySpace(); - 3f7c: 19 d0 rcall .+50 ; 0x3fb0 + 3f7c: 1d d0 rcall .+58 ; 0x3fb8 } putch(STK_OK); 3f7e: 80 e1 ldi r24, 0x10 ; 16 @@ -463,99 +463,109 @@ void putch(char ch) { 3f92: 08 95 ret 00003f94 : + [uartBit] "I" (UART_RX_BIT) + : + "r25" +); +#else + while(!(UCSR0A & _BV(RXC0))) + 3f94: 80 91 c0 00 lds r24, 0x00C0 + 3f98: 87 ff sbrs r24, 7 + 3f9a: fc cf rjmp .-8 ; 0x3f94 + ; + if (!(UCSR0A & _BV(FE0))) { + 3f9c: 80 91 c0 00 lds r24, 0x00C0 + 3fa0: 84 fd sbrc r24, 4 + 3fa2: 01 c0 rjmp .+2 ; 0x3fa6 } #endif // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( - 3f94: a8 95 wdr - [uartBit] "I" (UART_RX_BIT) - : - "r25" -); -#else - while(!(UCSR0A & _BV(RXC0))); - 3f96: 80 91 c0 00 lds r24, 0x00C0 - 3f9a: 87 ff sbrs r24, 7 - 3f9c: fc cf rjmp .-8 ; 0x3f96 + 3fa4: a8 95 wdr + * don't care that an invalid char is returned...) + */ + watchdogReset(); + } + ch = UDR0; - 3f9e: 80 91 c6 00 lds r24, 0x00C6 + 3fa6: 80 91 c6 00 lds r24, 0x00C6 LED_PIN |= _BV(LED); #endif #endif return ch; } - 3fa2: 08 95 ret + 3faa: 08 95 ret -00003fa4 : +00003fac : "wdr\n" ); } void watchdogConfig(uint8_t x) { WDTCSR = _BV(WDCE) | _BV(WDE); - 3fa4: e0 e6 ldi r30, 0x60 ; 96 - 3fa6: f0 e0 ldi r31, 0x00 ; 0 - 3fa8: 98 e1 ldi r25, 0x18 ; 24 - 3faa: 90 83 st Z, r25 + 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; - 3fac: 80 83 st Z, r24 + 3fb4: 80 83 st Z, r24 } - 3fae: 08 95 ret + 3fb6: 08 95 ret -00003fb0 : +00003fb8 : do getch(); while (--count); verifySpace(); } void verifySpace() { if (getch() != CRC_EOP) { - 3fb0: f1 df rcall .-30 ; 0x3f94 - 3fb2: 80 32 cpi r24, 0x20 ; 32 - 3fb4: 19 f0 breq .+6 ; 0x3fbc + 3fb8: ed df rcall .-38 ; 0x3f94 + 3fba: 80 32 cpi r24, 0x20 ; 32 + 3fbc: 19 f0 breq .+6 ; 0x3fc4 watchdogConfig(WATCHDOG_16MS); // shorten WD timeout - 3fb6: 88 e0 ldi r24, 0x08 ; 8 - 3fb8: f5 df rcall .-22 ; 0x3fa4 - 3fba: ff cf rjmp .-2 ; 0x3fba + 3fbe: 88 e0 ldi r24, 0x08 ; 8 + 3fc0: f5 df rcall .-22 ; 0x3fac + 3fc2: ff cf rjmp .-2 ; 0x3fc2 while (1) // and busy-loop so that WD causes ; // a reset and app start. } putch(STK_INSYNC); - 3fbc: 84 e1 ldi r24, 0x14 ; 20 + 3fc4: 84 e1 ldi r24, 0x14 ; 20 } - 3fbe: e2 cf rjmp .-60 ; 0x3f84 + 3fc6: de cf rjmp .-68 ; 0x3f84 -00003fc0 : +00003fc8 : ::[count] "M" (UART_B_VALUE) ); } #endif void getNch(uint8_t count) { - 3fc0: 1f 93 push r17 - 3fc2: 18 2f mov r17, r24 + 3fc8: 1f 93 push r17 + 3fca: 18 2f mov r17, r24 do getch(); while (--count); - 3fc4: e7 df rcall .-50 ; 0x3f94 - 3fc6: 11 50 subi r17, 0x01 ; 1 - 3fc8: e9 f7 brne .-6 ; 0x3fc4 + 3fcc: e3 df rcall .-58 ; 0x3f94 + 3fce: 11 50 subi r17, 0x01 ; 1 + 3fd0: e9 f7 brne .-6 ; 0x3fcc verifySpace(); - 3fca: f2 df rcall .-28 ; 0x3fb0 + 3fd2: f2 df rcall .-28 ; 0x3fb8 } - 3fcc: 1f 91 pop r17 - 3fce: 08 95 ret + 3fd4: 1f 91 pop r17 + 3fd6: 08 95 ret -00003fd0 : +00003fd8 : WDTCSR = _BV(WDCE) | _BV(WDE); WDTCSR = x; } void appStart() { watchdogConfig(WATCHDOG_OFF); - 3fd0: 80 e0 ldi r24, 0x00 ; 0 - 3fd2: e8 df rcall .-48 ; 0x3fa4 + 3fd8: 80 e0 ldi r24, 0x00 ; 0 + 3fda: e8 df rcall .-48 ; 0x3fac __asm__ __volatile__ ( - 3fd4: ee 27 eor r30, r30 - 3fd6: ff 27 eor r31, r31 - 3fd8: 09 94 ijmp + 3fdc: ee 27 eor r30, r30 + 3fde: ff 27 eor r31, r31 + 3fe0: 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_pro_8MHz.lst | 571 ----------------------------- 1 file changed, 571 deletions(-) delete mode 100644 bootloaders/optiboot/optiboot_pro_8MHz.lst (limited to 'bootloaders/optiboot/optiboot_pro_8MHz.lst') diff --git a/bootloaders/optiboot/optiboot_pro_8MHz.lst b/bootloaders/optiboot/optiboot_pro_8MHz.lst deleted file mode 100644 index 1fb903c..0000000 --- a/bootloaders/optiboot/optiboot_pro_8MHz.lst +++ /dev/null @@ -1,571 +0,0 @@ - -optiboot_pro_8MHz.elf: file format elf32-avr - -Sections: -Idx Name Size VMA LMA File off Algn - 0 .text 000001e2 00003e00 00003e00 00000054 2**1 - CONTENTS, ALLOC, LOAD, READONLY, CODE - 1 .version 00000002 00003ffe 00003ffe 00000236 2**0 - CONTENTS, READONLY - 2 .debug_aranges 00000028 00000000 00000000 00000238 2**0 - CONTENTS, READONLY, DEBUGGING - 3 .debug_pubnames 0000005f 00000000 00000000 00000260 2**0 - CONTENTS, READONLY, DEBUGGING - 4 .debug_info 0000028e 00000000 00000000 000002bf 2**0 - CONTENTS, READONLY, DEBUGGING - 5 .debug_abbrev 00000171 00000000 00000000 0000054d 2**0 - CONTENTS, READONLY, DEBUGGING - 6 .debug_line 0000045e 00000000 00000000 000006be 2**0 - CONTENTS, READONLY, DEBUGGING - 7 .debug_frame 00000080 00000000 00000000 00000b1c 2**2 - CONTENTS, READONLY, DEBUGGING - 8 .debug_str 00000149 00000000 00000000 00000b9c 2**0 - CONTENTS, READONLY, DEBUGGING - 9 .debug_loc 0000027e 00000000 00000000 00000ce5 2**0 - CONTENTS, READONLY, DEBUGGING - 10 .debug_ranges 00000060 00000000 00000000 00000f63 2**0 - CONTENTS, READONLY, DEBUGGING - -Disassembly of section .text: - -00003e00
: -#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) { - 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(); - 3e06: 81 ff sbrs r24, 1 - 3e08: e7 d0 rcall .+462 ; 0x3fd8 - -#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 - UCSR0A = _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); - 3e16: 88 e1 ldi r24, 0x18 ; 24 - 3e18: 80 93 c1 00 sts 0x00C1, r24 - UCSR0C = _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 ); - 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 - - /* 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 -#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 - /* 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); - 3e4c: 99 24 eor r9, r9 - 3e4e: 93 94 inc r9 - __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); - 3e50: a5 e0 ldi r26, 0x05 ; 5 - 3e52: aa 2e mov r10, r26 - boot_spm_busy_wait(); - -#if defined(RWWSRE) - // Reenable read access to flash - boot_rww_enable(); - 3e54: f1 e1 ldi r31, 0x11 ; 17 - 3e56: bf 2e mov r11, r31 -#endif - - /* Forever loop */ - for (;;) { - /* get character from UART */ - ch = getch(); - 3e58: 9d d0 rcall .+314 ; 0x3f94 - - if(ch == STK_GET_PARAMETER) { - 3e5a: 81 34 cpi r24, 0x41 ; 65 - 3e5c: 21 f4 brne .+8 ; 0x3e66 - // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy - getNch(1); - 3e5e: 81 e0 ldi r24, 0x01 ; 1 - 3e60: b3 d0 rcall .+358 ; 0x3fc8 - putch(0x03); - 3e62: 83 e0 ldi r24, 0x03 ; 3 - 3e64: 1f c0 rjmp .+62 ; 0x3ea4 - } - else if(ch == STK_SET_DEVICE) { - 3e66: 82 34 cpi r24, 0x42 ; 66 - 3e68: 11 f4 brne .+4 ; 0x3e6e - // SET DEVICE is ignored - getNch(20); - 3e6a: 84 e1 ldi r24, 0x14 ; 20 - 3e6c: 03 c0 rjmp .+6 ; 0x3e74 - } - else if(ch == STK_SET_DEVICE_EXT) { - 3e6e: 85 34 cpi r24, 0x45 ; 69 - 3e70: 19 f4 brne .+6 ; 0x3e78 - // SET DEVICE EXT is ignored - getNch(5); - 3e72: 85 e0 ldi r24, 0x05 ; 5 - 3e74: a9 d0 rcall .+338 ; 0x3fc8 - 3e76: 83 c0 rjmp .+262 ; 0x3f7e - } - else if(ch == STK_LOAD_ADDRESS) { - 3e78: 85 35 cpi r24, 0x55 ; 85 - 3e7a: 79 f4 brne .+30 ; 0x3e9a - // LOAD ADDRESS - uint16_t newAddress; - newAddress = getch(); - 3e7c: 8b d0 rcall .+278 ; 0x3f94 - newAddress = (newAddress & 0xff) | (getch() << 8); - 3e7e: e8 2e mov r14, r24 - 3e80: ff 24 eor r15, r15 - 3e82: 88 d0 rcall .+272 ; 0x3f94 - 3e84: 08 2f mov r16, r24 - 3e86: 10 e0 ldi r17, 0x00 ; 0 - 3e88: 10 2f mov r17, r16 - 3e8a: 00 27 eor r16, r16 - 3e8c: 0e 29 or r16, r14 - 3e8e: 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 - 3e90: 00 0f add r16, r16 - 3e92: 11 1f adc r17, r17 - address = newAddress; - verifySpace(); - 3e94: 91 d0 rcall .+290 ; 0x3fb8 - 3e96: 68 01 movw r12, r16 - 3e98: 72 c0 rjmp .+228 ; 0x3f7e - } - else if(ch == STK_UNIVERSAL) { - 3e9a: 86 35 cpi r24, 0x56 ; 86 - 3e9c: 29 f4 brne .+10 ; 0x3ea8 - // UNIVERSAL command is ignored - getNch(4); - 3e9e: 84 e0 ldi r24, 0x04 ; 4 - 3ea0: 93 d0 rcall .+294 ; 0x3fc8 - putch(0x00); - 3ea2: 80 e0 ldi r24, 0x00 ; 0 - 3ea4: 6f d0 rcall .+222 ; 0x3f84 - 3ea6: 6b c0 rjmp .+214 ; 0x3f7e - } - /* Write memory, length is big endian and is in bytes */ - else if(ch == STK_PROG_PAGE) { - 3ea8: 84 36 cpi r24, 0x64 ; 100 - 3eaa: 09 f0 breq .+2 ; 0x3eae - 3eac: 42 c0 rjmp .+132 ; 0x3f32 - // PROGRAM PAGE - we support flash programming only, not EEPROM - uint8_t *bufPtr; - uint16_t addrPtr; - - getch(); /* getlen() */ - 3eae: 72 d0 rcall .+228 ; 0x3f94 - length = getch(); - 3eb0: 71 d0 rcall .+226 ; 0x3f94 - 3eb2: 08 2f mov r16, r24 - getch(); - 3eb4: 6f d0 rcall .+222 ; 0x3f94 - - // If we are in RWW section, immediately start page erase - if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address); - 3eb6: 80 e0 ldi r24, 0x00 ; 0 - 3eb8: c8 16 cp r12, r24 - 3eba: 88 e3 ldi r24, 0x38 ; 56 - 3ebc: d8 06 cpc r13, r24 - 3ebe: 20 f4 brcc .+8 ; 0x3ec8 - 3ec0: 83 e0 ldi r24, 0x03 ; 3 - 3ec2: f6 01 movw r30, r12 - 3ec4: 87 bf out 0x37, r24 ; 55 - 3ec6: e8 95 spm - 3ec8: c0 e0 ldi r28, 0x00 ; 0 - 3eca: d1 e0 ldi r29, 0x01 ; 1 - - // While that is going on, read in page contents - bufPtr = buff; - do *bufPtr++ = getch(); - 3ecc: 63 d0 rcall .+198 ; 0x3f94 - 3ece: 89 93 st Y+, r24 - while (--length); - 3ed0: 0c 17 cp r16, r28 - 3ed2: e1 f7 brne .-8 ; 0x3ecc - - // 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); - 3ed4: f0 e0 ldi r31, 0x00 ; 0 - 3ed6: cf 16 cp r12, r31 - 3ed8: f8 e3 ldi r31, 0x38 ; 56 - 3eda: df 06 cpc r13, r31 - 3edc: 20 f0 brcs .+8 ; 0x3ee6 - 3ede: 83 e0 ldi r24, 0x03 ; 3 - 3ee0: f6 01 movw r30, r12 - 3ee2: 87 bf out 0x37, r24 ; 55 - 3ee4: e8 95 spm - - // Read command terminator, start reply - verifySpace(); - 3ee6: 68 d0 rcall .+208 ; 0x3fb8 - - // If only a partial page is to be programmed, the erase might not be complete. - // So check that here - boot_spm_busy_wait(); - 3ee8: 07 b6 in r0, 0x37 ; 55 - 3eea: 00 fc sbrc r0, 0 - 3eec: fd cf rjmp .-6 ; 0x3ee8 - 3eee: a6 01 movw r20, r12 - 3ef0: a0 e0 ldi r26, 0x00 ; 0 - 3ef2: b1 e0 ldi r27, 0x01 ; 1 - bufPtr = buff; - addrPtr = (uint16_t)(void*)address; - ch = SPM_PAGESIZE / 2; - do { - uint16_t a; - a = *bufPtr++; - 3ef4: 2c 91 ld r18, X - 3ef6: 30 e0 ldi r19, 0x00 ; 0 - a |= (*bufPtr++) << 8; - 3ef8: 11 96 adiw r26, 0x01 ; 1 - 3efa: 8c 91 ld r24, X - 3efc: 11 97 sbiw r26, 0x01 ; 1 - 3efe: 90 e0 ldi r25, 0x00 ; 0 - 3f00: 98 2f mov r25, r24 - 3f02: 88 27 eor r24, r24 - 3f04: 82 2b or r24, r18 - 3f06: 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) { - 3f08: 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); - 3f0a: fa 01 movw r30, r20 - 3f0c: 0c 01 movw r0, r24 - 3f0e: 97 be out 0x37, r9 ; 55 - 3f10: e8 95 spm - 3f12: 11 24 eor r1, r1 - addrPtr += 2; - 3f14: 4e 5f subi r20, 0xFE ; 254 - 3f16: 5f 4f sbci r21, 0xFF ; 255 - } while (--ch); - 3f18: f1 e0 ldi r31, 0x01 ; 1 - 3f1a: a0 38 cpi r26, 0x80 ; 128 - 3f1c: bf 07 cpc r27, r31 - 3f1e: 51 f7 brne .-44 ; 0x3ef4 - - // Write from programming buffer - __boot_page_write_short((uint16_t)(void*)address); - 3f20: f6 01 movw r30, r12 - 3f22: a7 be out 0x37, r10 ; 55 - 3f24: e8 95 spm - boot_spm_busy_wait(); - 3f26: 07 b6 in r0, 0x37 ; 55 - 3f28: 00 fc sbrc r0, 0 - 3f2a: fd cf rjmp .-6 ; 0x3f26 - -#if defined(RWWSRE) - // Reenable read access to flash - boot_rww_enable(); - 3f2c: b7 be out 0x37, r11 ; 55 - 3f2e: e8 95 spm - 3f30: 26 c0 rjmp .+76 ; 0x3f7e -#endif - - } - /* Read memory block mode, length is big endian. */ - else if(ch == STK_READ_PAGE) { - 3f32: 84 37 cpi r24, 0x74 ; 116 - 3f34: b1 f4 brne .+44 ; 0x3f62 - // READ PAGE - we only read flash - getch(); /* getlen() */ - 3f36: 2e d0 rcall .+92 ; 0x3f94 - length = getch(); - 3f38: 2d d0 rcall .+90 ; 0x3f94 - 3f3a: f8 2e mov r15, r24 - getch(); - 3f3c: 2b d0 rcall .+86 ; 0x3f94 - - verifySpace(); - 3f3e: 3c d0 rcall .+120 ; 0x3fb8 - 3f40: f6 01 movw r30, r12 - 3f42: ef 2c mov r14, r15 - putch(result); - address++; - } - while (--length); -#else - do putch(pgm_read_byte_near(address++)); - 3f44: 8f 01 movw r16, r30 - 3f46: 0f 5f subi r16, 0xFF ; 255 - 3f48: 1f 4f sbci r17, 0xFF ; 255 - 3f4a: 84 91 lpm r24, Z+ - 3f4c: 1b d0 rcall .+54 ; 0x3f84 - while (--length); - 3f4e: ea 94 dec r14 - 3f50: f8 01 movw r30, r16 - 3f52: c1 f7 brne .-16 ; 0x3f44 -#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) { - 3f54: 08 94 sec - 3f56: c1 1c adc r12, r1 - 3f58: d1 1c adc r13, r1 - 3f5a: fa 94 dec r15 - 3f5c: cf 0c add r12, r15 - 3f5e: d1 1c adc r13, r1 - 3f60: 0e c0 rjmp .+28 ; 0x3f7e -#endif -#endif - } - - /* Get device signature bytes */ - else if(ch == STK_READ_SIGN) { - 3f62: 85 37 cpi r24, 0x75 ; 117 - 3f64: 39 f4 brne .+14 ; 0x3f74 - // READ SIGN - return what Avrdude wants to hear - verifySpace(); - 3f66: 28 d0 rcall .+80 ; 0x3fb8 - putch(SIGNATURE_0); - 3f68: 8e e1 ldi r24, 0x1E ; 30 - 3f6a: 0c d0 rcall .+24 ; 0x3f84 - putch(SIGNATURE_1); - 3f6c: 84 e9 ldi r24, 0x94 ; 148 - 3f6e: 0a d0 rcall .+20 ; 0x3f84 - putch(SIGNATURE_2); - 3f70: 86 e0 ldi r24, 0x06 ; 6 - 3f72: 98 cf rjmp .-208 ; 0x3ea4 - } - else if (ch == 'Q') { - 3f74: 81 35 cpi r24, 0x51 ; 81 - 3f76: 11 f4 brne .+4 ; 0x3f7c - // Adaboot no-wait mod - watchdogConfig(WATCHDOG_16MS); - 3f78: 88 e0 ldi r24, 0x08 ; 8 - 3f7a: 18 d0 rcall .+48 ; 0x3fac - verifySpace(); - } - else { - // This covers the response to commands like STK_ENTER_PROGMODE - verifySpace(); - 3f7c: 1d d0 rcall .+58 ; 0x3fb8 - } - putch(STK_OK); - 3f7e: 80 e1 ldi r24, 0x10 ; 16 - 3f80: 01 d0 rcall .+2 ; 0x3f84 - 3f82: 6a cf rjmp .-300 ; 0x3e58 - -00003f84 : - } -} - -void putch(char ch) { - 3f84: 98 2f mov r25, r24 -#ifndef SOFT_UART - while (!(UCSR0A & _BV(UDRE0))); - 3f86: 80 91 c0 00 lds r24, 0x00C0 - 3f8a: 85 ff sbrs r24, 5 - 3f8c: fc cf rjmp .-8 ; 0x3f86 - UDR0 = ch; - 3f8e: 90 93 c6 00 sts 0x00C6, r25 - [uartBit] "I" (UART_TX_BIT) - : - "r25" - ); -#endif -} - 3f92: 08 95 ret - -00003f94 : - [uartBit] "I" (UART_RX_BIT) - : - "r25" -); -#else - while(!(UCSR0A & _BV(RXC0))) - 3f94: 80 91 c0 00 lds r24, 0x00C0 - 3f98: 87 ff sbrs r24, 7 - 3f9a: fc cf rjmp .-8 ; 0x3f94 - ; - if (!(UCSR0A & _BV(FE0))) { - 3f9c: 80 91 c0 00 lds r24, 0x00C0 - 3fa0: 84 fd sbrc r24, 4 - 3fa2: 01 c0 rjmp .+2 ; 0x3fa6 -} -#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 = UDR0; - 3fa6: 80 91 c6 00 lds r24, 0x00C6 - LED_PIN |= _BV(LED); -#endif -#endif - - return ch; -} - 3faa: 08 95 ret - -00003fac : - "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 : - do getch(); while (--count); - verifySpace(); -} - -void verifySpace() { - if (getch() != CRC_EOP) { - 3fb8: ed df rcall .-38 ; 0x3f94 - 3fba: 80 32 cpi r24, 0x20 ; 32 - 3fbc: 19 f0 breq .+6 ; 0x3fc4 - watchdogConfig(WATCHDOG_16MS); // shorten WD timeout - 3fbe: 88 e0 ldi r24, 0x08 ; 8 - 3fc0: f5 df rcall .-22 ; 0x3fac - 3fc2: ff cf rjmp .-2 ; 0x3fc2 - 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 - -00003fc8 : - ::[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 - 3fce: 11 50 subi r17, 0x01 ; 1 - 3fd0: e9 f7 brne .-6 ; 0x3fcc - verifySpace(); - 3fd2: f2 df rcall .-28 ; 0x3fb8 -} - 3fd4: 1f 91 pop r17 - 3fd6: 08 95 ret - -00003fd8 : - WDTCSR = _BV(WDCE) | _BV(WDE); - WDTCSR = x; -} - -void appStart() { - watchdogConfig(WATCHDOG_OFF); - 3fd8: 80 e0 ldi r24, 0x00 ; 0 - 3fda: e8 df rcall .-48 ; 0x3fac - __asm__ __volatile__ ( - 3fdc: ee 27 eor r30, r30 - 3fde: ff 27 eor r31, r31 - 3fe0: 09 94 ijmp -- cgit v1.2.3-18-g5258