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_luminet.lst | 670 +++++++++++++++--------------- 1 file changed, 344 insertions(+), 326 deletions(-) (limited to 'bootloaders/optiboot/optiboot_luminet.lst') diff --git a/bootloaders/optiboot/optiboot_luminet.lst b/bootloaders/optiboot/optiboot_luminet.lst index 59468cb..737d2c5 100644 --- a/bootloaders/optiboot/optiboot_luminet.lst +++ b/bootloaders/optiboot/optiboot_luminet.lst @@ -3,602 +3,620 @@ optiboot_luminet.elf: file format elf32-avr Sections: Idx Name Size VMA LMA File off Algn - 0 .text 00000280 00001d00 00001d00 00000054 2**1 + 0 .text 00000274 00001d00 00001d00 00000054 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE - 1 .debug_aranges 00000028 00000000 00000000 000002d4 2**0 + 1 .debug_aranges 00000028 00000000 00000000 000002c8 2**0 CONTENTS, READONLY, DEBUGGING - 2 .debug_pubnames 00000078 00000000 00000000 000002fc 2**0 + 2 .debug_pubnames 00000078 00000000 00000000 000002f0 2**0 CONTENTS, READONLY, DEBUGGING - 3 .debug_info 00000289 00000000 00000000 00000374 2**0 + 3 .debug_info 000002a4 00000000 00000000 00000368 2**0 CONTENTS, READONLY, DEBUGGING - 4 .debug_abbrev 000001a1 00000000 00000000 000005fd 2**0 + 4 .debug_abbrev 000001ac 00000000 00000000 0000060c 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_line 00000435 00000000 00000000 0000079e 2**0 + 5 .debug_line 000004a9 00000000 00000000 000007b8 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_frame 000000a0 00000000 00000000 00000bd4 2**2 + 6 .debug_frame 000000a0 00000000 00000000 00000c64 2**2 CONTENTS, READONLY, DEBUGGING - 7 .debug_str 00000144 00000000 00000000 00000c74 2**0 + 7 .debug_str 00000150 00000000 00000000 00000d04 2**0 CONTENTS, READONLY, DEBUGGING - 8 .debug_loc 00000194 00000000 00000000 00000db8 2**0 + 8 .debug_loc 00000194 00000000 00000000 00000e54 2**0 CONTENTS, READONLY, DEBUGGING - 9 .debug_ranges 00000088 00000000 00000000 00000f4c 2**0 + 9 .debug_ranges 00000088 00000000 00000000 00000fe8 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: 00001d00
: -#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) { - 1d00: 85 e0 ldi r24, 0x05 ; 5 - 1d02: 8e bd out 0x2e, r24 ; 46 - UCSR0C = _BV(UCSZ00) | _BV(UCSZ01); - UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); + 1d00: 11 24 eor r1, r1 +#ifdef __AVR_ATmega8__ + SP=RAMEND; // This is done by hardware reset #endif // Adaboot no-wait mod ch = MCUSR; - 1d04: 84 b7 in r24, 0x34 ; 52 + 1d02: 84 b7 in r24, 0x34 ; 52 MCUSR = 0; - 1d06: 14 be out 0x34, r1 ; 52 + 1d04: 14 be out 0x34, r1 ; 52 if (!(ch & _BV(EXTRF))) appStart(); - 1d08: 81 ff sbrs r24, 1 - 1d0a: 27 d1 rcall .+590 ; 0x1f5a + 1d06: 81 ff sbrs r24, 1 + 1d08: 22 d1 rcall .+580 ; 0x1f4e + +#if LED_START_FLASHES > 0 + // Set up Timer 1 for timeout counter + TCCR1B = _BV(CS12) | _BV(CS10); // div 1024 + 1d0a: 85 e0 ldi r24, 0x05 ; 5 + 1d0c: 8e bd out 0x2e, r24 ; 46 + UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); +#endif +#endif // Set up watchdog to trigger after 500ms - watchdogConfig(WATCHDOG_500MS); - 1d0c: 8d e0 ldi r24, 0x0D ; 13 - 1d0e: 21 d1 rcall .+578 ; 0x1f52 + watchdogConfig(WATCHDOG_1S); + 1d0e: 8e e0 ldi r24, 0x0E ; 14 + 1d10: 1a d1 rcall .+564 ; 0x1f46 /* Set LED pin as output */ LED_DDR |= _BV(LED); - 1d10: d4 9a sbi 0x1a, 4 ; 26 + 1d12: d4 9a sbi 0x1a, 4 ; 26 #ifdef SOFT_UART /* Set TX pin as output */ UART_DDR |= _BV(UART_TX_BIT); - 1d12: d2 9a sbi 0x1a, 2 ; 26 - 1d14: 86 e0 ldi r24, 0x06 ; 6 + 1d14: d2 9a sbi 0x1a, 2 ; 26 + 1d16: 86 e0 ldi r24, 0x06 ; 6 } #if LED_START_FLASHES > 0 void flash_led(uint8_t count) { do { TCNT1 = -(F_CPU/(1024*16)); - 1d16: 23 ec ldi r18, 0xC3 ; 195 - 1d18: 3f ef ldi r19, 0xFF ; 255 + 1d18: 23 ec ldi r18, 0xC3 ; 195 + 1d1a: 3f ef ldi r19, 0xFF ; 255 TIFR1 = _BV(TOV1); - 1d1a: 91 e0 ldi r25, 0x01 ; 1 + 1d1c: 91 e0 ldi r25, 0x01 ; 1 } #if LED_START_FLASHES > 0 void flash_led(uint8_t count) { do { TCNT1 = -(F_CPU/(1024*16)); - 1d1c: 3d bd out 0x2d, r19 ; 45 - 1d1e: 2c bd out 0x2c, r18 ; 44 + 1d1e: 3d bd out 0x2d, r19 ; 45 + 1d20: 2c bd out 0x2c, r18 ; 44 TIFR1 = _BV(TOV1); - 1d20: 9b b9 out 0x0b, r25 ; 11 + 1d22: 9b b9 out 0x0b, r25 ; 11 while(!(TIFR1 & _BV(TOV1))); - 1d22: 58 9b sbis 0x0b, 0 ; 11 - 1d24: fe cf rjmp .-4 ; 0x1d22 + 1d24: 58 9b sbis 0x0b, 0 ; 11 + 1d26: fe cf rjmp .-4 ; 0x1d24 +#ifdef __AVR_ATmega8__ + LED_PORT ^= _BV(LED); +#else LED_PIN |= _BV(LED); - 1d26: cc 9a sbi 0x19, 4 ; 25 + 1d28: cc 9a sbi 0x19, 4 ; 25 return getch(); } // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( - 1d28: a8 95 wdr - TCNT1 = -(F_CPU/(1024*16)); - TIFR1 = _BV(TOV1); - while(!(TIFR1 & _BV(TOV1))); + 1d2a: a8 95 wdr + LED_PORT ^= _BV(LED); +#else LED_PIN |= _BV(LED); +#endif watchdogReset(); } while (--count); - 1d2a: 81 50 subi r24, 0x01 ; 1 - 1d2c: b9 f7 brne .-18 ; 0x1d1c + 1d2c: 81 50 subi r24, 0x01 ; 1 + 1d2e: b9 f7 brne .-18 ; 0x1d1e /* 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); - 1d2e: cc 24 eor r12, r12 - 1d30: c3 94 inc r12 - boot_page_fill((uint16_t)(void*)addrPtr,a); + 1d30: dd 24 eor r13, r13 + 1d32: 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); - 1d32: 85 e0 ldi r24, 0x05 ; 5 - 1d34: e8 2e mov r14, r24 + __boot_page_write_short((uint16_t)(void*)address); + 1d34: 85 e0 ldi r24, 0x05 ; 5 + 1d36: c8 2e mov r12, r24 vect -= 4; // Instruction is a relative jump (rjmp), so recalculate. - buff[10] = vect & 0xff; - buff[11] = vect >> 8; + buff[8] = vect & 0xff; + buff[9] = vect >> 8; // Add jump to bootloader at RESET vector buff[0] = 0x7f; - 1d36: 0f e7 ldi r16, 0x7F ; 127 - 1d38: d0 2e mov r13, r16 + 1d38: 0f e7 ldi r16, 0x7F ; 127 + 1d3a: f0 2e mov r15, r16 buff[1] = 0xce; // rjmp 0x1d00 instruction - 1d3a: 1e ec ldi r17, 0xCE ; 206 - 1d3c: f1 2e mov r15, r17 + 1d3c: 1e ec ldi r17, 0xCE ; 206 + 1d3e: e1 2e mov r14, r17 #endif /* Forever loop */ for (;;) { /* get character from UART */ ch = getch(); - 1d3e: f0 d0 rcall .+480 ; 0x1f20 + 1d40: e9 d0 rcall .+466 ; 0x1f14 if(ch == STK_GET_PARAMETER) { - 1d40: 81 34 cpi r24, 0x41 ; 65 - 1d42: 21 f4 brne .+8 ; 0x1d4c + 1d42: 81 34 cpi r24, 0x41 ; 65 + 1d44: 21 f4 brne .+8 ; 0x1d4e // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy getNch(1); - 1d44: 81 e0 ldi r24, 0x01 ; 1 - 1d46: 14 d1 rcall .+552 ; 0x1f70 + 1d46: 81 e0 ldi r24, 0x01 ; 1 + 1d48: 0d d1 rcall .+538 ; 0x1f64 putch(0x03); - 1d48: 83 e0 ldi r24, 0x03 ; 3 - 1d4a: 24 c0 rjmp .+72 ; 0x1d94 + 1d4a: 83 e0 ldi r24, 0x03 ; 3 + 1d4c: 20 c0 rjmp .+64 ; 0x1d8e } else if(ch == STK_SET_DEVICE) { - 1d4c: 82 34 cpi r24, 0x42 ; 66 - 1d4e: 11 f4 brne .+4 ; 0x1d54 + 1d4e: 82 34 cpi r24, 0x42 ; 66 + 1d50: 11 f4 brne .+4 ; 0x1d56 // SET DEVICE is ignored getNch(20); - 1d50: 84 e1 ldi r24, 0x14 ; 20 - 1d52: 03 c0 rjmp .+6 ; 0x1d5a + 1d52: 84 e1 ldi r24, 0x14 ; 20 + 1d54: 03 c0 rjmp .+6 ; 0x1d5c } else if(ch == STK_SET_DEVICE_EXT) { - 1d54: 85 34 cpi r24, 0x45 ; 69 - 1d56: 19 f4 brne .+6 ; 0x1d5e + 1d56: 85 34 cpi r24, 0x45 ; 69 + 1d58: 19 f4 brne .+6 ; 0x1d60 // SET DEVICE EXT is ignored getNch(5); - 1d58: 85 e0 ldi r24, 0x05 ; 5 - 1d5a: 0a d1 rcall .+532 ; 0x1f70 - 1d5c: cf c0 rjmp .+414 ; 0x1efc + 1d5a: 85 e0 ldi r24, 0x05 ; 5 + 1d5c: 03 d1 rcall .+518 ; 0x1f64 + 1d5e: c8 c0 rjmp .+400 ; 0x1ef0 } else if(ch == STK_LOAD_ADDRESS) { - 1d5e: 85 35 cpi r24, 0x55 ; 85 - 1d60: a1 f4 brne .+40 ; 0x1d8a + 1d60: 85 35 cpi r24, 0x55 ; 85 + 1d62: 81 f4 brne .+32 ; 0x1d84 // LOAD ADDRESS - address = getch(); - 1d62: de d0 rcall .+444 ; 0x1f20 - 1d64: 08 2f mov r16, r24 - 1d66: 10 e0 ldi r17, 0x00 ; 0 - 1d68: 10 93 01 02 sts 0x0201, r17 - 1d6c: 00 93 00 02 sts 0x0200, r16 - address = (address & 0xff) | (getch() << 8); - 1d70: d7 d0 rcall .+430 ; 0x1f20 - 1d72: 90 e0 ldi r25, 0x00 ; 0 - 1d74: 98 2f mov r25, r24 - 1d76: 88 27 eor r24, r24 - 1d78: 80 2b or r24, r16 - 1d7a: 91 2b or r25, r17 - address += address; // Convert from word address to byte address - 1d7c: 88 0f add r24, r24 - 1d7e: 99 1f adc r25, r25 - 1d80: 90 93 01 02 sts 0x0201, r25 - 1d84: 80 93 00 02 sts 0x0200, r24 - 1d88: b8 c0 rjmp .+368 ; 0x1efa + uint16_t newAddress; + newAddress = getch(); + 1d64: d7 d0 rcall .+430 ; 0x1f14 + newAddress = (newAddress & 0xff) | (getch() << 8); + 1d66: 08 2f mov r16, r24 + 1d68: 10 e0 ldi r17, 0x00 ; 0 + 1d6a: d4 d0 rcall .+424 ; 0x1f14 + 1d6c: 90 e0 ldi r25, 0x00 ; 0 + 1d6e: 98 2f mov r25, r24 + 1d70: 88 27 eor r24, r24 + 1d72: 80 2b or r24, r16 + 1d74: 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 + 1d76: 88 0f add r24, r24 + 1d78: 99 1f adc r25, r25 + address = newAddress; + 1d7a: 90 93 81 01 sts 0x0181, r25 + 1d7e: 80 93 80 01 sts 0x0180, r24 + 1d82: b5 c0 rjmp .+362 ; 0x1eee verifySpace(); } else if(ch == STK_UNIVERSAL) { - 1d8a: 86 35 cpi r24, 0x56 ; 86 - 1d8c: 29 f4 brne .+10 ; 0x1d98 + 1d84: 86 35 cpi r24, 0x56 ; 86 + 1d86: 29 f4 brne .+10 ; 0x1d92 // UNIVERSAL command is ignored getNch(4); - 1d8e: 84 e0 ldi r24, 0x04 ; 4 - 1d90: ef d0 rcall .+478 ; 0x1f70 + 1d88: 84 e0 ldi r24, 0x04 ; 4 + 1d8a: ec d0 rcall .+472 ; 0x1f64 putch(0x00); - 1d92: 80 e0 ldi r24, 0x00 ; 0 - 1d94: b6 d0 rcall .+364 ; 0x1f02 - 1d96: b2 c0 rjmp .+356 ; 0x1efc + 1d8c: 80 e0 ldi r24, 0x00 ; 0 + 1d8e: b3 d0 rcall .+358 ; 0x1ef6 + 1d90: af c0 rjmp .+350 ; 0x1ef0 } - /* 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) { - 1d98: 84 36 cpi r24, 0x64 ; 100 - 1d9a: 09 f0 breq .+2 ; 0x1d9e - 1d9c: 6e c0 rjmp .+220 ; 0x1e7a + 1d92: 84 36 cpi r24, 0x64 ; 100 + 1d94: 09 f0 breq .+2 ; 0x1d98 + 1d96: 6b c0 rjmp .+214 ; 0x1e6e // PROGRAM PAGE - we support flash programming only, not EEPROM uint8_t *bufPtr; uint16_t addrPtr; getLen(); - 1d9e: d4 d0 rcall .+424 ; 0x1f48 - - // Immediately start page erase - this will 4.5ms - boot_page_erase((uint16_t)(void*)address); - 1da0: e0 91 00 02 lds r30, 0x0200 - 1da4: f0 91 01 02 lds r31, 0x0201 - 1da8: 83 e0 ldi r24, 0x03 ; 3 - 1daa: 80 93 57 00 sts 0x0057, r24 - 1dae: e8 95 spm - 1db0: c0 e0 ldi r28, 0x00 ; 0 - 1db2: d1 e0 ldi r29, 0x01 ; 1 - + 1d98: d1 d0 rcall .+418 ; 0x1f3c + 1d9a: c0 e0 ldi r28, 0x00 ; 0 + 1d9c: d1 e0 ldi r29, 0x01 ; 1 + // If we are in RWW section, immediately start page erase + if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address); + // While that is going on, read in page contents bufPtr = buff; do *bufPtr++ = getch(); - 1db4: b5 d0 rcall .+362 ; 0x1f20 - 1db6: 89 93 st Y+, r24 + 1d9e: ba d0 rcall .+372 ; 0x1f14 + 1da0: 89 93 st Y+, r24 while (--length); - 1db8: 80 91 02 02 lds r24, 0x0202 - 1dbc: 81 50 subi r24, 0x01 ; 1 - 1dbe: 80 93 02 02 sts 0x0202, r24 - 1dc2: 88 23 and r24, r24 - 1dc4: b9 f7 brne .-18 ; 0x1db4 + 1da2: 80 91 82 01 lds r24, 0x0182 + 1da6: 81 50 subi r24, 0x01 ; 1 + 1da8: 80 93 82 01 sts 0x0182, r24 + 1dac: 88 23 and r24, r24 + 1dae: b9 f7 brne .-18 ; 0x1d9e + + // 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); + 1db0: e0 91 80 01 lds r30, 0x0180 + 1db4: f0 91 81 01 lds r31, 0x0181 + 1db8: 83 e0 ldi r24, 0x03 ; 3 + 1dba: 87 bf out 0x37, r24 ; 55 + 1dbc: e8 95 spm // Read command terminator, start reply verifySpace(); - 1dc6: ce d0 rcall .+412 ; 0x1f64 + 1dbe: cc d0 rcall .+408 ; 0x1f58 // If only a partial page is to be programmed, the erase might not be complete. // So check that here boot_spm_busy_wait(); - 1dc8: 07 b6 in r0, 0x37 ; 55 - 1dca: 00 fc sbrc r0, 0 - 1dcc: fd cf rjmp .-6 ; 0x1dc8 + 1dc0: 07 b6 in r0, 0x37 ; 55 + 1dc2: 00 fc sbrc r0, 0 + 1dc4: fd cf rjmp .-6 ; 0x1dc0 #ifdef VIRTUAL_BOOT_PARTITION if ((uint16_t)(void*)address == 0) { - 1dce: 80 91 00 02 lds r24, 0x0200 - 1dd2: 90 91 01 02 lds r25, 0x0201 - 1dd6: 89 2b or r24, r25 - 1dd8: 41 f5 brne .+80 ; 0x1e2a + 1dc6: 80 91 80 01 lds r24, 0x0180 + 1dca: 90 91 81 01 lds r25, 0x0181 + 1dce: 89 2b or r24, r25 + 1dd0: 41 f5 brne .+80 ; 0x1e22 // This is the reset vector page. We need to live-patch the code so the // bootloader runs. // // Move RESET vector to WDT vector uint16_t vect = buff[0] | (buff[1]<<8); - 1dda: 80 91 00 01 lds r24, 0x0100 - 1dde: 20 91 01 01 lds r18, 0x0101 - 1de2: 30 e0 ldi r19, 0x00 ; 0 - 1de4: 32 2f mov r19, r18 - 1de6: 22 27 eor r18, r18 - 1de8: 90 e0 ldi r25, 0x00 ; 0 - 1dea: 28 2b or r18, r24 - 1dec: 39 2b or r19, r25 + 1dd2: 80 91 00 01 lds r24, 0x0100 + 1dd6: 20 91 01 01 lds r18, 0x0101 + 1dda: 30 e0 ldi r19, 0x00 ; 0 + 1ddc: 32 2f mov r19, r18 + 1dde: 22 27 eor r18, r18 + 1de0: 90 e0 ldi r25, 0x00 ; 0 + 1de2: 28 2b or r18, r24 + 1de4: 39 2b or r19, r25 rstVect = vect; - 1dee: 30 93 05 02 sts 0x0205, r19 - 1df2: 20 93 04 02 sts 0x0204, r18 - wdtVect = buff[10] | (buff[11]<<8); - 1df6: 40 91 0a 01 lds r20, 0x010A - 1dfa: 80 91 0b 01 lds r24, 0x010B - 1dfe: 90 e0 ldi r25, 0x00 ; 0 - 1e00: 98 2f mov r25, r24 - 1e02: 88 27 eor r24, r24 - 1e04: 50 e0 ldi r21, 0x00 ; 0 - 1e06: 84 2b or r24, r20 - 1e08: 95 2b or r25, r21 - 1e0a: 90 93 07 02 sts 0x0207, r25 - 1e0e: 80 93 06 02 sts 0x0206, r24 + 1de6: 30 93 85 01 sts 0x0185, r19 + 1dea: 20 93 84 01 sts 0x0184, r18 + wdtVect = buff[8] | (buff[9]<<8); + 1dee: 40 91 08 01 lds r20, 0x0108 + 1df2: 80 91 09 01 lds r24, 0x0109 + 1df6: 90 e0 ldi r25, 0x00 ; 0 + 1df8: 98 2f mov r25, r24 + 1dfa: 88 27 eor r24, r24 + 1dfc: 50 e0 ldi r21, 0x00 ; 0 + 1dfe: 84 2b or r24, r20 + 1e00: 95 2b or r25, r21 + 1e02: 90 93 87 01 sts 0x0187, r25 + 1e06: 80 93 86 01 sts 0x0186, r24 vect -= 4; // Instruction is a relative jump (rjmp), so recalculate. - 1e12: 24 50 subi r18, 0x04 ; 4 - 1e14: 30 40 sbci r19, 0x00 ; 0 - buff[10] = vect & 0xff; - 1e16: 20 93 0a 01 sts 0x010A, r18 - buff[11] = vect >> 8; - 1e1a: 23 2f mov r18, r19 - 1e1c: 33 27 eor r19, r19 - 1e1e: 20 93 0b 01 sts 0x010B, r18 + 1e0a: 24 50 subi r18, 0x04 ; 4 + 1e0c: 30 40 sbci r19, 0x00 ; 0 + buff[8] = vect & 0xff; + 1e0e: 20 93 08 01 sts 0x0108, r18 + buff[9] = vect >> 8; + 1e12: 23 2f mov r18, r19 + 1e14: 33 27 eor r19, r19 + 1e16: 20 93 09 01 sts 0x0109, r18 // Add jump to bootloader at RESET vector buff[0] = 0x7f; - 1e22: d0 92 00 01 sts 0x0100, r13 + 1e1a: f0 92 00 01 sts 0x0100, r15 buff[1] = 0xce; // rjmp 0x1d00 instruction - 1e26: f0 92 01 01 sts 0x0101, r15 + 1e1e: e0 92 01 01 sts 0x0101, r14 } #endif // Copy buffer into programming buffer bufPtr = buff; addrPtr = (uint16_t)(void*)address; - 1e2a: 40 91 00 02 lds r20, 0x0200 - 1e2e: 50 91 01 02 lds r21, 0x0201 - 1e32: a0 e0 ldi r26, 0x00 ; 0 - 1e34: b1 e0 ldi r27, 0x01 ; 1 + 1e22: 40 91 80 01 lds r20, 0x0180 + 1e26: 50 91 81 01 lds r21, 0x0181 + 1e2a: a0 e0 ldi r26, 0x00 ; 0 + 1e2c: b1 e0 ldi r27, 0x01 ; 1 ch = SPM_PAGESIZE / 2; do { uint16_t a; a = *bufPtr++; - 1e36: 2c 91 ld r18, X - 1e38: 30 e0 ldi r19, 0x00 ; 0 + 1e2e: 2c 91 ld r18, X + 1e30: 30 e0 ldi r19, 0x00 ; 0 a |= (*bufPtr++) << 8; - 1e3a: 11 96 adiw r26, 0x01 ; 1 - 1e3c: 8c 91 ld r24, X - 1e3e: 11 97 sbiw r26, 0x01 ; 1 - 1e40: 90 e0 ldi r25, 0x00 ; 0 - 1e42: 98 2f mov r25, r24 - 1e44: 88 27 eor r24, r24 - 1e46: 82 2b or r24, r18 - 1e48: 93 2b or r25, r19 -#ifdef VIRTUAL_BOOT_PARTITION -#define rstVect (*(uint16_t*)(0x204)) -#define wdtVect (*(uint16_t*)(0x206)) + 1e32: 11 96 adiw r26, 0x01 ; 1 + 1e34: 8c 91 ld r24, X + 1e36: 11 97 sbiw r26, 0x01 ; 1 + 1e38: 90 e0 ldi r25, 0x00 ; 0 + 1e3a: 98 2f mov r25, r24 + 1e3c: 88 27 eor r24, r24 + 1e3e: 82 2b or r24, r18 + 1e40: 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) { - 1e4a: 12 96 adiw r26, 0x02 ; 2 + 1e42: 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); - 1e4c: fa 01 movw r30, r20 - 1e4e: 0c 01 movw r0, r24 - 1e50: c0 92 57 00 sts 0x0057, r12 - 1e54: e8 95 spm - 1e56: 11 24 eor r1, r1 + __boot_page_fill_short((uint16_t)(void*)addrPtr,a); + 1e44: fa 01 movw r30, r20 + 1e46: 0c 01 movw r0, r24 + 1e48: d7 be out 0x37, r13 ; 55 + 1e4a: e8 95 spm + 1e4c: 11 24 eor r1, r1 addrPtr += 2; - 1e58: 4e 5f subi r20, 0xFE ; 254 - 1e5a: 5f 4f sbci r21, 0xFF ; 255 + 1e4e: 4e 5f subi r20, 0xFE ; 254 + 1e50: 5f 4f sbci r21, 0xFF ; 255 } while (--ch); - 1e5c: f1 e0 ldi r31, 0x01 ; 1 - 1e5e: a0 34 cpi r26, 0x40 ; 64 - 1e60: bf 07 cpc r27, r31 - 1e62: 49 f7 brne .-46 ; 0x1e36 + 1e52: f1 e0 ldi r31, 0x01 ; 1 + 1e54: a0 34 cpi r26, 0x40 ; 64 + 1e56: bf 07 cpc r27, r31 + 1e58: 51 f7 brne .-44 ; 0x1e2e // Write from programming buffer - boot_page_write((uint16_t)(void*)address); - 1e64: e0 91 00 02 lds r30, 0x0200 - 1e68: f0 91 01 02 lds r31, 0x0201 - 1e6c: e0 92 57 00 sts 0x0057, r14 - 1e70: e8 95 spm + __boot_page_write_short((uint16_t)(void*)address); + 1e5a: e0 91 80 01 lds r30, 0x0180 + 1e5e: f0 91 81 01 lds r31, 0x0181 + 1e62: c7 be out 0x37, r12 ; 55 + 1e64: e8 95 spm boot_spm_busy_wait(); - 1e72: 07 b6 in r0, 0x37 ; 55 - 1e74: 00 fc sbrc r0, 0 - 1e76: fd cf rjmp .-6 ; 0x1e72 - 1e78: 41 c0 rjmp .+130 ; 0x1efc + 1e66: 07 b6 in r0, 0x37 ; 55 + 1e68: 00 fc sbrc r0, 0 + 1e6a: fd cf rjmp .-6 ; 0x1e66 + 1e6c: 41 c0 rjmp .+130 ; 0x1ef0 boot_rww_enable(); #endif } /* Read memory block mode, length is big endian. */ else if(ch == STK_READ_PAGE) { - 1e7a: 84 37 cpi r24, 0x74 ; 116 - 1e7c: 89 f5 brne .+98 ; 0x1ee0 + 1e6e: 84 37 cpi r24, 0x74 ; 116 + 1e70: 89 f5 brne .+98 ; 0x1ed4 // READ PAGE - we only read flash getLen(); - 1e7e: 64 d0 rcall .+200 ; 0x1f48 + 1e72: 64 d0 rcall .+200 ; 0x1f3c verifySpace(); - 1e80: 71 d0 rcall .+226 ; 0x1f64 + 1e74: 71 d0 rcall .+226 ; 0x1f58 #ifdef VIRTUAL_BOOT_PARTITION do { // Undo vector patch in bottom page so verify passes if (address == 0) ch=rstVect & 0xff; - 1e82: e0 91 00 02 lds r30, 0x0200 - 1e86: f0 91 01 02 lds r31, 0x0201 - 1e8a: 30 97 sbiw r30, 0x00 ; 0 - 1e8c: 19 f4 brne .+6 ; 0x1e94 - 1e8e: 20 91 04 02 lds r18, 0x0204 - 1e92: 13 c0 rjmp .+38 ; 0x1eba + 1e76: e0 91 80 01 lds r30, 0x0180 + 1e7a: f0 91 81 01 lds r31, 0x0181 + 1e7e: 30 97 sbiw r30, 0x00 ; 0 + 1e80: 19 f4 brne .+6 ; 0x1e88 + 1e82: 20 91 84 01 lds r18, 0x0184 + 1e86: 13 c0 rjmp .+38 ; 0x1eae else if (address == 1) ch=rstVect >> 8; - 1e94: e1 30 cpi r30, 0x01 ; 1 + 1e88: e1 30 cpi r30, 0x01 ; 1 + 1e8a: f1 05 cpc r31, r1 + 1e8c: 19 f4 brne .+6 ; 0x1e94 + 1e8e: 20 91 85 01 lds r18, 0x0185 + 1e92: 0d c0 rjmp .+26 ; 0x1eae + else if (address == 8) ch=wdtVect & 0xff; + 1e94: e8 30 cpi r30, 0x08 ; 8 1e96: f1 05 cpc r31, r1 1e98: 19 f4 brne .+6 ; 0x1ea0 - 1e9a: 20 91 05 02 lds r18, 0x0205 - 1e9e: 0d c0 rjmp .+26 ; 0x1eba - else if (address == 10) ch=wdtVect & 0xff; - 1ea0: ea 30 cpi r30, 0x0A ; 10 + 1e9a: 20 91 86 01 lds r18, 0x0186 + 1e9e: 07 c0 rjmp .+14 ; 0x1eae + else if (address == 9) ch=wdtVect >> 8; + 1ea0: e9 30 cpi r30, 0x09 ; 9 1ea2: f1 05 cpc r31, r1 1ea4: 19 f4 brne .+6 ; 0x1eac - 1ea6: 20 91 06 02 lds r18, 0x0206 - 1eaa: 07 c0 rjmp .+14 ; 0x1eba - else if (address == 11) ch=wdtVect >> 8; - 1eac: eb 30 cpi r30, 0x0B ; 11 - 1eae: f1 05 cpc r31, r1 - 1eb0: 19 f4 brne .+6 ; 0x1eb8 - 1eb2: 20 91 07 02 lds r18, 0x0207 - 1eb6: 01 c0 rjmp .+2 ; 0x1eba + 1ea6: 20 91 87 01 lds r18, 0x0187 + 1eaa: 01 c0 rjmp .+2 ; 0x1eae else ch = pgm_read_byte_near(address); - 1eb8: 24 91 lpm r18, Z+ + 1eac: 24 91 lpm r18, Z+ address++; - 1eba: 80 91 00 02 lds r24, 0x0200 - 1ebe: 90 91 01 02 lds r25, 0x0201 - 1ec2: 01 96 adiw r24, 0x01 ; 1 - 1ec4: 90 93 01 02 sts 0x0201, r25 - 1ec8: 80 93 00 02 sts 0x0200, r24 + 1eae: 80 91 80 01 lds r24, 0x0180 + 1eb2: 90 91 81 01 lds r25, 0x0181 + 1eb6: 01 96 adiw r24, 0x01 ; 1 + 1eb8: 90 93 81 01 sts 0x0181, r25 + 1ebc: 80 93 80 01 sts 0x0180, r24 putch(ch); - 1ecc: 82 2f mov r24, r18 - 1ece: 19 d0 rcall .+50 ; 0x1f02 + 1ec0: 82 2f mov r24, r18 + 1ec2: 19 d0 rcall .+50 ; 0x1ef6 } while (--length); - 1ed0: 80 91 02 02 lds r24, 0x0202 - 1ed4: 81 50 subi r24, 0x01 ; 1 - 1ed6: 80 93 02 02 sts 0x0202, r24 - 1eda: 88 23 and r24, r24 - 1edc: 91 f6 brne .-92 ; 0x1e82 - 1ede: 0e c0 rjmp .+28 ; 0x1efc - while (--length); + 1ec4: 80 91 82 01 lds r24, 0x0182 + 1ec8: 81 50 subi r24, 0x01 ; 1 + 1eca: 80 93 82 01 sts 0x0182, r24 + 1ece: 88 23 and r24, r24 + 1ed0: 91 f6 brne .-92 ; 0x1e76 + 1ed2: 0e c0 rjmp .+28 ; 0x1ef0 +#endif #endif } /* Get device signature bytes */ else if(ch == STK_READ_SIGN) { - 1ee0: 85 37 cpi r24, 0x75 ; 117 - 1ee2: 39 f4 brne .+14 ; 0x1ef2 + 1ed4: 85 37 cpi r24, 0x75 ; 117 + 1ed6: 39 f4 brne .+14 ; 0x1ee6 // READ SIGN - return what Avrdude wants to hear verifySpace(); - 1ee4: 3f d0 rcall .+126 ; 0x1f64 + 1ed8: 3f d0 rcall .+126 ; 0x1f58 putch(SIGNATURE_0); - 1ee6: 8e e1 ldi r24, 0x1E ; 30 - 1ee8: 0c d0 rcall .+24 ; 0x1f02 + 1eda: 8e e1 ldi r24, 0x1E ; 30 + 1edc: 0c d0 rcall .+24 ; 0x1ef6 putch(SIGNATURE_1); - 1eea: 83 e9 ldi r24, 0x93 ; 147 - 1eec: 0a d0 rcall .+20 ; 0x1f02 + 1ede: 83 e9 ldi r24, 0x93 ; 147 + 1ee0: 0a d0 rcall .+20 ; 0x1ef6 putch(SIGNATURE_2); - 1eee: 8c e0 ldi r24, 0x0C ; 12 - 1ef0: 51 cf rjmp .-350 ; 0x1d94 + 1ee2: 8c e0 ldi r24, 0x0C ; 12 + 1ee4: 54 cf rjmp .-344 ; 0x1d8e } else if (ch == 'Q') { - 1ef2: 81 35 cpi r24, 0x51 ; 81 - 1ef4: 11 f4 brne .+4 ; 0x1efa + 1ee6: 81 35 cpi r24, 0x51 ; 81 + 1ee8: 11 f4 brne .+4 ; 0x1eee // Adaboot no-wait mod watchdogConfig(WATCHDOG_16MS); - 1ef6: 88 e0 ldi r24, 0x08 ; 8 - 1ef8: 2c d0 rcall .+88 ; 0x1f52 + 1eea: 88 e0 ldi r24, 0x08 ; 8 + 1eec: 2c d0 rcall .+88 ; 0x1f46 verifySpace(); } else { // This covers the response to commands like STK_ENTER_PROGMODE verifySpace(); - 1efa: 34 d0 rcall .+104 ; 0x1f64 + 1eee: 34 d0 rcall .+104 ; 0x1f58 } putch(STK_OK); - 1efc: 80 e1 ldi r24, 0x10 ; 16 - 1efe: 01 d0 rcall .+2 ; 0x1f02 - 1f00: 1e cf rjmp .-452 ; 0x1d3e + 1ef0: 80 e1 ldi r24, 0x10 ; 16 + 1ef2: 01 d0 rcall .+2 ; 0x1ef6 + 1ef4: 25 cf rjmp .-438 ; 0x1d40 -00001f02 : +00001ef6 : void putch(char ch) { #ifndef SOFT_UART while (!(UCSR0A & _BV(UDRE0))); UDR0 = ch; #else __asm__ __volatile__ ( - 1f02: 2a e0 ldi r18, 0x0A ; 10 - 1f04: 30 e0 ldi r19, 0x00 ; 0 - 1f06: 80 95 com r24 - 1f08: 08 94 sec - 1f0a: 10 f4 brcc .+4 ; 0x1f10 - 1f0c: da 98 cbi 0x1b, 2 ; 27 - 1f0e: 02 c0 rjmp .+4 ; 0x1f14 - 1f10: da 9a sbi 0x1b, 2 ; 27 - 1f12: 00 00 nop - 1f14: 15 d0 rcall .+42 ; 0x1f40 - 1f16: 14 d0 rcall .+40 ; 0x1f40 - 1f18: 86 95 lsr r24 - 1f1a: 2a 95 dec r18 - 1f1c: b1 f7 brne .-20 ; 0x1f0a + 1ef6: 2a e0 ldi r18, 0x0A ; 10 + 1ef8: 30 e0 ldi r19, 0x00 ; 0 + 1efa: 80 95 com r24 + 1efc: 08 94 sec + 1efe: 10 f4 brcc .+4 ; 0x1f04 + 1f00: da 98 cbi 0x1b, 2 ; 27 + 1f02: 02 c0 rjmp .+4 ; 0x1f08 + 1f04: da 9a sbi 0x1b, 2 ; 27 + 1f06: 00 00 nop + 1f08: 15 d0 rcall .+42 ; 0x1f34 + 1f0a: 14 d0 rcall .+40 ; 0x1f34 + 1f0c: 86 95 lsr r24 + 1f0e: 2a 95 dec r18 + 1f10: b1 f7 brne .-20 ; 0x1efe [uartBit] "I" (UART_TX_BIT) : "r25" ); #endif } - 1f1e: 08 95 ret + 1f12: 08 95 ret -00001f20 : +00001f14 : return getch(); } // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( - 1f20: a8 95 wdr -#ifdef LED_DATA_FLASH + 1f14: a8 95 wdr LED_PIN |= _BV(LED); +#endif #endif return ch; } - 1f22: 29 e0 ldi r18, 0x09 ; 9 - 1f24: 30 e0 ldi r19, 0x00 ; 0 + 1f16: 29 e0 ldi r18, 0x09 ; 9 + 1f18: 30 e0 ldi r19, 0x00 ; 0 + 1f1a: cb 99 sbic 0x19, 3 ; 25 + 1f1c: fe cf rjmp .-4 ; 0x1f1a + 1f1e: 0a d0 rcall .+20 ; 0x1f34 + 1f20: 09 d0 rcall .+18 ; 0x1f34 + 1f22: 08 d0 rcall .+16 ; 0x1f34 + 1f24: 88 94 clc 1f26: cb 99 sbic 0x19, 3 ; 25 - 1f28: fe cf rjmp .-4 ; 0x1f26 - 1f2a: 0a d0 rcall .+20 ; 0x1f40 - 1f2c: 09 d0 rcall .+18 ; 0x1f40 - 1f2e: 08 d0 rcall .+16 ; 0x1f40 - 1f30: 88 94 clc - 1f32: cb 99 sbic 0x19, 3 ; 25 - 1f34: 08 94 sec - 1f36: 2a 95 dec r18 - 1f38: 11 f0 breq .+4 ; 0x1f3e - 1f3a: 87 95 ror r24 - 1f3c: f7 cf rjmp .-18 ; 0x1f2c - 1f3e: 08 95 ret - -00001f40 : + 1f28: 08 94 sec + 1f2a: 2a 95 dec r18 + 1f2c: 11 f0 breq .+4 ; 0x1f32 + 1f2e: 87 95 ror r24 + 1f30: f7 cf rjmp .-18 ; 0x1f20 + 1f32: 08 95 ret + +00001f34 : #if UART_B_VALUE > 255 #error Baud rate too slow for soft UART #endif void uartDelay() { __asm__ __volatile__ ( - 1f40: 9e e0 ldi r25, 0x0E ; 14 - 1f42: 9a 95 dec r25 - 1f44: f1 f7 brne .-4 ; 0x1f42 - 1f46: 08 95 ret + 1f34: 9e e0 ldi r25, 0x0E ; 14 + 1f36: 9a 95 dec r25 + 1f38: f1 f7 brne .-4 ; 0x1f36 + 1f3a: 08 95 ret -00001f48 : +00001f3c : } while (--count); } #endif uint8_t getLen() { getch(); - 1f48: eb df rcall .-42 ; 0x1f20 + 1f3c: eb df rcall .-42 ; 0x1f14 length = getch(); - 1f4a: ea df rcall .-44 ; 0x1f20 - 1f4c: 80 93 02 02 sts 0x0202, r24 + 1f3e: ea df rcall .-44 ; 0x1f14 + 1f40: 80 93 82 01 sts 0x0182, r24 return getch(); } - 1f50: e7 cf rjmp .-50 ; 0x1f20 + 1f44: e7 cf rjmp .-50 ; 0x1f14 -00001f52 : +00001f46 : "wdr\n" ); } void watchdogConfig(uint8_t x) { WDTCSR = _BV(WDCE) | _BV(WDE); - 1f52: 98 e1 ldi r25, 0x18 ; 24 - 1f54: 91 bd out 0x21, r25 ; 33 + 1f46: 98 e1 ldi r25, 0x18 ; 24 + 1f48: 91 bd out 0x21, r25 ; 33 WDTCSR = x; - 1f56: 81 bd out 0x21, r24 ; 33 + 1f4a: 81 bd out 0x21, r24 ; 33 } - 1f58: 08 95 ret + 1f4c: 08 95 ret -00001f5a : +00001f4e : void appStart() { watchdogConfig(WATCHDOG_OFF); - 1f5a: 80 e0 ldi r24, 0x00 ; 0 - 1f5c: fa df rcall .-12 ; 0x1f52 + 1f4e: 80 e0 ldi r24, 0x00 ; 0 + 1f50: fa df rcall .-12 ; 0x1f46 __asm__ __volatile__ ( - 1f5e: e5 e0 ldi r30, 0x05 ; 5 - 1f60: ff 27 eor r31, r31 - 1f62: 09 94 ijmp + 1f52: e4 e0 ldi r30, 0x04 ; 4 + 1f54: ff 27 eor r31, r31 + 1f56: 09 94 ijmp -00001f64 : +00001f58 : do getch(); while (--count); verifySpace(); } void verifySpace() { if (getch() != CRC_EOP) appStart(); - 1f64: dd df rcall .-70 ; 0x1f20 - 1f66: 80 32 cpi r24, 0x20 ; 32 - 1f68: 09 f0 breq .+2 ; 0x1f6c - 1f6a: f7 df rcall .-18 ; 0x1f5a + 1f58: dd df rcall .-70 ; 0x1f14 + 1f5a: 80 32 cpi r24, 0x20 ; 32 + 1f5c: 09 f0 breq .+2 ; 0x1f60 + 1f5e: f7 df rcall .-18 ; 0x1f4e putch(STK_INSYNC); - 1f6c: 84 e1 ldi r24, 0x14 ; 20 + 1f60: 84 e1 ldi r24, 0x14 ; 20 } - 1f6e: c9 cf rjmp .-110 ; 0x1f02 + 1f62: c9 cf rjmp .-110 ; 0x1ef6 + +00001f64 : ::[count] "M" (UART_B_VALUE) ); } #endif void getNch(uint8_t count) { - 1f70: 1f 93 push r17 - 1f72: 18 2f mov r17, r24 - -00001f74 : + 1f64: 1f 93 push r17 + 1f66: 18 2f mov r17, r24 do getch(); while (--count); - 1f74: d5 df rcall .-86 ; 0x1f20 - 1f76: 11 50 subi r17, 0x01 ; 1 - 1f78: e9 f7 brne .-6 ; 0x1f74 + 1f68: d5 df rcall .-86 ; 0x1f14 + 1f6a: 11 50 subi r17, 0x01 ; 1 + 1f6c: e9 f7 brne .-6 ; 0x1f68 verifySpace(); - 1f7a: f4 df rcall .-24 ; 0x1f64 + 1f6e: f4 df rcall .-24 ; 0x1f58 } - 1f7c: 1f 91 pop r17 - 1f7e: 08 95 ret + 1f70: 1f 91 pop r17 + 1f72: 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_luminet.lst | 604 +++++++++++++++--------------- 1 file changed, 303 insertions(+), 301 deletions(-) (limited to 'bootloaders/optiboot/optiboot_luminet.lst') diff --git a/bootloaders/optiboot/optiboot_luminet.lst b/bootloaders/optiboot/optiboot_luminet.lst index 737d2c5..1be7e4f 100644 --- a/bootloaders/optiboot/optiboot_luminet.lst +++ b/bootloaders/optiboot/optiboot_luminet.lst @@ -3,620 +3,622 @@ optiboot_luminet.elf: file format elf32-avr Sections: Idx Name Size VMA LMA File off Algn - 0 .text 00000274 00001d00 00001d00 00000054 2**1 + 0 .version 00000002 00001efe 00001efe 000002c8 2**0 + CONTENTS, READONLY + 1 .text 00000274 00000000 00000000 00000054 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE - 1 .debug_aranges 00000028 00000000 00000000 000002c8 2**0 + 2 .debug_aranges 00000028 00000000 00000000 000002ca 2**0 CONTENTS, READONLY, DEBUGGING - 2 .debug_pubnames 00000078 00000000 00000000 000002f0 2**0 + 3 .debug_pubnames 00000078 00000000 00000000 000002f2 2**0 CONTENTS, READONLY, DEBUGGING - 3 .debug_info 000002a4 00000000 00000000 00000368 2**0 + 4 .debug_info 000002a5 00000000 00000000 0000036a 2**0 CONTENTS, READONLY, DEBUGGING - 4 .debug_abbrev 000001ac 00000000 00000000 0000060c 2**0 + 5 .debug_abbrev 0000019d 00000000 00000000 0000060f 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_line 000004a9 00000000 00000000 000007b8 2**0 + 6 .debug_line 000004ac 00000000 00000000 000007ac 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_frame 000000a0 00000000 00000000 00000c64 2**2 + 7 .debug_frame 000000a0 00000000 00000000 00000c58 2**2 CONTENTS, READONLY, DEBUGGING - 7 .debug_str 00000150 00000000 00000000 00000d04 2**0 + 8 .debug_str 00000150 00000000 00000000 00000cf8 2**0 CONTENTS, READONLY, DEBUGGING - 8 .debug_loc 00000194 00000000 00000000 00000e54 2**0 + 9 .debug_loc 00000194 00000000 00000000 00000e48 2**0 CONTENTS, READONLY, DEBUGGING - 9 .debug_ranges 00000088 00000000 00000000 00000fe8 2**0 + 10 .debug_ranges 00000088 00000000 00000000 00000fdc 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: -00001d00
: +00000000
: #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) { - 1d00: 11 24 eor r1, r1 + 0: 11 24 eor r1, r1 #ifdef __AVR_ATmega8__ SP=RAMEND; // This is done by hardware reset #endif // Adaboot no-wait mod ch = MCUSR; - 1d02: 84 b7 in r24, 0x34 ; 52 + 2: 84 b7 in r24, 0x34 ; 52 MCUSR = 0; - 1d04: 14 be out 0x34, r1 ; 52 + 4: 14 be out 0x34, r1 ; 52 if (!(ch & _BV(EXTRF))) appStart(); - 1d06: 81 ff sbrs r24, 1 - 1d08: 22 d1 rcall .+580 ; 0x1f4e + 6: 81 ff sbrs r24, 1 + 8: 22 d1 rcall .+580 ; 0x24e #if LED_START_FLASHES > 0 // Set up Timer 1 for timeout counter TCCR1B = _BV(CS12) | _BV(CS10); // div 1024 - 1d0a: 85 e0 ldi r24, 0x05 ; 5 - 1d0c: 8e bd out 0x2e, r24 ; 46 + a: 85 e0 ldi r24, 0x05 ; 5 + c: 8e bd out 0x2e, r24 ; 46 UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); #endif #endif // Set up watchdog to trigger after 500ms watchdogConfig(WATCHDOG_1S); - 1d0e: 8e e0 ldi r24, 0x0E ; 14 - 1d10: 1a d1 rcall .+564 ; 0x1f46 + e: 8e e0 ldi r24, 0x0E ; 14 + 10: 1a d1 rcall .+564 ; 0x246 /* Set LED pin as output */ LED_DDR |= _BV(LED); - 1d12: d4 9a sbi 0x1a, 4 ; 26 + 12: d4 9a sbi 0x1a, 4 ; 26 #ifdef SOFT_UART /* Set TX pin as output */ UART_DDR |= _BV(UART_TX_BIT); - 1d14: d2 9a sbi 0x1a, 2 ; 26 - 1d16: 86 e0 ldi r24, 0x06 ; 6 + 14: d2 9a sbi 0x1a, 2 ; 26 + 16: 86 e0 ldi r24, 0x06 ; 6 } #if LED_START_FLASHES > 0 void flash_led(uint8_t count) { do { TCNT1 = -(F_CPU/(1024*16)); - 1d18: 23 ec ldi r18, 0xC3 ; 195 - 1d1a: 3f ef ldi r19, 0xFF ; 255 + 18: 23 ec ldi r18, 0xC3 ; 195 + 1a: 3f ef ldi r19, 0xFF ; 255 TIFR1 = _BV(TOV1); - 1d1c: 91 e0 ldi r25, 0x01 ; 1 + 1c: 91 e0 ldi r25, 0x01 ; 1 } #if LED_START_FLASHES > 0 void flash_led(uint8_t count) { do { TCNT1 = -(F_CPU/(1024*16)); - 1d1e: 3d bd out 0x2d, r19 ; 45 - 1d20: 2c bd out 0x2c, r18 ; 44 + 1e: 3d bd out 0x2d, r19 ; 45 + 20: 2c bd out 0x2c, r18 ; 44 TIFR1 = _BV(TOV1); - 1d22: 9b b9 out 0x0b, r25 ; 11 + 22: 9b b9 out 0x0b, r25 ; 11 while(!(TIFR1 & _BV(TOV1))); - 1d24: 58 9b sbis 0x0b, 0 ; 11 - 1d26: fe cf rjmp .-4 ; 0x1d24 + 24: 58 9b sbis 0x0b, 0 ; 11 + 26: fe cf rjmp .-4 ; 0x24 <__zero_reg__+0x23> #ifdef __AVR_ATmega8__ LED_PORT ^= _BV(LED); #else LED_PIN |= _BV(LED); - 1d28: cc 9a sbi 0x19, 4 ; 25 + 28: cc 9a sbi 0x19, 4 ; 25 return getch(); } // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( - 1d2a: a8 95 wdr + 2a: a8 95 wdr LED_PORT ^= _BV(LED); #else LED_PIN |= _BV(LED); #endif watchdogReset(); } while (--count); - 1d2c: 81 50 subi r24, 0x01 ; 1 - 1d2e: b9 f7 brne .-18 ; 0x1d1e + 2c: 81 50 subi r24, 0x01 ; 1 + 2e: b9 f7 brne .-18 ; 0x1e <__zero_reg__+0x1d> /* 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); - 1d30: dd 24 eor r13, r13 - 1d32: d3 94 inc r13 + 30: dd 24 eor r13, r13 + 32: d3 94 inc r13 __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); - 1d34: 85 e0 ldi r24, 0x05 ; 5 - 1d36: c8 2e mov r12, r24 + 34: 85 e0 ldi r24, 0x05 ; 5 + 36: c8 2e mov r12, r24 vect -= 4; // Instruction is a relative jump (rjmp), so recalculate. buff[8] = vect & 0xff; buff[9] = vect >> 8; // Add jump to bootloader at RESET vector buff[0] = 0x7f; - 1d38: 0f e7 ldi r16, 0x7F ; 127 - 1d3a: f0 2e mov r15, r16 + 38: 0f e7 ldi r16, 0x7F ; 127 + 3a: f0 2e mov r15, r16 buff[1] = 0xce; // rjmp 0x1d00 instruction - 1d3c: 1e ec ldi r17, 0xCE ; 206 - 1d3e: e1 2e mov r14, r17 + 3c: 1e ec ldi r17, 0xCE ; 206 + 3e: e1 2e mov r14, r17 #endif /* Forever loop */ for (;;) { /* get character from UART */ ch = getch(); - 1d40: e9 d0 rcall .+466 ; 0x1f14 + 40: e9 d0 rcall .+466 ; 0x214 if(ch == STK_GET_PARAMETER) { - 1d42: 81 34 cpi r24, 0x41 ; 65 - 1d44: 21 f4 brne .+8 ; 0x1d4e + 42: 81 34 cpi r24, 0x41 ; 65 + 44: 21 f4 brne .+8 ; 0x4e <__SREG__+0xf> // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy getNch(1); - 1d46: 81 e0 ldi r24, 0x01 ; 1 - 1d48: 0d d1 rcall .+538 ; 0x1f64 + 46: 81 e0 ldi r24, 0x01 ; 1 + 48: 0d d1 rcall .+538 ; 0x264 putch(0x03); - 1d4a: 83 e0 ldi r24, 0x03 ; 3 - 1d4c: 20 c0 rjmp .+64 ; 0x1d8e + 4a: 83 e0 ldi r24, 0x03 ; 3 + 4c: 20 c0 rjmp .+64 ; 0x8e <__SREG__+0x4f> } else if(ch == STK_SET_DEVICE) { - 1d4e: 82 34 cpi r24, 0x42 ; 66 - 1d50: 11 f4 brne .+4 ; 0x1d56 + 4e: 82 34 cpi r24, 0x42 ; 66 + 50: 11 f4 brne .+4 ; 0x56 <__SREG__+0x17> // SET DEVICE is ignored getNch(20); - 1d52: 84 e1 ldi r24, 0x14 ; 20 - 1d54: 03 c0 rjmp .+6 ; 0x1d5c + 52: 84 e1 ldi r24, 0x14 ; 20 + 54: 03 c0 rjmp .+6 ; 0x5c <__SREG__+0x1d> } else if(ch == STK_SET_DEVICE_EXT) { - 1d56: 85 34 cpi r24, 0x45 ; 69 - 1d58: 19 f4 brne .+6 ; 0x1d60 + 56: 85 34 cpi r24, 0x45 ; 69 + 58: 19 f4 brne .+6 ; 0x60 <__SREG__+0x21> // SET DEVICE EXT is ignored getNch(5); - 1d5a: 85 e0 ldi r24, 0x05 ; 5 - 1d5c: 03 d1 rcall .+518 ; 0x1f64 - 1d5e: c8 c0 rjmp .+400 ; 0x1ef0 + 5a: 85 e0 ldi r24, 0x05 ; 5 + 5c: 03 d1 rcall .+518 ; 0x264 + 5e: c8 c0 rjmp .+400 ; 0x1f0 <__SREG__+0x1b1> } else if(ch == STK_LOAD_ADDRESS) { - 1d60: 85 35 cpi r24, 0x55 ; 85 - 1d62: 81 f4 brne .+32 ; 0x1d84 + 60: 85 35 cpi r24, 0x55 ; 85 + 62: 81 f4 brne .+32 ; 0x84 <__SREG__+0x45> // LOAD ADDRESS uint16_t newAddress; newAddress = getch(); - 1d64: d7 d0 rcall .+430 ; 0x1f14 + 64: d7 d0 rcall .+430 ; 0x214 newAddress = (newAddress & 0xff) | (getch() << 8); - 1d66: 08 2f mov r16, r24 - 1d68: 10 e0 ldi r17, 0x00 ; 0 - 1d6a: d4 d0 rcall .+424 ; 0x1f14 - 1d6c: 90 e0 ldi r25, 0x00 ; 0 - 1d6e: 98 2f mov r25, r24 - 1d70: 88 27 eor r24, r24 - 1d72: 80 2b or r24, r16 - 1d74: 91 2b or r25, r17 + 66: 08 2f mov r16, r24 + 68: 10 e0 ldi r17, 0x00 ; 0 + 6a: d4 d0 rcall .+424 ; 0x214 + 6c: 90 e0 ldi r25, 0x00 ; 0 + 6e: 98 2f mov r25, r24 + 70: 88 27 eor r24, r24 + 72: 80 2b or r24, r16 + 74: 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 - 1d76: 88 0f add r24, r24 - 1d78: 99 1f adc r25, r25 + 76: 88 0f add r24, r24 + 78: 99 1f adc r25, r25 address = newAddress; - 1d7a: 90 93 81 01 sts 0x0181, r25 - 1d7e: 80 93 80 01 sts 0x0180, r24 - 1d82: b5 c0 rjmp .+362 ; 0x1eee + 7a: 90 93 81 01 sts 0x0181, r25 + 7e: 80 93 80 01 sts 0x0180, r24 + 82: b5 c0 rjmp .+362 ; 0x1ee <__SREG__+0x1af> verifySpace(); } else if(ch == STK_UNIVERSAL) { - 1d84: 86 35 cpi r24, 0x56 ; 86 - 1d86: 29 f4 brne .+10 ; 0x1d92 + 84: 86 35 cpi r24, 0x56 ; 86 + 86: 29 f4 brne .+10 ; 0x92 <__SREG__+0x53> // UNIVERSAL command is ignored getNch(4); - 1d88: 84 e0 ldi r24, 0x04 ; 4 - 1d8a: ec d0 rcall .+472 ; 0x1f64 + 88: 84 e0 ldi r24, 0x04 ; 4 + 8a: ec d0 rcall .+472 ; 0x264 putch(0x00); - 1d8c: 80 e0 ldi r24, 0x00 ; 0 - 1d8e: b3 d0 rcall .+358 ; 0x1ef6 - 1d90: af c0 rjmp .+350 ; 0x1ef0 + 8c: 80 e0 ldi r24, 0x00 ; 0 + 8e: b3 d0 rcall .+358 ; 0x1f6 + 90: af c0 rjmp .+350 ; 0x1f0 <__SREG__+0x1b1> } /* Write memory, length is big endian and is in bytes */ else if(ch == STK_PROG_PAGE) { - 1d92: 84 36 cpi r24, 0x64 ; 100 - 1d94: 09 f0 breq .+2 ; 0x1d98 - 1d96: 6b c0 rjmp .+214 ; 0x1e6e + 92: 84 36 cpi r24, 0x64 ; 100 + 94: 09 f0 breq .+2 ; 0x98 <__SREG__+0x59> + 96: 6b c0 rjmp .+214 ; 0x16e <__SREG__+0x12f> // PROGRAM PAGE - we support flash programming only, not EEPROM uint8_t *bufPtr; uint16_t addrPtr; getLen(); - 1d98: d1 d0 rcall .+418 ; 0x1f3c - 1d9a: c0 e0 ldi r28, 0x00 ; 0 - 1d9c: d1 e0 ldi r29, 0x01 ; 1 + 98: d1 d0 rcall .+418 ; 0x23c + 9a: c0 e0 ldi r28, 0x00 ; 0 + 9c: d1 e0 ldi r29, 0x01 ; 1 // If we are in RWW section, immediately start page erase if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address); - + // While that is going on, read in page contents bufPtr = buff; do *bufPtr++ = getch(); - 1d9e: ba d0 rcall .+372 ; 0x1f14 - 1da0: 89 93 st Y+, r24 + 9e: ba d0 rcall .+372 ; 0x214 + a0: 89 93 st Y+, r24 while (--length); - 1da2: 80 91 82 01 lds r24, 0x0182 - 1da6: 81 50 subi r24, 0x01 ; 1 - 1da8: 80 93 82 01 sts 0x0182, r24 - 1dac: 88 23 and r24, r24 - 1dae: b9 f7 brne .-18 ; 0x1d9e + a2: 80 91 82 01 lds r24, 0x0182 + a6: 81 50 subi r24, 0x01 ; 1 + a8: 80 93 82 01 sts 0x0182, r24 + ac: 88 23 and r24, r24 + ae: b9 f7 brne .-18 ; 0x9e <__SREG__+0x5f> // 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); - 1db0: e0 91 80 01 lds r30, 0x0180 - 1db4: f0 91 81 01 lds r31, 0x0181 - 1db8: 83 e0 ldi r24, 0x03 ; 3 - 1dba: 87 bf out 0x37, r24 ; 55 - 1dbc: e8 95 spm + b0: e0 91 80 01 lds r30, 0x0180 + b4: f0 91 81 01 lds r31, 0x0181 + b8: 83 e0 ldi r24, 0x03 ; 3 + ba: 87 bf out 0x37, r24 ; 55 + bc: e8 95 spm // Read command terminator, start reply verifySpace(); - 1dbe: cc d0 rcall .+408 ; 0x1f58 - + be: cc d0 rcall .+408 ; 0x258 + // If only a partial page is to be programmed, the erase might not be complete. // So check that here boot_spm_busy_wait(); - 1dc0: 07 b6 in r0, 0x37 ; 55 - 1dc2: 00 fc sbrc r0, 0 - 1dc4: fd cf rjmp .-6 ; 0x1dc0 + c0: 07 b6 in r0, 0x37 ; 55 + c2: 00 fc sbrc r0, 0 + c4: fd cf rjmp .-6 ; 0xc0 <__SREG__+0x81> #ifdef VIRTUAL_BOOT_PARTITION if ((uint16_t)(void*)address == 0) { - 1dc6: 80 91 80 01 lds r24, 0x0180 - 1dca: 90 91 81 01 lds r25, 0x0181 - 1dce: 89 2b or r24, r25 - 1dd0: 41 f5 brne .+80 ; 0x1e22 + c6: 80 91 80 01 lds r24, 0x0180 + ca: 90 91 81 01 lds r25, 0x0181 + ce: 89 2b or r24, r25 + d0: 41 f5 brne .+80 ; 0x122 <__SREG__+0xe3> // This is the reset vector page. We need to live-patch the code so the // bootloader runs. // // Move RESET vector to WDT vector uint16_t vect = buff[0] | (buff[1]<<8); - 1dd2: 80 91 00 01 lds r24, 0x0100 - 1dd6: 20 91 01 01 lds r18, 0x0101 - 1dda: 30 e0 ldi r19, 0x00 ; 0 - 1ddc: 32 2f mov r19, r18 - 1dde: 22 27 eor r18, r18 - 1de0: 90 e0 ldi r25, 0x00 ; 0 - 1de2: 28 2b or r18, r24 - 1de4: 39 2b or r19, r25 + d2: 80 91 00 01 lds r24, 0x0100 + d6: 20 91 01 01 lds r18, 0x0101 + da: 30 e0 ldi r19, 0x00 ; 0 + dc: 32 2f mov r19, r18 + de: 22 27 eor r18, r18 + e0: 90 e0 ldi r25, 0x00 ; 0 + e2: 28 2b or r18, r24 + e4: 39 2b or r19, r25 rstVect = vect; - 1de6: 30 93 85 01 sts 0x0185, r19 - 1dea: 20 93 84 01 sts 0x0184, r18 + e6: 30 93 85 01 sts 0x0185, r19 + ea: 20 93 84 01 sts 0x0184, r18 wdtVect = buff[8] | (buff[9]<<8); - 1dee: 40 91 08 01 lds r20, 0x0108 - 1df2: 80 91 09 01 lds r24, 0x0109 - 1df6: 90 e0 ldi r25, 0x00 ; 0 - 1df8: 98 2f mov r25, r24 - 1dfa: 88 27 eor r24, r24 - 1dfc: 50 e0 ldi r21, 0x00 ; 0 - 1dfe: 84 2b or r24, r20 - 1e00: 95 2b or r25, r21 - 1e02: 90 93 87 01 sts 0x0187, r25 - 1e06: 80 93 86 01 sts 0x0186, r24 + ee: 40 91 08 01 lds r20, 0x0108 + f2: 80 91 09 01 lds r24, 0x0109 + f6: 90 e0 ldi r25, 0x00 ; 0 + f8: 98 2f mov r25, r24 + fa: 88 27 eor r24, r24 + fc: 50 e0 ldi r21, 0x00 ; 0 + fe: 84 2b or r24, r20 + 100: 95 2b or r25, r21 + 102: 90 93 87 01 sts 0x0187, r25 + 106: 80 93 86 01 sts 0x0186, r24 vect -= 4; // Instruction is a relative jump (rjmp), so recalculate. - 1e0a: 24 50 subi r18, 0x04 ; 4 - 1e0c: 30 40 sbci r19, 0x00 ; 0 + 10a: 24 50 subi r18, 0x04 ; 4 + 10c: 30 40 sbci r19, 0x00 ; 0 buff[8] = vect & 0xff; - 1e0e: 20 93 08 01 sts 0x0108, r18 + 10e: 20 93 08 01 sts 0x0108, r18 buff[9] = vect >> 8; - 1e12: 23 2f mov r18, r19 - 1e14: 33 27 eor r19, r19 - 1e16: 20 93 09 01 sts 0x0109, r18 + 112: 23 2f mov r18, r19 + 114: 33 27 eor r19, r19 + 116: 20 93 09 01 sts 0x0109, r18 // Add jump to bootloader at RESET vector buff[0] = 0x7f; - 1e1a: f0 92 00 01 sts 0x0100, r15 + 11a: f0 92 00 01 sts 0x0100, r15 buff[1] = 0xce; // rjmp 0x1d00 instruction - 1e1e: e0 92 01 01 sts 0x0101, r14 + 11e: e0 92 01 01 sts 0x0101, r14 } #endif // Copy buffer into programming buffer bufPtr = buff; addrPtr = (uint16_t)(void*)address; - 1e22: 40 91 80 01 lds r20, 0x0180 - 1e26: 50 91 81 01 lds r21, 0x0181 - 1e2a: a0 e0 ldi r26, 0x00 ; 0 - 1e2c: b1 e0 ldi r27, 0x01 ; 1 + 122: 40 91 80 01 lds r20, 0x0180 + 126: 50 91 81 01 lds r21, 0x0181 + 12a: a0 e0 ldi r26, 0x00 ; 0 + 12c: b1 e0 ldi r27, 0x01 ; 1 ch = SPM_PAGESIZE / 2; do { uint16_t a; a = *bufPtr++; - 1e2e: 2c 91 ld r18, X - 1e30: 30 e0 ldi r19, 0x00 ; 0 + 12e: 2c 91 ld r18, X + 130: 30 e0 ldi r19, 0x00 ; 0 a |= (*bufPtr++) << 8; - 1e32: 11 96 adiw r26, 0x01 ; 1 - 1e34: 8c 91 ld r24, X - 1e36: 11 97 sbiw r26, 0x01 ; 1 - 1e38: 90 e0 ldi r25, 0x00 ; 0 - 1e3a: 98 2f mov r25, r24 - 1e3c: 88 27 eor r24, r24 - 1e3e: 82 2b or r24, r18 - 1e40: 93 2b or r25, r19 + 132: 11 96 adiw r26, 0x01 ; 1 + 134: 8c 91 ld r24, X + 136: 11 97 sbiw r26, 0x01 ; 1 + 138: 90 e0 ldi r25, 0x00 ; 0 + 13a: 98 2f mov r25, r24 + 13c: 88 27 eor r24, r24 + 13e: 82 2b or r24, r18 + 140: 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) { - 1e42: 12 96 adiw r26, 0x02 ; 2 + 142: 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); - 1e44: fa 01 movw r30, r20 - 1e46: 0c 01 movw r0, r24 - 1e48: d7 be out 0x37, r13 ; 55 - 1e4a: e8 95 spm - 1e4c: 11 24 eor r1, r1 + 144: fa 01 movw r30, r20 + 146: 0c 01 movw r0, r24 + 148: d7 be out 0x37, r13 ; 55 + 14a: e8 95 spm + 14c: 11 24 eor r1, r1 addrPtr += 2; - 1e4e: 4e 5f subi r20, 0xFE ; 254 - 1e50: 5f 4f sbci r21, 0xFF ; 255 + 14e: 4e 5f subi r20, 0xFE ; 254 + 150: 5f 4f sbci r21, 0xFF ; 255 } while (--ch); - 1e52: f1 e0 ldi r31, 0x01 ; 1 - 1e54: a0 34 cpi r26, 0x40 ; 64 - 1e56: bf 07 cpc r27, r31 - 1e58: 51 f7 brne .-44 ; 0x1e2e - + 152: f1 e0 ldi r31, 0x01 ; 1 + 154: a0 34 cpi r26, 0x40 ; 64 + 156: bf 07 cpc r27, r31 + 158: 51 f7 brne .-44 ; 0x12e <__SREG__+0xef> + // Write from programming buffer __boot_page_write_short((uint16_t)(void*)address); - 1e5a: e0 91 80 01 lds r30, 0x0180 - 1e5e: f0 91 81 01 lds r31, 0x0181 - 1e62: c7 be out 0x37, r12 ; 55 - 1e64: e8 95 spm + 15a: e0 91 80 01 lds r30, 0x0180 + 15e: f0 91 81 01 lds r31, 0x0181 + 162: c7 be out 0x37, r12 ; 55 + 164: e8 95 spm boot_spm_busy_wait(); - 1e66: 07 b6 in r0, 0x37 ; 55 - 1e68: 00 fc sbrc r0, 0 - 1e6a: fd cf rjmp .-6 ; 0x1e66 - 1e6c: 41 c0 rjmp .+130 ; 0x1ef0 + 166: 07 b6 in r0, 0x37 ; 55 + 168: 00 fc sbrc r0, 0 + 16a: fd cf rjmp .-6 ; 0x166 <__SREG__+0x127> + 16c: 41 c0 rjmp .+130 ; 0x1f0 <__SREG__+0x1b1> boot_rww_enable(); #endif } /* Read memory block mode, length is big endian. */ else if(ch == STK_READ_PAGE) { - 1e6e: 84 37 cpi r24, 0x74 ; 116 - 1e70: 89 f5 brne .+98 ; 0x1ed4 + 16e: 84 37 cpi r24, 0x74 ; 116 + 170: 89 f5 brne .+98 ; 0x1d4 <__SREG__+0x195> // READ PAGE - we only read flash getLen(); - 1e72: 64 d0 rcall .+200 ; 0x1f3c + 172: 64 d0 rcall .+200 ; 0x23c verifySpace(); - 1e74: 71 d0 rcall .+226 ; 0x1f58 + 174: 71 d0 rcall .+226 ; 0x258 #ifdef VIRTUAL_BOOT_PARTITION do { // Undo vector patch in bottom page so verify passes if (address == 0) ch=rstVect & 0xff; - 1e76: e0 91 80 01 lds r30, 0x0180 - 1e7a: f0 91 81 01 lds r31, 0x0181 - 1e7e: 30 97 sbiw r30, 0x00 ; 0 - 1e80: 19 f4 brne .+6 ; 0x1e88 - 1e82: 20 91 84 01 lds r18, 0x0184 - 1e86: 13 c0 rjmp .+38 ; 0x1eae + 176: e0 91 80 01 lds r30, 0x0180 + 17a: f0 91 81 01 lds r31, 0x0181 + 17e: 30 97 sbiw r30, 0x00 ; 0 + 180: 19 f4 brne .+6 ; 0x188 <__SREG__+0x149> + 182: 20 91 84 01 lds r18, 0x0184 + 186: 13 c0 rjmp .+38 ; 0x1ae <__SREG__+0x16f> else if (address == 1) ch=rstVect >> 8; - 1e88: e1 30 cpi r30, 0x01 ; 1 - 1e8a: f1 05 cpc r31, r1 - 1e8c: 19 f4 brne .+6 ; 0x1e94 - 1e8e: 20 91 85 01 lds r18, 0x0185 - 1e92: 0d c0 rjmp .+26 ; 0x1eae + 188: e1 30 cpi r30, 0x01 ; 1 + 18a: f1 05 cpc r31, r1 + 18c: 19 f4 brne .+6 ; 0x194 <__SREG__+0x155> + 18e: 20 91 85 01 lds r18, 0x0185 + 192: 0d c0 rjmp .+26 ; 0x1ae <__SREG__+0x16f> else if (address == 8) ch=wdtVect & 0xff; - 1e94: e8 30 cpi r30, 0x08 ; 8 - 1e96: f1 05 cpc r31, r1 - 1e98: 19 f4 brne .+6 ; 0x1ea0 - 1e9a: 20 91 86 01 lds r18, 0x0186 - 1e9e: 07 c0 rjmp .+14 ; 0x1eae + 194: e8 30 cpi r30, 0x08 ; 8 + 196: f1 05 cpc r31, r1 + 198: 19 f4 brne .+6 ; 0x1a0 <__SREG__+0x161> + 19a: 20 91 86 01 lds r18, 0x0186 + 19e: 07 c0 rjmp .+14 ; 0x1ae <__SREG__+0x16f> else if (address == 9) ch=wdtVect >> 8; - 1ea0: e9 30 cpi r30, 0x09 ; 9 - 1ea2: f1 05 cpc r31, r1 - 1ea4: 19 f4 brne .+6 ; 0x1eac - 1ea6: 20 91 87 01 lds r18, 0x0187 - 1eaa: 01 c0 rjmp .+2 ; 0x1eae + 1a0: e9 30 cpi r30, 0x09 ; 9 + 1a2: f1 05 cpc r31, r1 + 1a4: 19 f4 brne .+6 ; 0x1ac <__SREG__+0x16d> + 1a6: 20 91 87 01 lds r18, 0x0187 + 1aa: 01 c0 rjmp .+2 ; 0x1ae <__SREG__+0x16f> else ch = pgm_read_byte_near(address); - 1eac: 24 91 lpm r18, Z+ + 1ac: 24 91 lpm r18, Z+ address++; - 1eae: 80 91 80 01 lds r24, 0x0180 - 1eb2: 90 91 81 01 lds r25, 0x0181 - 1eb6: 01 96 adiw r24, 0x01 ; 1 - 1eb8: 90 93 81 01 sts 0x0181, r25 - 1ebc: 80 93 80 01 sts 0x0180, r24 + 1ae: 80 91 80 01 lds r24, 0x0180 + 1b2: 90 91 81 01 lds r25, 0x0181 + 1b6: 01 96 adiw r24, 0x01 ; 1 + 1b8: 90 93 81 01 sts 0x0181, r25 + 1bc: 80 93 80 01 sts 0x0180, r24 putch(ch); - 1ec0: 82 2f mov r24, r18 - 1ec2: 19 d0 rcall .+50 ; 0x1ef6 + 1c0: 82 2f mov r24, r18 + 1c2: 19 d0 rcall .+50 ; 0x1f6 } while (--length); - 1ec4: 80 91 82 01 lds r24, 0x0182 - 1ec8: 81 50 subi r24, 0x01 ; 1 - 1eca: 80 93 82 01 sts 0x0182, r24 - 1ece: 88 23 and r24, r24 - 1ed0: 91 f6 brne .-92 ; 0x1e76 - 1ed2: 0e c0 rjmp .+28 ; 0x1ef0 + 1c4: 80 91 82 01 lds r24, 0x0182 + 1c8: 81 50 subi r24, 0x01 ; 1 + 1ca: 80 93 82 01 sts 0x0182, r24 + 1ce: 88 23 and r24, r24 + 1d0: 91 f6 brne .-92 ; 0x176 <__SREG__+0x137> + 1d2: 0e c0 rjmp .+28 ; 0x1f0 <__SREG__+0x1b1> #endif #endif } /* Get device signature bytes */ else if(ch == STK_READ_SIGN) { - 1ed4: 85 37 cpi r24, 0x75 ; 117 - 1ed6: 39 f4 brne .+14 ; 0x1ee6 + 1d4: 85 37 cpi r24, 0x75 ; 117 + 1d6: 39 f4 brne .+14 ; 0x1e6 <__SREG__+0x1a7> // READ SIGN - return what Avrdude wants to hear verifySpace(); - 1ed8: 3f d0 rcall .+126 ; 0x1f58 + 1d8: 3f d0 rcall .+126 ; 0x258 putch(SIGNATURE_0); - 1eda: 8e e1 ldi r24, 0x1E ; 30 - 1edc: 0c d0 rcall .+24 ; 0x1ef6 + 1da: 8e e1 ldi r24, 0x1E ; 30 + 1dc: 0c d0 rcall .+24 ; 0x1f6 putch(SIGNATURE_1); - 1ede: 83 e9 ldi r24, 0x93 ; 147 - 1ee0: 0a d0 rcall .+20 ; 0x1ef6 + 1de: 83 e9 ldi r24, 0x93 ; 147 + 1e0: 0a d0 rcall .+20 ; 0x1f6 putch(SIGNATURE_2); - 1ee2: 8c e0 ldi r24, 0x0C ; 12 - 1ee4: 54 cf rjmp .-344 ; 0x1d8e + 1e2: 8c e0 ldi r24, 0x0C ; 12 + 1e4: 54 cf rjmp .-344 ; 0x8e <__SREG__+0x4f> } else if (ch == 'Q') { - 1ee6: 81 35 cpi r24, 0x51 ; 81 - 1ee8: 11 f4 brne .+4 ; 0x1eee + 1e6: 81 35 cpi r24, 0x51 ; 81 + 1e8: 11 f4 brne .+4 ; 0x1ee <__SREG__+0x1af> // Adaboot no-wait mod watchdogConfig(WATCHDOG_16MS); - 1eea: 88 e0 ldi r24, 0x08 ; 8 - 1eec: 2c d0 rcall .+88 ; 0x1f46 + 1ea: 88 e0 ldi r24, 0x08 ; 8 + 1ec: 2c d0 rcall .+88 ; 0x246 verifySpace(); } else { // This covers the response to commands like STK_ENTER_PROGMODE verifySpace(); - 1eee: 34 d0 rcall .+104 ; 0x1f58 + 1ee: 34 d0 rcall .+104 ; 0x258 } putch(STK_OK); - 1ef0: 80 e1 ldi r24, 0x10 ; 16 - 1ef2: 01 d0 rcall .+2 ; 0x1ef6 - 1ef4: 25 cf rjmp .-438 ; 0x1d40 + 1f0: 80 e1 ldi r24, 0x10 ; 16 + 1f2: 01 d0 rcall .+2 ; 0x1f6 + 1f4: 25 cf rjmp .-438 ; 0x40 <__SREG__+0x1> -00001ef6 : +000001f6 : void putch(char ch) { #ifndef SOFT_UART while (!(UCSR0A & _BV(UDRE0))); UDR0 = ch; #else __asm__ __volatile__ ( - 1ef6: 2a e0 ldi r18, 0x0A ; 10 - 1ef8: 30 e0 ldi r19, 0x00 ; 0 - 1efa: 80 95 com r24 - 1efc: 08 94 sec - 1efe: 10 f4 brcc .+4 ; 0x1f04 - 1f00: da 98 cbi 0x1b, 2 ; 27 - 1f02: 02 c0 rjmp .+4 ; 0x1f08 - 1f04: da 9a sbi 0x1b, 2 ; 27 - 1f06: 00 00 nop - 1f08: 15 d0 rcall .+42 ; 0x1f34 - 1f0a: 14 d0 rcall .+40 ; 0x1f34 - 1f0c: 86 95 lsr r24 - 1f0e: 2a 95 dec r18 - 1f10: b1 f7 brne .-20 ; 0x1efe + 1f6: 2a e0 ldi r18, 0x0A ; 10 + 1f8: 30 e0 ldi r19, 0x00 ; 0 + 1fa: 80 95 com r24 + 1fc: 08 94 sec + 1fe: 10 f4 brcc .+4 ; 0x204 + 200: da 98 cbi 0x1b, 2 ; 27 + 202: 02 c0 rjmp .+4 ; 0x208 + 204: da 9a sbi 0x1b, 2 ; 27 + 206: 00 00 nop + 208: 15 d0 rcall .+42 ; 0x234 + 20a: 14 d0 rcall .+40 ; 0x234 + 20c: 86 95 lsr r24 + 20e: 2a 95 dec r18 + 210: b1 f7 brne .-20 ; 0x1fe [uartBit] "I" (UART_TX_BIT) : "r25" ); #endif } - 1f12: 08 95 ret + 212: 08 95 ret -00001f14 : +00000214 : return getch(); } // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( - 1f14: a8 95 wdr + 214: a8 95 wdr LED_PIN |= _BV(LED); #endif #endif return ch; } - 1f16: 29 e0 ldi r18, 0x09 ; 9 - 1f18: 30 e0 ldi r19, 0x00 ; 0 - 1f1a: cb 99 sbic 0x19, 3 ; 25 - 1f1c: fe cf rjmp .-4 ; 0x1f1a - 1f1e: 0a d0 rcall .+20 ; 0x1f34 - 1f20: 09 d0 rcall .+18 ; 0x1f34 - 1f22: 08 d0 rcall .+16 ; 0x1f34 - 1f24: 88 94 clc - 1f26: cb 99 sbic 0x19, 3 ; 25 - 1f28: 08 94 sec - 1f2a: 2a 95 dec r18 - 1f2c: 11 f0 breq .+4 ; 0x1f32 - 1f2e: 87 95 ror r24 - 1f30: f7 cf rjmp .-18 ; 0x1f20 - 1f32: 08 95 ret - -00001f34 : + 216: 29 e0 ldi r18, 0x09 ; 9 + 218: 30 e0 ldi r19, 0x00 ; 0 + 21a: cb 99 sbic 0x19, 3 ; 25 + 21c: fe cf rjmp .-4 ; 0x21a + 21e: 0a d0 rcall .+20 ; 0x234 + 220: 09 d0 rcall .+18 ; 0x234 + 222: 08 d0 rcall .+16 ; 0x234 + 224: 88 94 clc + 226: cb 99 sbic 0x19, 3 ; 25 + 228: 08 94 sec + 22a: 2a 95 dec r18 + 22c: 11 f0 breq .+4 ; 0x232 + 22e: 87 95 ror r24 + 230: f7 cf rjmp .-18 ; 0x220 + 232: 08 95 ret + +00000234 : #if UART_B_VALUE > 255 #error Baud rate too slow for soft UART #endif void uartDelay() { __asm__ __volatile__ ( - 1f34: 9e e0 ldi r25, 0x0E ; 14 - 1f36: 9a 95 dec r25 - 1f38: f1 f7 brne .-4 ; 0x1f36 - 1f3a: 08 95 ret + 234: 9e e0 ldi r25, 0x0E ; 14 + 236: 9a 95 dec r25 + 238: f1 f7 brne .-4 ; 0x236 + 23a: 08 95 ret -00001f3c : +0000023c : } while (--count); } #endif uint8_t getLen() { getch(); - 1f3c: eb df rcall .-42 ; 0x1f14 + 23c: eb df rcall .-42 ; 0x214 length = getch(); - 1f3e: ea df rcall .-44 ; 0x1f14 - 1f40: 80 93 82 01 sts 0x0182, r24 + 23e: ea df rcall .-44 ; 0x214 + 240: 80 93 82 01 sts 0x0182, r24 return getch(); } - 1f44: e7 cf rjmp .-50 ; 0x1f14 + 244: e7 cf rjmp .-50 ; 0x214 -00001f46 : +00000246 : "wdr\n" ); } void watchdogConfig(uint8_t x) { WDTCSR = _BV(WDCE) | _BV(WDE); - 1f46: 98 e1 ldi r25, 0x18 ; 24 - 1f48: 91 bd out 0x21, r25 ; 33 + 246: 98 e1 ldi r25, 0x18 ; 24 + 248: 91 bd out 0x21, r25 ; 33 WDTCSR = x; - 1f4a: 81 bd out 0x21, r24 ; 33 + 24a: 81 bd out 0x21, r24 ; 33 } - 1f4c: 08 95 ret + 24c: 08 95 ret -00001f4e : +0000024e : void appStart() { watchdogConfig(WATCHDOG_OFF); - 1f4e: 80 e0 ldi r24, 0x00 ; 0 - 1f50: fa df rcall .-12 ; 0x1f46 + 24e: 80 e0 ldi r24, 0x00 ; 0 + 250: fa df rcall .-12 ; 0x246 __asm__ __volatile__ ( - 1f52: e4 e0 ldi r30, 0x04 ; 4 - 1f54: ff 27 eor r31, r31 - 1f56: 09 94 ijmp + 252: e4 e0 ldi r30, 0x04 ; 4 + 254: ff 27 eor r31, r31 + 256: 09 94 ijmp -00001f58 : +00000258 : do getch(); while (--count); verifySpace(); } void verifySpace() { if (getch() != CRC_EOP) appStart(); - 1f58: dd df rcall .-70 ; 0x1f14 - 1f5a: 80 32 cpi r24, 0x20 ; 32 - 1f5c: 09 f0 breq .+2 ; 0x1f60 - 1f5e: f7 df rcall .-18 ; 0x1f4e + 258: dd df rcall .-70 ; 0x214 + 25a: 80 32 cpi r24, 0x20 ; 32 + 25c: 09 f0 breq .+2 ; 0x260 + 25e: f7 df rcall .-18 ; 0x24e putch(STK_INSYNC); - 1f60: 84 e1 ldi r24, 0x14 ; 20 + 260: 84 e1 ldi r24, 0x14 ; 20 } - 1f62: c9 cf rjmp .-110 ; 0x1ef6 + 262: c9 cf rjmp .-110 ; 0x1f6 -00001f64 : +00000264 : ::[count] "M" (UART_B_VALUE) ); } #endif void getNch(uint8_t count) { - 1f64: 1f 93 push r17 - 1f66: 18 2f mov r17, r24 + 264: 1f 93 push r17 + 266: 18 2f mov r17, r24 do getch(); while (--count); - 1f68: d5 df rcall .-86 ; 0x1f14 - 1f6a: 11 50 subi r17, 0x01 ; 1 - 1f6c: e9 f7 brne .-6 ; 0x1f68 + 268: d5 df rcall .-86 ; 0x214 + 26a: 11 50 subi r17, 0x01 ; 1 + 26c: e9 f7 brne .-6 ; 0x268 verifySpace(); - 1f6e: f4 df rcall .-24 ; 0x1f58 + 26e: f4 df rcall .-24 ; 0x258 } - 1f70: 1f 91 pop r17 - 1f72: 08 95 ret + 270: 1f 91 pop r17 + 272: 08 95 ret -- 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_luminet.lst | 574 +++++++++++++++--------------- 1 file changed, 287 insertions(+), 287 deletions(-) (limited to 'bootloaders/optiboot/optiboot_luminet.lst') diff --git a/bootloaders/optiboot/optiboot_luminet.lst b/bootloaders/optiboot/optiboot_luminet.lst index 1be7e4f..8333670 100644 --- a/bootloaders/optiboot/optiboot_luminet.lst +++ b/bootloaders/optiboot/optiboot_luminet.lst @@ -3,27 +3,27 @@ optiboot_luminet.elf: file format elf32-avr Sections: Idx Name Size VMA LMA File off Algn - 0 .version 00000002 00001efe 00001efe 000002c8 2**0 + 0 .version 00000002 00001efe 00001efe 00000298 2**0 CONTENTS, READONLY - 1 .text 00000274 00000000 00000000 00000054 2**1 + 1 .text 00000244 00000000 00000000 00000054 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE - 2 .debug_aranges 00000028 00000000 00000000 000002ca 2**0 + 2 .debug_aranges 00000028 00000000 00000000 0000029a 2**0 CONTENTS, READONLY, DEBUGGING - 3 .debug_pubnames 00000078 00000000 00000000 000002f2 2**0 + 3 .debug_pubnames 0000006d 00000000 00000000 000002c2 2**0 CONTENTS, READONLY, DEBUGGING - 4 .debug_info 000002a5 00000000 00000000 0000036a 2**0 + 4 .debug_info 000002b0 00000000 00000000 0000032f 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_abbrev 0000019d 00000000 00000000 0000060f 2**0 + 5 .debug_abbrev 00000197 00000000 00000000 000005df 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_line 000004ac 00000000 00000000 000007ac 2**0 + 6 .debug_line 000004a7 00000000 00000000 00000776 2**0 CONTENTS, READONLY, DEBUGGING - 7 .debug_frame 000000a0 00000000 00000000 00000c58 2**2 + 7 .debug_frame 00000090 00000000 00000000 00000c20 2**2 CONTENTS, READONLY, DEBUGGING - 8 .debug_str 00000150 00000000 00000000 00000cf8 2**0 + 8 .debug_str 00000158 00000000 00000000 00000cb0 2**0 CONTENTS, READONLY, DEBUGGING - 9 .debug_loc 00000194 00000000 00000000 00000e48 2**0 + 9 .debug_loc 00000268 00000000 00000000 00000e08 2**0 CONTENTS, READONLY, DEBUGGING - 10 .debug_ranges 00000088 00000000 00000000 00000fdc 2**0 + 10 .debug_ranges 00000080 00000000 00000000 00001070 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: @@ -47,7 +47,7 @@ int main(void) { 4: 14 be out 0x34, r1 ; 52 if (!(ch & _BV(EXTRF))) appStart(); 6: 81 ff sbrs r24, 1 - 8: 22 d1 rcall .+580 ; 0x24e + 8: 18 d1 rcall .+560 ; 0x23a #if LED_START_FLASHES > 0 // Set up Timer 1 for timeout counter @@ -61,7 +61,7 @@ int main(void) { // Set up watchdog to trigger after 500ms watchdogConfig(WATCHDOG_1S); e: 8e e0 ldi r24, 0x0E ; 14 - 10: 1a d1 rcall .+564 ; 0x246 + 10: 00 d1 rcall .+512 ; 0x212 /* Set LED pin as output */ LED_DDR |= _BV(LED); @@ -100,8 +100,8 @@ void flash_led(uint8_t count) { #else LED_PIN |= _BV(LED); 28: cc 9a sbi 0x19, 4 ; 25 - return getch(); } +#endif // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { @@ -121,34 +121,34 @@ void watchdogReset() { if(ch == STK_GET_PARAMETER) { // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy getNch(1); - 30: dd 24 eor r13, r13 - 32: d3 94 inc r13 + 30: bb 24 eor r11, r11 + 32: b3 94 inc r11 __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); - 34: 85 e0 ldi r24, 0x05 ; 5 - 36: c8 2e mov r12, r24 + 34: 25 e0 ldi r18, 0x05 ; 5 + 36: a2 2e mov r10, r18 vect -= 4; // Instruction is a relative jump (rjmp), so recalculate. buff[8] = vect & 0xff; buff[9] = vect >> 8; // Add jump to bootloader at RESET vector buff[0] = 0x7f; - 38: 0f e7 ldi r16, 0x7F ; 127 - 3a: f0 2e mov r15, r16 + 38: 9f e7 ldi r25, 0x7F ; 127 + 3a: d9 2e mov r13, r25 buff[1] = 0xce; // rjmp 0x1d00 instruction - 3c: 1e ec ldi r17, 0xCE ; 206 - 3e: e1 2e mov r14, r17 + 3c: 8e ec ldi r24, 0xCE ; 206 + 3e: c8 2e mov r12, r24 #endif /* Forever loop */ for (;;) { /* get character from UART */ ch = getch(); - 40: e9 d0 rcall .+466 ; 0x214 + 40: d4 d0 rcall .+424 ; 0x1ea if(ch == STK_GET_PARAMETER) { 42: 81 34 cpi r24, 0x41 ; 65 @@ -156,10 +156,10 @@ void watchdogReset() { // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy getNch(1); 46: 81 e0 ldi r24, 0x01 ; 1 - 48: 0d d1 rcall .+538 ; 0x264 + 48: f0 d0 rcall .+480 ; 0x22a putch(0x03); 4a: 83 e0 ldi r24, 0x03 ; 3 - 4c: 20 c0 rjmp .+64 ; 0x8e <__SREG__+0x4f> + 4c: b5 c0 rjmp .+362 ; 0x1b8 <__SREG__+0x179> } else if(ch == STK_SET_DEVICE) { 4e: 82 34 cpi r24, 0x42 ; 66 @@ -175,450 +175,450 @@ void watchdogReset() { // SET DEVICE EXT is ignored getNch(5); 5a: 85 e0 ldi r24, 0x05 ; 5 - 5c: 03 d1 rcall .+518 ; 0x264 - 5e: c8 c0 rjmp .+400 ; 0x1f0 <__SREG__+0x1b1> + 5c: e6 d0 rcall .+460 ; 0x22a + 5e: b3 c0 rjmp .+358 ; 0x1c6 <__SREG__+0x187> } else if(ch == STK_LOAD_ADDRESS) { 60: 85 35 cpi r24, 0x55 ; 85 - 62: 81 f4 brne .+32 ; 0x84 <__SREG__+0x45> + 62: 69 f4 brne .+26 ; 0x7e <__SREG__+0x3f> // LOAD ADDRESS uint16_t newAddress; newAddress = getch(); - 64: d7 d0 rcall .+430 ; 0x214 + 64: c2 d0 rcall .+388 ; 0x1ea newAddress = (newAddress & 0xff) | (getch() << 8); - 66: 08 2f mov r16, r24 - 68: 10 e0 ldi r17, 0x00 ; 0 - 6a: d4 d0 rcall .+424 ; 0x214 - 6c: 90 e0 ldi r25, 0x00 ; 0 - 6e: 98 2f mov r25, r24 - 70: 88 27 eor r24, r24 - 72: 80 2b or r24, r16 - 74: 91 2b or r25, r17 + 66: e8 2e mov r14, r24 + 68: ff 24 eor r15, r15 + 6a: bf d0 rcall .+382 ; 0x1ea + 6c: 08 2f mov r16, r24 + 6e: 10 e0 ldi r17, 0x00 ; 0 + 70: 10 2f mov r17, r16 + 72: 00 27 eor r16, r16 + 74: 0e 29 or r16, r14 + 76: 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 - 76: 88 0f add r24, r24 - 78: 99 1f adc r25, r25 + 78: 00 0f add r16, r16 + 7a: 11 1f adc r17, r17 + 7c: a3 c0 rjmp .+326 ; 0x1c4 <__SREG__+0x185> address = newAddress; - 7a: 90 93 81 01 sts 0x0181, r25 - 7e: 80 93 80 01 sts 0x0180, r24 - 82: b5 c0 rjmp .+362 ; 0x1ee <__SREG__+0x1af> verifySpace(); } else if(ch == STK_UNIVERSAL) { - 84: 86 35 cpi r24, 0x56 ; 86 - 86: 29 f4 brne .+10 ; 0x92 <__SREG__+0x53> + 7e: 86 35 cpi r24, 0x56 ; 86 + 80: 21 f4 brne .+8 ; 0x8a <__SREG__+0x4b> // UNIVERSAL command is ignored getNch(4); - 88: 84 e0 ldi r24, 0x04 ; 4 - 8a: ec d0 rcall .+472 ; 0x264 + 82: 84 e0 ldi r24, 0x04 ; 4 + 84: d2 d0 rcall .+420 ; 0x22a putch(0x00); - 8c: 80 e0 ldi r24, 0x00 ; 0 - 8e: b3 d0 rcall .+358 ; 0x1f6 - 90: af c0 rjmp .+350 ; 0x1f0 <__SREG__+0x1b1> + 86: 80 e0 ldi r24, 0x00 ; 0 + 88: 97 c0 rjmp .+302 ; 0x1b8 <__SREG__+0x179> } /* Write memory, length is big endian and is in bytes */ else if(ch == STK_PROG_PAGE) { - 92: 84 36 cpi r24, 0x64 ; 100 - 94: 09 f0 breq .+2 ; 0x98 <__SREG__+0x59> - 96: 6b c0 rjmp .+214 ; 0x16e <__SREG__+0x12f> + 8a: 84 36 cpi r24, 0x64 ; 100 + 8c: 09 f0 breq .+2 ; 0x90 <__SREG__+0x51> + 8e: 60 c0 rjmp .+192 ; 0x150 <__SREG__+0x111> // PROGRAM PAGE - we support flash programming only, not EEPROM uint8_t *bufPtr; uint16_t addrPtr; - getLen(); - 98: d1 d0 rcall .+418 ; 0x23c - 9a: c0 e0 ldi r28, 0x00 ; 0 - 9c: d1 e0 ldi r29, 0x01 ; 1 + getch(); /* getlen() */ + 90: ac d0 rcall .+344 ; 0x1ea + length = getch(); + 92: ab d0 rcall .+342 ; 0x1ea + 94: f8 2e mov r15, r24 + getch(); + 96: a9 d0 rcall .+338 ; 0x1ea + 98: c0 e0 ldi r28, 0x00 ; 0 + 9a: d1 e0 ldi r29, 0x01 ; 1 // If we are in RWW section, immediately start page erase if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address); // While that is going on, read in page contents bufPtr = buff; do *bufPtr++ = getch(); - 9e: ba d0 rcall .+372 ; 0x214 - a0: 89 93 st Y+, r24 + 9c: a6 d0 rcall .+332 ; 0x1ea + 9e: 89 93 st Y+, r24 while (--length); - a2: 80 91 82 01 lds r24, 0x0182 - a6: 81 50 subi r24, 0x01 ; 1 - a8: 80 93 82 01 sts 0x0182, r24 - ac: 88 23 and r24, r24 - ae: b9 f7 brne .-18 ; 0x9e <__SREG__+0x5f> + a0: fc 16 cp r15, r28 + a2: e1 f7 brne .-8 ; 0x9c <__SREG__+0x5d> // 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); - b0: e0 91 80 01 lds r30, 0x0180 - b4: f0 91 81 01 lds r31, 0x0181 - b8: 83 e0 ldi r24, 0x03 ; 3 - ba: 87 bf out 0x37, r24 ; 55 - bc: e8 95 spm + a4: 83 e0 ldi r24, 0x03 ; 3 + a6: f8 01 movw r30, r16 + a8: 87 bf out 0x37, r24 ; 55 + aa: e8 95 spm // Read command terminator, start reply verifySpace(); - be: cc d0 rcall .+408 ; 0x258 + ac: b6 d0 rcall .+364 ; 0x21a // If only a partial page is to be programmed, the erase might not be complete. // So check that here boot_spm_busy_wait(); - c0: 07 b6 in r0, 0x37 ; 55 - c2: 00 fc sbrc r0, 0 - c4: fd cf rjmp .-6 ; 0xc0 <__SREG__+0x81> + ae: 07 b6 in r0, 0x37 ; 55 + b0: 00 fc sbrc r0, 0 + b2: fd cf rjmp .-6 ; 0xae <__SREG__+0x6f> #ifdef VIRTUAL_BOOT_PARTITION if ((uint16_t)(void*)address == 0) { - c6: 80 91 80 01 lds r24, 0x0180 - ca: 90 91 81 01 lds r25, 0x0181 - ce: 89 2b or r24, r25 - d0: 41 f5 brne .+80 ; 0x122 <__SREG__+0xe3> + b4: 01 15 cp r16, r1 + b6: 11 05 cpc r17, r1 + b8: 11 f0 breq .+4 ; 0xbe <__SREG__+0x7f> + ba: a8 01 movw r20, r16 + bc: 2a c0 rjmp .+84 ; 0x112 <__SREG__+0xd3> // This is the reset vector page. We need to live-patch the code so the // bootloader runs. // // Move RESET vector to WDT vector uint16_t vect = buff[0] | (buff[1]<<8); - d2: 80 91 00 01 lds r24, 0x0100 - d6: 20 91 01 01 lds r18, 0x0101 - da: 30 e0 ldi r19, 0x00 ; 0 - dc: 32 2f mov r19, r18 - de: 22 27 eor r18, r18 - e0: 90 e0 ldi r25, 0x00 ; 0 - e2: 28 2b or r18, r24 - e4: 39 2b or r19, r25 + be: 80 91 00 01 lds r24, 0x0100 + c2: 20 91 01 01 lds r18, 0x0101 + c6: 30 e0 ldi r19, 0x00 ; 0 + c8: 32 2f mov r19, r18 + ca: 22 27 eor r18, r18 + cc: 90 e0 ldi r25, 0x00 ; 0 + ce: 28 2b or r18, r24 + d0: 39 2b or r19, r25 rstVect = vect; - e6: 30 93 85 01 sts 0x0185, r19 - ea: 20 93 84 01 sts 0x0184, r18 + d2: 30 93 85 01 sts 0x0185, r19 + d6: 20 93 84 01 sts 0x0184, r18 wdtVect = buff[8] | (buff[9]<<8); - ee: 40 91 08 01 lds r20, 0x0108 - f2: 80 91 09 01 lds r24, 0x0109 - f6: 90 e0 ldi r25, 0x00 ; 0 - f8: 98 2f mov r25, r24 - fa: 88 27 eor r24, r24 - fc: 50 e0 ldi r21, 0x00 ; 0 - fe: 84 2b or r24, r20 - 100: 95 2b or r25, r21 - 102: 90 93 87 01 sts 0x0187, r25 - 106: 80 93 86 01 sts 0x0186, r24 + da: 40 91 08 01 lds r20, 0x0108 + de: 80 91 09 01 lds r24, 0x0109 + e2: 90 e0 ldi r25, 0x00 ; 0 + e4: 98 2f mov r25, r24 + e6: 88 27 eor r24, r24 + e8: 50 e0 ldi r21, 0x00 ; 0 + ea: 84 2b or r24, r20 + ec: 95 2b or r25, r21 + ee: 90 93 87 01 sts 0x0187, r25 + f2: 80 93 86 01 sts 0x0186, r24 vect -= 4; // Instruction is a relative jump (rjmp), so recalculate. - 10a: 24 50 subi r18, 0x04 ; 4 - 10c: 30 40 sbci r19, 0x00 ; 0 + f6: 24 50 subi r18, 0x04 ; 4 + f8: 30 40 sbci r19, 0x00 ; 0 buff[8] = vect & 0xff; - 10e: 20 93 08 01 sts 0x0108, r18 + fa: 20 93 08 01 sts 0x0108, r18 buff[9] = vect >> 8; - 112: 23 2f mov r18, r19 - 114: 33 27 eor r19, r19 - 116: 20 93 09 01 sts 0x0109, r18 + fe: 23 2f mov r18, r19 + 100: 33 27 eor r19, r19 + 102: 20 93 09 01 sts 0x0109, r18 // Add jump to bootloader at RESET vector buff[0] = 0x7f; - 11a: f0 92 00 01 sts 0x0100, r15 + 106: d0 92 00 01 sts 0x0100, r13 buff[1] = 0xce; // rjmp 0x1d00 instruction - 11e: e0 92 01 01 sts 0x0101, r14 - } -#endif - - // Copy buffer into programming buffer + 10a: c0 92 01 01 sts 0x0101, r12 + 10e: 40 e0 ldi r20, 0x00 ; 0 + 110: 50 e0 ldi r21, 0x00 ; 0 + 112: a0 e0 ldi r26, 0x00 ; 0 + 114: b1 e0 ldi r27, 0x01 ; 1 bufPtr = buff; addrPtr = (uint16_t)(void*)address; - 122: 40 91 80 01 lds r20, 0x0180 - 126: 50 91 81 01 lds r21, 0x0181 - 12a: a0 e0 ldi r26, 0x00 ; 0 - 12c: b1 e0 ldi r27, 0x01 ; 1 ch = SPM_PAGESIZE / 2; do { uint16_t a; a = *bufPtr++; - 12e: 2c 91 ld r18, X - 130: 30 e0 ldi r19, 0x00 ; 0 + 116: 2c 91 ld r18, X + 118: 30 e0 ldi r19, 0x00 ; 0 a |= (*bufPtr++) << 8; - 132: 11 96 adiw r26, 0x01 ; 1 - 134: 8c 91 ld r24, X - 136: 11 97 sbiw r26, 0x01 ; 1 - 138: 90 e0 ldi r25, 0x00 ; 0 - 13a: 98 2f mov r25, r24 - 13c: 88 27 eor r24, r24 - 13e: 82 2b or r24, r18 - 140: 93 2b or r25, r19 + 11a: 11 96 adiw r26, 0x01 ; 1 + 11c: 8c 91 ld r24, X + 11e: 11 97 sbiw r26, 0x01 ; 1 + 120: 90 e0 ldi r25, 0x00 ; 0 + 122: 98 2f mov r25, r24 + 124: 88 27 eor r24, r24 + 126: 82 2b or r24, r18 + 128: 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) { - 142: 12 96 adiw r26, 0x02 ; 2 + 12a: 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); - 144: fa 01 movw r30, r20 - 146: 0c 01 movw r0, r24 - 148: d7 be out 0x37, r13 ; 55 - 14a: e8 95 spm - 14c: 11 24 eor r1, r1 + 12c: fa 01 movw r30, r20 + 12e: 0c 01 movw r0, r24 + 130: b7 be out 0x37, r11 ; 55 + 132: e8 95 spm + 134: 11 24 eor r1, r1 addrPtr += 2; - 14e: 4e 5f subi r20, 0xFE ; 254 - 150: 5f 4f sbci r21, 0xFF ; 255 + 136: 4e 5f subi r20, 0xFE ; 254 + 138: 5f 4f sbci r21, 0xFF ; 255 } while (--ch); - 152: f1 e0 ldi r31, 0x01 ; 1 - 154: a0 34 cpi r26, 0x40 ; 64 - 156: bf 07 cpc r27, r31 - 158: 51 f7 brne .-44 ; 0x12e <__SREG__+0xef> + 13a: f1 e0 ldi r31, 0x01 ; 1 + 13c: a0 34 cpi r26, 0x40 ; 64 + 13e: bf 07 cpc r27, r31 + 140: 51 f7 brne .-44 ; 0x116 <__SREG__+0xd7> // Write from programming buffer __boot_page_write_short((uint16_t)(void*)address); - 15a: e0 91 80 01 lds r30, 0x0180 - 15e: f0 91 81 01 lds r31, 0x0181 - 162: c7 be out 0x37, r12 ; 55 - 164: e8 95 spm + 142: f8 01 movw r30, r16 + 144: a7 be out 0x37, r10 ; 55 + 146: e8 95 spm boot_spm_busy_wait(); - 166: 07 b6 in r0, 0x37 ; 55 - 168: 00 fc sbrc r0, 0 - 16a: fd cf rjmp .-6 ; 0x166 <__SREG__+0x127> - 16c: 41 c0 rjmp .+130 ; 0x1f0 <__SREG__+0x1b1> + 148: 07 b6 in r0, 0x37 ; 55 + 14a: 00 fc sbrc r0, 0 + 14c: fd cf rjmp .-6 ; 0x148 <__SREG__+0x109> + 14e: 3b c0 rjmp .+118 ; 0x1c6 <__SREG__+0x187> boot_rww_enable(); #endif } /* Read memory block mode, length is big endian. */ else if(ch == STK_READ_PAGE) { - 16e: 84 37 cpi r24, 0x74 ; 116 - 170: 89 f5 brne .+98 ; 0x1d4 <__SREG__+0x195> + 150: 84 37 cpi r24, 0x74 ; 116 + 152: 51 f5 brne .+84 ; 0x1a8 <__SREG__+0x169> // READ PAGE - we only read flash - getLen(); - 172: 64 d0 rcall .+200 ; 0x23c + getch(); /* getlen() */ + 154: 4a d0 rcall .+148 ; 0x1ea + length = getch(); + 156: 49 d0 rcall .+146 ; 0x1ea + 158: f8 2e mov r15, r24 + getch(); + 15a: 47 d0 rcall .+142 ; 0x1ea + verifySpace(); - 174: 71 d0 rcall .+226 ; 0x258 + 15c: 5e d0 rcall .+188 ; 0x21a + 15e: e8 01 movw r28, r16 + 160: ef 2c mov r14, r15 #ifdef VIRTUAL_BOOT_PARTITION do { // Undo vector patch in bottom page so verify passes if (address == 0) ch=rstVect & 0xff; - 176: e0 91 80 01 lds r30, 0x0180 - 17a: f0 91 81 01 lds r31, 0x0181 - 17e: 30 97 sbiw r30, 0x00 ; 0 - 180: 19 f4 brne .+6 ; 0x188 <__SREG__+0x149> - 182: 20 91 84 01 lds r18, 0x0184 - 186: 13 c0 rjmp .+38 ; 0x1ae <__SREG__+0x16f> + 162: 20 97 sbiw r28, 0x00 ; 0 + 164: 19 f4 brne .+6 ; 0x16c <__SREG__+0x12d> + 166: 80 91 84 01 lds r24, 0x0184 + 16a: 14 c0 rjmp .+40 ; 0x194 <__SREG__+0x155> else if (address == 1) ch=rstVect >> 8; - 188: e1 30 cpi r30, 0x01 ; 1 - 18a: f1 05 cpc r31, r1 - 18c: 19 f4 brne .+6 ; 0x194 <__SREG__+0x155> - 18e: 20 91 85 01 lds r18, 0x0185 - 192: 0d c0 rjmp .+26 ; 0x1ae <__SREG__+0x16f> + 16c: c1 30 cpi r28, 0x01 ; 1 + 16e: d1 05 cpc r29, r1 + 170: 19 f4 brne .+6 ; 0x178 <__SREG__+0x139> + 172: 80 91 85 01 lds r24, 0x0185 + 176: 0e c0 rjmp .+28 ; 0x194 <__SREG__+0x155> else if (address == 8) ch=wdtVect & 0xff; - 194: e8 30 cpi r30, 0x08 ; 8 - 196: f1 05 cpc r31, r1 - 198: 19 f4 brne .+6 ; 0x1a0 <__SREG__+0x161> - 19a: 20 91 86 01 lds r18, 0x0186 - 19e: 07 c0 rjmp .+14 ; 0x1ae <__SREG__+0x16f> + 178: c8 30 cpi r28, 0x08 ; 8 + 17a: d1 05 cpc r29, r1 + 17c: 19 f4 brne .+6 ; 0x184 <__SREG__+0x145> + 17e: 80 91 86 01 lds r24, 0x0186 + 182: 08 c0 rjmp .+16 ; 0x194 <__SREG__+0x155> else if (address == 9) ch=wdtVect >> 8; - 1a0: e9 30 cpi r30, 0x09 ; 9 - 1a2: f1 05 cpc r31, r1 - 1a4: 19 f4 brne .+6 ; 0x1ac <__SREG__+0x16d> - 1a6: 20 91 87 01 lds r18, 0x0187 - 1aa: 01 c0 rjmp .+2 ; 0x1ae <__SREG__+0x16f> + 184: c9 30 cpi r28, 0x09 ; 9 + 186: d1 05 cpc r29, r1 + 188: 19 f4 brne .+6 ; 0x190 <__SREG__+0x151> + 18a: 80 91 87 01 lds r24, 0x0187 + 18e: 02 c0 rjmp .+4 ; 0x194 <__SREG__+0x155> else ch = pgm_read_byte_near(address); - 1ac: 24 91 lpm r18, Z+ + 190: fe 01 movw r30, r28 + 192: 84 91 lpm r24, Z+ address++; - 1ae: 80 91 80 01 lds r24, 0x0180 - 1b2: 90 91 81 01 lds r25, 0x0181 - 1b6: 01 96 adiw r24, 0x01 ; 1 - 1b8: 90 93 81 01 sts 0x0181, r25 - 1bc: 80 93 80 01 sts 0x0180, r24 + 194: 21 96 adiw r28, 0x01 ; 1 putch(ch); - 1c0: 82 2f mov r24, r18 - 1c2: 19 d0 rcall .+50 ; 0x1f6 + 196: 1a d0 rcall .+52 ; 0x1cc } while (--length); - 1c4: 80 91 82 01 lds r24, 0x0182 - 1c8: 81 50 subi r24, 0x01 ; 1 - 1ca: 80 93 82 01 sts 0x0182, r24 - 1ce: 88 23 and r24, r24 - 1d0: 91 f6 brne .-92 ; 0x176 <__SREG__+0x137> - 1d2: 0e c0 rjmp .+28 ; 0x1f0 <__SREG__+0x1b1> + 198: ea 94 dec r14 + 19a: 19 f7 brne .-58 ; 0x162 <__SREG__+0x123> +#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) { + 19c: 0f 5f subi r16, 0xFF ; 255 + 19e: 1f 4f sbci r17, 0xFF ; 255 + 1a0: fa 94 dec r15 + 1a2: 0f 0d add r16, r15 + 1a4: 11 1d adc r17, r1 + 1a6: 0f c0 rjmp .+30 ; 0x1c6 <__SREG__+0x187> #endif #endif } /* Get device signature bytes */ else if(ch == STK_READ_SIGN) { - 1d4: 85 37 cpi r24, 0x75 ; 117 - 1d6: 39 f4 brne .+14 ; 0x1e6 <__SREG__+0x1a7> + 1a8: 85 37 cpi r24, 0x75 ; 117 + 1aa: 41 f4 brne .+16 ; 0x1bc <__SREG__+0x17d> // READ SIGN - return what Avrdude wants to hear verifySpace(); - 1d8: 3f d0 rcall .+126 ; 0x258 + 1ac: 36 d0 rcall .+108 ; 0x21a putch(SIGNATURE_0); - 1da: 8e e1 ldi r24, 0x1E ; 30 - 1dc: 0c d0 rcall .+24 ; 0x1f6 + 1ae: 8e e1 ldi r24, 0x1E ; 30 + 1b0: 0d d0 rcall .+26 ; 0x1cc putch(SIGNATURE_1); - 1de: 83 e9 ldi r24, 0x93 ; 147 - 1e0: 0a d0 rcall .+20 ; 0x1f6 + 1b2: 83 e9 ldi r24, 0x93 ; 147 + 1b4: 0b d0 rcall .+22 ; 0x1cc putch(SIGNATURE_2); - 1e2: 8c e0 ldi r24, 0x0C ; 12 - 1e4: 54 cf rjmp .-344 ; 0x8e <__SREG__+0x4f> + 1b6: 8c e0 ldi r24, 0x0C ; 12 + 1b8: 09 d0 rcall .+18 ; 0x1cc + 1ba: 05 c0 rjmp .+10 ; 0x1c6 <__SREG__+0x187> } else if (ch == 'Q') { - 1e6: 81 35 cpi r24, 0x51 ; 81 - 1e8: 11 f4 brne .+4 ; 0x1ee <__SREG__+0x1af> + 1bc: 81 35 cpi r24, 0x51 ; 81 + 1be: 11 f4 brne .+4 ; 0x1c4 <__SREG__+0x185> // Adaboot no-wait mod watchdogConfig(WATCHDOG_16MS); - 1ea: 88 e0 ldi r24, 0x08 ; 8 - 1ec: 2c d0 rcall .+88 ; 0x246 + 1c0: 88 e0 ldi r24, 0x08 ; 8 + 1c2: 27 d0 rcall .+78 ; 0x212 verifySpace(); } else { // This covers the response to commands like STK_ENTER_PROGMODE verifySpace(); - 1ee: 34 d0 rcall .+104 ; 0x258 + 1c4: 2a d0 rcall .+84 ; 0x21a } putch(STK_OK); - 1f0: 80 e1 ldi r24, 0x10 ; 16 - 1f2: 01 d0 rcall .+2 ; 0x1f6 - 1f4: 25 cf rjmp .-438 ; 0x40 <__SREG__+0x1> + 1c6: 80 e1 ldi r24, 0x10 ; 16 + 1c8: 01 d0 rcall .+2 ; 0x1cc + 1ca: 3a cf rjmp .-396 ; 0x40 <__SREG__+0x1> -000001f6 : +000001cc : void putch(char ch) { #ifndef SOFT_UART while (!(UCSR0A & _BV(UDRE0))); UDR0 = ch; #else __asm__ __volatile__ ( - 1f6: 2a e0 ldi r18, 0x0A ; 10 - 1f8: 30 e0 ldi r19, 0x00 ; 0 - 1fa: 80 95 com r24 - 1fc: 08 94 sec - 1fe: 10 f4 brcc .+4 ; 0x204 - 200: da 98 cbi 0x1b, 2 ; 27 - 202: 02 c0 rjmp .+4 ; 0x208 - 204: da 9a sbi 0x1b, 2 ; 27 - 206: 00 00 nop - 208: 15 d0 rcall .+42 ; 0x234 - 20a: 14 d0 rcall .+40 ; 0x234 - 20c: 86 95 lsr r24 - 20e: 2a 95 dec r18 - 210: b1 f7 brne .-20 ; 0x1fe + 1cc: 2a e0 ldi r18, 0x0A ; 10 + 1ce: 30 e0 ldi r19, 0x00 ; 0 + 1d0: 80 95 com r24 + 1d2: 08 94 sec + 1d4: 10 f4 brcc .+4 ; 0x1da + 1d6: da 98 cbi 0x1b, 2 ; 27 + 1d8: 02 c0 rjmp .+4 ; 0x1de + 1da: da 9a sbi 0x1b, 2 ; 27 + 1dc: 00 00 nop + 1de: 15 d0 rcall .+42 ; 0x20a + 1e0: 14 d0 rcall .+40 ; 0x20a + 1e2: 86 95 lsr r24 + 1e4: 2a 95 dec r18 + 1e6: b1 f7 brne .-20 ; 0x1d4 [uartBit] "I" (UART_TX_BIT) : "r25" ); #endif } - 212: 08 95 ret + 1e8: 08 95 ret -00000214 : - return getch(); +000001ea : } +#endif // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( - 214: a8 95 wdr + 1ea: a8 95 wdr LED_PIN |= _BV(LED); #endif #endif return ch; } - 216: 29 e0 ldi r18, 0x09 ; 9 - 218: 30 e0 ldi r19, 0x00 ; 0 - 21a: cb 99 sbic 0x19, 3 ; 25 - 21c: fe cf rjmp .-4 ; 0x21a - 21e: 0a d0 rcall .+20 ; 0x234 - 220: 09 d0 rcall .+18 ; 0x234 - 222: 08 d0 rcall .+16 ; 0x234 - 224: 88 94 clc - 226: cb 99 sbic 0x19, 3 ; 25 - 228: 08 94 sec - 22a: 2a 95 dec r18 - 22c: 11 f0 breq .+4 ; 0x232 - 22e: 87 95 ror r24 - 230: f7 cf rjmp .-18 ; 0x220 - 232: 08 95 ret - -00000234 : + 1ec: 29 e0 ldi r18, 0x09 ; 9 + 1ee: 30 e0 ldi r19, 0x00 ; 0 + 1f0: cb 99 sbic 0x19, 3 ; 25 + 1f2: fe cf rjmp .-4 ; 0x1f0 + 1f4: 0a d0 rcall .+20 ; 0x20a + 1f6: 09 d0 rcall .+18 ; 0x20a + 1f8: 08 d0 rcall .+16 ; 0x20a + 1fa: 88 94 clc + 1fc: cb 99 sbic 0x19, 3 ; 25 + 1fe: 08 94 sec + 200: 2a 95 dec r18 + 202: 11 f0 breq .+4 ; 0x208 + 204: 87 95 ror r24 + 206: f7 cf rjmp .-18 ; 0x1f6 + 208: 08 95 ret + +0000020a : #if UART_B_VALUE > 255 #error Baud rate too slow for soft UART #endif void uartDelay() { __asm__ __volatile__ ( - 234: 9e e0 ldi r25, 0x0E ; 14 - 236: 9a 95 dec r25 - 238: f1 f7 brne .-4 ; 0x236 - 23a: 08 95 ret - -0000023c : - } while (--count); -} -#endif + 20a: 9e e0 ldi r25, 0x0E ; 14 + 20c: 9a 95 dec r25 + 20e: f1 f7 brne .-4 ; 0x20c + 210: 08 95 ret -uint8_t getLen() { - getch(); - 23c: eb df rcall .-42 ; 0x214 - length = getch(); - 23e: ea df rcall .-44 ; 0x214 - 240: 80 93 82 01 sts 0x0182, r24 - return getch(); -} - 244: e7 cf rjmp .-50 ; 0x214 - -00000246 : +00000212 : "wdr\n" ); } void watchdogConfig(uint8_t x) { WDTCSR = _BV(WDCE) | _BV(WDE); - 246: 98 e1 ldi r25, 0x18 ; 24 - 248: 91 bd out 0x21, r25 ; 33 + 212: 98 e1 ldi r25, 0x18 ; 24 + 214: 91 bd out 0x21, r25 ; 33 WDTCSR = x; - 24a: 81 bd out 0x21, r24 ; 33 + 216: 81 bd out 0x21, r24 ; 33 } - 24c: 08 95 ret - -0000024e : - -void appStart() { - watchdogConfig(WATCHDOG_OFF); - 24e: 80 e0 ldi r24, 0x00 ; 0 - 250: fa df rcall .-12 ; 0x246 - __asm__ __volatile__ ( - 252: e4 e0 ldi r30, 0x04 ; 4 - 254: ff 27 eor r31, r31 - 256: 09 94 ijmp + 218: 08 95 ret -00000258 : +0000021a : do getch(); while (--count); verifySpace(); } void verifySpace() { - if (getch() != CRC_EOP) appStart(); - 258: dd df rcall .-70 ; 0x214 - 25a: 80 32 cpi r24, 0x20 ; 32 - 25c: 09 f0 breq .+2 ; 0x260 - 25e: f7 df rcall .-18 ; 0x24e + if (getch() != CRC_EOP) { + 21a: e7 df rcall .-50 ; 0x1ea + 21c: 80 32 cpi r24, 0x20 ; 32 + 21e: 19 f0 breq .+6 ; 0x226 + watchdogConfig(WATCHDOG_16MS); // shorten WD timeout + 220: 88 e0 ldi r24, 0x08 ; 8 + 222: f7 df rcall .-18 ; 0x212 + 224: ff cf rjmp .-2 ; 0x224 + while (1) // and busy-loop so that WD causes + ; // a reset and app start. + } putch(STK_INSYNC); - 260: 84 e1 ldi r24, 0x14 ; 20 + 226: 84 e1 ldi r24, 0x14 ; 20 } - 262: c9 cf rjmp .-110 ; 0x1f6 + 228: d1 cf rjmp .-94 ; 0x1cc -00000264 : +0000022a : ::[count] "M" (UART_B_VALUE) ); } #endif void getNch(uint8_t count) { - 264: 1f 93 push r17 - 266: 18 2f mov r17, r24 + 22a: 1f 93 push r17 + 22c: 18 2f mov r17, r24 do getch(); while (--count); - 268: d5 df rcall .-86 ; 0x214 - 26a: 11 50 subi r17, 0x01 ; 1 - 26c: e9 f7 brne .-6 ; 0x268 + 22e: dd df rcall .-70 ; 0x1ea + 230: 11 50 subi r17, 0x01 ; 1 + 232: e9 f7 brne .-6 ; 0x22e verifySpace(); - 26e: f4 df rcall .-24 ; 0x258 + 234: f2 df rcall .-28 ; 0x21a } - 270: 1f 91 pop r17 - 272: 08 95 ret + 236: 1f 91 pop r17 + 238: 08 95 ret + +0000023a : + WDTCSR = _BV(WDCE) | _BV(WDE); + WDTCSR = x; +} + +void appStart() { + watchdogConfig(WATCHDOG_OFF); + 23a: 80 e0 ldi r24, 0x00 ; 0 + 23c: ea df rcall .-44 ; 0x212 + __asm__ __volatile__ ( + 23e: e4 e0 ldi r30, 0x04 ; 4 + 240: ff 27 eor r31, r31 + 242: 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_luminet.lst | 586 +++++++++++++++--------------- 1 file changed, 293 insertions(+), 293 deletions(-) (limited to 'bootloaders/optiboot/optiboot_luminet.lst') diff --git a/bootloaders/optiboot/optiboot_luminet.lst b/bootloaders/optiboot/optiboot_luminet.lst index 8333670..447349d 100644 --- a/bootloaders/optiboot/optiboot_luminet.lst +++ b/bootloaders/optiboot/optiboot_luminet.lst @@ -3,622 +3,622 @@ optiboot_luminet.elf: file format elf32-avr Sections: Idx Name Size VMA LMA File off Algn - 0 .version 00000002 00001efe 00001efe 00000298 2**0 - CONTENTS, READONLY - 1 .text 00000244 00000000 00000000 00000054 2**1 + 0 .text 00000244 00001d00 00001d00 00000054 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE + 1 .version 00000002 00001efe 00001efe 00000298 2**0 + CONTENTS, READONLY 2 .debug_aranges 00000028 00000000 00000000 0000029a 2**0 CONTENTS, READONLY, DEBUGGING 3 .debug_pubnames 0000006d 00000000 00000000 000002c2 2**0 CONTENTS, READONLY, DEBUGGING - 4 .debug_info 000002b0 00000000 00000000 0000032f 2**0 + 4 .debug_info 000002b1 00000000 00000000 0000032f 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_abbrev 00000197 00000000 00000000 000005df 2**0 + 5 .debug_abbrev 00000188 00000000 00000000 000005e0 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_line 000004a7 00000000 00000000 00000776 2**0 + 6 .debug_line 000004a7 00000000 00000000 00000768 2**0 CONTENTS, READONLY, DEBUGGING - 7 .debug_frame 00000090 00000000 00000000 00000c20 2**2 + 7 .debug_frame 00000090 00000000 00000000 00000c10 2**2 CONTENTS, READONLY, DEBUGGING - 8 .debug_str 00000158 00000000 00000000 00000cb0 2**0 + 8 .debug_str 00000158 00000000 00000000 00000ca0 2**0 CONTENTS, READONLY, DEBUGGING - 9 .debug_loc 00000268 00000000 00000000 00000e08 2**0 + 9 .debug_loc 00000268 00000000 00000000 00000df8 2**0 CONTENTS, READONLY, DEBUGGING - 10 .debug_ranges 00000080 00000000 00000000 00001070 2**0 + 10 .debug_ranges 00000080 00000000 00000000 00001060 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: -00000000
: +00001d00
: #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) { - 0: 11 24 eor r1, r1 + 1d00: 11 24 eor r1, r1 #ifdef __AVR_ATmega8__ SP=RAMEND; // This is done by hardware reset #endif // Adaboot no-wait mod ch = MCUSR; - 2: 84 b7 in r24, 0x34 ; 52 + 1d02: 84 b7 in r24, 0x34 ; 52 MCUSR = 0; - 4: 14 be out 0x34, r1 ; 52 + 1d04: 14 be out 0x34, r1 ; 52 if (!(ch & _BV(EXTRF))) appStart(); - 6: 81 ff sbrs r24, 1 - 8: 18 d1 rcall .+560 ; 0x23a + 1d06: 81 ff sbrs r24, 1 + 1d08: 18 d1 rcall .+560 ; 0x1f3a #if LED_START_FLASHES > 0 // Set up Timer 1 for timeout counter TCCR1B = _BV(CS12) | _BV(CS10); // div 1024 - a: 85 e0 ldi r24, 0x05 ; 5 - c: 8e bd out 0x2e, r24 ; 46 + 1d0a: 85 e0 ldi r24, 0x05 ; 5 + 1d0c: 8e bd out 0x2e, r24 ; 46 UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); #endif #endif // Set up watchdog to trigger after 500ms watchdogConfig(WATCHDOG_1S); - e: 8e e0 ldi r24, 0x0E ; 14 - 10: 00 d1 rcall .+512 ; 0x212 + 1d0e: 8e e0 ldi r24, 0x0E ; 14 + 1d10: 00 d1 rcall .+512 ; 0x1f12 /* Set LED pin as output */ LED_DDR |= _BV(LED); - 12: d4 9a sbi 0x1a, 4 ; 26 + 1d12: d4 9a sbi 0x1a, 4 ; 26 #ifdef SOFT_UART /* Set TX pin as output */ UART_DDR |= _BV(UART_TX_BIT); - 14: d2 9a sbi 0x1a, 2 ; 26 - 16: 86 e0 ldi r24, 0x06 ; 6 + 1d14: d2 9a sbi 0x1a, 2 ; 26 + 1d16: 86 e0 ldi r24, 0x06 ; 6 } #if LED_START_FLASHES > 0 void flash_led(uint8_t count) { do { TCNT1 = -(F_CPU/(1024*16)); - 18: 23 ec ldi r18, 0xC3 ; 195 - 1a: 3f ef ldi r19, 0xFF ; 255 + 1d18: 23 ec ldi r18, 0xC3 ; 195 + 1d1a: 3f ef ldi r19, 0xFF ; 255 TIFR1 = _BV(TOV1); - 1c: 91 e0 ldi r25, 0x01 ; 1 + 1d1c: 91 e0 ldi r25, 0x01 ; 1 } #if LED_START_FLASHES > 0 void flash_led(uint8_t count) { do { TCNT1 = -(F_CPU/(1024*16)); - 1e: 3d bd out 0x2d, r19 ; 45 - 20: 2c bd out 0x2c, r18 ; 44 + 1d1e: 3d bd out 0x2d, r19 ; 45 + 1d20: 2c bd out 0x2c, r18 ; 44 TIFR1 = _BV(TOV1); - 22: 9b b9 out 0x0b, r25 ; 11 + 1d22: 9b b9 out 0x0b, r25 ; 11 while(!(TIFR1 & _BV(TOV1))); - 24: 58 9b sbis 0x0b, 0 ; 11 - 26: fe cf rjmp .-4 ; 0x24 <__zero_reg__+0x23> + 1d24: 58 9b sbis 0x0b, 0 ; 11 + 1d26: fe cf rjmp .-4 ; 0x1d24 #ifdef __AVR_ATmega8__ LED_PORT ^= _BV(LED); #else LED_PIN |= _BV(LED); - 28: cc 9a sbi 0x19, 4 ; 25 + 1d28: cc 9a sbi 0x19, 4 ; 25 } #endif // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( - 2a: a8 95 wdr + 1d2a: a8 95 wdr LED_PORT ^= _BV(LED); #else LED_PIN |= _BV(LED); #endif watchdogReset(); } while (--count); - 2c: 81 50 subi r24, 0x01 ; 1 - 2e: b9 f7 brne .-18 ; 0x1e <__zero_reg__+0x1d> + 1d2c: 81 50 subi r24, 0x01 ; 1 + 1d2e: b9 f7 brne .-18 ; 0x1d1e /* 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); - 30: bb 24 eor r11, r11 - 32: b3 94 inc r11 + 1d30: bb 24 eor r11, r11 + 1d32: b3 94 inc r11 __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); - 34: 25 e0 ldi r18, 0x05 ; 5 - 36: a2 2e mov r10, r18 + 1d34: 25 e0 ldi r18, 0x05 ; 5 + 1d36: a2 2e mov r10, r18 vect -= 4; // Instruction is a relative jump (rjmp), so recalculate. buff[8] = vect & 0xff; buff[9] = vect >> 8; // Add jump to bootloader at RESET vector buff[0] = 0x7f; - 38: 9f e7 ldi r25, 0x7F ; 127 - 3a: d9 2e mov r13, r25 + 1d38: 9f e7 ldi r25, 0x7F ; 127 + 1d3a: d9 2e mov r13, r25 buff[1] = 0xce; // rjmp 0x1d00 instruction - 3c: 8e ec ldi r24, 0xCE ; 206 - 3e: c8 2e mov r12, r24 + 1d3c: 8e ec ldi r24, 0xCE ; 206 + 1d3e: c8 2e mov r12, r24 #endif /* Forever loop */ for (;;) { /* get character from UART */ ch = getch(); - 40: d4 d0 rcall .+424 ; 0x1ea + 1d40: d4 d0 rcall .+424 ; 0x1eea if(ch == STK_GET_PARAMETER) { - 42: 81 34 cpi r24, 0x41 ; 65 - 44: 21 f4 brne .+8 ; 0x4e <__SREG__+0xf> + 1d42: 81 34 cpi r24, 0x41 ; 65 + 1d44: 21 f4 brne .+8 ; 0x1d4e // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy getNch(1); - 46: 81 e0 ldi r24, 0x01 ; 1 - 48: f0 d0 rcall .+480 ; 0x22a + 1d46: 81 e0 ldi r24, 0x01 ; 1 + 1d48: f0 d0 rcall .+480 ; 0x1f2a putch(0x03); - 4a: 83 e0 ldi r24, 0x03 ; 3 - 4c: b5 c0 rjmp .+362 ; 0x1b8 <__SREG__+0x179> + 1d4a: 83 e0 ldi r24, 0x03 ; 3 + 1d4c: b5 c0 rjmp .+362 ; 0x1eb8 } else if(ch == STK_SET_DEVICE) { - 4e: 82 34 cpi r24, 0x42 ; 66 - 50: 11 f4 brne .+4 ; 0x56 <__SREG__+0x17> + 1d4e: 82 34 cpi r24, 0x42 ; 66 + 1d50: 11 f4 brne .+4 ; 0x1d56 // SET DEVICE is ignored getNch(20); - 52: 84 e1 ldi r24, 0x14 ; 20 - 54: 03 c0 rjmp .+6 ; 0x5c <__SREG__+0x1d> + 1d52: 84 e1 ldi r24, 0x14 ; 20 + 1d54: 03 c0 rjmp .+6 ; 0x1d5c } else if(ch == STK_SET_DEVICE_EXT) { - 56: 85 34 cpi r24, 0x45 ; 69 - 58: 19 f4 brne .+6 ; 0x60 <__SREG__+0x21> + 1d56: 85 34 cpi r24, 0x45 ; 69 + 1d58: 19 f4 brne .+6 ; 0x1d60 // SET DEVICE EXT is ignored getNch(5); - 5a: 85 e0 ldi r24, 0x05 ; 5 - 5c: e6 d0 rcall .+460 ; 0x22a - 5e: b3 c0 rjmp .+358 ; 0x1c6 <__SREG__+0x187> + 1d5a: 85 e0 ldi r24, 0x05 ; 5 + 1d5c: e6 d0 rcall .+460 ; 0x1f2a + 1d5e: b3 c0 rjmp .+358 ; 0x1ec6 } else if(ch == STK_LOAD_ADDRESS) { - 60: 85 35 cpi r24, 0x55 ; 85 - 62: 69 f4 brne .+26 ; 0x7e <__SREG__+0x3f> + 1d60: 85 35 cpi r24, 0x55 ; 85 + 1d62: 69 f4 brne .+26 ; 0x1d7e // LOAD ADDRESS uint16_t newAddress; newAddress = getch(); - 64: c2 d0 rcall .+388 ; 0x1ea + 1d64: c2 d0 rcall .+388 ; 0x1eea newAddress = (newAddress & 0xff) | (getch() << 8); - 66: e8 2e mov r14, r24 - 68: ff 24 eor r15, r15 - 6a: bf d0 rcall .+382 ; 0x1ea - 6c: 08 2f mov r16, r24 - 6e: 10 e0 ldi r17, 0x00 ; 0 - 70: 10 2f mov r17, r16 - 72: 00 27 eor r16, r16 - 74: 0e 29 or r16, r14 - 76: 1f 29 or r17, r15 + 1d66: e8 2e mov r14, r24 + 1d68: ff 24 eor r15, r15 + 1d6a: bf d0 rcall .+382 ; 0x1eea + 1d6c: 08 2f mov r16, r24 + 1d6e: 10 e0 ldi r17, 0x00 ; 0 + 1d70: 10 2f mov r17, r16 + 1d72: 00 27 eor r16, r16 + 1d74: 0e 29 or r16, r14 + 1d76: 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 - 78: 00 0f add r16, r16 - 7a: 11 1f adc r17, r17 - 7c: a3 c0 rjmp .+326 ; 0x1c4 <__SREG__+0x185> + 1d78: 00 0f add r16, r16 + 1d7a: 11 1f adc r17, r17 + 1d7c: a3 c0 rjmp .+326 ; 0x1ec4 address = newAddress; verifySpace(); } else if(ch == STK_UNIVERSAL) { - 7e: 86 35 cpi r24, 0x56 ; 86 - 80: 21 f4 brne .+8 ; 0x8a <__SREG__+0x4b> + 1d7e: 86 35 cpi r24, 0x56 ; 86 + 1d80: 21 f4 brne .+8 ; 0x1d8a // UNIVERSAL command is ignored getNch(4); - 82: 84 e0 ldi r24, 0x04 ; 4 - 84: d2 d0 rcall .+420 ; 0x22a + 1d82: 84 e0 ldi r24, 0x04 ; 4 + 1d84: d2 d0 rcall .+420 ; 0x1f2a putch(0x00); - 86: 80 e0 ldi r24, 0x00 ; 0 - 88: 97 c0 rjmp .+302 ; 0x1b8 <__SREG__+0x179> + 1d86: 80 e0 ldi r24, 0x00 ; 0 + 1d88: 97 c0 rjmp .+302 ; 0x1eb8 } /* Write memory, length is big endian and is in bytes */ else if(ch == STK_PROG_PAGE) { - 8a: 84 36 cpi r24, 0x64 ; 100 - 8c: 09 f0 breq .+2 ; 0x90 <__SREG__+0x51> - 8e: 60 c0 rjmp .+192 ; 0x150 <__SREG__+0x111> + 1d8a: 84 36 cpi r24, 0x64 ; 100 + 1d8c: 09 f0 breq .+2 ; 0x1d90 + 1d8e: 60 c0 rjmp .+192 ; 0x1e50 // PROGRAM PAGE - we support flash programming only, not EEPROM uint8_t *bufPtr; uint16_t addrPtr; getch(); /* getlen() */ - 90: ac d0 rcall .+344 ; 0x1ea + 1d90: ac d0 rcall .+344 ; 0x1eea length = getch(); - 92: ab d0 rcall .+342 ; 0x1ea - 94: f8 2e mov r15, r24 + 1d92: ab d0 rcall .+342 ; 0x1eea + 1d94: f8 2e mov r15, r24 getch(); - 96: a9 d0 rcall .+338 ; 0x1ea - 98: c0 e0 ldi r28, 0x00 ; 0 - 9a: d1 e0 ldi r29, 0x01 ; 1 + 1d96: a9 d0 rcall .+338 ; 0x1eea + 1d98: c0 e0 ldi r28, 0x00 ; 0 + 1d9a: d1 e0 ldi r29, 0x01 ; 1 // If we are in RWW section, immediately start page erase if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address); // While that is going on, read in page contents bufPtr = buff; do *bufPtr++ = getch(); - 9c: a6 d0 rcall .+332 ; 0x1ea - 9e: 89 93 st Y+, r24 + 1d9c: a6 d0 rcall .+332 ; 0x1eea + 1d9e: 89 93 st Y+, r24 while (--length); - a0: fc 16 cp r15, r28 - a2: e1 f7 brne .-8 ; 0x9c <__SREG__+0x5d> + 1da0: fc 16 cp r15, r28 + 1da2: e1 f7 brne .-8 ; 0x1d9c // 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); - a4: 83 e0 ldi r24, 0x03 ; 3 - a6: f8 01 movw r30, r16 - a8: 87 bf out 0x37, r24 ; 55 - aa: e8 95 spm + 1da4: 83 e0 ldi r24, 0x03 ; 3 + 1da6: f8 01 movw r30, r16 + 1da8: 87 bf out 0x37, r24 ; 55 + 1daa: e8 95 spm // Read command terminator, start reply verifySpace(); - ac: b6 d0 rcall .+364 ; 0x21a + 1dac: b6 d0 rcall .+364 ; 0x1f1a // If only a partial page is to be programmed, the erase might not be complete. // So check that here boot_spm_busy_wait(); - ae: 07 b6 in r0, 0x37 ; 55 - b0: 00 fc sbrc r0, 0 - b2: fd cf rjmp .-6 ; 0xae <__SREG__+0x6f> + 1dae: 07 b6 in r0, 0x37 ; 55 + 1db0: 00 fc sbrc r0, 0 + 1db2: fd cf rjmp .-6 ; 0x1dae #ifdef VIRTUAL_BOOT_PARTITION if ((uint16_t)(void*)address == 0) { - b4: 01 15 cp r16, r1 - b6: 11 05 cpc r17, r1 - b8: 11 f0 breq .+4 ; 0xbe <__SREG__+0x7f> - ba: a8 01 movw r20, r16 - bc: 2a c0 rjmp .+84 ; 0x112 <__SREG__+0xd3> + 1db4: 01 15 cp r16, r1 + 1db6: 11 05 cpc r17, r1 + 1db8: 11 f0 breq .+4 ; 0x1dbe + 1dba: a8 01 movw r20, r16 + 1dbc: 2a c0 rjmp .+84 ; 0x1e12 // This is the reset vector page. We need to live-patch the code so the // bootloader runs. // // Move RESET vector to WDT vector uint16_t vect = buff[0] | (buff[1]<<8); - be: 80 91 00 01 lds r24, 0x0100 - c2: 20 91 01 01 lds r18, 0x0101 - c6: 30 e0 ldi r19, 0x00 ; 0 - c8: 32 2f mov r19, r18 - ca: 22 27 eor r18, r18 - cc: 90 e0 ldi r25, 0x00 ; 0 - ce: 28 2b or r18, r24 - d0: 39 2b or r19, r25 + 1dbe: 80 91 00 01 lds r24, 0x0100 + 1dc2: 20 91 01 01 lds r18, 0x0101 + 1dc6: 30 e0 ldi r19, 0x00 ; 0 + 1dc8: 32 2f mov r19, r18 + 1dca: 22 27 eor r18, r18 + 1dcc: 90 e0 ldi r25, 0x00 ; 0 + 1dce: 28 2b or r18, r24 + 1dd0: 39 2b or r19, r25 rstVect = vect; - d2: 30 93 85 01 sts 0x0185, r19 - d6: 20 93 84 01 sts 0x0184, r18 + 1dd2: 30 93 85 01 sts 0x0185, r19 + 1dd6: 20 93 84 01 sts 0x0184, r18 wdtVect = buff[8] | (buff[9]<<8); - da: 40 91 08 01 lds r20, 0x0108 - de: 80 91 09 01 lds r24, 0x0109 - e2: 90 e0 ldi r25, 0x00 ; 0 - e4: 98 2f mov r25, r24 - e6: 88 27 eor r24, r24 - e8: 50 e0 ldi r21, 0x00 ; 0 - ea: 84 2b or r24, r20 - ec: 95 2b or r25, r21 - ee: 90 93 87 01 sts 0x0187, r25 - f2: 80 93 86 01 sts 0x0186, r24 + 1dda: 40 91 08 01 lds r20, 0x0108 + 1dde: 80 91 09 01 lds r24, 0x0109 + 1de2: 90 e0 ldi r25, 0x00 ; 0 + 1de4: 98 2f mov r25, r24 + 1de6: 88 27 eor r24, r24 + 1de8: 50 e0 ldi r21, 0x00 ; 0 + 1dea: 84 2b or r24, r20 + 1dec: 95 2b or r25, r21 + 1dee: 90 93 87 01 sts 0x0187, r25 + 1df2: 80 93 86 01 sts 0x0186, r24 vect -= 4; // Instruction is a relative jump (rjmp), so recalculate. - f6: 24 50 subi r18, 0x04 ; 4 - f8: 30 40 sbci r19, 0x00 ; 0 + 1df6: 24 50 subi r18, 0x04 ; 4 + 1df8: 30 40 sbci r19, 0x00 ; 0 buff[8] = vect & 0xff; - fa: 20 93 08 01 sts 0x0108, r18 + 1dfa: 20 93 08 01 sts 0x0108, r18 buff[9] = vect >> 8; - fe: 23 2f mov r18, r19 - 100: 33 27 eor r19, r19 - 102: 20 93 09 01 sts 0x0109, r18 + 1dfe: 23 2f mov r18, r19 + 1e00: 33 27 eor r19, r19 + 1e02: 20 93 09 01 sts 0x0109, r18 // Add jump to bootloader at RESET vector buff[0] = 0x7f; - 106: d0 92 00 01 sts 0x0100, r13 + 1e06: d0 92 00 01 sts 0x0100, r13 buff[1] = 0xce; // rjmp 0x1d00 instruction - 10a: c0 92 01 01 sts 0x0101, r12 - 10e: 40 e0 ldi r20, 0x00 ; 0 - 110: 50 e0 ldi r21, 0x00 ; 0 - 112: a0 e0 ldi r26, 0x00 ; 0 - 114: b1 e0 ldi r27, 0x01 ; 1 + 1e0a: c0 92 01 01 sts 0x0101, r12 + 1e0e: 40 e0 ldi r20, 0x00 ; 0 + 1e10: 50 e0 ldi r21, 0x00 ; 0 + 1e12: a0 e0 ldi r26, 0x00 ; 0 + 1e14: b1 e0 ldi r27, 0x01 ; 1 bufPtr = buff; addrPtr = (uint16_t)(void*)address; ch = SPM_PAGESIZE / 2; do { uint16_t a; a = *bufPtr++; - 116: 2c 91 ld r18, X - 118: 30 e0 ldi r19, 0x00 ; 0 + 1e16: 2c 91 ld r18, X + 1e18: 30 e0 ldi r19, 0x00 ; 0 a |= (*bufPtr++) << 8; - 11a: 11 96 adiw r26, 0x01 ; 1 - 11c: 8c 91 ld r24, X - 11e: 11 97 sbiw r26, 0x01 ; 1 - 120: 90 e0 ldi r25, 0x00 ; 0 - 122: 98 2f mov r25, r24 - 124: 88 27 eor r24, r24 - 126: 82 2b or r24, r18 - 128: 93 2b or r25, r19 + 1e1a: 11 96 adiw r26, 0x01 ; 1 + 1e1c: 8c 91 ld r24, X + 1e1e: 11 97 sbiw r26, 0x01 ; 1 + 1e20: 90 e0 ldi r25, 0x00 ; 0 + 1e22: 98 2f mov r25, r24 + 1e24: 88 27 eor r24, r24 + 1e26: 82 2b or r24, r18 + 1e28: 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) { - 12a: 12 96 adiw r26, 0x02 ; 2 + 1e2a: 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); - 12c: fa 01 movw r30, r20 - 12e: 0c 01 movw r0, r24 - 130: b7 be out 0x37, r11 ; 55 - 132: e8 95 spm - 134: 11 24 eor r1, r1 + 1e2c: fa 01 movw r30, r20 + 1e2e: 0c 01 movw r0, r24 + 1e30: b7 be out 0x37, r11 ; 55 + 1e32: e8 95 spm + 1e34: 11 24 eor r1, r1 addrPtr += 2; - 136: 4e 5f subi r20, 0xFE ; 254 - 138: 5f 4f sbci r21, 0xFF ; 255 + 1e36: 4e 5f subi r20, 0xFE ; 254 + 1e38: 5f 4f sbci r21, 0xFF ; 255 } while (--ch); - 13a: f1 e0 ldi r31, 0x01 ; 1 - 13c: a0 34 cpi r26, 0x40 ; 64 - 13e: bf 07 cpc r27, r31 - 140: 51 f7 brne .-44 ; 0x116 <__SREG__+0xd7> + 1e3a: f1 e0 ldi r31, 0x01 ; 1 + 1e3c: a0 34 cpi r26, 0x40 ; 64 + 1e3e: bf 07 cpc r27, r31 + 1e40: 51 f7 brne .-44 ; 0x1e16 // Write from programming buffer __boot_page_write_short((uint16_t)(void*)address); - 142: f8 01 movw r30, r16 - 144: a7 be out 0x37, r10 ; 55 - 146: e8 95 spm + 1e42: f8 01 movw r30, r16 + 1e44: a7 be out 0x37, r10 ; 55 + 1e46: e8 95 spm boot_spm_busy_wait(); - 148: 07 b6 in r0, 0x37 ; 55 - 14a: 00 fc sbrc r0, 0 - 14c: fd cf rjmp .-6 ; 0x148 <__SREG__+0x109> - 14e: 3b c0 rjmp .+118 ; 0x1c6 <__SREG__+0x187> + 1e48: 07 b6 in r0, 0x37 ; 55 + 1e4a: 00 fc sbrc r0, 0 + 1e4c: fd cf rjmp .-6 ; 0x1e48 + 1e4e: 3b c0 rjmp .+118 ; 0x1ec6 boot_rww_enable(); #endif } /* Read memory block mode, length is big endian. */ else if(ch == STK_READ_PAGE) { - 150: 84 37 cpi r24, 0x74 ; 116 - 152: 51 f5 brne .+84 ; 0x1a8 <__SREG__+0x169> + 1e50: 84 37 cpi r24, 0x74 ; 116 + 1e52: 51 f5 brne .+84 ; 0x1ea8 // READ PAGE - we only read flash getch(); /* getlen() */ - 154: 4a d0 rcall .+148 ; 0x1ea + 1e54: 4a d0 rcall .+148 ; 0x1eea length = getch(); - 156: 49 d0 rcall .+146 ; 0x1ea - 158: f8 2e mov r15, r24 + 1e56: 49 d0 rcall .+146 ; 0x1eea + 1e58: f8 2e mov r15, r24 getch(); - 15a: 47 d0 rcall .+142 ; 0x1ea + 1e5a: 47 d0 rcall .+142 ; 0x1eea verifySpace(); - 15c: 5e d0 rcall .+188 ; 0x21a - 15e: e8 01 movw r28, r16 - 160: ef 2c mov r14, r15 + 1e5c: 5e d0 rcall .+188 ; 0x1f1a + 1e5e: e8 01 movw r28, r16 + 1e60: ef 2c mov r14, r15 #ifdef VIRTUAL_BOOT_PARTITION do { // Undo vector patch in bottom page so verify passes if (address == 0) ch=rstVect & 0xff; - 162: 20 97 sbiw r28, 0x00 ; 0 - 164: 19 f4 brne .+6 ; 0x16c <__SREG__+0x12d> - 166: 80 91 84 01 lds r24, 0x0184 - 16a: 14 c0 rjmp .+40 ; 0x194 <__SREG__+0x155> + 1e62: 20 97 sbiw r28, 0x00 ; 0 + 1e64: 19 f4 brne .+6 ; 0x1e6c + 1e66: 80 91 84 01 lds r24, 0x0184 + 1e6a: 14 c0 rjmp .+40 ; 0x1e94 else if (address == 1) ch=rstVect >> 8; - 16c: c1 30 cpi r28, 0x01 ; 1 - 16e: d1 05 cpc r29, r1 - 170: 19 f4 brne .+6 ; 0x178 <__SREG__+0x139> - 172: 80 91 85 01 lds r24, 0x0185 - 176: 0e c0 rjmp .+28 ; 0x194 <__SREG__+0x155> + 1e6c: c1 30 cpi r28, 0x01 ; 1 + 1e6e: d1 05 cpc r29, r1 + 1e70: 19 f4 brne .+6 ; 0x1e78 + 1e72: 80 91 85 01 lds r24, 0x0185 + 1e76: 0e c0 rjmp .+28 ; 0x1e94 else if (address == 8) ch=wdtVect & 0xff; - 178: c8 30 cpi r28, 0x08 ; 8 - 17a: d1 05 cpc r29, r1 - 17c: 19 f4 brne .+6 ; 0x184 <__SREG__+0x145> - 17e: 80 91 86 01 lds r24, 0x0186 - 182: 08 c0 rjmp .+16 ; 0x194 <__SREG__+0x155> + 1e78: c8 30 cpi r28, 0x08 ; 8 + 1e7a: d1 05 cpc r29, r1 + 1e7c: 19 f4 brne .+6 ; 0x1e84 + 1e7e: 80 91 86 01 lds r24, 0x0186 + 1e82: 08 c0 rjmp .+16 ; 0x1e94 else if (address == 9) ch=wdtVect >> 8; - 184: c9 30 cpi r28, 0x09 ; 9 - 186: d1 05 cpc r29, r1 - 188: 19 f4 brne .+6 ; 0x190 <__SREG__+0x151> - 18a: 80 91 87 01 lds r24, 0x0187 - 18e: 02 c0 rjmp .+4 ; 0x194 <__SREG__+0x155> + 1e84: c9 30 cpi r28, 0x09 ; 9 + 1e86: d1 05 cpc r29, r1 + 1e88: 19 f4 brne .+6 ; 0x1e90 + 1e8a: 80 91 87 01 lds r24, 0x0187 + 1e8e: 02 c0 rjmp .+4 ; 0x1e94 else ch = pgm_read_byte_near(address); - 190: fe 01 movw r30, r28 - 192: 84 91 lpm r24, Z+ + 1e90: fe 01 movw r30, r28 + 1e92: 84 91 lpm r24, Z+ address++; - 194: 21 96 adiw r28, 0x01 ; 1 + 1e94: 21 96 adiw r28, 0x01 ; 1 putch(ch); - 196: 1a d0 rcall .+52 ; 0x1cc + 1e96: 1a d0 rcall .+52 ; 0x1ecc } while (--length); - 198: ea 94 dec r14 - 19a: 19 f7 brne .-58 ; 0x162 <__SREG__+0x123> + 1e98: ea 94 dec r14 + 1e9a: 19 f7 brne .-58 ; 0x1e62 #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) { - 19c: 0f 5f subi r16, 0xFF ; 255 - 19e: 1f 4f sbci r17, 0xFF ; 255 - 1a0: fa 94 dec r15 - 1a2: 0f 0d add r16, r15 - 1a4: 11 1d adc r17, r1 - 1a6: 0f c0 rjmp .+30 ; 0x1c6 <__SREG__+0x187> + 1e9c: 0f 5f subi r16, 0xFF ; 255 + 1e9e: 1f 4f sbci r17, 0xFF ; 255 + 1ea0: fa 94 dec r15 + 1ea2: 0f 0d add r16, r15 + 1ea4: 11 1d adc r17, r1 + 1ea6: 0f c0 rjmp .+30 ; 0x1ec6 #endif #endif } /* Get device signature bytes */ else if(ch == STK_READ_SIGN) { - 1a8: 85 37 cpi r24, 0x75 ; 117 - 1aa: 41 f4 brne .+16 ; 0x1bc <__SREG__+0x17d> + 1ea8: 85 37 cpi r24, 0x75 ; 117 + 1eaa: 41 f4 brne .+16 ; 0x1ebc // READ SIGN - return what Avrdude wants to hear verifySpace(); - 1ac: 36 d0 rcall .+108 ; 0x21a + 1eac: 36 d0 rcall .+108 ; 0x1f1a putch(SIGNATURE_0); - 1ae: 8e e1 ldi r24, 0x1E ; 30 - 1b0: 0d d0 rcall .+26 ; 0x1cc + 1eae: 8e e1 ldi r24, 0x1E ; 30 + 1eb0: 0d d0 rcall .+26 ; 0x1ecc putch(SIGNATURE_1); - 1b2: 83 e9 ldi r24, 0x93 ; 147 - 1b4: 0b d0 rcall .+22 ; 0x1cc + 1eb2: 83 e9 ldi r24, 0x93 ; 147 + 1eb4: 0b d0 rcall .+22 ; 0x1ecc putch(SIGNATURE_2); - 1b6: 8c e0 ldi r24, 0x0C ; 12 - 1b8: 09 d0 rcall .+18 ; 0x1cc - 1ba: 05 c0 rjmp .+10 ; 0x1c6 <__SREG__+0x187> + 1eb6: 8c e0 ldi r24, 0x0C ; 12 + 1eb8: 09 d0 rcall .+18 ; 0x1ecc + 1eba: 05 c0 rjmp .+10 ; 0x1ec6 } else if (ch == 'Q') { - 1bc: 81 35 cpi r24, 0x51 ; 81 - 1be: 11 f4 brne .+4 ; 0x1c4 <__SREG__+0x185> + 1ebc: 81 35 cpi r24, 0x51 ; 81 + 1ebe: 11 f4 brne .+4 ; 0x1ec4 // Adaboot no-wait mod watchdogConfig(WATCHDOG_16MS); - 1c0: 88 e0 ldi r24, 0x08 ; 8 - 1c2: 27 d0 rcall .+78 ; 0x212 + 1ec0: 88 e0 ldi r24, 0x08 ; 8 + 1ec2: 27 d0 rcall .+78 ; 0x1f12 verifySpace(); } else { // This covers the response to commands like STK_ENTER_PROGMODE verifySpace(); - 1c4: 2a d0 rcall .+84 ; 0x21a + 1ec4: 2a d0 rcall .+84 ; 0x1f1a } putch(STK_OK); - 1c6: 80 e1 ldi r24, 0x10 ; 16 - 1c8: 01 d0 rcall .+2 ; 0x1cc - 1ca: 3a cf rjmp .-396 ; 0x40 <__SREG__+0x1> + 1ec6: 80 e1 ldi r24, 0x10 ; 16 + 1ec8: 01 d0 rcall .+2 ; 0x1ecc + 1eca: 3a cf rjmp .-396 ; 0x1d40 -000001cc : +00001ecc : void putch(char ch) { #ifndef SOFT_UART while (!(UCSR0A & _BV(UDRE0))); UDR0 = ch; #else __asm__ __volatile__ ( - 1cc: 2a e0 ldi r18, 0x0A ; 10 - 1ce: 30 e0 ldi r19, 0x00 ; 0 - 1d0: 80 95 com r24 - 1d2: 08 94 sec - 1d4: 10 f4 brcc .+4 ; 0x1da - 1d6: da 98 cbi 0x1b, 2 ; 27 - 1d8: 02 c0 rjmp .+4 ; 0x1de - 1da: da 9a sbi 0x1b, 2 ; 27 - 1dc: 00 00 nop - 1de: 15 d0 rcall .+42 ; 0x20a - 1e0: 14 d0 rcall .+40 ; 0x20a - 1e2: 86 95 lsr r24 - 1e4: 2a 95 dec r18 - 1e6: b1 f7 brne .-20 ; 0x1d4 + 1ecc: 2a e0 ldi r18, 0x0A ; 10 + 1ece: 30 e0 ldi r19, 0x00 ; 0 + 1ed0: 80 95 com r24 + 1ed2: 08 94 sec + 1ed4: 10 f4 brcc .+4 ; 0x1eda + 1ed6: da 98 cbi 0x1b, 2 ; 27 + 1ed8: 02 c0 rjmp .+4 ; 0x1ede + 1eda: da 9a sbi 0x1b, 2 ; 27 + 1edc: 00 00 nop + 1ede: 15 d0 rcall .+42 ; 0x1f0a + 1ee0: 14 d0 rcall .+40 ; 0x1f0a + 1ee2: 86 95 lsr r24 + 1ee4: 2a 95 dec r18 + 1ee6: b1 f7 brne .-20 ; 0x1ed4 [uartBit] "I" (UART_TX_BIT) : "r25" ); #endif } - 1e8: 08 95 ret + 1ee8: 08 95 ret -000001ea : +00001eea : } #endif // Watchdog functions. These are only safe with interrupts turned off. void watchdogReset() { __asm__ __volatile__ ( - 1ea: a8 95 wdr + 1eea: a8 95 wdr LED_PIN |= _BV(LED); #endif #endif return ch; } - 1ec: 29 e0 ldi r18, 0x09 ; 9 - 1ee: 30 e0 ldi r19, 0x00 ; 0 - 1f0: cb 99 sbic 0x19, 3 ; 25 - 1f2: fe cf rjmp .-4 ; 0x1f0 - 1f4: 0a d0 rcall .+20 ; 0x20a - 1f6: 09 d0 rcall .+18 ; 0x20a - 1f8: 08 d0 rcall .+16 ; 0x20a - 1fa: 88 94 clc - 1fc: cb 99 sbic 0x19, 3 ; 25 - 1fe: 08 94 sec - 200: 2a 95 dec r18 - 202: 11 f0 breq .+4 ; 0x208 - 204: 87 95 ror r24 - 206: f7 cf rjmp .-18 ; 0x1f6 - 208: 08 95 ret - -0000020a : + 1eec: 29 e0 ldi r18, 0x09 ; 9 + 1eee: 30 e0 ldi r19, 0x00 ; 0 + 1ef0: cb 99 sbic 0x19, 3 ; 25 + 1ef2: fe cf rjmp .-4 ; 0x1ef0 + 1ef4: 0a d0 rcall .+20 ; 0x1f0a + 1ef6: 09 d0 rcall .+18 ; 0x1f0a + 1ef8: 08 d0 rcall .+16 ; 0x1f0a + 1efa: 88 94 clc + 1efc: cb 99 sbic 0x19, 3 ; 25 + 1efe: 08 94 sec + 1f00: 2a 95 dec r18 + 1f02: 11 f0 breq .+4 ; 0x1f08 + 1f04: 87 95 ror r24 + 1f06: f7 cf rjmp .-18 ; 0x1ef6 + 1f08: 08 95 ret + +00001f0a : #if UART_B_VALUE > 255 #error Baud rate too slow for soft UART #endif void uartDelay() { __asm__ __volatile__ ( - 20a: 9e e0 ldi r25, 0x0E ; 14 - 20c: 9a 95 dec r25 - 20e: f1 f7 brne .-4 ; 0x20c - 210: 08 95 ret + 1f0a: 9e e0 ldi r25, 0x0E ; 14 + 1f0c: 9a 95 dec r25 + 1f0e: f1 f7 brne .-4 ; 0x1f0c + 1f10: 08 95 ret -00000212 : +00001f12 : "wdr\n" ); } void watchdogConfig(uint8_t x) { WDTCSR = _BV(WDCE) | _BV(WDE); - 212: 98 e1 ldi r25, 0x18 ; 24 - 214: 91 bd out 0x21, r25 ; 33 + 1f12: 98 e1 ldi r25, 0x18 ; 24 + 1f14: 91 bd out 0x21, r25 ; 33 WDTCSR = x; - 216: 81 bd out 0x21, r24 ; 33 + 1f16: 81 bd out 0x21, r24 ; 33 } - 218: 08 95 ret + 1f18: 08 95 ret -0000021a : +00001f1a : do getch(); while (--count); verifySpace(); } void verifySpace() { if (getch() != CRC_EOP) { - 21a: e7 df rcall .-50 ; 0x1ea - 21c: 80 32 cpi r24, 0x20 ; 32 - 21e: 19 f0 breq .+6 ; 0x226 + 1f1a: e7 df rcall .-50 ; 0x1eea + 1f1c: 80 32 cpi r24, 0x20 ; 32 + 1f1e: 19 f0 breq .+6 ; 0x1f26 watchdogConfig(WATCHDOG_16MS); // shorten WD timeout - 220: 88 e0 ldi r24, 0x08 ; 8 - 222: f7 df rcall .-18 ; 0x212 - 224: ff cf rjmp .-2 ; 0x224 + 1f20: 88 e0 ldi r24, 0x08 ; 8 + 1f22: f7 df rcall .-18 ; 0x1f12 + 1f24: ff cf rjmp .-2 ; 0x1f24 while (1) // and busy-loop so that WD causes ; // a reset and app start. } putch(STK_INSYNC); - 226: 84 e1 ldi r24, 0x14 ; 20 + 1f26: 84 e1 ldi r24, 0x14 ; 20 } - 228: d1 cf rjmp .-94 ; 0x1cc + 1f28: d1 cf rjmp .-94 ; 0x1ecc -0000022a : +00001f2a : ::[count] "M" (UART_B_VALUE) ); } #endif void getNch(uint8_t count) { - 22a: 1f 93 push r17 - 22c: 18 2f mov r17, r24 + 1f2a: 1f 93 push r17 + 1f2c: 18 2f mov r17, r24 do getch(); while (--count); - 22e: dd df rcall .-70 ; 0x1ea - 230: 11 50 subi r17, 0x01 ; 1 - 232: e9 f7 brne .-6 ; 0x22e + 1f2e: dd df rcall .-70 ; 0x1eea + 1f30: 11 50 subi r17, 0x01 ; 1 + 1f32: e9 f7 brne .-6 ; 0x1f2e verifySpace(); - 234: f2 df rcall .-28 ; 0x21a + 1f34: f2 df rcall .-28 ; 0x1f1a } - 236: 1f 91 pop r17 - 238: 08 95 ret + 1f36: 1f 91 pop r17 + 1f38: 08 95 ret -0000023a : +00001f3a : WDTCSR = _BV(WDCE) | _BV(WDE); WDTCSR = x; } void appStart() { watchdogConfig(WATCHDOG_OFF); - 23a: 80 e0 ldi r24, 0x00 ; 0 - 23c: ea df rcall .-44 ; 0x212 + 1f3a: 80 e0 ldi r24, 0x00 ; 0 + 1f3c: ea df rcall .-44 ; 0x1f12 __asm__ __volatile__ ( - 23e: e4 e0 ldi r30, 0x04 ; 4 - 240: ff 27 eor r31, r31 - 242: 09 94 ijmp + 1f3e: e4 e0 ldi r30, 0x04 ; 4 + 1f40: ff 27 eor r31, r31 + 1f42: 09 94 ijmp -- 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_luminet.lst | 153 ++++++++++++++---------------- 1 file changed, 73 insertions(+), 80 deletions(-) (limited to 'bootloaders/optiboot/optiboot_luminet.lst') diff --git a/bootloaders/optiboot/optiboot_luminet.lst b/bootloaders/optiboot/optiboot_luminet.lst index 447349d..e40e0ef 100644 --- a/bootloaders/optiboot/optiboot_luminet.lst +++ b/bootloaders/optiboot/optiboot_luminet.lst @@ -3,27 +3,27 @@ optiboot_luminet.elf: file format elf32-avr Sections: Idx Name Size VMA LMA File off Algn - 0 .text 00000244 00001d00 00001d00 00000054 2**1 + 0 .text 00000242 00001d00 00001d00 00000054 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE - 1 .version 00000002 00001efe 00001efe 00000298 2**0 + 1 .version 00000002 00001efe 00001efe 00000296 2**0 CONTENTS, READONLY - 2 .debug_aranges 00000028 00000000 00000000 0000029a 2**0 + 2 .debug_aranges 00000028 00000000 00000000 00000298 2**0 CONTENTS, READONLY, DEBUGGING - 3 .debug_pubnames 0000006d 00000000 00000000 000002c2 2**0 + 3 .debug_pubnames 0000006d 00000000 00000000 000002c0 2**0 CONTENTS, READONLY, DEBUGGING - 4 .debug_info 000002b1 00000000 00000000 0000032f 2**0 + 4 .debug_info 000002a2 00000000 00000000 0000032d 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_abbrev 00000188 00000000 00000000 000005e0 2**0 + 5 .debug_abbrev 0000016f 00000000 00000000 000005cf 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_line 000004a7 00000000 00000000 00000768 2**0 + 6 .debug_line 0000049d 00000000 00000000 0000073e 2**0 CONTENTS, READONLY, DEBUGGING - 7 .debug_frame 00000090 00000000 00000000 00000c10 2**2 + 7 .debug_frame 00000090 00000000 00000000 00000bdc 2**2 CONTENTS, READONLY, DEBUGGING - 8 .debug_str 00000158 00000000 00000000 00000ca0 2**0 + 8 .debug_str 00000158 00000000 00000000 00000c6c 2**0 CONTENTS, READONLY, DEBUGGING - 9 .debug_loc 00000268 00000000 00000000 00000df8 2**0 + 9 .debug_loc 00000268 00000000 00000000 00000dc4 2**0 CONTENTS, READONLY, DEBUGGING - 10 .debug_ranges 00000080 00000000 00000000 00001060 2**0 + 10 .debug_ranges 00000080 00000000 00000000 0000102c 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: @@ -47,7 +47,7 @@ int main(void) { 1d04: 14 be out 0x34, r1 ; 52 if (!(ch & _BV(EXTRF))) appStart(); 1d06: 81 ff sbrs r24, 1 - 1d08: 18 d1 rcall .+560 ; 0x1f3a + 1d08: 17 d1 rcall .+558 ; 0x1f38 #if LED_START_FLASHES > 0 // Set up Timer 1 for timeout counter @@ -61,7 +61,7 @@ int main(void) { // Set up watchdog to trigger after 500ms watchdogConfig(WATCHDOG_1S); 1d0e: 8e e0 ldi r24, 0x0E ; 14 - 1d10: 00 d1 rcall .+512 ; 0x1f12 + 1d10: ff d0 rcall .+510 ; 0x1f10 /* Set LED pin as output */ LED_DDR |= _BV(LED); @@ -156,7 +156,7 @@ void watchdogReset() { // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy getNch(1); 1d46: 81 e0 ldi r24, 0x01 ; 1 - 1d48: f0 d0 rcall .+480 ; 0x1f2a + 1d48: ef d0 rcall .+478 ; 0x1f28 putch(0x03); 1d4a: 83 e0 ldi r24, 0x03 ; 3 1d4c: b5 c0 rjmp .+362 ; 0x1eb8 @@ -175,7 +175,7 @@ void watchdogReset() { // SET DEVICE EXT is ignored getNch(5); 1d5a: 85 e0 ldi r24, 0x05 ; 5 - 1d5c: e6 d0 rcall .+460 ; 0x1f2a + 1d5c: e5 d0 rcall .+458 ; 0x1f28 1d5e: b3 c0 rjmp .+358 ; 0x1ec6 } else if(ch == STK_LOAD_ADDRESS) { @@ -212,7 +212,7 @@ void watchdogReset() { // UNIVERSAL command is ignored getNch(4); 1d82: 84 e0 ldi r24, 0x04 ; 4 - 1d84: d2 d0 rcall .+420 ; 0x1f2a + 1d84: d1 d0 rcall .+418 ; 0x1f28 putch(0x00); 1d86: 80 e0 ldi r24, 0x00 ; 0 1d88: 97 c0 rjmp .+302 ; 0x1eb8 @@ -257,7 +257,7 @@ void watchdogReset() { // Read command terminator, start reply verifySpace(); - 1dac: b6 d0 rcall .+364 ; 0x1f1a + 1dac: b5 d0 rcall .+362 ; 0x1f18 // If only a partial page is to be programmed, the erase might not be complete. // So check that here @@ -391,7 +391,7 @@ int main(void) { 1e5a: 47 d0 rcall .+142 ; 0x1eea verifySpace(); - 1e5c: 5e d0 rcall .+188 ; 0x1f1a + 1e5c: 5d d0 rcall .+186 ; 0x1f18 1e5e: e8 01 movw r28, r16 1e60: ef 2c mov r14, r15 #ifdef VIRTUAL_BOOT_PARTITION @@ -452,7 +452,7 @@ int main(void) { 1eaa: 41 f4 brne .+16 ; 0x1ebc // READ SIGN - return what Avrdude wants to hear verifySpace(); - 1eac: 36 d0 rcall .+108 ; 0x1f1a + 1eac: 35 d0 rcall .+106 ; 0x1f18 putch(SIGNATURE_0); 1eae: 8e e1 ldi r24, 0x1E ; 30 1eb0: 0d d0 rcall .+26 ; 0x1ecc @@ -470,13 +470,13 @@ int main(void) { // Adaboot no-wait mod watchdogConfig(WATCHDOG_16MS); 1ec0: 88 e0 ldi r24, 0x08 ; 8 - 1ec2: 27 d0 rcall .+78 ; 0x1f12 + 1ec2: 26 d0 rcall .+76 ; 0x1f10 verifySpace(); } else { // This covers the response to commands like STK_ENTER_PROGMODE verifySpace(); - 1ec4: 2a d0 rcall .+84 ; 0x1f1a + 1ec4: 29 d0 rcall .+82 ; 0x1f18 } putch(STK_OK); 1ec6: 80 e1 ldi r24, 0x10 ; 16 @@ -499,8 +499,8 @@ void putch(char ch) { 1ed8: 02 c0 rjmp .+4 ; 0x1ede 1eda: da 9a sbi 0x1b, 2 ; 27 1edc: 00 00 nop - 1ede: 15 d0 rcall .+42 ; 0x1f0a - 1ee0: 14 d0 rcall .+40 ; 0x1f0a + 1ede: 14 d0 rcall .+40 ; 0x1f08 + 1ee0: 13 d0 rcall .+38 ; 0x1f08 1ee2: 86 95 lsr r24 1ee4: 2a 95 dec r18 1ee6: b1 f7 brne .-20 ; 0x1ed4 @@ -513,112 +513,105 @@ void putch(char ch) { 1ee8: 08 95 ret 00001eea : -} -#endif - -// Watchdog functions. These are only safe with interrupts turned off. -void watchdogReset() { - __asm__ __volatile__ ( - 1eea: a8 95 wdr LED_PIN |= _BV(LED); #endif #endif return ch; } - 1eec: 29 e0 ldi r18, 0x09 ; 9 - 1eee: 30 e0 ldi r19, 0x00 ; 0 - 1ef0: cb 99 sbic 0x19, 3 ; 25 - 1ef2: fe cf rjmp .-4 ; 0x1ef0 - 1ef4: 0a d0 rcall .+20 ; 0x1f0a - 1ef6: 09 d0 rcall .+18 ; 0x1f0a - 1ef8: 08 d0 rcall .+16 ; 0x1f0a - 1efa: 88 94 clc - 1efc: cb 99 sbic 0x19, 3 ; 25 - 1efe: 08 94 sec - 1f00: 2a 95 dec r18 - 1f02: 11 f0 breq .+4 ; 0x1f08 - 1f04: 87 95 ror r24 - 1f06: f7 cf rjmp .-18 ; 0x1ef6 - 1f08: 08 95 ret - -00001f0a : + 1eea: 29 e0 ldi r18, 0x09 ; 9 + 1eec: 30 e0 ldi r19, 0x00 ; 0 + 1eee: cb 99 sbic 0x19, 3 ; 25 + 1ef0: fe cf rjmp .-4 ; 0x1eee + 1ef2: 0a d0 rcall .+20 ; 0x1f08 + 1ef4: 09 d0 rcall .+18 ; 0x1f08 + 1ef6: 08 d0 rcall .+16 ; 0x1f08 + 1ef8: 88 94 clc + 1efa: cb 99 sbic 0x19, 3 ; 25 + 1efc: 08 94 sec + 1efe: 2a 95 dec r18 + 1f00: 11 f0 breq .+4 ; 0x1f06 + 1f02: 87 95 ror r24 + 1f04: f7 cf rjmp .-18 ; 0x1ef4 + 1f06: 08 95 ret + +00001f08 : #if UART_B_VALUE > 255 #error Baud rate too slow for soft UART #endif void uartDelay() { __asm__ __volatile__ ( - 1f0a: 9e e0 ldi r25, 0x0E ; 14 - 1f0c: 9a 95 dec r25 - 1f0e: f1 f7 brne .-4 ; 0x1f0c - 1f10: 08 95 ret + 1f08: 9e e0 ldi r25, 0x0E ; 14 + 1f0a: 9a 95 dec r25 + 1f0c: f1 f7 brne .-4 ; 0x1f0a + 1f0e: 08 95 ret -00001f12 : +00001f10 : "wdr\n" ); } void watchdogConfig(uint8_t x) { WDTCSR = _BV(WDCE) | _BV(WDE); - 1f12: 98 e1 ldi r25, 0x18 ; 24 - 1f14: 91 bd out 0x21, r25 ; 33 + 1f10: 98 e1 ldi r25, 0x18 ; 24 + 1f12: 91 bd out 0x21, r25 ; 33 WDTCSR = x; - 1f16: 81 bd out 0x21, r24 ; 33 + 1f14: 81 bd out 0x21, r24 ; 33 } - 1f18: 08 95 ret + 1f16: 08 95 ret -00001f1a : +00001f18 : do getch(); while (--count); verifySpace(); } void verifySpace() { if (getch() != CRC_EOP) { - 1f1a: e7 df rcall .-50 ; 0x1eea - 1f1c: 80 32 cpi r24, 0x20 ; 32 - 1f1e: 19 f0 breq .+6 ; 0x1f26 + 1f18: e8 df rcall .-48 ; 0x1eea + 1f1a: 80 32 cpi r24, 0x20 ; 32 + 1f1c: 19 f0 breq .+6 ; 0x1f24 watchdogConfig(WATCHDOG_16MS); // shorten WD timeout - 1f20: 88 e0 ldi r24, 0x08 ; 8 - 1f22: f7 df rcall .-18 ; 0x1f12 - 1f24: ff cf rjmp .-2 ; 0x1f24 + 1f1e: 88 e0 ldi r24, 0x08 ; 8 + 1f20: f7 df rcall .-18 ; 0x1f10 + 1f22: ff cf rjmp .-2 ; 0x1f22 while (1) // and busy-loop so that WD causes ; // a reset and app start. } putch(STK_INSYNC); - 1f26: 84 e1 ldi r24, 0x14 ; 20 + 1f24: 84 e1 ldi r24, 0x14 ; 20 } - 1f28: d1 cf rjmp .-94 ; 0x1ecc + 1f26: d2 cf rjmp .-92 ; 0x1ecc -00001f2a : +00001f28 : ::[count] "M" (UART_B_VALUE) ); } #endif void getNch(uint8_t count) { - 1f2a: 1f 93 push r17 - 1f2c: 18 2f mov r17, r24 + 1f28: 1f 93 push r17 + 1f2a: 18 2f mov r17, r24 do getch(); while (--count); - 1f2e: dd df rcall .-70 ; 0x1eea - 1f30: 11 50 subi r17, 0x01 ; 1 - 1f32: e9 f7 brne .-6 ; 0x1f2e + 1f2c: de df rcall .-68 ; 0x1eea + 1f2e: 11 50 subi r17, 0x01 ; 1 + 1f30: e9 f7 brne .-6 ; 0x1f2c verifySpace(); - 1f34: f2 df rcall .-28 ; 0x1f1a + 1f32: f2 df rcall .-28 ; 0x1f18 } - 1f36: 1f 91 pop r17 - 1f38: 08 95 ret + 1f34: 1f 91 pop r17 + 1f36: 08 95 ret -00001f3a : +00001f38 : WDTCSR = _BV(WDCE) | _BV(WDE); WDTCSR = x; } void appStart() { watchdogConfig(WATCHDOG_OFF); - 1f3a: 80 e0 ldi r24, 0x00 ; 0 - 1f3c: ea df rcall .-44 ; 0x1f12 + 1f38: 80 e0 ldi r24, 0x00 ; 0 + 1f3a: ea df rcall .-44 ; 0x1f10 __asm__ __volatile__ ( - 1f3e: e4 e0 ldi r30, 0x04 ; 4 - 1f40: ff 27 eor r31, r31 - 1f42: 09 94 ijmp + 1f3c: e4 e0 ldi r30, 0x04 ; 4 + 1f3e: ff 27 eor r31, r31 + 1f40: 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_luminet.lst | 617 ------------------------------ 1 file changed, 617 deletions(-) delete mode 100644 bootloaders/optiboot/optiboot_luminet.lst (limited to 'bootloaders/optiboot/optiboot_luminet.lst') diff --git a/bootloaders/optiboot/optiboot_luminet.lst b/bootloaders/optiboot/optiboot_luminet.lst deleted file mode 100644 index e40e0ef..0000000 --- a/bootloaders/optiboot/optiboot_luminet.lst +++ /dev/null @@ -1,617 +0,0 @@ - -optiboot_luminet.elf: file format elf32-avr - -Sections: -Idx Name Size VMA LMA File off Algn - 0 .text 00000242 00001d00 00001d00 00000054 2**1 - CONTENTS, ALLOC, LOAD, READONLY, CODE - 1 .version 00000002 00001efe 00001efe 00000296 2**0 - CONTENTS, READONLY - 2 .debug_aranges 00000028 00000000 00000000 00000298 2**0 - CONTENTS, READONLY, DEBUGGING - 3 .debug_pubnames 0000006d 00000000 00000000 000002c0 2**0 - CONTENTS, READONLY, DEBUGGING - 4 .debug_info 000002a2 00000000 00000000 0000032d 2**0 - CONTENTS, READONLY, DEBUGGING - 5 .debug_abbrev 0000016f 00000000 00000000 000005cf 2**0 - CONTENTS, READONLY, DEBUGGING - 6 .debug_line 0000049d 00000000 00000000 0000073e 2**0 - CONTENTS, READONLY, DEBUGGING - 7 .debug_frame 00000090 00000000 00000000 00000bdc 2**2 - CONTENTS, READONLY, DEBUGGING - 8 .debug_str 00000158 00000000 00000000 00000c6c 2**0 - CONTENTS, READONLY, DEBUGGING - 9 .debug_loc 00000268 00000000 00000000 00000dc4 2**0 - CONTENTS, READONLY, DEBUGGING - 10 .debug_ranges 00000080 00000000 00000000 0000102c 2**0 - CONTENTS, READONLY, DEBUGGING - -Disassembly of section .text: - -00001d00
: -#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) { - 1d00: 11 24 eor r1, r1 -#ifdef __AVR_ATmega8__ - SP=RAMEND; // This is done by hardware reset -#endif - - // Adaboot no-wait mod - ch = MCUSR; - 1d02: 84 b7 in r24, 0x34 ; 52 - MCUSR = 0; - 1d04: 14 be out 0x34, r1 ; 52 - if (!(ch & _BV(EXTRF))) appStart(); - 1d06: 81 ff sbrs r24, 1 - 1d08: 17 d1 rcall .+558 ; 0x1f38 - -#if LED_START_FLASHES > 0 - // Set up Timer 1 for timeout counter - TCCR1B = _BV(CS12) | _BV(CS10); // div 1024 - 1d0a: 85 e0 ldi r24, 0x05 ; 5 - 1d0c: 8e bd out 0x2e, r24 ; 46 - UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 ); -#endif -#endif - - // Set up watchdog to trigger after 500ms - watchdogConfig(WATCHDOG_1S); - 1d0e: 8e e0 ldi r24, 0x0E ; 14 - 1d10: ff d0 rcall .+510 ; 0x1f10 - - /* Set LED pin as output */ - LED_DDR |= _BV(LED); - 1d12: d4 9a sbi 0x1a, 4 ; 26 - -#ifdef SOFT_UART - /* Set TX pin as output */ - UART_DDR |= _BV(UART_TX_BIT); - 1d14: d2 9a sbi 0x1a, 2 ; 26 - 1d16: 86 e0 ldi r24, 0x06 ; 6 -} - -#if LED_START_FLASHES > 0 -void flash_led(uint8_t count) { - do { - TCNT1 = -(F_CPU/(1024*16)); - 1d18: 23 ec ldi r18, 0xC3 ; 195 - 1d1a: 3f ef ldi r19, 0xFF ; 255 - TIFR1 = _BV(TOV1); - 1d1c: 91 e0 ldi r25, 0x01 ; 1 -} - -#if LED_START_FLASHES > 0 -void flash_led(uint8_t count) { - do { - TCNT1 = -(F_CPU/(1024*16)); - 1d1e: 3d bd out 0x2d, r19 ; 45 - 1d20: 2c bd out 0x2c, r18 ; 44 - TIFR1 = _BV(TOV1); - 1d22: 9b b9 out 0x0b, r25 ; 11 - while(!(TIFR1 & _BV(TOV1))); - 1d24: 58 9b sbis 0x0b, 0 ; 11 - 1d26: fe cf rjmp .-4 ; 0x1d24 -#ifdef __AVR_ATmega8__ - LED_PORT ^= _BV(LED); -#else - LED_PIN |= _BV(LED); - 1d28: cc 9a sbi 0x19, 4 ; 25 -} -#endif - -// Watchdog functions. These are only safe with interrupts turned off. -void watchdogReset() { - __asm__ __volatile__ ( - 1d2a: a8 95 wdr - LED_PORT ^= _BV(LED); -#else - LED_PIN |= _BV(LED); -#endif - watchdogReset(); - } while (--count); - 1d2c: 81 50 subi r24, 0x01 ; 1 - 1d2e: b9 f7 brne .-18 ; 0x1d1e - /* 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); - 1d30: bb 24 eor r11, r11 - 1d32: b3 94 inc r11 - __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); - 1d34: 25 e0 ldi r18, 0x05 ; 5 - 1d36: a2 2e mov r10, r18 - vect -= 4; // Instruction is a relative jump (rjmp), so recalculate. - buff[8] = vect & 0xff; - buff[9] = vect >> 8; - - // Add jump to bootloader at RESET vector - buff[0] = 0x7f; - 1d38: 9f e7 ldi r25, 0x7F ; 127 - 1d3a: d9 2e mov r13, r25 - buff[1] = 0xce; // rjmp 0x1d00 instruction - 1d3c: 8e ec ldi r24, 0xCE ; 206 - 1d3e: c8 2e mov r12, r24 -#endif - - /* Forever loop */ - for (;;) { - /* get character from UART */ - ch = getch(); - 1d40: d4 d0 rcall .+424 ; 0x1eea - - if(ch == STK_GET_PARAMETER) { - 1d42: 81 34 cpi r24, 0x41 ; 65 - 1d44: 21 f4 brne .+8 ; 0x1d4e - // GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy - getNch(1); - 1d46: 81 e0 ldi r24, 0x01 ; 1 - 1d48: ef d0 rcall .+478 ; 0x1f28 - putch(0x03); - 1d4a: 83 e0 ldi r24, 0x03 ; 3 - 1d4c: b5 c0 rjmp .+362 ; 0x1eb8 - } - else if(ch == STK_SET_DEVICE) { - 1d4e: 82 34 cpi r24, 0x42 ; 66 - 1d50: 11 f4 brne .+4 ; 0x1d56 - // SET DEVICE is ignored - getNch(20); - 1d52: 84 e1 ldi r24, 0x14 ; 20 - 1d54: 03 c0 rjmp .+6 ; 0x1d5c - } - else if(ch == STK_SET_DEVICE_EXT) { - 1d56: 85 34 cpi r24, 0x45 ; 69 - 1d58: 19 f4 brne .+6 ; 0x1d60 - // SET DEVICE EXT is ignored - getNch(5); - 1d5a: 85 e0 ldi r24, 0x05 ; 5 - 1d5c: e5 d0 rcall .+458 ; 0x1f28 - 1d5e: b3 c0 rjmp .+358 ; 0x1ec6 - } - else if(ch == STK_LOAD_ADDRESS) { - 1d60: 85 35 cpi r24, 0x55 ; 85 - 1d62: 69 f4 brne .+26 ; 0x1d7e - // LOAD ADDRESS - uint16_t newAddress; - newAddress = getch(); - 1d64: c2 d0 rcall .+388 ; 0x1eea - newAddress = (newAddress & 0xff) | (getch() << 8); - 1d66: e8 2e mov r14, r24 - 1d68: ff 24 eor r15, r15 - 1d6a: bf d0 rcall .+382 ; 0x1eea - 1d6c: 08 2f mov r16, r24 - 1d6e: 10 e0 ldi r17, 0x00 ; 0 - 1d70: 10 2f mov r17, r16 - 1d72: 00 27 eor r16, r16 - 1d74: 0e 29 or r16, r14 - 1d76: 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 - 1d78: 00 0f add r16, r16 - 1d7a: 11 1f adc r17, r17 - 1d7c: a3 c0 rjmp .+326 ; 0x1ec4 - address = newAddress; - verifySpace(); - } - else if(ch == STK_UNIVERSAL) { - 1d7e: 86 35 cpi r24, 0x56 ; 86 - 1d80: 21 f4 brne .+8 ; 0x1d8a - // UNIVERSAL command is ignored - getNch(4); - 1d82: 84 e0 ldi r24, 0x04 ; 4 - 1d84: d1 d0 rcall .+418 ; 0x1f28 - putch(0x00); - 1d86: 80 e0 ldi r24, 0x00 ; 0 - 1d88: 97 c0 rjmp .+302 ; 0x1eb8 - } - /* Write memory, length is big endian and is in bytes */ - else if(ch == STK_PROG_PAGE) { - 1d8a: 84 36 cpi r24, 0x64 ; 100 - 1d8c: 09 f0 breq .+2 ; 0x1d90 - 1d8e: 60 c0 rjmp .+192 ; 0x1e50 - // PROGRAM PAGE - we support flash programming only, not EEPROM - uint8_t *bufPtr; - uint16_t addrPtr; - - getch(); /* getlen() */ - 1d90: ac d0 rcall .+344 ; 0x1eea - length = getch(); - 1d92: ab d0 rcall .+342 ; 0x1eea - 1d94: f8 2e mov r15, r24 - getch(); - 1d96: a9 d0 rcall .+338 ; 0x1eea - 1d98: c0 e0 ldi r28, 0x00 ; 0 - 1d9a: d1 e0 ldi r29, 0x01 ; 1 - // If we are in RWW section, immediately start page erase - if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address); - - // While that is going on, read in page contents - bufPtr = buff; - do *bufPtr++ = getch(); - 1d9c: a6 d0 rcall .+332 ; 0x1eea - 1d9e: 89 93 st Y+, r24 - while (--length); - 1da0: fc 16 cp r15, r28 - 1da2: e1 f7 brne .-8 ; 0x1d9c - - // 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); - 1da4: 83 e0 ldi r24, 0x03 ; 3 - 1da6: f8 01 movw r30, r16 - 1da8: 87 bf out 0x37, r24 ; 55 - 1daa: e8 95 spm - - // Read command terminator, start reply - verifySpace(); - 1dac: b5 d0 rcall .+362 ; 0x1f18 - - // If only a partial page is to be programmed, the erase might not be complete. - // So check that here - boot_spm_busy_wait(); - 1dae: 07 b6 in r0, 0x37 ; 55 - 1db0: 00 fc sbrc r0, 0 - 1db2: fd cf rjmp .-6 ; 0x1dae - -#ifdef VIRTUAL_BOOT_PARTITION - if ((uint16_t)(void*)address == 0) { - 1db4: 01 15 cp r16, r1 - 1db6: 11 05 cpc r17, r1 - 1db8: 11 f0 breq .+4 ; 0x1dbe - 1dba: a8 01 movw r20, r16 - 1dbc: 2a c0 rjmp .+84 ; 0x1e12 - // This is the reset vector page. We need to live-patch the code so the - // bootloader runs. - // - // Move RESET vector to WDT vector - uint16_t vect = buff[0] | (buff[1]<<8); - 1dbe: 80 91 00 01 lds r24, 0x0100 - 1dc2: 20 91 01 01 lds r18, 0x0101 - 1dc6: 30 e0 ldi r19, 0x00 ; 0 - 1dc8: 32 2f mov r19, r18 - 1dca: 22 27 eor r18, r18 - 1dcc: 90 e0 ldi r25, 0x00 ; 0 - 1dce: 28 2b or r18, r24 - 1dd0: 39 2b or r19, r25 - rstVect = vect; - 1dd2: 30 93 85 01 sts 0x0185, r19 - 1dd6: 20 93 84 01 sts 0x0184, r18 - wdtVect = buff[8] | (buff[9]<<8); - 1dda: 40 91 08 01 lds r20, 0x0108 - 1dde: 80 91 09 01 lds r24, 0x0109 - 1de2: 90 e0 ldi r25, 0x00 ; 0 - 1de4: 98 2f mov r25, r24 - 1de6: 88 27 eor r24, r24 - 1de8: 50 e0 ldi r21, 0x00 ; 0 - 1dea: 84 2b or r24, r20 - 1dec: 95 2b or r25, r21 - 1dee: 90 93 87 01 sts 0x0187, r25 - 1df2: 80 93 86 01 sts 0x0186, r24 - vect -= 4; // Instruction is a relative jump (rjmp), so recalculate. - 1df6: 24 50 subi r18, 0x04 ; 4 - 1df8: 30 40 sbci r19, 0x00 ; 0 - buff[8] = vect & 0xff; - 1dfa: 20 93 08 01 sts 0x0108, r18 - buff[9] = vect >> 8; - 1dfe: 23 2f mov r18, r19 - 1e00: 33 27 eor r19, r19 - 1e02: 20 93 09 01 sts 0x0109, r18 - - // Add jump to bootloader at RESET vector - buff[0] = 0x7f; - 1e06: d0 92 00 01 sts 0x0100, r13 - buff[1] = 0xce; // rjmp 0x1d00 instruction - 1e0a: c0 92 01 01 sts 0x0101, r12 - 1e0e: 40 e0 ldi r20, 0x00 ; 0 - 1e10: 50 e0 ldi r21, 0x00 ; 0 - 1e12: a0 e0 ldi r26, 0x00 ; 0 - 1e14: b1 e0 ldi r27, 0x01 ; 1 - bufPtr = buff; - addrPtr = (uint16_t)(void*)address; - ch = SPM_PAGESIZE / 2; - do { - uint16_t a; - a = *bufPtr++; - 1e16: 2c 91 ld r18, X - 1e18: 30 e0 ldi r19, 0x00 ; 0 - a |= (*bufPtr++) << 8; - 1e1a: 11 96 adiw r26, 0x01 ; 1 - 1e1c: 8c 91 ld r24, X - 1e1e: 11 97 sbiw r26, 0x01 ; 1 - 1e20: 90 e0 ldi r25, 0x00 ; 0 - 1e22: 98 2f mov r25, r24 - 1e24: 88 27 eor r24, r24 - 1e26: 82 2b or r24, r18 - 1e28: 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) { - 1e2a: 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); - 1e2c: fa 01 movw r30, r20 - 1e2e: 0c 01 movw r0, r24 - 1e30: b7 be out 0x37, r11 ; 55 - 1e32: e8 95 spm - 1e34: 11 24 eor r1, r1 - addrPtr += 2; - 1e36: 4e 5f subi r20, 0xFE ; 254 - 1e38: 5f 4f sbci r21, 0xFF ; 255 - } while (--ch); - 1e3a: f1 e0 ldi r31, 0x01 ; 1 - 1e3c: a0 34 cpi r26, 0x40 ; 64 - 1e3e: bf 07 cpc r27, r31 - 1e40: 51 f7 brne .-44 ; 0x1e16 - - // Write from programming buffer - __boot_page_write_short((uint16_t)(void*)address); - 1e42: f8 01 movw r30, r16 - 1e44: a7 be out 0x37, r10 ; 55 - 1e46: e8 95 spm - boot_spm_busy_wait(); - 1e48: 07 b6 in r0, 0x37 ; 55 - 1e4a: 00 fc sbrc r0, 0 - 1e4c: fd cf rjmp .-6 ; 0x1e48 - 1e4e: 3b c0 rjmp .+118 ; 0x1ec6 - boot_rww_enable(); -#endif - - } - /* Read memory block mode, length is big endian. */ - else if(ch == STK_READ_PAGE) { - 1e50: 84 37 cpi r24, 0x74 ; 116 - 1e52: 51 f5 brne .+84 ; 0x1ea8 - // READ PAGE - we only read flash - getch(); /* getlen() */ - 1e54: 4a d0 rcall .+148 ; 0x1eea - length = getch(); - 1e56: 49 d0 rcall .+146 ; 0x1eea - 1e58: f8 2e mov r15, r24 - getch(); - 1e5a: 47 d0 rcall .+142 ; 0x1eea - - verifySpace(); - 1e5c: 5d d0 rcall .+186 ; 0x1f18 - 1e5e: e8 01 movw r28, r16 - 1e60: ef 2c mov r14, r15 -#ifdef VIRTUAL_BOOT_PARTITION - do { - // Undo vector patch in bottom page so verify passes - if (address == 0) ch=rstVect & 0xff; - 1e62: 20 97 sbiw r28, 0x00 ; 0 - 1e64: 19 f4 brne .+6 ; 0x1e6c - 1e66: 80 91 84 01 lds r24, 0x0184 - 1e6a: 14 c0 rjmp .+40 ; 0x1e94 - else if (address == 1) ch=rstVect >> 8; - 1e6c: c1 30 cpi r28, 0x01 ; 1 - 1e6e: d1 05 cpc r29, r1 - 1e70: 19 f4 brne .+6 ; 0x1e78 - 1e72: 80 91 85 01 lds r24, 0x0185 - 1e76: 0e c0 rjmp .+28 ; 0x1e94 - else if (address == 8) ch=wdtVect & 0xff; - 1e78: c8 30 cpi r28, 0x08 ; 8 - 1e7a: d1 05 cpc r29, r1 - 1e7c: 19 f4 brne .+6 ; 0x1e84 - 1e7e: 80 91 86 01 lds r24, 0x0186 - 1e82: 08 c0 rjmp .+16 ; 0x1e94 - else if (address == 9) ch=wdtVect >> 8; - 1e84: c9 30 cpi r28, 0x09 ; 9 - 1e86: d1 05 cpc r29, r1 - 1e88: 19 f4 brne .+6 ; 0x1e90 - 1e8a: 80 91 87 01 lds r24, 0x0187 - 1e8e: 02 c0 rjmp .+4 ; 0x1e94 - else ch = pgm_read_byte_near(address); - 1e90: fe 01 movw r30, r28 - 1e92: 84 91 lpm r24, Z+ - address++; - 1e94: 21 96 adiw r28, 0x01 ; 1 - putch(ch); - 1e96: 1a d0 rcall .+52 ; 0x1ecc - } while (--length); - 1e98: ea 94 dec r14 - 1e9a: 19 f7 brne .-58 ; 0x1e62 -#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) { - 1e9c: 0f 5f subi r16, 0xFF ; 255 - 1e9e: 1f 4f sbci r17, 0xFF ; 255 - 1ea0: fa 94 dec r15 - 1ea2: 0f 0d add r16, r15 - 1ea4: 11 1d adc r17, r1 - 1ea6: 0f c0 rjmp .+30 ; 0x1ec6 -#endif -#endif - } - - /* Get device signature bytes */ - else if(ch == STK_READ_SIGN) { - 1ea8: 85 37 cpi r24, 0x75 ; 117 - 1eaa: 41 f4 brne .+16 ; 0x1ebc - // READ SIGN - return what Avrdude wants to hear - verifySpace(); - 1eac: 35 d0 rcall .+106 ; 0x1f18 - putch(SIGNATURE_0); - 1eae: 8e e1 ldi r24, 0x1E ; 30 - 1eb0: 0d d0 rcall .+26 ; 0x1ecc - putch(SIGNATURE_1); - 1eb2: 83 e9 ldi r24, 0x93 ; 147 - 1eb4: 0b d0 rcall .+22 ; 0x1ecc - putch(SIGNATURE_2); - 1eb6: 8c e0 ldi r24, 0x0C ; 12 - 1eb8: 09 d0 rcall .+18 ; 0x1ecc - 1eba: 05 c0 rjmp .+10 ; 0x1ec6 - } - else if (ch == 'Q') { - 1ebc: 81 35 cpi r24, 0x51 ; 81 - 1ebe: 11 f4 brne .+4 ; 0x1ec4 - // Adaboot no-wait mod - watchdogConfig(WATCHDOG_16MS); - 1ec0: 88 e0 ldi r24, 0x08 ; 8 - 1ec2: 26 d0 rcall .+76 ; 0x1f10 - verifySpace(); - } - else { - // This covers the response to commands like STK_ENTER_PROGMODE - verifySpace(); - 1ec4: 29 d0 rcall .+82 ; 0x1f18 - } - putch(STK_OK); - 1ec6: 80 e1 ldi r24, 0x10 ; 16 - 1ec8: 01 d0 rcall .+2 ; 0x1ecc - 1eca: 3a cf rjmp .-396 ; 0x1d40 - -00001ecc : -void putch(char ch) { -#ifndef SOFT_UART - while (!(UCSR0A & _BV(UDRE0))); - UDR0 = ch; -#else - __asm__ __volatile__ ( - 1ecc: 2a e0 ldi r18, 0x0A ; 10 - 1ece: 30 e0 ldi r19, 0x00 ; 0 - 1ed0: 80 95 com r24 - 1ed2: 08 94 sec - 1ed4: 10 f4 brcc .+4 ; 0x1eda - 1ed6: da 98 cbi 0x1b, 2 ; 27 - 1ed8: 02 c0 rjmp .+4 ; 0x1ede - 1eda: da 9a sbi 0x1b, 2 ; 27 - 1edc: 00 00 nop - 1ede: 14 d0 rcall .+40 ; 0x1f08 - 1ee0: 13 d0 rcall .+38 ; 0x1f08 - 1ee2: 86 95 lsr r24 - 1ee4: 2a 95 dec r18 - 1ee6: b1 f7 brne .-20 ; 0x1ed4 - [uartBit] "I" (UART_TX_BIT) - : - "r25" - ); -#endif -} - 1ee8: 08 95 ret - -00001eea : - LED_PIN |= _BV(LED); -#endif -#endif - - return ch; -} - 1eea: 29 e0 ldi r18, 0x09 ; 9 - 1eec: 30 e0 ldi r19, 0x00 ; 0 - 1eee: cb 99 sbic 0x19, 3 ; 25 - 1ef0: fe cf rjmp .-4 ; 0x1eee - 1ef2: 0a d0 rcall .+20 ; 0x1f08 - 1ef4: 09 d0 rcall .+18 ; 0x1f08 - 1ef6: 08 d0 rcall .+16 ; 0x1f08 - 1ef8: 88 94 clc - 1efa: cb 99 sbic 0x19, 3 ; 25 - 1efc: 08 94 sec - 1efe: 2a 95 dec r18 - 1f00: 11 f0 breq .+4 ; 0x1f06 - 1f02: 87 95 ror r24 - 1f04: f7 cf rjmp .-18 ; 0x1ef4 - 1f06: 08 95 ret - -00001f08 : -#if UART_B_VALUE > 255 -#error Baud rate too slow for soft UART -#endif - -void uartDelay() { - __asm__ __volatile__ ( - 1f08: 9e e0 ldi r25, 0x0E ; 14 - 1f0a: 9a 95 dec r25 - 1f0c: f1 f7 brne .-4 ; 0x1f0a - 1f0e: 08 95 ret - -00001f10 : - "wdr\n" - ); -} - -void watchdogConfig(uint8_t x) { - WDTCSR = _BV(WDCE) | _BV(WDE); - 1f10: 98 e1 ldi r25, 0x18 ; 24 - 1f12: 91 bd out 0x21, r25 ; 33 - WDTCSR = x; - 1f14: 81 bd out 0x21, r24 ; 33 -} - 1f16: 08 95 ret - -00001f18 : - do getch(); while (--count); - verifySpace(); -} - -void verifySpace() { - if (getch() != CRC_EOP) { - 1f18: e8 df rcall .-48 ; 0x1eea - 1f1a: 80 32 cpi r24, 0x20 ; 32 - 1f1c: 19 f0 breq .+6 ; 0x1f24 - watchdogConfig(WATCHDOG_16MS); // shorten WD timeout - 1f1e: 88 e0 ldi r24, 0x08 ; 8 - 1f20: f7 df rcall .-18 ; 0x1f10 - 1f22: ff cf rjmp .-2 ; 0x1f22 - while (1) // and busy-loop so that WD causes - ; // a reset and app start. - } - putch(STK_INSYNC); - 1f24: 84 e1 ldi r24, 0x14 ; 20 -} - 1f26: d2 cf rjmp .-92 ; 0x1ecc - -00001f28 : - ::[count] "M" (UART_B_VALUE) - ); -} -#endif - -void getNch(uint8_t count) { - 1f28: 1f 93 push r17 - 1f2a: 18 2f mov r17, r24 - do getch(); while (--count); - 1f2c: de df rcall .-68 ; 0x1eea - 1f2e: 11 50 subi r17, 0x01 ; 1 - 1f30: e9 f7 brne .-6 ; 0x1f2c - verifySpace(); - 1f32: f2 df rcall .-28 ; 0x1f18 -} - 1f34: 1f 91 pop r17 - 1f36: 08 95 ret - -00001f38 : - WDTCSR = _BV(WDCE) | _BV(WDE); - WDTCSR = x; -} - -void appStart() { - watchdogConfig(WATCHDOG_OFF); - 1f38: 80 e0 ldi r24, 0x00 ; 0 - 1f3a: ea df rcall .-44 ; 0x1f10 - __asm__ __volatile__ ( - 1f3c: e4 e0 ldi r30, 0x04 ; 4 - 1f3e: ff 27 eor r31, r31 - 1f40: 09 94 ijmp -- cgit v1.2.3-18-g5258