1 # 1 "added/bootload.S" 1 /* 1 ... 0 0 22 .list 23 24 /* 25 atmel_def.h contains some definitions taken from the Atmel's def 26 file (which one is defined in the Makefile). Always keep in mind 27 that flash addresses taken from there are word addresses. 28 */ 29 #undef FLASHEND 30 #include "atmel_def.h" 1 #define SIGNATURE_000 0x1e 2 #define SIGNATURE_001 0x91 3 #define SIGNATURE_002 0x08 4 ; ***** BOOT_LOAD ******************** 5 #define FLASHEND 0x03ff // Note: Word address 6 #define SRAM_START 0x0060 7 #define SRAM_SIZE 128 8 ; ***** BOOTLOADER DECLARATIONS ****************************************** 9 #define PAGESIZE 16 31 32 #define byte3(x) ((x)>>16) 33 #define byte2(x) ((x & 0xff00)>>8) 34 #define byte1(x) (x & 0xff) 35 36 37 /* 38 Atmel's AVR assembler is case insensitive, gcc is not. 39 mangled_case.h covers the cases where the representations in the 40 program mix case. 41 */ 42 #include "mangled_case.h" 1 /* 43 44 /* 45 This includes the program: 46 */ 47 #include "bootload.asm" 1 ;************************************************************************* 2 ;* * 3 ;* Generic AVR Bootloader * 4 ;* * 5 ;* Author: Peter Dannegger * 6 ;* * 7 ;************************************************************************* 8 ; select the appropriate include file: 9 ;.include "tn13def.inc" 10 ;.include "tn2313def.inc" 11 ;.include "tn25def.inc" 12 ;.include "tn261def.inc" 13 ;.include "tn44def.inc" 14 ;.include "tn45def.inc" 15 ;.include "tn461def.inc" 16 ;.include "m48def.inc" 17 ;.include "tn84def.inc" 18 ;.include "tn85def.inc" 19 ;.include "tn861def.inc" 20 21 ; set the SecondBootStart fuse on these AVRs: 22 ;.include "m8def.inc" 23 ;.include "m8515def.inc" 24 ;.include "m8535def.inc" 25 ;.include "m88def.inc" 26 ;.include "m16def.inc" 27 ;.include "m162def.inc" 28 ;.include "m168def.inc" 29 30 ; set the FirstBootStart fuse on these AVRs: 31 ;.include "m32def.inc" 32 ;.include "m64def.inc" 33 ;.include "m644def.inc" 34 ;.include "m128def.inc" 35 ;.include "m1281def.inc" 36 ;.include "m2561def.inc" 37 38 39 ; remove comment sign to exclude API-Call: 40 ; only on ATmega >= 8kB supported 41 // #define APICALL 0 42 43 ; remove comment sign to exclude Watchdog trigger: 44 // #define WDTRIGGER 0 45 46 ; remove comment sign to exclude CRC: 47 // #define CRC 0 48 49 ; remove comment sign to exclude Verify: 50 // #define VERIFY 0 51 52 ;------------------------------------------------------------------------- 53 ; Port definitions 54 ;------------------------------------------------------------------------- 55 56 ;------------------------------------------------------------------------- 57 #include "fastload.inc" 1 /* 2 3 fastload.inc 4 5 Written by Peter Dannegger, modified by H. C. Zimmerer 6 7 Time-stamp: <2010-01-14 21:16:21 hcz> 8 9 You may use my modifications here and in the accompanying files of 10 this project for whatever you want to do with them provided you 11 don't remove this copyright notice. 12 13 14 */ 15 ;************************************************************************* 16 ;* * 17 ;* AVR universal Bootloader * 18 ;* * 19 ;* Author: Peter Dannegger * 20 ;* * 21 ;************************************************************************* 22 #include "fastload.h" 1 /* 2 fastload.h 3 4 Written by Peter Dannegger, modified by H. C. Zimmerer 5 6 Time-stamp: <2010-01-14 21:58:08 hcz> 7 8 You may use my modifications here and in the accompanying files of 9 this project for whatever you want to do with them provided you 10 don't remove this copyright notice. 11 12 */ 13 14 ;************************************************************************* 15 #include "compat.h" // compatibility definitions 1 /* 2 3 compat.h 4 5 Written by Peter Dannegger, modified by H. C. Zimmerer 6 7 Time-stamp: <2009-07-18 13:14:35 hcz> 8 9 You may use my modifications here and in the accompanying files of 10 this project for whatever you want to do with them provided you 11 don't remove this copyright notice. 12 13 14 */ 15 ;------------------------------------------------------------------------ 16 ; redefinitions for compatibility 17 ;------------------------------------------------------------------------ 18 #ifndef WDTCSR 19 #define WDTCSR WDTCR 20 #define wdtcsr WDTCR 21 #endif 22 ;--------------------------- 23 #ifndef WDCE 24 #define WDCE WDTOE 25 #define wdce WDTOE 26 #endif 27 ;--------------------------- 28 #ifndef SPMCSR 29 #define SPMCSR SPMCR 30 #define spmcsr SPMCR 31 #endif 32 ;--------------------------- 33 #ifndef RWWSRE 34 #ifdef ASRE 35 #define RWWSRE ASRE 36 #define rwwsre ASRE 37 #endif 38 #endif 39 ;--------------------------- 40 #ifndef SPMEN 41 #define SPMEN SELFPRGEN 42 #define spmen SELFPRGEN 43 #endif 44 ;---------------------- macros for extended IO access ------------------- 45 .macro xout arg0, arg1 46 .if \arg0 > 0x3F 47 sts \arg0, \arg1 48 .else 49 out \arg0, \arg1 50 .endif 51 .endm 52 ;--------------------------- 53 .macro xin arg0, arg1 54 .if \arg1 > 0x3F 55 lds \arg0, \arg1 56 .else 57 in \arg0, \arg1 58 .endif 59 .endm 60 ;--------------------------- 61 .macro xlpm arg0, arg1 62 .if FLASHEND > 0x7FFF 63 elpm \arg0, \arg1 64 .else 65 lpm \arg0, \arg1 66 .endif 67 .endm 68 ;------------------------------------------------------------------------ 69 ... 16 #include "protocol.h" 1 //************************************************************************* 17 ;------------------------------------------------------------------------- 18 ; Constant definitions 19 ;------------------------------------------------------------------------- 20 #define VERSION 0x0201 21 22 #define XTAL F_CPU // 8MHz, not critical 23 #define BootDelay XTAL / 3 // 0.33s 24 #define BOOTDELAY XTAL / 3 25 26 ;------------------------------ select UART mode ------------------------- 27 #if SRX == STX && SRX_PORT == STX_PORT 28 #define ONEWIRE 3 29 #else 30 #define ONEWIRE 0 31 #endif 32 33 #define SRX_PIN SRX_PORT - 2 34 #define STX_DDR STX_PORT - 1 35 36 ;------------------------------ select bootloader size ------------------- 37 38 #ifndef APICALL 39 #ifndef FirstBootStart 40 #define APICALL 0 41 #else 42 #define APICALL 2*12 43 #endif 44 #endif 45 46 #ifndef CRC 47 #define CRC 2*15 48 #endif 49 50 #ifndef VERIFY 51 #define VERIFY 2*14 52 #endif 53 54 #ifndef WDTRIGGER 55 #define WDTRIGGER 2*9 56 #endif 57 58 #ifndef SPH 59 #define MinSize 2*198 60 #define MINSIZE 2*198 61 #else 62 #define MinSize 2*203 63 #define MINSIZE 2*203 64 #endif 65 66 #define BootSize CRC + VERIFY + ONEWIRE + WDTRIGGER + MinSize 67 #define BOOTSIZE CRC + VERIFY + ONEWIRE + WDTRIGGER + MinSize 68 69 ;------------------------------ UART delay loop value -------------------- 70 #if CRC 71 #define UartLoop 28 // UART loop time 72 #define UARTLOOP 28 73 #else 74 #define UartLoop 24 75 #define UARTLOOP 24 76 #endif 77 78 ;------------------------------ Bootloader fuse setting ------------------ 79 #ifdef FIRSTBOOTSTART 80 # if (FlashEnd - FirstBootStart) >= 256 // 256 Words needed 81 # define BootStart FirstBootStart 82 # define BOOTSTART FirstBootStart 83 # else 84 # define BootStart SecondBootStart 85 # define BOOTSTART SecondBootStart 86 # endif 87 ;---------------------------- max possible buffer size ----------------- 88 89 .equ BufferSize,((SRAM_SIZE / 2) - PAGESIZE) 90 .macro testpage 91 .if BootStart % BufferSize 92 .set BufferSize, BufferSize - PAGESIZE 93 .if BootStart % BufferSize 94 .set Buffersize, BufferSize - PAGESIZE 95 testpage 96 .endif 97 .endif 98 .endm 99 testpage ; calculate Buffersize to fit into BootStart 100 101 ;----------------------------------------------------------------------- 102 # define UserFlash (2*BootStart) 103 # define USERFLASH (2*BootStart) 104 #else /* FirstBootStart not defined */ 105 # ifndef FLASHEND 106 # define FLASHEND FlashEnd 107 # endif 108 # define BootStart (FLASHEND - 255) 109 # define BOOTSTART (FLASHEND - 255) 110 # define BufferSize PageSize 111 # define BUFFERSIZE PageSize 112 # define UserFlash (2 * BootStart - 2) 113 # define USERFLASH (2 * BootStart - 2) 114 #endif 115 ;------------------------------------------------------------------------- 116 ; Using register 117 ;------------------------------------------------------------------------- 118 #define zerol r2 119 #define ZEROL r2 120 #define zeroh r3 121 #define ZEROH r3 122 #define baudl r4 // baud divider 123 #define BAUDL r4 124 #define baudh r5 125 #define BAUDH r5 126 #define crcl r6 127 #define CRCL r6 128 #define crch r7 129 #define CRCH r7 130 131 ;------------------------------------------------------------------------- 132 #define appl r16 // rjmp to application 133 #define APPL r16 134 #define apph r17 135 #define APPH r17 136 #define polynoml r18 // CRC polynom 0xA001 137 #define POLYNOML r18 138 #define polynomh r19 139 #define POLYNOMH r19 140 141 #define zx r21 // 3 byte Z pointer 142 #define ZX r21 143 #define a0 r22 // working registers 144 #define A0 r22 145 #define a1 r23 146 #define A1 r23 147 #define twl r24 // wait time 148 #define TWL r24 149 #define twh r25 150 #define TWH r25 151 ;------------------------------------------------------------------------- 152 ; Using SRAM 153 ;------------------------------------------------------------------------- 154 .section .bss 155 .global PROGBUFF,PROGBUFFEND 156 0000 0000 0000 PROGBUFF: .space 2*BufferSize 156 0000 0000 156 0000 0000 156 0000 0000 156 0000 0000 157 PROGBUFFEND: 158 ProgBuffEnd: 159 .section .text 160 ;------------------------------------------------------------------------- 161 ; Macros 162 ;------------------------------------------------------------------------- 163 #if ONEWIRE 164 .macro IOPortInit 165 sbi STX_PORT, SRX ; weak pullup on 166 cbi STX_DDR, SRX ; as input 167 .endm 168 .macro TXD_0 169 sbi STX_DDR, SRX ; strong pullup = 0 170 .endm 171 .macro TXD_1 172 cbi STX_DDR, SRX ; weak pullup = 1 173 .endm 174 .macro SKIP_RXD_0 175 sbis SRX_PIN, SRX ; low = 1 176 .endm 177 .macro SKIP_RXD_1 178 sbic SRX_PIN, SRX ; high = 0 179 .endm 180 #else 181 .macro IOPortInit 182 sbi SRX_PORT, SRX 183 sbi STX_PORT, STX 184 sbi STX_DDR, STX 185 .endm 186 .macro TXD_0 187 cbi STX_PORT, STX 188 .endm 189 .macro TXD_1 190 sbi STX_PORT, STX 191 .endm 192 .macro SKIP_RXD_0 193 sbic SRX_PIN, SRX 194 .endm 195 .macro SKIP_RXD_1 196 sbis SRX_PIN, SRX 197 .endm 198 #endif 199 ;------------------------------------------------------------------------- 200 ... 23 .list 24 init: 25 #ifndef FIRSTBOOTSTART 26 ; .equ Application,init-2 27 #endif 28 0000 F894 cli ; no interrupts allowed 29 0002 6FED ldi a0, lo8(RamEnd) ; initialize stack 30 0004 6DBF out SPL, a0 31 #ifdef SPH 32 ldi a0, hi8(RamEnd) 33 out SPH, a0 34 #endif 35 0006 2224 clr zerol ; for faster clear 36 0008 3324 clr zeroh 37 38 #if WDTRIGGER 39 #include "watchdog.inc" 1 ;------------------------------ check, if watchdog active ---------------- 2 000a A895 wdr 3 000c 61B5 xin a0, WDTCSR 4 000e 6061 ori a0, 1< 0x7FFF 6 ldi a0, hh8(/* 2* */Password) 7 out RAMPZ, a0 8 #endif 9 checkpwd: 10 005a E0E0 ldi zl, lo8(/* 2* */Password) 11 005c F0E0 ldi zh, hi8(/* 2* */Password) 12 _cpw2: 13 005e 0590 XLPM r0, z+ 14 0060 0020 tst r0 15 0062 01F0 breq _cpw3 ; end if zero byte 16 0064 00D0 rcall getchar 17 0066 0616 cp r0, a0 18 0068 01F0 breq _cpw2 ; compare next byte 19 006a CA95 dec yl ; count down wrong compares 20 006c 01F0 breq timeout 21 006e 00C0 rjmp checkpwd ; try again 22 _cpw3: 23 ;------------------------------------------------------------------------- 24 ... 50 ;------------------------------------------------------------------------- 51 connected: 52 0070 66EA ldi a0, CONNECT ; password recognized 53 #if ONEWIRE 54 0072 00D0 rcall syncputchar ; avoid message garbage 55 #else 56 rcall putchar 57 #endif 58 0074 00D0 rcall getchar 59 0076 01F4 brne connected ; until COMMAND received 60 ;------------------------------------------------------------------------- 61 #include "command.inc" // execute commands 1 ;------------------------------------------------------------------------- 2 ; Receive commands 3 ;------------------------------------------------------------------------- 4 ;00 get bootloader revision 5 ;01 get buffer size 6 ;02 get target signature 7 ;03 get user flash size 8 ;04 program flash 9 ;05 start application 10 ;06 check crc 11 ;07 verify flash 12 ;------------------------------------------------------------------------- 13 main_ok: 14 0078 6AEA ldi a0, SUCCESS 15 _cex1: 16 007a 00D0 rcall putchar 17 _cex2: 18 007c 00D0 rcall getchar 19 007e 01F4 brne _cex2 ; ignore until COMMAND 20 _cex3: 21 0080 00D0 rcall getchar 22 0082 01F0 breq _cex3 ; ignore further COMMAND 23 #if FLASHEND > 0x7FFF 24 ldi zx, 0 25 #endif 26 0084 F101 movw zl, zerol ; Z = 0x0000, 27 0086 E894 clt ; T = 0 (for program, verify) 28 0088 6430 cpi a0, 4 29 008a 00F0 brcs SendMessage ; command 0 ... 3 30 008c 01F0 breq program ; command 4 31 008e 6530 cpi a0, 5 32 0090 01F0 breq timeout ; command 5 33 0092 6730 cpi a0, 7 34 #if VERIFY 35 0094 01F0 breq VerifyFlash ; command 7 36 #endif 37 0096 67EA ldi a0, BADCOMMAND 38 ;------------------------------------------------------------------------- 39 #if CRC 40 0098 00F4 brcc _cex1 ; command >7 41 ;------------------------------------------------------------------------- 42 CheckCRC: ; command 6 43 009a 00D0 rcall getchar ; read CRC low 44 009c 00D0 rcall getchar ; read CRC high 45 009e 6728 or crcl, crch ; now CRC = 0x0000 ? 46 00a0 01F0 breq main_ok ; yes 47 00a2 3101 movw crcl, zerol ; clear CRC 48 #else 49 rjmp _cex1 50 #endif 51 ;------------------------------------------------------------------------- 52 main_error: 53 00a4 6BEA ldi a0, FAIL 54 00a6 00C0 rjmp _cex1 55 ;------------------------------------------------------------------------- 56 timeout: ; command 5 57 00a8 27BA out STX_DDR, zerol 58 00aa 28BA out STX_PORT, zerol 59 #if SRX_PORT != STX_PORT 60 out SRX_PORT, zerol 61 #endif 62 #if FlashEnd > 0x0fff 63 jmp Application 64 #else 65 00ac 00C0 rjmp Application ; run application 66 #endif 67 ;------------------------------------------------------------------------- 68 #include "message.inc" // command 0 ... 3 1 ;------------------------------------------------------------------------- 2 ; Send Messages 3 ;------------------------------------------------------------------------- 4 ;input: a0 = number of message 0 .. 3 5 ; 6 SendMessage: 7 #if FLASHEND > 0x7FFF 8 ldi zx, hh8(/* 2* */Messages) 9 out RAMPZ, zx 10 #endif 11 00ae E0E0 ldi zl, lo8(/* 2* */Messages) 12 00b0 F0E0 ldi zh, hi8(/* 2* */Messages) 13 00b2 C0E0 ldi yl, 0 14 _sme1: 15 00b4 EC0F add zl, yl ; add offset to next message 16 00b6 F21D adc zh, zerol 17 00b8 C491 XLPM yl, z 18 00ba 6150 subi a0, 1 ; count down until message found 19 00bc 00F4 brcc _sme1 20 00be 68EA ldi a0, ANSWER ; first byte of message 21 _sme2: 22 00c0 00D0 rcall putchar 23 00c2 6591 XLPM a0, z+ 24 00c4 C150 subi yl, 1 25 00c6 00F4 brcc _sme2 26 00c8 00C0 rjmp main_ok 27 ;------------------------------------------------------------------------- 28 ... 69 ;------------------------------------------------------------------------- 70 #if VERIFY 71 #include "verify.inc" // command 7 1 ;------------------------------------------------------------------------- 2 ; Verify User Flash 3 ;------------------------------------------------------------------------- 4 ; 5 _ver1: 6 #if FLASHEND > 0x7FFF 7 out RAMPZ, zx 8 elpm r0, z 9 adiw zl, 1 10 adc zx, zerol ; 24 bit addition 11 #else 12 00ca 0590 lpm r0, z+ 13 #endif 14 #ifndef FirstBootStart 15 00cc E330 cpi zl, 3 16 00ce F205 cpc zh, zerol 17 00d0 00F0 brcs VerifyFlash ; exclude jump to bootloader 18 #endif 19 00d2 0612 cpse r0, a0 20 00d4 6894 set 21 VerifyFlash: 22 00d6 00D0 rcall getchar 23 00d8 01F4 brne _ver1 ; not COMMAND ? 24 00da 00D0 rcall getchar 25 00dc 6058 subi a0, ESC_SHIFT 26 00de 01F4 brne _ver1 ; COMMMAND + not COMMAND = End 27 00e0 06F0 brts main_error ; error, Flash not equal 28 00e2 00C0 rjmp main_ok 29 ;------------------------------------------------------------------------- 30 ... 72 #endif 73 ;------------------------------------------------------------------------- 74 #ifdef FirstBootStart 75 #include "progmega.inc" // mega with bootstart fuse set 76 #else 77 #include "progtiny.inc" // tiny, mega without RWW section 1 ;------------------------------------------------------------------------- 2 ; Program User Flash 3 ;------------------------------------------------------------------------- 4 ; 5 Program: 6 00e4 A0E0 ldi xl, lo8(ProgBuff) 7 00e6 B0E0 ldi xh, hi8(ProgBuff) 8 00e8 ED01 movw yl, xl 9 00ea 06F0 brts _pro5 10 ;---------------------- Receive data for one Page ------------------------ 11 _pro1: 12 00ec 00D0 rcall getchar 13 00ee 01F4 brne _pro2 14 00f0 00D0 rcall getchar 15 00f2 6058 subi a0, ESC_SHIFT 16 00f4 6894 set ; end mark received set 17 00f6 01F0 breq _pro3 18 00f8 E894 clt 19 _pro2: 20 00fa 6D93 st x+, a0 21 00fc A030 cpi xl, lo8(ProgBuffEnd) ; since buffer size below 256 22 00fe 01F4 brne _pro1 23 ;------------------------------------------------------------------------- 24 _pro3: 25 0100 3096 adiw zl, 0 26 0102 01F4 brne _pro5 27 ;------------------------------ Insert rjmp to boot loader --------------- 28 0104 0881 ld appl, y 29 0106 1981 ldd apph, y+1 30 0108 0F5F subi appl, lo8(BootStart - 0x1001) ; new application jump 31 010a 124F sbci apph, hi8(BootStart - 0x1001) 32 010c 6FEF ldi a0, lo8(BootStart-1) 33 010e 72EC ldi a1, hi8(BootStart-1 + 0xC000) ; = RJMP 34 0110 6883 st y, a0 35 0112 7983 std y+1, a1 ; replace by bootloader jump 36 ;------------------------------------------------------------------------- 37 ; Erase application Flash backward (avoid lock out) 38 ;------------------------------------------------------------------------- 39 0114 E0E0 ldi zl, (2*BOOTSTART)&0xff 40 0116 F6E0 ldi zh, BOOTSTART>>7 41 _pro4: 42 #if PageSize < 32 43 0118 B097 sbiw zl, PageSize * 2 44 #else 45 subi zl, lo8(2 * PageSize) 46 sbci zh, hi8(2 * PageSize) 47 #endif 48 011a 63E0 ldi a0, 1<>7 90 014c F607 cpc zh, a0 ; last page reached ? 91 014e 00F0 brcs Program 92 0150 06F0 brts _pro9 93 0152 00C0 rjmp main_error ; error, size exceeded 94 _pro9: 95 0154 00C0 rjmp main_ok 96 ;------------------------------------------------------------------------- 97 ... 78 #endif 79 ;------------------------------------------------------------------------- 80 ... 62 #include "uart.inc" // UART subroutines 1 ;------------------------------------------------------------------------- 2 ; Receive Byte 3 ;------------------------------------------------------------------------- 4 ;output: a0 = byte 5 ;used: a1 6 ; 7 getchar: 8 #if WDTRIGGER 9 0156 A895 wdr 10 #endif 11 0158 B499 SKIP_RXD_1 ; wait for RXD = 1 12 015a 00C0 rjmp getchar 13 _rx1: 14 015c B49B SKIP_RXD_0 ; wait for RXD = 0 (start bit) 15 015e 00C0 rjmp _rx1 16 0160 78E0 ldi a1, 8 17 0162 C201 movw twl, baudl 18 0164 9695 lsr twh 19 0166 8795 ror twl 20 0168 00D0 rcall wait_time ; middle of start bit 21 _rx2: 22 016a 00D0 rcall wait_bit_time ;14 + tw 23 016c 6695 lsr a0 ;1 24 016e B49B SKIP_RXD_0 ;1/2 25 0170 6068 ori a0, 0x80 ;1 26 #if CRC 27 ;------------------------------ CRC -------------------------------------- 28 0172 67FD sbrc a0, 7 ;1 29 0174 6226 eor crcl, polynoml ;1 crcl.0 ^= a0.7 30 0176 7694 lsr crch ;1 31 0178 6794 ror crcl ;1 32 017a 00F4 brcc _rx5 ;1 33 017c 6226 eor crcl, polynoml ;1 ^0x01 34 _rx5: 35 017e 00F4 brcc _rx6 ;1 36 0180 7326 eor crch, polynomh ;1 ^0xA0 37 _rx6: 38 ;------------------------------------------------------------------------- 39 #else 40 rjmp . ;2 41 rjmp . ;2 42 #endif 43 0182 7A95 dec a1 ;1 44 0184 01F4 brne _rx2 ;2 = 24 + tw 45 0186 653A cpi a0, COMMAND ; needed several times 46 0188 0895 ret 47 ;------------------------------------------------------------------------- 48 ; transmit byte 49 ;------------------------------------------------------------------------- 50 ;input: a0 = byte 51 ;used: a1 52 ; 53 putchar: 54 018a 00D0 rcall wait_bit_time 55 018c BC9A TXD_0 56 #if ONEWIRE 57 018e 00C0 rjmp _tx2 58 syncputchar: ; start with 1->0 from master 59 0190 B499 SKIP_RXD_1 60 0192 00C0 rjmp syncputchar 61 _tx1: 62 0194 B49B SKIP_RXD_0 63 0196 00C0 rjmp _tx1 64 _tx2: 65 #else 66 lpm a1, z ;3 67 #endif 68 0198 79E0 ldi a1, 9 ;1 69 019a 6095 com a0 ;1 = 5 70 _tx3: 71 #if CRC 72 019c 00C0 rjmp . ;2 73 019e 00C0 rjmp . ;2 74 #endif 75 01a0 00D0 rcall wait_bit_time ;14 + tw 76 01a2 6695 lsr a0 ;1 77 01a4 00F4 brcc _tx4 ;1/2 78 01a6 0000 nop ;1 79 01a8 BC9A TXD_0 ;2 80 01aa 00C0 rjmp _tx5 ;2 81 _tx4: 82 01ac BC98 TXD_1 ;2 83 01ae 00C0 rjmp _tx5 ;2 84 _tx5: 85 01b0 7A95 dec a1 ;1 86 01b2 01F4 brne _tx3 ;2 = 24 + tw 87 01b4 0895 ret 88 ;------------------------------------------------------------------------- 89 ; Wait 14 cycle + tw 90 ; 91 wait_bit_time: 92 01b6 C201 movw twl, baudl ;1 93 wait_time: 94 01b8 0497 sbiw twl, 4 ;2 95 01ba 00F4 brcc wait_time ;2/1 96 01bc 8D3F cpi twl, 0xFD ;1 97 01be 00F0 brcs _wt1 ;2/1 (2) 98 01c0 01F0 breq _wt1 ;2/1 (3) 99 01c2 8F3F cpi twl, 0xFF ;1 100 01c4 01F0 breq _wt1 ;2/1 (4/5) 101 _wt1: 102 01c6 0895 ret ;4 + 3 (rcall) = 14 103 ;------------------------------------------------------------------------- 104 ... 63 ;------------------------------------------------------------------------- 64 Password: 65 01c8 5065 6461 .ascii "Peda", "\0", "\0" ; 'a' was recognized by ABAUD 65 0000 66 67 .list 68 Messages: 69 01ce 03 .byte 3 70 01cf 02 .byte VERSION>>8 71 01d0 01 .byte VERSION&0xff 72 01d1 03 .byte 3 73 01d2 00 .byte ((2*BufferSize)>>8) 74 01d3 20 .byte ((2*BufferSize) & 0xff) 75 01d4 04 .byte 4 76 01d5 1E .byte SIGNATURE_000 77 01d6 91 .byte SIGNATURE_001 78 01d7 08 .byte SIGNATURE_002 79 01d8 04 .byte 4 80 01d9 00 .byte UserFlash>>16 81 01da 05 .byte (UserFlash>>8) & 0xff 82 01db FE .byte UserFlash & 0xff 83 .align 1 84 ;------------------------------------------------------------------------- 85 #if APICALL 86 #include "apicall.inc" // program Flash from application 87 #endif 88 ;------------------------------------------------------------------------- 89 ... 58 ;------------------------------------------------------------------------- 59 ... 48 49 50 .global api_call DEFINED SYMBOLS ./added/fastload.h:156 .bss:0000000000000000 PROGBUFF ./added/fastload.h:157 .bss:0000000000000020 PROGBUFFEND ./added/fastload.h:158 .bss:0000000000000020 ProgBuffEnd ./added/fastload.inc:24 .text:0000000000000000 init ./converted/abaud.inc:15 .text:0000000000000020 abaud ./converted/abaud.inc:17 .text:0000000000000022 _aba1 ./converted/abaud.inc:19 .text:0000000000000024 _aba2 ./converted/abaud.inc:22 .text:0000000000000028 _aba3 ./converted/command.inc:56 .text:00000000000000a8 timeout ./converted/abaud.inc:28 .text:0000000000000032 _aba4 ./converted/abaud.inc:36 .text:000000000000003e _aba5 ./converted/password.inc:9 .text:000000000000005a checkpwd ./added/fastload.inc:64 .text:00000000000001c8 Password ./converted/password.inc:12 .text:000000000000005e _cpw2 ./converted/password.inc:22 .text:0000000000000070 _cpw3 ./converted/uart.inc:7 .text:0000000000000156 getchar ./added/fastload.inc:51 .text:0000000000000070 connected ./converted/uart.inc:58 .text:0000000000000190 syncputchar ./converted/command.inc:13 .text:0000000000000078 main_ok ./converted/command.inc:15 .text:000000000000007a _cex1 ./converted/uart.inc:53 .text:000000000000018a putchar ./converted/command.inc:17 .text:000000000000007c _cex2 ./converted/command.inc:20 .text:0000000000000080 _cex3 ./converted/message.inc:6 .text:00000000000000ae SendMessage ./converted/progtiny.inc:5 .text:00000000000000e4 Program ./converted/verify.inc:21 .text:00000000000000d6 VerifyFlash ./converted/command.inc:42 .text:000000000000009a CheckCRC ./converted/command.inc:52 .text:00000000000000a4 main_error ./added/fastload.inc:68 .text:00000000000001ce Messages ./converted/message.inc:14 .text:00000000000000b4 _sme1 ./converted/message.inc:21 .text:00000000000000c0 _sme2 ./converted/verify.inc:5 .text:00000000000000ca _ver1 ./converted/progtiny.inc:53 .text:0000000000000122 _pro5 ./converted/progtiny.inc:11 .text:00000000000000ec _pro1 ./converted/progtiny.inc:19 .text:00000000000000fa _pro2 ./converted/progtiny.inc:24 .text:0000000000000100 _pro3 ./converted/progtiny.inc:41 .text:0000000000000118 _pro4 ./converted/progtiny.inc:58 .text:0000000000000128 _pro6 ./converted/progtiny.inc:87 .text:0000000000000148 _pro8 ./converted/progtiny.inc:94 .text:0000000000000154 _pro9 ./converted/uart.inc:13 .text:000000000000015c _rx1 ./converted/uart.inc:93 .text:00000000000001b8 wait_time ./converted/uart.inc:21 .text:000000000000016a _rx2 ./converted/uart.inc:91 .text:00000000000001b6 wait_bit_time ./converted/uart.inc:34 .text:000000000000017e _rx5 ./converted/uart.inc:37 .text:0000000000000182 _rx6 ./converted/uart.inc:64 .text:0000000000000198 _tx2 ./converted/uart.inc:61 .text:0000000000000194 _tx1 ./converted/uart.inc:70 .text:000000000000019c _tx3 ./converted/uart.inc:81 .text:00000000000001ac _tx4 ./converted/uart.inc:84 .text:00000000000001b0 _tx5 ./converted/uart.inc:101 .text:00000000000001c6 _wt1 UNDEFINED SYMBOLS Application api_call