2010-09-22 15:04:33 +02:00
|
|
|
|
|
|
|
optiboot_pro_20mhz.elf: file format elf32-avr
|
|
|
|
|
|
|
|
Sections:
|
|
|
|
Idx Name Size VMA LMA File off Algn
|
2011-06-11 08:02:25 +02:00
|
|
|
0 .text 000001da 00003e00 00003e00 00000054 2**1
|
2010-09-22 15:04:33 +02:00
|
|
|
CONTENTS, ALLOC, LOAD, READONLY, CODE
|
2011-06-11 08:02:25 +02:00
|
|
|
1 .version 00000002 00003ffe 00003ffe 0000022e 2**0
|
2011-06-11 02:47:47 +02:00
|
|
|
CONTENTS, READONLY
|
2011-06-11 08:02:25 +02:00
|
|
|
2 .debug_aranges 00000028 00000000 00000000 00000230 2**0
|
2010-09-22 15:04:33 +02:00
|
|
|
CONTENTS, READONLY, DEBUGGING
|
2011-06-11 08:02:25 +02:00
|
|
|
3 .debug_pubnames 0000005f 00000000 00000000 00000258 2**0
|
2010-09-22 15:04:33 +02:00
|
|
|
CONTENTS, READONLY, DEBUGGING
|
2011-06-11 08:02:25 +02:00
|
|
|
4 .debug_info 0000028c 00000000 00000000 000002b7 2**0
|
2010-09-22 15:04:33 +02:00
|
|
|
CONTENTS, READONLY, DEBUGGING
|
2011-06-11 08:02:25 +02:00
|
|
|
5 .debug_abbrev 00000199 00000000 00000000 00000543 2**0
|
2010-09-22 15:04:33 +02:00
|
|
|
CONTENTS, READONLY, DEBUGGING
|
2011-06-11 08:02:25 +02:00
|
|
|
6 .debug_line 00000456 00000000 00000000 000006dc 2**0
|
2010-09-22 15:04:33 +02:00
|
|
|
CONTENTS, READONLY, DEBUGGING
|
2011-06-11 08:02:25 +02:00
|
|
|
7 .debug_frame 00000080 00000000 00000000 00000b34 2**2
|
2010-09-22 15:04:33 +02:00
|
|
|
CONTENTS, READONLY, DEBUGGING
|
2011-06-11 08:02:25 +02:00
|
|
|
8 .debug_str 00000149 00000000 00000000 00000bb4 2**0
|
2010-09-22 15:04:33 +02:00
|
|
|
CONTENTS, READONLY, DEBUGGING
|
2011-06-11 08:02:25 +02:00
|
|
|
9 .debug_loc 0000027e 00000000 00000000 00000cfd 2**0
|
2010-09-22 15:04:33 +02:00
|
|
|
CONTENTS, READONLY, DEBUGGING
|
2011-06-11 08:02:25 +02:00
|
|
|
10 .debug_ranges 00000060 00000000 00000000 00000f7b 2**0
|
2010-09-22 15:04:33 +02:00
|
|
|
CONTENTS, READONLY, DEBUGGING
|
|
|
|
|
|
|
|
Disassembly of section .text:
|
|
|
|
|
|
|
|
00003e00 <main>:
|
2011-06-11 01:17:13 +02:00
|
|
|
#define rstVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+4))
|
|
|
|
#define wdtVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+6))
|
2010-09-22 15:04:33 +02:00
|
|
|
#endif
|
2011-06-11 01:17:13 +02:00
|
|
|
|
2010-09-22 15:04:33 +02:00
|
|
|
/* main program starts here */
|
|
|
|
int main(void) {
|
2011-06-11 01:17:13 +02:00
|
|
|
3e00: 11 24 eor r1, r1
|
|
|
|
#ifdef __AVR_ATmega8__
|
|
|
|
SP=RAMEND; // This is done by hardware reset
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Adaboot no-wait mod
|
|
|
|
ch = MCUSR;
|
|
|
|
3e02: 84 b7 in r24, 0x34 ; 52
|
|
|
|
MCUSR = 0;
|
|
|
|
3e04: 14 be out 0x34, r1 ; 52
|
|
|
|
if (!(ch & _BV(EXTRF))) appStart();
|
|
|
|
3e06: 81 ff sbrs r24, 1
|
2011-06-11 08:02:25 +02:00
|
|
|
3e08: e3 d0 rcall .+454 ; 0x3fd0 <appStart>
|
2011-06-11 01:17:13 +02:00
|
|
|
|
2010-09-22 15:04:33 +02:00
|
|
|
#if LED_START_FLASHES > 0
|
|
|
|
// Set up Timer 1 for timeout counter
|
|
|
|
TCCR1B = _BV(CS12) | _BV(CS10); // div 1024
|
2011-06-11 01:17:13 +02:00
|
|
|
3e0a: 85 e0 ldi r24, 0x05 ; 5
|
|
|
|
3e0c: 80 93 81 00 sts 0x0081, r24
|
|
|
|
UCSRA = _BV(U2X); //Double speed mode USART
|
|
|
|
UCSRB = _BV(RXEN) | _BV(TXEN); // enable Rx & Tx
|
|
|
|
UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0); // config USART; 8N1
|
|
|
|
UBRRL = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
|
|
|
|
#else
|
2010-09-22 15:04:33 +02:00
|
|
|
UCSR0A = _BV(U2X0); //Double speed mode USART0
|
2011-06-11 01:17:13 +02:00
|
|
|
3e10: 82 e0 ldi r24, 0x02 ; 2
|
|
|
|
3e12: 80 93 c0 00 sts 0x00C0, r24
|
2010-09-22 15:04:33 +02:00
|
|
|
UCSR0B = _BV(RXEN0) | _BV(TXEN0);
|
2011-06-11 01:17:13 +02:00
|
|
|
3e16: 88 e1 ldi r24, 0x18 ; 24
|
|
|
|
3e18: 80 93 c1 00 sts 0x00C1, r24
|
2010-09-22 15:04:33 +02:00
|
|
|
UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
|
2011-06-11 01:17:13 +02:00
|
|
|
3e1c: 86 e0 ldi r24, 0x06 ; 6
|
|
|
|
3e1e: 80 93 c2 00 sts 0x00C2, r24
|
2010-09-22 15:04:33 +02:00
|
|
|
UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
|
2011-06-11 01:17:13 +02:00
|
|
|
3e22: 85 e1 ldi r24, 0x15 ; 21
|
|
|
|
3e24: 80 93 c4 00 sts 0x00C4, r24
|
|
|
|
#endif
|
2010-09-22 15:04:33 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Set up watchdog to trigger after 500ms
|
2011-06-11 01:17:13 +02:00
|
|
|
watchdogConfig(WATCHDOG_1S);
|
|
|
|
3e28: 8e e0 ldi r24, 0x0E ; 14
|
2011-06-11 08:02:25 +02:00
|
|
|
3e2a: bc d0 rcall .+376 ; 0x3fa4 <watchdogConfig>
|
2010-09-22 15:04:33 +02:00
|
|
|
|
|
|
|
/* Set LED pin as output */
|
|
|
|
LED_DDR |= _BV(LED);
|
2011-06-11 01:17:13 +02:00
|
|
|
3e2c: 25 9a sbi 0x04, 5 ; 4
|
|
|
|
3e2e: 86 e0 ldi r24, 0x06 ; 6
|
2010-09-22 15:04:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#if LED_START_FLASHES > 0
|
|
|
|
void flash_led(uint8_t count) {
|
|
|
|
do {
|
|
|
|
TCNT1 = -(F_CPU/(1024*16));
|
2011-06-11 01:17:13 +02:00
|
|
|
3e30: 2c e3 ldi r18, 0x3C ; 60
|
|
|
|
3e32: 3b ef ldi r19, 0xFB ; 251
|
2010-09-22 15:04:33 +02:00
|
|
|
TIFR1 = _BV(TOV1);
|
2011-06-11 01:17:13 +02:00
|
|
|
3e34: 91 e0 ldi r25, 0x01 ; 1
|
2010-09-22 15:04:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#if LED_START_FLASHES > 0
|
|
|
|
void flash_led(uint8_t count) {
|
|
|
|
do {
|
|
|
|
TCNT1 = -(F_CPU/(1024*16));
|
2011-06-11 01:17:13 +02:00
|
|
|
3e36: 30 93 85 00 sts 0x0085, r19
|
|
|
|
3e3a: 20 93 84 00 sts 0x0084, r18
|
2010-09-22 15:04:33 +02:00
|
|
|
TIFR1 = _BV(TOV1);
|
2011-06-11 01:17:13 +02:00
|
|
|
3e3e: 96 bb out 0x16, r25 ; 22
|
2010-09-22 15:04:33 +02:00
|
|
|
while(!(TIFR1 & _BV(TOV1)));
|
2011-06-11 01:17:13 +02:00
|
|
|
3e40: b0 9b sbis 0x16, 0 ; 22
|
|
|
|
3e42: fe cf rjmp .-4 ; 0x3e40 <main+0x40>
|
|
|
|
#ifdef __AVR_ATmega8__
|
|
|
|
LED_PORT ^= _BV(LED);
|
|
|
|
#else
|
2010-09-22 15:04:33 +02:00
|
|
|
LED_PIN |= _BV(LED);
|
2011-06-11 01:17:13 +02:00
|
|
|
3e44: 1d 9a sbi 0x03, 5 ; 3
|
2010-09-22 15:04:33 +02:00
|
|
|
}
|
2011-06-11 08:02:25 +02:00
|
|
|
#endif
|
2010-09-22 15:04:33 +02:00
|
|
|
|
|
|
|
// Watchdog functions. These are only safe with interrupts turned off.
|
|
|
|
void watchdogReset() {
|
|
|
|
__asm__ __volatile__ (
|
2011-06-11 01:17:13 +02:00
|
|
|
3e46: a8 95 wdr
|
|
|
|
LED_PORT ^= _BV(LED);
|
|
|
|
#else
|
2010-09-22 15:04:33 +02:00
|
|
|
LED_PIN |= _BV(LED);
|
2011-06-11 01:17:13 +02:00
|
|
|
#endif
|
2010-09-22 15:04:33 +02:00
|
|
|
watchdogReset();
|
|
|
|
} while (--count);
|
2011-06-11 01:17:13 +02:00
|
|
|
3e48: 81 50 subi r24, 0x01 ; 1
|
|
|
|
3e4a: a9 f7 brne .-22 ; 0x3e36 <main+0x36>
|
2010-09-22 15:04:33 +02:00
|
|
|
/* 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);
|
2011-06-11 08:02:25 +02:00
|
|
|
3e4c: 99 24 eor r9, r9
|
|
|
|
3e4e: 93 94 inc r9
|
2011-06-11 01:17:13 +02:00
|
|
|
__boot_page_fill_short((uint16_t)(void*)addrPtr,a);
|
2010-09-22 15:04:33 +02:00
|
|
|
addrPtr += 2;
|
|
|
|
} while (--ch);
|
2011-06-11 02:47:47 +02:00
|
|
|
|
2010-09-22 15:04:33 +02:00
|
|
|
// Write from programming buffer
|
2011-06-11 01:17:13 +02:00
|
|
|
__boot_page_write_short((uint16_t)(void*)address);
|
|
|
|
3e50: a5 e0 ldi r26, 0x05 ; 5
|
2011-06-11 08:02:25 +02:00
|
|
|
3e52: aa 2e mov r10, r26
|
2010-09-22 15:04:33 +02:00
|
|
|
boot_spm_busy_wait();
|
|
|
|
|
|
|
|
#if defined(RWWSRE)
|
|
|
|
// Reenable read access to flash
|
|
|
|
boot_rww_enable();
|
2011-06-11 01:17:13 +02:00
|
|
|
3e54: f1 e1 ldi r31, 0x11 ; 17
|
2011-06-11 08:02:25 +02:00
|
|
|
3e56: bf 2e mov r11, r31
|
2010-09-22 15:04:33 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Forever loop */
|
|
|
|
for (;;) {
|
|
|
|
/* get character from UART */
|
|
|
|
ch = getch();
|
2011-06-11 08:02:25 +02:00
|
|
|
3e58: 9d d0 rcall .+314 ; 0x3f94 <getch>
|
2010-09-22 15:04:33 +02:00
|
|
|
|
|
|
|
if(ch == STK_GET_PARAMETER) {
|
2011-06-11 01:17:13 +02:00
|
|
|
3e5a: 81 34 cpi r24, 0x41 ; 65
|
|
|
|
3e5c: 21 f4 brne .+8 ; 0x3e66 <main+0x66>
|
2010-09-22 15:04:33 +02:00
|
|
|
// GET PARAMETER returns a generic 0x03 reply - enough to keep Avrdude happy
|
|
|
|
getNch(1);
|
2011-06-11 01:17:13 +02:00
|
|
|
3e5e: 81 e0 ldi r24, 0x01 ; 1
|
2011-06-11 08:02:25 +02:00
|
|
|
3e60: af d0 rcall .+350 ; 0x3fc0 <getNch>
|
2010-09-22 15:04:33 +02:00
|
|
|
putch(0x03);
|
2011-06-11 01:17:13 +02:00
|
|
|
3e62: 83 e0 ldi r24, 0x03 ; 3
|
2011-06-11 08:02:25 +02:00
|
|
|
3e64: 1f c0 rjmp .+62 ; 0x3ea4 <main+0xa4>
|
2010-09-22 15:04:33 +02:00
|
|
|
}
|
|
|
|
else if(ch == STK_SET_DEVICE) {
|
2011-06-11 01:17:13 +02:00
|
|
|
3e66: 82 34 cpi r24, 0x42 ; 66
|
|
|
|
3e68: 11 f4 brne .+4 ; 0x3e6e <main+0x6e>
|
2010-09-22 15:04:33 +02:00
|
|
|
// SET DEVICE is ignored
|
|
|
|
getNch(20);
|
2011-06-11 01:17:13 +02:00
|
|
|
3e6a: 84 e1 ldi r24, 0x14 ; 20
|
|
|
|
3e6c: 03 c0 rjmp .+6 ; 0x3e74 <main+0x74>
|
2010-09-22 15:04:33 +02:00
|
|
|
}
|
|
|
|
else if(ch == STK_SET_DEVICE_EXT) {
|
2011-06-11 01:17:13 +02:00
|
|
|
3e6e: 85 34 cpi r24, 0x45 ; 69
|
|
|
|
3e70: 19 f4 brne .+6 ; 0x3e78 <main+0x78>
|
2010-09-22 15:04:33 +02:00
|
|
|
// SET DEVICE EXT is ignored
|
|
|
|
getNch(5);
|
2011-06-11 01:17:13 +02:00
|
|
|
3e72: 85 e0 ldi r24, 0x05 ; 5
|
2011-06-11 08:02:25 +02:00
|
|
|
3e74: a5 d0 rcall .+330 ; 0x3fc0 <getNch>
|
|
|
|
3e76: 83 c0 rjmp .+262 ; 0x3f7e <main+0x17e>
|
2010-09-22 15:04:33 +02:00
|
|
|
}
|
|
|
|
else if(ch == STK_LOAD_ADDRESS) {
|
2011-06-11 01:17:13 +02:00
|
|
|
3e78: 85 35 cpi r24, 0x55 ; 85
|
2011-06-11 08:02:25 +02:00
|
|
|
3e7a: 79 f4 brne .+30 ; 0x3e9a <main+0x9a>
|
2010-09-22 15:04:33 +02:00
|
|
|
// LOAD ADDRESS
|
2011-06-11 01:17:13 +02:00
|
|
|
uint16_t newAddress;
|
|
|
|
newAddress = getch();
|
2011-06-11 08:02:25 +02:00
|
|
|
3e7c: 8b d0 rcall .+278 ; 0x3f94 <getch>
|
2011-06-11 01:17:13 +02:00
|
|
|
newAddress = (newAddress & 0xff) | (getch() << 8);
|
2011-06-11 08:02:25 +02:00
|
|
|
3e7e: e8 2e mov r14, r24
|
|
|
|
3e80: ff 24 eor r15, r15
|
|
|
|
3e82: 88 d0 rcall .+272 ; 0x3f94 <getch>
|
|
|
|
3e84: 08 2f mov r16, r24
|
|
|
|
3e86: 10 e0 ldi r17, 0x00 ; 0
|
|
|
|
3e88: 10 2f mov r17, r16
|
|
|
|
3e8a: 00 27 eor r16, r16
|
|
|
|
3e8c: 0e 29 or r16, r14
|
|
|
|
3e8e: 1f 29 or r17, r15
|
2011-06-11 01:17:13 +02:00
|
|
|
#ifdef RAMPZ
|
|
|
|
// Transfer top bit to RAMPZ
|
|
|
|
RAMPZ = (newAddress & 0x8000) ? 1 : 0;
|
|
|
|
#endif
|
|
|
|
newAddress += newAddress; // Convert from word address to byte address
|
2011-06-11 08:02:25 +02:00
|
|
|
3e90: 00 0f add r16, r16
|
|
|
|
3e92: 11 1f adc r17, r17
|
2011-06-11 01:17:13 +02:00
|
|
|
address = newAddress;
|
2010-09-22 15:04:33 +02:00
|
|
|
verifySpace();
|
2011-06-11 08:02:25 +02:00
|
|
|
3e94: 8d d0 rcall .+282 ; 0x3fb0 <verifySpace>
|
|
|
|
3e96: 68 01 movw r12, r16
|
|
|
|
3e98: 72 c0 rjmp .+228 ; 0x3f7e <main+0x17e>
|
2010-09-22 15:04:33 +02:00
|
|
|
}
|
|
|
|
else if(ch == STK_UNIVERSAL) {
|
2011-06-11 08:02:25 +02:00
|
|
|
3e9a: 86 35 cpi r24, 0x56 ; 86
|
|
|
|
3e9c: 29 f4 brne .+10 ; 0x3ea8 <main+0xa8>
|
2010-09-22 15:04:33 +02:00
|
|
|
// UNIVERSAL command is ignored
|
|
|
|
getNch(4);
|
2011-06-11 08:02:25 +02:00
|
|
|
3e9e: 84 e0 ldi r24, 0x04 ; 4
|
|
|
|
3ea0: 8f d0 rcall .+286 ; 0x3fc0 <getNch>
|
2010-09-22 15:04:33 +02:00
|
|
|
putch(0x00);
|
2011-06-11 08:02:25 +02:00
|
|
|
3ea2: 80 e0 ldi r24, 0x00 ; 0
|
|
|
|
3ea4: 6f d0 rcall .+222 ; 0x3f84 <putch>
|
|
|
|
3ea6: 6b c0 rjmp .+214 ; 0x3f7e <main+0x17e>
|
2010-09-22 15:04:33 +02:00
|
|
|
}
|
2011-06-11 01:17:13 +02:00
|
|
|
/* Write memory, length is big endian and is in bytes */
|
2010-09-22 15:04:33 +02:00
|
|
|
else if(ch == STK_PROG_PAGE) {
|
2011-06-11 08:02:25 +02:00
|
|
|
3ea8: 84 36 cpi r24, 0x64 ; 100
|
|
|
|
3eaa: 09 f0 breq .+2 ; 0x3eae <main+0xae>
|
|
|
|
3eac: 42 c0 rjmp .+132 ; 0x3f32 <main+0x132>
|
2010-09-22 15:04:33 +02:00
|
|
|
// PROGRAM PAGE - we support flash programming only, not EEPROM
|
|
|
|
uint8_t *bufPtr;
|
|
|
|
uint16_t addrPtr;
|
|
|
|
|
2011-06-11 08:02:25 +02:00
|
|
|
getch(); /* getlen() */
|
|
|
|
3eae: 72 d0 rcall .+228 ; 0x3f94 <getch>
|
|
|
|
length = getch();
|
|
|
|
3eb0: 71 d0 rcall .+226 ; 0x3f94 <getch>
|
|
|
|
3eb2: 08 2f mov r16, r24
|
|
|
|
getch();
|
|
|
|
3eb4: 6f d0 rcall .+222 ; 0x3f94 <getch>
|
2011-06-11 01:17:13 +02:00
|
|
|
|
|
|
|
// If we are in RWW section, immediately start page erase
|
|
|
|
if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
|
2011-06-11 08:02:25 +02:00
|
|
|
3eb6: 80 e0 ldi r24, 0x00 ; 0
|
|
|
|
3eb8: c8 16 cp r12, r24
|
2011-06-11 01:17:13 +02:00
|
|
|
3eba: 88 e3 ldi r24, 0x38 ; 56
|
2011-06-11 08:02:25 +02:00
|
|
|
3ebc: d8 06 cpc r13, r24
|
|
|
|
3ebe: 20 f4 brcc .+8 ; 0x3ec8 <main+0xc8>
|
|
|
|
3ec0: 83 e0 ldi r24, 0x03 ; 3
|
|
|
|
3ec2: f6 01 movw r30, r12
|
2011-06-11 01:17:13 +02:00
|
|
|
3ec4: 87 bf out 0x37, r24 ; 55
|
2010-09-22 15:04:33 +02:00
|
|
|
3ec6: e8 95 spm
|
|
|
|
3ec8: c0 e0 ldi r28, 0x00 ; 0
|
|
|
|
3eca: d1 e0 ldi r29, 0x01 ; 1
|
2011-06-11 02:47:47 +02:00
|
|
|
|
2010-09-22 15:04:33 +02:00
|
|
|
// While that is going on, read in page contents
|
|
|
|
bufPtr = buff;
|
|
|
|
do *bufPtr++ = getch();
|
2011-06-11 08:02:25 +02:00
|
|
|
3ecc: 63 d0 rcall .+198 ; 0x3f94 <getch>
|
2010-09-22 15:04:33 +02:00
|
|
|
3ece: 89 93 st Y+, r24
|
|
|
|
while (--length);
|
2011-06-11 08:02:25 +02:00
|
|
|
3ed0: 0c 17 cp r16, r28
|
|
|
|
3ed2: e1 f7 brne .-8 ; 0x3ecc <main+0xcc>
|
2010-09-22 15:04:33 +02:00
|
|
|
|
2011-06-11 01:17:13 +02:00
|
|
|
// 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);
|
2011-06-11 08:02:25 +02:00
|
|
|
3ed4: f0 e0 ldi r31, 0x00 ; 0
|
|
|
|
3ed6: cf 16 cp r12, r31
|
|
|
|
3ed8: f8 e3 ldi r31, 0x38 ; 56
|
|
|
|
3eda: df 06 cpc r13, r31
|
|
|
|
3edc: 20 f0 brcs .+8 ; 0x3ee6 <main+0xe6>
|
|
|
|
3ede: 83 e0 ldi r24, 0x03 ; 3
|
|
|
|
3ee0: f6 01 movw r30, r12
|
|
|
|
3ee2: 87 bf out 0x37, r24 ; 55
|
|
|
|
3ee4: e8 95 spm
|
2011-06-11 01:17:13 +02:00
|
|
|
|
2010-09-22 15:04:33 +02:00
|
|
|
// Read command terminator, start reply
|
|
|
|
verifySpace();
|
2011-06-11 08:02:25 +02:00
|
|
|
3ee6: 64 d0 rcall .+200 ; 0x3fb0 <verifySpace>
|
2011-06-11 02:47:47 +02:00
|
|
|
|
2010-09-22 15:04:33 +02:00
|
|
|
// If only a partial page is to be programmed, the erase might not be complete.
|
|
|
|
// So check that here
|
|
|
|
boot_spm_busy_wait();
|
2011-06-11 08:02:25 +02:00
|
|
|
3ee8: 07 b6 in r0, 0x37 ; 55
|
|
|
|
3eea: 00 fc sbrc r0, 0
|
|
|
|
3eec: fd cf rjmp .-6 ; 0x3ee8 <main+0xe8>
|
|
|
|
3eee: a6 01 movw r20, r12
|
|
|
|
3ef0: a0 e0 ldi r26, 0x00 ; 0
|
|
|
|
3ef2: b1 e0 ldi r27, 0x01 ; 1
|
2010-09-22 15:04:33 +02:00
|
|
|
bufPtr = buff;
|
|
|
|
addrPtr = (uint16_t)(void*)address;
|
|
|
|
ch = SPM_PAGESIZE / 2;
|
|
|
|
do {
|
|
|
|
uint16_t a;
|
|
|
|
a = *bufPtr++;
|
2011-06-11 08:02:25 +02:00
|
|
|
3ef4: 2c 91 ld r18, X
|
|
|
|
3ef6: 30 e0 ldi r19, 0x00 ; 0
|
2010-09-22 15:04:33 +02:00
|
|
|
a |= (*bufPtr++) << 8;
|
2011-06-11 08:02:25 +02:00
|
|
|
3ef8: 11 96 adiw r26, 0x01 ; 1
|
|
|
|
3efa: 8c 91 ld r24, X
|
|
|
|
3efc: 11 97 sbiw r26, 0x01 ; 1
|
|
|
|
3efe: 90 e0 ldi r25, 0x00 ; 0
|
|
|
|
3f00: 98 2f mov r25, r24
|
|
|
|
3f02: 88 27 eor r24, r24
|
|
|
|
3f04: 82 2b or r24, r18
|
|
|
|
3f06: 93 2b or r25, r19
|
2011-06-11 01:17:13 +02:00
|
|
|
#define rstVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+4))
|
|
|
|
#define wdtVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+6))
|
2010-09-22 15:04:33 +02:00
|
|
|
#endif
|
2011-06-11 01:17:13 +02:00
|
|
|
|
2010-09-22 15:04:33 +02:00
|
|
|
/* main program starts here */
|
|
|
|
int main(void) {
|
2011-06-11 08:02:25 +02:00
|
|
|
3f08: 12 96 adiw r26, 0x02 ; 2
|
2010-09-22 15:04:33 +02:00
|
|
|
ch = SPM_PAGESIZE / 2;
|
|
|
|
do {
|
|
|
|
uint16_t a;
|
|
|
|
a = *bufPtr++;
|
|
|
|
a |= (*bufPtr++) << 8;
|
2011-06-11 01:17:13 +02:00
|
|
|
__boot_page_fill_short((uint16_t)(void*)addrPtr,a);
|
2011-06-11 08:02:25 +02:00
|
|
|
3f0a: fa 01 movw r30, r20
|
|
|
|
3f0c: 0c 01 movw r0, r24
|
|
|
|
3f0e: 97 be out 0x37, r9 ; 55
|
|
|
|
3f10: e8 95 spm
|
|
|
|
3f12: 11 24 eor r1, r1
|
2010-09-22 15:04:33 +02:00
|
|
|
addrPtr += 2;
|
2011-06-11 08:02:25 +02:00
|
|
|
3f14: 4e 5f subi r20, 0xFE ; 254
|
|
|
|
3f16: 5f 4f sbci r21, 0xFF ; 255
|
2010-09-22 15:04:33 +02:00
|
|
|
} while (--ch);
|
2011-06-11 08:02:25 +02:00
|
|
|
3f18: f1 e0 ldi r31, 0x01 ; 1
|
|
|
|
3f1a: a0 38 cpi r26, 0x80 ; 128
|
|
|
|
3f1c: bf 07 cpc r27, r31
|
|
|
|
3f1e: 51 f7 brne .-44 ; 0x3ef4 <main+0xf4>
|
2011-06-11 02:47:47 +02:00
|
|
|
|
2010-09-22 15:04:33 +02:00
|
|
|
// Write from programming buffer
|
2011-06-11 01:17:13 +02:00
|
|
|
__boot_page_write_short((uint16_t)(void*)address);
|
2011-06-11 08:02:25 +02:00
|
|
|
3f20: f6 01 movw r30, r12
|
|
|
|
3f22: a7 be out 0x37, r10 ; 55
|
|
|
|
3f24: e8 95 spm
|
2010-09-22 15:04:33 +02:00
|
|
|
boot_spm_busy_wait();
|
2011-06-11 08:02:25 +02:00
|
|
|
3f26: 07 b6 in r0, 0x37 ; 55
|
|
|
|
3f28: 00 fc sbrc r0, 0
|
|
|
|
3f2a: fd cf rjmp .-6 ; 0x3f26 <main+0x126>
|
2010-09-22 15:04:33 +02:00
|
|
|
|
|
|
|
#if defined(RWWSRE)
|
|
|
|
// Reenable read access to flash
|
|
|
|
boot_rww_enable();
|
2011-06-11 08:02:25 +02:00
|
|
|
3f2c: b7 be out 0x37, r11 ; 55
|
|
|
|
3f2e: e8 95 spm
|
|
|
|
3f30: 26 c0 rjmp .+76 ; 0x3f7e <main+0x17e>
|
2010-09-22 15:04:33 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
/* Read memory block mode, length is big endian. */
|
|
|
|
else if(ch == STK_READ_PAGE) {
|
2011-06-11 08:02:25 +02:00
|
|
|
3f32: 84 37 cpi r24, 0x74 ; 116
|
|
|
|
3f34: b1 f4 brne .+44 ; 0x3f62 <main+0x162>
|
2010-09-22 15:04:33 +02:00
|
|
|
// READ PAGE - we only read flash
|
2011-06-11 08:02:25 +02:00
|
|
|
getch(); /* getlen() */
|
|
|
|
3f36: 2e d0 rcall .+92 ; 0x3f94 <getch>
|
|
|
|
length = getch();
|
|
|
|
3f38: 2d d0 rcall .+90 ; 0x3f94 <getch>
|
|
|
|
3f3a: f8 2e mov r15, r24
|
|
|
|
getch();
|
|
|
|
3f3c: 2b d0 rcall .+86 ; 0x3f94 <getch>
|
|
|
|
|
2010-09-22 15:04:33 +02:00
|
|
|
verifySpace();
|
2011-06-11 08:02:25 +02:00
|
|
|
3f3e: 38 d0 rcall .+112 ; 0x3fb0 <verifySpace>
|
|
|
|
3f40: f6 01 movw r30, r12
|
|
|
|
3f42: ef 2c mov r14, r15
|
2011-06-11 01:17:13 +02:00
|
|
|
putch(result);
|
2010-09-22 15:04:33 +02:00
|
|
|
address++;
|
2011-06-11 01:17:13 +02:00
|
|
|
}
|
|
|
|
while (--length);
|
2010-09-22 15:04:33 +02:00
|
|
|
#else
|
|
|
|
do putch(pgm_read_byte_near(address++));
|
2011-06-11 08:02:25 +02:00
|
|
|
3f44: 8f 01 movw r16, r30
|
|
|
|
3f46: 0f 5f subi r16, 0xFF ; 255
|
|
|
|
3f48: 1f 4f sbci r17, 0xFF ; 255
|
|
|
|
3f4a: 84 91 lpm r24, Z+
|
|
|
|
3f4c: 1b d0 rcall .+54 ; 0x3f84 <putch>
|
2010-09-22 15:04:33 +02:00
|
|
|
while (--length);
|
2011-06-11 08:02:25 +02:00
|
|
|
3f4e: ea 94 dec r14
|
|
|
|
3f50: f8 01 movw r30, r16
|
|
|
|
3f52: c1 f7 brne .-16 ; 0x3f44 <main+0x144>
|
|
|
|
#define rstVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+4))
|
|
|
|
#define wdtVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+6))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* main program starts here */
|
|
|
|
int main(void) {
|
|
|
|
3f54: 08 94 sec
|
|
|
|
3f56: c1 1c adc r12, r1
|
|
|
|
3f58: d1 1c adc r13, r1
|
|
|
|
3f5a: fa 94 dec r15
|
|
|
|
3f5c: cf 0c add r12, r15
|
|
|
|
3f5e: d1 1c adc r13, r1
|
|
|
|
3f60: 0e c0 rjmp .+28 ; 0x3f7e <main+0x17e>
|
2011-06-11 01:17:13 +02:00
|
|
|
#endif
|
2010-09-22 15:04:33 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get device signature bytes */
|
|
|
|
else if(ch == STK_READ_SIGN) {
|
2011-06-11 08:02:25 +02:00
|
|
|
3f62: 85 37 cpi r24, 0x75 ; 117
|
|
|
|
3f64: 39 f4 brne .+14 ; 0x3f74 <main+0x174>
|
2010-09-22 15:04:33 +02:00
|
|
|
// READ SIGN - return what Avrdude wants to hear
|
|
|
|
verifySpace();
|
2011-06-11 08:02:25 +02:00
|
|
|
3f66: 24 d0 rcall .+72 ; 0x3fb0 <verifySpace>
|
2010-09-22 15:04:33 +02:00
|
|
|
putch(SIGNATURE_0);
|
2011-06-11 08:02:25 +02:00
|
|
|
3f68: 8e e1 ldi r24, 0x1E ; 30
|
|
|
|
3f6a: 0c d0 rcall .+24 ; 0x3f84 <putch>
|
2010-09-22 15:04:33 +02:00
|
|
|
putch(SIGNATURE_1);
|
2011-06-11 08:02:25 +02:00
|
|
|
3f6c: 84 e9 ldi r24, 0x94 ; 148
|
|
|
|
3f6e: 0a d0 rcall .+20 ; 0x3f84 <putch>
|
2010-09-22 15:04:33 +02:00
|
|
|
putch(SIGNATURE_2);
|
2011-06-11 08:02:25 +02:00
|
|
|
3f70: 86 e0 ldi r24, 0x06 ; 6
|
|
|
|
3f72: 98 cf rjmp .-208 ; 0x3ea4 <main+0xa4>
|
2010-09-22 15:04:33 +02:00
|
|
|
}
|
|
|
|
else if (ch == 'Q') {
|
2011-06-11 08:02:25 +02:00
|
|
|
3f74: 81 35 cpi r24, 0x51 ; 81
|
|
|
|
3f76: 11 f4 brne .+4 ; 0x3f7c <main+0x17c>
|
2010-09-22 15:04:33 +02:00
|
|
|
// Adaboot no-wait mod
|
|
|
|
watchdogConfig(WATCHDOG_16MS);
|
2011-06-11 08:02:25 +02:00
|
|
|
3f78: 88 e0 ldi r24, 0x08 ; 8
|
|
|
|
3f7a: 14 d0 rcall .+40 ; 0x3fa4 <watchdogConfig>
|
2010-09-22 15:04:33 +02:00
|
|
|
verifySpace();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// This covers the response to commands like STK_ENTER_PROGMODE
|
|
|
|
verifySpace();
|
2011-06-11 08:02:25 +02:00
|
|
|
3f7c: 19 d0 rcall .+50 ; 0x3fb0 <verifySpace>
|
2010-09-22 15:04:33 +02:00
|
|
|
}
|
|
|
|
putch(STK_OK);
|
2011-06-11 08:02:25 +02:00
|
|
|
3f7e: 80 e1 ldi r24, 0x10 ; 16
|
|
|
|
3f80: 01 d0 rcall .+2 ; 0x3f84 <putch>
|
|
|
|
3f82: 6a cf rjmp .-300 ; 0x3e58 <main+0x58>
|
2010-09-22 15:04:33 +02:00
|
|
|
|
2011-06-11 08:02:25 +02:00
|
|
|
00003f84 <putch>:
|
2010-09-22 15:04:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void putch(char ch) {
|
2011-06-11 08:02:25 +02:00
|
|
|
3f84: 98 2f mov r25, r24
|
2010-09-22 15:04:33 +02:00
|
|
|
#ifndef SOFT_UART
|
|
|
|
while (!(UCSR0A & _BV(UDRE0)));
|
2011-06-11 08:02:25 +02:00
|
|
|
3f86: 80 91 c0 00 lds r24, 0x00C0
|
|
|
|
3f8a: 85 ff sbrs r24, 5
|
|
|
|
3f8c: fc cf rjmp .-8 ; 0x3f86 <putch+0x2>
|
2010-09-22 15:04:33 +02:00
|
|
|
UDR0 = ch;
|
2011-06-11 08:02:25 +02:00
|
|
|
3f8e: 90 93 c6 00 sts 0x00C6, r25
|
2010-09-22 15:04:33 +02:00
|
|
|
[uartBit] "I" (UART_TX_BIT)
|
|
|
|
:
|
|
|
|
"r25"
|
|
|
|
);
|
|
|
|
#endif
|
|
|
|
}
|
2011-06-11 08:02:25 +02:00
|
|
|
3f92: 08 95 ret
|
2010-09-22 15:04:33 +02:00
|
|
|
|
2011-06-11 08:02:25 +02:00
|
|
|
00003f94 <getch>:
|
2010-09-22 15:04:33 +02:00
|
|
|
}
|
2011-06-11 08:02:25 +02:00
|
|
|
#endif
|
2010-09-22 15:04:33 +02:00
|
|
|
|
|
|
|
// Watchdog functions. These are only safe with interrupts turned off.
|
|
|
|
void watchdogReset() {
|
|
|
|
__asm__ __volatile__ (
|
2011-06-11 08:02:25 +02:00
|
|
|
3f94: a8 95 wdr
|
2010-09-22 15:04:33 +02:00
|
|
|
[uartBit] "I" (UART_RX_BIT)
|
|
|
|
:
|
|
|
|
"r25"
|
|
|
|
);
|
|
|
|
#else
|
|
|
|
while(!(UCSR0A & _BV(RXC0)));
|
2011-06-11 08:02:25 +02:00
|
|
|
3f96: 80 91 c0 00 lds r24, 0x00C0
|
|
|
|
3f9a: 87 ff sbrs r24, 7
|
|
|
|
3f9c: fc cf rjmp .-8 ; 0x3f96 <getch+0x2>
|
2010-09-22 15:04:33 +02:00
|
|
|
ch = UDR0;
|
2011-06-11 08:02:25 +02:00
|
|
|
3f9e: 80 91 c6 00 lds r24, 0x00C6
|
2010-09-22 15:04:33 +02:00
|
|
|
LED_PIN |= _BV(LED);
|
2011-06-11 01:17:13 +02:00
|
|
|
#endif
|
2010-09-22 15:04:33 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return ch;
|
|
|
|
}
|
2011-06-11 08:02:25 +02:00
|
|
|
3fa2: 08 95 ret
|
2010-09-22 15:04:33 +02:00
|
|
|
|
2011-06-11 08:02:25 +02:00
|
|
|
00003fa4 <watchdogConfig>:
|
2010-09-22 15:04:33 +02:00
|
|
|
"wdr\n"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void watchdogConfig(uint8_t x) {
|
|
|
|
WDTCSR = _BV(WDCE) | _BV(WDE);
|
2011-06-11 08:02:25 +02:00
|
|
|
3fa4: e0 e6 ldi r30, 0x60 ; 96
|
|
|
|
3fa6: f0 e0 ldi r31, 0x00 ; 0
|
|
|
|
3fa8: 98 e1 ldi r25, 0x18 ; 24
|
|
|
|
3faa: 90 83 st Z, r25
|
2010-09-22 15:04:33 +02:00
|
|
|
WDTCSR = x;
|
2011-06-11 08:02:25 +02:00
|
|
|
3fac: 80 83 st Z, r24
|
2010-09-22 15:04:33 +02:00
|
|
|
}
|
2011-06-11 08:02:25 +02:00
|
|
|
3fae: 08 95 ret
|
2010-09-22 15:04:33 +02:00
|
|
|
|
2011-06-11 08:02:25 +02:00
|
|
|
00003fb0 <verifySpace>:
|
2010-09-22 15:04:33 +02:00
|
|
|
do getch(); while (--count);
|
|
|
|
verifySpace();
|
|
|
|
}
|
|
|
|
|
|
|
|
void verifySpace() {
|
2011-06-11 08:02:25 +02:00
|
|
|
if (getch() != CRC_EOP) {
|
|
|
|
3fb0: f1 df rcall .-30 ; 0x3f94 <getch>
|
|
|
|
3fb2: 80 32 cpi r24, 0x20 ; 32
|
|
|
|
3fb4: 19 f0 breq .+6 ; 0x3fbc <verifySpace+0xc>
|
|
|
|
watchdogConfig(WATCHDOG_16MS); // shorten WD timeout
|
|
|
|
3fb6: 88 e0 ldi r24, 0x08 ; 8
|
|
|
|
3fb8: f5 df rcall .-22 ; 0x3fa4 <watchdogConfig>
|
|
|
|
3fba: ff cf rjmp .-2 ; 0x3fba <verifySpace+0xa>
|
|
|
|
while (1) // and busy-loop so that WD causes
|
|
|
|
; // a reset and app start.
|
|
|
|
}
|
2010-09-22 15:04:33 +02:00
|
|
|
putch(STK_INSYNC);
|
2011-06-11 08:02:25 +02:00
|
|
|
3fbc: 84 e1 ldi r24, 0x14 ; 20
|
2010-09-22 15:04:33 +02:00
|
|
|
}
|
2011-06-11 08:02:25 +02:00
|
|
|
3fbe: e2 cf rjmp .-60 ; 0x3f84 <putch>
|
2011-06-11 01:17:13 +02:00
|
|
|
|
2011-06-11 08:02:25 +02:00
|
|
|
00003fc0 <getNch>:
|
2010-09-22 15:04:33 +02:00
|
|
|
::[count] "M" (UART_B_VALUE)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void getNch(uint8_t count) {
|
2011-06-11 08:02:25 +02:00
|
|
|
3fc0: 1f 93 push r17
|
|
|
|
3fc2: 18 2f mov r17, r24
|
2010-09-22 15:04:33 +02:00
|
|
|
do getch(); while (--count);
|
2011-06-11 08:02:25 +02:00
|
|
|
3fc4: e7 df rcall .-50 ; 0x3f94 <getch>
|
|
|
|
3fc6: 11 50 subi r17, 0x01 ; 1
|
|
|
|
3fc8: e9 f7 brne .-6 ; 0x3fc4 <getNch+0x4>
|
2010-09-22 15:04:33 +02:00
|
|
|
verifySpace();
|
2011-06-11 08:02:25 +02:00
|
|
|
3fca: f2 df rcall .-28 ; 0x3fb0 <verifySpace>
|
|
|
|
}
|
|
|
|
3fcc: 1f 91 pop r17
|
|
|
|
3fce: 08 95 ret
|
|
|
|
|
|
|
|
00003fd0 <appStart>:
|
|
|
|
WDTCSR = _BV(WDCE) | _BV(WDE);
|
|
|
|
WDTCSR = x;
|
2010-09-22 15:04:33 +02:00
|
|
|
}
|
2011-06-11 08:02:25 +02:00
|
|
|
|
|
|
|
void appStart() {
|
|
|
|
watchdogConfig(WATCHDOG_OFF);
|
|
|
|
3fd0: 80 e0 ldi r24, 0x00 ; 0
|
|
|
|
3fd2: e8 df rcall .-48 ; 0x3fa4 <watchdogConfig>
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
3fd4: ee 27 eor r30, r30
|
|
|
|
3fd6: ff 27 eor r31, r31
|
|
|
|
3fd8: 09 94 ijmp
|