netload_debug2560.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .data 0000001a 00800200 0003f784 00001818 2**0
CONTENTS, ALLOC, LOAD, DATA
1 .text 00001784 0003e000 0003e000 00000094 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .bss 0000000d 0080021a 0080021a 00001832 2**0
ALLOC
3 .comment 00000030 00000000 00000000 00001832 2**0
CONTENTS, READONLY
4 .debug_aranges 00000178 00000000 00000000 00001862 2**0
CONTENTS, READONLY, DEBUGGING
5 .debug_info 0000305e 00000000 00000000 000019da 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_abbrev 00000e91 00000000 00000000 00004a38 2**0
CONTENTS, READONLY, DEBUGGING
7 .debug_line 00001807 00000000 00000000 000058c9 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_frame 0000051c 00000000 00000000 000070d0 2**2
CONTENTS, READONLY, DEBUGGING
9 .debug_str 000009d1 00000000 00000000 000075ec 2**0
CONTENTS, READONLY, DEBUGGING
10 .debug_loc 00001c75 00000000 00000000 00007fbd 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_ranges 000000b8 00000000 00000000 00009c32 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
0003e000 <__vectors>:
3e000:ee c1 rjmp.+988 ; 0x3e3de <__ctors_end>
3e002:00 00 nop
3e004:76 c2 rjmp.+1260 ; 0x3e4f2 <__bad_interrupt>
3e006:00 00 nop
3e008:74 c2 rjmp.+1256 ; 0x3e4f2 <__bad_interrupt>
3e00a:00 00 nop
3e00c:72 c2 rjmp.+1252 ; 0x3e4f2 <__bad_interrupt>
3e00e:00 00 nop
3e010:70 c2 rjmp.+1248 ; 0x3e4f2 <__bad_interrupt>
3e012:00 00 nop
3e014:6e c2 rjmp.+1244 ; 0x3e4f2 <__bad_interrupt>
3e016:00 00 nop
3e018:6c c2 rjmp.+1240 ; 0x3e4f2 <__bad_interrupt>
3e01a:00 00 nop
3e01c:6a c2 rjmp.+1236 ; 0x3e4f2 <__bad_interrupt>
3e01e:00 00 nop
3e020:68 c2 rjmp.+1232 ; 0x3e4f2 <__bad_interrupt>
3e022:00 00 nop
3e024:66 c2 rjmp.+1228 ; 0x3e4f2 <__bad_interrupt>
3e026:00 00 nop
3e028:64 c2 rjmp.+1224 ; 0x3e4f2 <__bad_interrupt>
3e02a:00 00 nop
3e02c:62 c2 rjmp.+1220 ; 0x3e4f2 <__bad_interrupt>
3e02e:00 00 nop
3e030:60 c2 rjmp.+1216 ; 0x3e4f2 <__bad_interrupt>
3e032:00 00 nop
3e034:5e c2 rjmp.+1212 ; 0x3e4f2 <__bad_interrupt>
3e036:00 00 nop
3e038:5c c2 rjmp.+1208 ; 0x3e4f2 <__bad_interrupt>
3e03a:00 00 nop
3e03c:5a c2 rjmp.+1204 ; 0x3e4f2 <__bad_interrupt>
3e03e:00 00 nop
3e040:58 c2 rjmp.+1200 ; 0x3e4f2 <__bad_interrupt>
3e042:00 00 nop
3e044:56 c2 rjmp.+1196 ; 0x3e4f2 <__bad_interrupt>
3e046:00 00 nop
3e048:54 c2 rjmp.+1192 ; 0x3e4f2 <__bad_interrupt>
3e04a:00 00 nop
3e04c:52 c2 rjmp.+1188 ; 0x3e4f2 <__bad_interrupt>
3e04e:00 00 nop
3e050:50 c2 rjmp.+1184 ; 0x3e4f2 <__bad_interrupt>
3e052:00 00 nop
3e054:4e c2 rjmp.+1180 ; 0x3e4f2 <__bad_interrupt>
3e056:00 00 nop
3e058:4c c2 rjmp.+1176 ; 0x3e4f2 <__bad_interrupt>
3e05a:00 00 nop
3e05c:4a c2 rjmp.+1172 ; 0x3e4f2 <__bad_interrupt>
3e05e:00 00 nop
3e060:48 c2 rjmp.+1168 ; 0x3e4f2 <__bad_interrupt>
3e062:00 00 nop
3e064:46 c2 rjmp.+1164 ; 0x3e4f2 <__bad_interrupt>
3e066:00 00 nop
3e068:44 c2 rjmp.+1160 ; 0x3e4f2 <__bad_interrupt>
3e06a:00 00 nop
3e06c:42 c2 rjmp.+1156 ; 0x3e4f2 <__bad_interrupt>
3e06e:00 00 nop
3e070:40 c2 rjmp.+1152 ; 0x3e4f2 <__bad_interrupt>
3e072:00 00 nop
3e074:3e c2 rjmp.+1148 ; 0x3e4f2 <__bad_interrupt>
3e076:00 00 nop
3e078:3c c2 rjmp.+1144 ; 0x3e4f2 <__bad_interrupt>
3e07a:00 00 nop
3e07c:3a c2 rjmp.+1140 ; 0x3e4f2 <__bad_interrupt>
3e07e:00 00 nop
3e080:38 c2 rjmp.+1136 ; 0x3e4f2 <__bad_interrupt>
3e082:00 00 nop
3e084:36 c2 rjmp.+1132 ; 0x3e4f2 <__bad_interrupt>
3e086:00 00 nop
3e088:34 c2 rjmp.+1128 ; 0x3e4f2 <__bad_interrupt>
3e08a:00 00 nop
3e08c:32 c2 rjmp.+1124 ; 0x3e4f2 <__bad_interrupt>
3e08e:00 00 nop
3e090:30 c2 rjmp.+1120 ; 0x3e4f2 <__bad_interrupt>
3e092:00 00 nop
3e094:2e c2 rjmp.+1116 ; 0x3e4f2 <__bad_interrupt>
3e096:00 00 nop
3e098:2c c2 rjmp.+1112 ; 0x3e4f2 <__bad_interrupt>
3e09a:00 00 nop
3e09c:2a c2 rjmp.+1108 ; 0x3e4f2 <__bad_interrupt>
3e09e:00 00 nop
3e0a0:28 c2 rjmp.+1104 ; 0x3e4f2 <__bad_interrupt>
3e0a2:00 00 nop
3e0a4:26 c2 rjmp.+1100 ; 0x3e4f2 <__bad_interrupt>
3e0a6:00 00 nop
3e0a8:24 c2 rjmp.+1096 ; 0x3e4f2 <__bad_interrupt>
3e0aa:00 00 nop
3e0ac:22 c2 rjmp.+1092 ; 0x3e4f2 <__bad_interrupt>
3e0ae:00 00 nop
3e0b0:20 c2 rjmp.+1088 ; 0x3e4f2 <__bad_interrupt>
3e0b2:00 00 nop
3e0b4:1e c2 rjmp.+1084 ; 0x3e4f2 <__bad_interrupt>
3e0b6:00 00 nop
3e0b8:1c c2 rjmp.+1080 ; 0x3e4f2 <__bad_interrupt>
3e0ba:00 00 nop
3e0bc:1a c2 rjmp.+1076 ; 0x3e4f2 <__bad_interrupt>
3e0be:00 00 nop
3e0c0:18 c2 rjmp.+1072 ; 0x3e4f2 <__bad_interrupt>
3e0c2:00 00 nop
3e0c4:16 c2 rjmp.+1068 ; 0x3e4f2 <__bad_interrupt>
3e0c6:00 00 nop
3e0c8:14 c2 rjmp.+1064 ; 0x3e4f2 <__bad_interrupt>
3e0ca:00 00 nop
3e0cc:12 c2 rjmp.+1060 ; 0x3e4f2 <__bad_interrupt>
3e0ce:00 00 nop
3e0d0:10 c2 rjmp.+1056 ; 0x3e4f2 <__bad_interrupt>
3e0d2:00 00 nop
3e0d4:0e c2 rjmp.+1052 ; 0x3e4f2 <__bad_interrupt>
3e0d6:00 00 nop
3e0d8:0c c2 rjmp.+1048 ; 0x3e4f2 <__bad_interrupt>
3e0da:00 00 nop
3e0dc:0a c2 rjmp.+1044 ; 0x3e4f2 <__bad_interrupt>
3e0de:00 00 nop
3e0e0:08 c2 rjmp.+1040 ; 0x3e4f2 <__bad_interrupt>
...
0003e0e4 <__trampolines_end>:
3e0e4:53 74 andir21, 0x43; 67
3e0e6:61 72 andir22, 0x21; 33
3e0e8:74 20 andr7, r4
3e0ea:75 73 andir23, 0x35; 53
3e0ec:65 72 andir22, 0x25; 37
3e0ee:20 61 orir18, 0x10; 16
3e0f0:70 70 andir23, 0x00; 0
...
0003e0f3 :
3e0f3:41 72 69 61 64 6e 65 20 66 6f 72 20 41 72 64 75 Ariadne for Ardu
3e103:69 6e 6f 20 4d 65 67 61 32 35 36 30 2c 20 56 65 ino Mega2560, Ve
3e113:72 73 69 6f 6e 20 30 2e 35 00 rsion 0.5.
0003e11d :
3e11d:4d 61 69 6e 3a 20 00 Main: .
0003e124 :
3e124:4e 65 74 77 6f 72 6b 20 69 6e 69 74 20 64 6f 6e Network init don
3e134:65 00 e.
0003e136 :
3e136:09 20 20 20 20 4d 41 43 3a 20 00 . MAC: .
0003e141 :
3e141:09 47 61 74 65 77 61 79 3a 20 00 .Gateway: .
0003e14c :
3e14c:09 20 53 75 62 6e 65 74 3a 20 00 . Subnet: .
0003e157 :
3e157:09 41 64 64 72 65 73 73 3a 20 00 .Address: .
0003e162 :
3e162:42 75 69 6c 74 2d 69 6e 20 73 65 74 74 69 6e 67 Built-in setting
3e172:73 00 s.
0003e174 :
3e174:45 45 50 52 4f 4d 20 73 65 74 74 69 6e 67 73 00 EEPROM settings.
0003e184 :
3e184:20 4e 65 74 3a 20 00 Net: .
0003e18b :
3e18b:00 05 00 00 49 6e 76 61 6c 69 64 20 69 6d 61 67 ....Invalid imag
3e19b:65 20 66 69 6c 65 00 e file.
0003e1a2 :
3e1a2:00 05 00 00 45 72 72 6f 72 00 ....Error.
0003e1ac :
3e1ac:00 05 00 03 46 75 6c 6c 00 ....Full.
0003e1b5 :
3e1b5:00 05 00 04 4f 70 63 6f 64 65 3f 00 ....Opcode?.
0003e1c1 :
3e1c1:20 61 74 20 6f 66 66 73 65 74 20 00 at offset .
0003e1cd :
3e1cd:57 72 69 74 69 6e 67 20 00 Writing .
0003e1d6 :
3e1d6:42 79 74 65 73 20 6c 65 66 74 20 00 Bytes left .
0003e1e2 :
3e1e2:52 65 61 64 69 6e 67 20 66 72 6f 6d 20 70 6f 73 Reading from pos
3e1f2:69 74 69 6f 6e 20 00 ition .
0003e1f9 :
3e1f9:72 65 61 64 50 6f 69 6e 74 65 72 20 61 74 20 70 readPointer at p
3e209:6f 73 69 74 69 6f 6e 20 00 osition .
0003e212 :
3e212:0d 0a 00 ...
0003e215 :
3e215:49 6e 69 74 20 73 6f 63 6b 65 74 20 74 6f 20 70 Init socket to p
3e225:6f 72 74 20 00 ort .
0003e22a :
3e22a:09 44 61 74 61 50 6f 72 74 3a 20 00 .DataPort: .
0003e236 :
3e236:54 46 54 50 20 73 65 72 76 65 72 20 69 6e 69 74 TFTP server init
3e246:20 64 6f 6e 65 00 done.
0003e24c :
3e24c:52 65 73 70 6f 6e 73 65 20 73 65 6e 74 00 Response sent.
0003e25a :
3e25a:53 65 6e 74 20 46 69 6e 61 6c 20 41 43 4b 00 Sent Final ACK.
0003e269 :
3e269:53 65 6e 74 20 41 43 4b 00 Sent ACK.
0003e272 :
3e272:49 6e 76 61 6c 69 64 20 6f 70 63 6f 64 65 20 00 Invalid opcode .
0003e282 :
3e282:45 72 72 6f 72 00 Error.
0003e288 :
3e288:41 63 6b 6e 6f 77 6c 65 64 67 65 00 Acknowledge.
0003e294 :
3e294:46 6c 61 73 68 69 6e 67 20 63 6f 6d 70 6c 65 74 Flashing complet
3e2a4:65 00 e.
0003e2a6 :
3e2a6:50 61 63 6b 65 74 20 6c 65 6e 67 74 68 20 61 64 Packet length ad
3e2b6:6a 75 73 74 65 64 20 74 6f 20 00 justed to .
0003e2c1 :
3e2c1:57 72 69 74 69 6e 67 20 64 61 74 61 20 66 72 6f Writing data fro
3e2d1:6d 20 61 64 64 72 65 73 73 20 00 m address .
0003e2dc :
3e2dc:46 6c 61 73 68 20 69 73 20 66 75 6c 6c 00 Flash is full.
0003e2ea :
3e2ea:43 68 61 6e 67 65 64 20 74 6f 20 70 6f 72 74 20 Changed to port
...
0003e2fb :
3e2fb:44 61 74 61 20 62 6c 6f 63 6b 00 Data block.
0003e306 :
3e306:57 72 69 74 65 20 72 65 71 75 65 73 74 00 Write request.
0003e314 :
3e314:52 65 61 64 20 72 65 71 75 65 73 74 00 Read request.
0003e321 :
3e321:20 61 6e 64 20 64 61 74 61 20 6c 65 6e 67 74 68 and data length
3e331:20 00 .
0003e333 :
3e333:20 77 69 74 68 20 6f 70 63 6f 64 65 20 00 with opcode .
0003e341 :
3e341:54 68 69 73 20 69 73 20 62 6c 6f 63 6b 20 00 This is block .
0003e350 :
3e350:53 65 74 20 75 70 20 72 65 74 75 72 6e 20 61 64 Set up return ad
3e360:64 72 65 73 73 00 dress.
0003e366 :
3e366:4f 76 65 72 66 6c 6f 77 00 Overflow.
0003e36f :
3e36f:50 72 6f 63 65 73 73 69 6e 67 20 70 61 63 6b 65 Processing packe
3e37f:74 20 6f 66 20 73 69 7a 65 20 00 t of size .
0003e38a :
3e38a:54 66 74 70 3a 20 00 Tftp: .
0003e391 :
3e391:20 69 6e 73 74 65 61 64 20 6f 66 20 30 78 39 34 instead of 0x94
...
0003e3a2 :
3e3a2:20 69 6e 73 74 65 61 64 20 6f 66 20 30 78 30 43 instead of 0x0C
...
0003e3b3 :
3e3b3:20 77 69 74 68 20 00 with .
0003e3ba :
3e3ba:46 61 69 6c 65 64 20 61 74 20 00 Failed at .
0003e3c5 :
3e3c5:56 61 6c 69 64 20 69 6d 61 67 65 00 Valid image.
0003e3d1 :
3e3d1:56 61 6c 64 3a 20 00 Vald: .
0003e3d8 :
3e3d8:30 78 00 0x.
0003e3db :
3e3db:0d 0a 00 ...
0003e3de <__ctors_end>:
3e3de:11 24 eorr1, r1
3e3e0:1f be out0x3f, r1; 63
3e3e2:cf ef ldir28, 0xFF; 255
3e3e4:d1 e2 ldir29, 0x21; 33
3e3e6:de bf out0x3e, r29; 62
3e3e8:cd bf out0x3d, r28; 61
3e3ea:01 e0 ldir16, 0x01; 1
3e3ec:0c bf out0x3c, r16; 60
0003e3ee <__do_copy_data>:
3e3ee:12 e0 ldir17, 0x02; 2
3e3f0:a0 e0 ldir26, 0x00; 0
3e3f2:b2 e0 ldir27, 0x02; 2
3e3f4:e4 e8 ldir30, 0x84; 132
3e3f6:f7 ef ldir31, 0xF7; 247
3e3f8:03 e0 ldir16, 0x03; 3
3e3fa:0b bf out0x3b, r16; 59
3e3fc:02 c0 rjmp.+4 ; 0x3e402 <__do_copy_data>
3e3fe:07 90 elpmr0, Z+
3e400:0d 92 stX+, r0
3e402:aa 31 cpir26, 0x1A; 26
3e404:b1 07 cpcr27, r17
3e406:d9 f7 brne.-10 ; 0x3e3fe <__do_copy_data>
0003e408 <__do_clear_bss>:
3e408:22 e0 ldir18, 0x02; 2
3e40a:aa e1 ldir26, 0x1A; 26
3e40c:b2 e0 ldir27, 0x02; 2
3e40e:01 c0 rjmp.+2 ; 0x3e412 <.do_clear_bss_start>
0003e410 <.do_clear_bss_loop>:
3e410:1d 92 stX+, r1
0003e412 <.do_clear_bss_start>:
3e412:a7 32 cpir26, 0x27; 39
3e414:b2 07 cpcr27, r18
3e416:e1 f7 brne.-8 ; 0x3e410 <.do_clear_bss_loop>
3e418:02 d0 rcall.+4 ; 0x3e41e
3e41a:0d 94 c0 fb jmp0x3f780; 0x3f780 <_exit>
0003e41e :
int main(void)
{
/* Disable the watchdog timer to prevent
* eternal reset loop of doom and despair */
MCUSR = 0;
3e41e:14 be out0x34, r1; 52
wdt_disable();
3e420:88 e1 ldir24, 0x18; 24
3e422:0f b6 inr0, 0x3f; 63
3e424:f8 94 cli
3e426:80 93 60 00 sts0x0060, r24
3e42a:10 92 60 00 sts0x0060, r1
3e42e:0f be out0x3f, r0; 63
#else
//round up by default
__ticks_dc = (uint32_t)(ceil(fabs(__tmp)));
#endif
__builtin_avr_delay_cycles(__ticks_dc);
3e430:2f ef ldir18, 0xFF; 255
3e432:83 ec ldir24, 0xC3; 195
3e434:99 e0 ldir25, 0x09; 9
3e436:21 50 subir18, 0x01; 1
3e438:80 40 sbcir24, 0x00; 0
3e43a:90 40 sbcir25, 0x00; 0
3e43c:e1 f7 brne.-8 ; 0x3e436
3e43e:00 c0 rjmp.+0 ; 0x3e440
3e440:00 00 nop
/* This code makes the following assumptions:
* No interrupts will execute
* SP points to RAMEND
* r1 contains zero */
//cli();
asm volatile("clr __zero_reg__");
3e442:11 24 eorr1, r1
// 0x02 -> ClkIO/8 -> 500ns period, 32ms max
// 0X03 -> ClkIO/64 -> 4us period, 256ms max
// 0x04 -> ClkIO/256 -> 16us period, 1024ms max
// 0x05 -> ClkIO/1024 -> 64us period, 4096ms max
// Set up Timer 1 as timekeeper for LED flashing
TCCR1B = _BV(CS12); // Same thing as TCCR1B = 0x04;
3e444:84 e0 ldir24, 0x04; 4
3e446:80 93 81 00 sts0x0081, r24
/* Initialize UART communication */
serialInit();
3e44a:3e d6 rcall.+3196 ; 0x3f0c8
DBG_MAIN(tracePGMlnMain(mDebugMain_TITLE);)
3e44c:63 ef ldir22, 0xF3; 243
3e44e:70 ee ldir23, 0xE0; 224
3e450:8d e1 ldir24, 0x1D; 29
3e452:91 ee ldir25, 0xE1; 225
3e454:e0 d5 rcall.+3008 ; 0x3f016
buttonInit();
)
/* Initalize SPI communication */
DBG_MAIN_EX(tracePGMlnMain(mDebugMain_SPI);)
spiInit();
3e456:a6 d0 rcall.+332 ; 0x3e5a4
/* Initialize networking */
DBG_MAIN_EX(tracePGMlnMain(mDebugMain_NET);)
netInit();
3e458:b2 d0 rcall.+356 ; 0x3e5be
/* Initialize the UDP socket for tftp */
DBG_MAIN_EX(tracePGMlnMain(mDebugMain_TFTP);)
uint8_t hasW5100 = isW5100();
3e45a:81 d1 rcall.+770 ; 0x3e75e
3e45c:c8 2f movr28, r24
if (hasW5100) {
3e45e:88 23 andr24, r24
3e460:29 f0 breq.+10 ; 0x3e46c
tftpInit();
3e462:60 d4 rcall.+2240 ; 0x3ed24
timeout=5;
3e464:85 e0 ldir24, 0x05; 5
3e466:80 93 26 02 sts0x0226, r24
3e46a:03 c0 rjmp.+6 ; 0x3e472
} else
timeout=1;
3e46c:81 e0 ldir24, 0x01; 1
3e46e:80 93 26 02 sts0x0226, r24
#if defined(ANNOUNCE)
DBG_MAIN_EX(tracePGMlnMain(mDebugMain_ANN);)
announceInit();
#endif
serialFlashing = FALSE;
3e472:10 92 24 02 sts0x0224, r1
tftpFlashing = FALSE;
3e476:10 92 25 02 sts0x0225, r1
if(timedOut()) {
if (!tftpFlashing && !serialFlashing) break;
//TODO: determine the conditions for reseting server OR reseting socket
if(tftpFlashing == TRUE) {
// Delete first page of flash memory
boot_page_erase(0);
3e47a:d3 e0 ldir29, 0x03; 3
3e47c:c1 2c movr12, r1
3e47e:d1 2c movr13, r1
3e480:76 01 movwr14, r12
serialFlashing = FALSE;
tftpFlashing = FALSE;
for(;;) {
// If there is no serial flashing under way, poll tftp
if(!serialFlashing)
3e482:80 91 24 02 ldsr24, 0x0224
3e486:88 23 andr24, r24
3e488:29 f0 breq.+10 ; 0x3e494
if(hasW5100 && tftpPoll() == 0)
break;
// If there is no tftp flashing, poll serial
if(!tftpFlashing)
3e48a:80 91 25 02 ldsr24, 0x0225
3e48e:88 23 andr24, r24
3e490:59 f0 breq.+22 ; 0x3e4a8
3e492:06 c0 rjmp.+12 ; 0x3e4a0
for(;;) {
// If there is no serial flashing under way, poll tftp
if(!serialFlashing)
// If tftp recieved a FINAL_ACK, break
if(hasW5100 && tftpPoll() == 0)
3e494:cc 23 andr28, r28
3e496:c9 f3 breq.-14 ; 0x3e48a
3e498:5a d4 rcall.+2228 ; 0x3ed4e
3e49a:81 11 cpser24, r1
3e49c:f6 cf rjmp.-20 ; 0x3e48a
3e49e:1f c0 rjmp.+62 ; 0x3e4de
/* As explained above this goes out */
#if defined(ANNOUNCE)
announcePoll();
#endif
if(timedOut()) {
3e4a0:6e d6 rcall.+3292 ; 0x3f17e
3e4a2:81 11 cpser24, r1
3e4a4:05 c0 rjmp.+10 ; 0x3e4b0
3e4a6:19 c0 rjmp.+50 ; 0x3e4da
break;
// If there is no tftp flashing, poll serial
if(!tftpFlashing)
// If flashing is done exit
if(serialPoll() == 0)
3e4a8:35 d6 rcall.+3178 ; 0x3f114
3e4aa:81 11 cpser24, r1
3e4ac:f9 cf rjmp.-14 ; 0x3e4a0
3e4ae:17 c0 rjmp.+46 ; 0x3e4de
#if defined(ANNOUNCE)
announcePoll();
#endif
if(timedOut()) {
if (!tftpFlashing && !serialFlashing) break;
3e4b0:80 91 25 02 ldsr24, 0x0225
3e4b4:81 11 cpser24, r1
3e4b6:05 c0 rjmp.+10 ; 0x3e4c2
3e4b8:80 91 24 02 ldsr24, 0x0224
3e4bc:81 11 cpser24, r1
3e4be:0d c0 rjmp.+26 ; 0x3e4da
3e4c0:0e c0 rjmp.+28 ; 0x3e4de
//TODO: determine the conditions for reseting server OR reseting socket
if(tftpFlashing == TRUE) {
3e4c2:81 30 cpir24, 0x01; 1
3e4c4:51 f4 brne.+20 ; 0x3e4da
// Delete first page of flash memory
boot_page_erase(0);
3e4c6:f6 01 movwr30, r12
3e4c8:e0 92 5b 00 sts0x005B, r14
3e4cc:d0 93 57 00 sts0x0057, r29
3e4d0:e8 95 spm
// Reinitialize TFTP
tftpInit();
3e4d2:28 d4 rcall.+2128 ; 0x3ed24
// Reset the timeout counter
resetTick();
3e4d4:4b d6 rcall.+3222 ; 0x3f16c
// Unset tftp flag
tftpFlashing = FALSE;
3e4d6:10 92 25 02 sts0x0225, r1
}
}
/* Blink the notification led */
updateLed();
3e4da:27 d6 rcall.+3150 ; 0x3f12a
}
3e4dc:d2 cf rjmp.-92 ; 0x3e482
/* Exit to user application */
DBG_MAIN(tracePGMlnMain(mDebugMain_EXIT);)
3e4de:64 ee ldir22, 0xE4; 228
3e4e0:70 ee ldir23, 0xE0; 224
3e4e2:8d e1 ldir24, 0x1D; 29
3e4e4:91 ee ldir25, 0xE1; 225
3e4e6:97 d5 rcall.+2862 ; 0x3f016
asm volatile(
3e4e8:ee 27 eorr30, r30
3e4ea:ff 27 eorr31, r31
3e4ec:09 94 ijmp
"clrr31\n\t"
"ijmp\n\t"
);
//appStart();
//return(0); /* never reached */
}
3e4ee:80 e0 ldir24, 0x00; 0
3e4f0:90 e0 ldir25, 0x00; 0
0003e4f2 <__bad_interrupt>:
3e4f2:86 cd rjmp.-1268 ; 0x3e000 <__vectors>
0003e4f4 :
tracenum(address);
tracePGM(mDebugSpi_COMMA);
tracenum(value);
)
SPCR = _BV(SPE) | _BV(MSTR); // Set SPI as master
3e4f4:20 e5 ldir18, 0x50; 80
3e4f6:2c bd out0x2c, r18; 44
SS_LOW();
3e4f8:2c 98 cbi0x05, 4; 5
SPDR = SPI_WRITE;
3e4fa:20 ef ldir18, 0xF0; 240
3e4fc:2e bd out0x2e, r18; 46
while(!(SPSR & _BV(SPIF)));
3e4fe:0d b4 inr0, 0x2d; 45
3e500:07 fe sbrsr0, 7
3e502:fd cf rjmp.-6 ; 0x3e4fe
SPDR = address >> 8;
3e504:29 2f movr18, r25
3e506:33 27 eorr19, r19
3e508:2e bd out0x2e, r18; 46
while(!(SPSR & _BV(SPIF)));
3e50a:0d b4 inr0, 0x2d; 45
3e50c:07 fe sbrsr0, 7
3e50e:fd cf rjmp.-6 ; 0x3e50a
SPDR = address & 0xff;
3e510:8e bd out0x2e, r24; 46
while(!(SPSR & _BV(SPIF)));
3e512:0d b4 inr0, 0x2d; 45
3e514:07 fe sbrsr0, 7
3e516:fd cf rjmp.-6 ; 0x3e512
SPDR = value;
3e518:6e bd out0x2e, r22; 46
while(!(SPSR & _BV(SPIF)));
3e51a:0d b4 inr0, 0x2d; 45
3e51c:07 fe sbrsr0, 7
3e51e:fd cf rjmp.-6 ; 0x3e51a
SS_HIGH();
3e520:2c 9a sbi0x05, 4; 5
SPCR = 0; // Turn off SPI
3e522:1c bc out0x2c, r1; 44
3e524:08 95 ret
0003e526 :
}
void spiWriteWord(uint16_t address, uint16_t value)
{
3e526:0f 93 pushr16
3e528:1f 93 pushr17
3e52a:cf 93 pushr28
3e52c:df 93 pushr29
3e52e:8c 01 movwr16, r24
3e530:eb 01 movwr28, r22
// Write uint16_t to Ethernet controller
spiWriteReg(address++, value >> 8);
3e532:67 2f movr22, r23
3e534:77 27 eorr23, r23
3e536:de df rcall.-68 ; 0x3e4f4
spiWriteReg(address, value & 0xff);
3e538:6c 2f movr22, r28
3e53a:c8 01 movwr24, r16
3e53c:01 96 adiwr24, 0x01; 1
}
3e53e:df 91 popr29
3e540:cf 91 popr28
3e542:1f 91 popr17
3e544:0f 91 popr16
void spiWriteWord(uint16_t address, uint16_t value)
{
// Write uint16_t to Ethernet controller
spiWriteReg(address++, value >> 8);
spiWriteReg(address, value & 0xff);
3e546:d6 cf rjmp.-84 ; 0x3e4f4
0003e548 :
)
#endif
uint8_t returnValue;
SPCR = _BV(SPE) | _BV(MSTR);
3e548:20 e5 ldir18, 0x50; 80
3e54a:2c bd out0x2c, r18; 44
SS_LOW();
3e54c:2c 98 cbi0x05, 4; 5
SPDR = SPI_READ;
3e54e:2f e0 ldir18, 0x0F; 15
3e550:2e bd out0x2e, r18; 46
while(!(SPSR & _BV(SPIF)));
3e552:0d b4 inr0, 0x2d; 45
3e554:07 fe sbrsr0, 7
3e556:fd cf rjmp.-6 ; 0x3e552
SPDR = address >> 8;
3e558:29 2f movr18, r25
3e55a:33 27 eorr19, r19
3e55c:2e bd out0x2e, r18; 46
while(!(SPSR & _BV(SPIF)));
3e55e:0d b4 inr0, 0x2d; 45
3e560:07 fe sbrsr0, 7
3e562:fd cf rjmp.-6 ; 0x3e55e
SPDR = address & 0xff;
3e564:8e bd out0x2e, r24; 46
while(!(SPSR & _BV(SPIF)));
3e566:0d b4 inr0, 0x2d; 45
3e568:07 fe sbrsr0, 7
3e56a:fd cf rjmp.-6 ; 0x3e566
SPDR = 0;
3e56c:1e bc out0x2e, r1; 46
while(!(SPSR & _BV(SPIF)));
3e56e:0d b4 inr0, 0x2d; 45
3e570:07 fe sbrsr0, 7
3e572:fd cf rjmp.-6 ; 0x3e56e
SS_HIGH();
3e574:2c 9a sbi0x05, 4; 5
returnValue = SPDR;
3e576:8e b5 inr24, 0x2e; 46
SPCR = 0;
3e578:1c bc out0x2c, r1; 44
return(returnValue);
}
3e57a:08 95 ret
0003e57c :
uint16_t spiReadWord(uint16_t address)
{
3e57c:1f 93 pushr17
3e57e:cf 93 pushr28
3e580:df 93 pushr29
3e582:ec 01 movwr28, r24
// Read uint16_t from Ethernet controller
return((spiReadReg(address) << 8) | spiReadReg(address + 1));
3e584:e1 df rcall.-62 ; 0x3e548
3e586:18 2f movr17, r24
3e588:ce 01 movwr24, r28
3e58a:01 96 adiwr24, 0x01; 1
3e58c:dd df rcall.-70 ; 0x3e548
3e58e:21 2f movr18, r17
3e590:30 e0 ldir19, 0x00; 0
3e592:32 2f movr19, r18
3e594:22 27 eorr18, r18
}
3e596:a9 01 movwr20, r18
3e598:48 2b orr20, r24
3e59a:ca 01 movwr24, r20
3e59c:df 91 popr29
3e59e:cf 91 popr28
3e5a0:1f 91 popr17
3e5a2:08 95 ret
0003e5a4 :
* At this stage all pins are set to HIGH. This in fact DISABLES SPI for both Ethernet and SD.
* SS pin for ethernet is pulled low just in time for reading or writing data inside those
* functions. */
/** Set SPI pins high */
SPI_PORT = _BV(SCK) | _BV(MISO) | _BV(MOSI) | _BV(SS);
3e5a4:8f e0 ldir24, 0x0F; 15
3e5a6:85 b9 out0x05, r24; 5
/** Set SPI pins as output */
SPI_DDR = _BV(SCK) | _BV(MOSI) | _BV(SS);
3e5a8:87 e0 ldir24, 0x07; 7
3e5aa:84 b9 out0x04, r24; 4
#if (ETH_SS != SS)
/** Initialize extra SS pin used in some boards (mega) */
/** Set ethernet SS high */
ETH_PORT |= _BV(ETH_SS);
3e5ac:2c 9a sbi0x05, 4; 5
/** Set ethernet SS as output */
ETH_DDR |= _BV(ETH_SS);
3e5ae:24 9a sbi0x04, 4; 4
#endif
/** Disable SD card */
/** Set SD SS pin high */
SD_PORT |= _BV(SD_SS);
3e5b0:a5 9a sbi0x14, 5; 20
/** Set SD SS pin as output */
SD_DDR |= _BV(SD_SS);
3e5b2:9d 9a sbi0x13, 5; 19
#if (LED != SCK)
/** Set up pins to flash the onboard led */
/** Set led pin to high */
LED_PORT |= _BV(LED);
3e5b4:2f 9a sbi0x05, 7; 5
/** Set led pin as output */
LED_DDR |= _BV(LED);
3e5b6:27 9a sbi0x04, 7; 4
#endif
/** Set up SPI
** Set the Double SPI Speed Bit */
SPSR = (1 << SPI2X);
3e5b8:81 e0 ldir24, 0x01; 1
3e5ba:8d bd out0x2d, r24; 45
3e5bc:08 95 ret
0003e5be :
#include "serial.h"
#include "debug.h"
#include "debug_net.h"
void netInit(void)
{
3e5be:df 92 pushr13
3e5c0:ef 92 pushr14
3e5c2:ff 92 pushr15
3e5c4:0f 93 pushr16
3e5c6:1f 93 pushr17
3e5c8:cf 93 pushr28
3e5ca:df 93 pushr29
3e5cc:cd b7 inr28, 0x3d; 61
3e5ce:de b7 inr29, 0x3e; 62
3e5d0:ac 97 sbiwr28, 0x2c; 44
3e5d2:de bf out0x3e, r29; 62
3e5d4:cd bf out0x3d, r28; 61
conf_t conf;
eeprom_read_block((void*)&conf,(void*)BASE_ADDRESS,CONFSIZE);
3e5d6:46 e1 ldir20, 0x16; 22
3e5d8:50 e0 ldir21, 0x00; 0
3e5da:69 ee ldir22, 0xE9; 233
3e5dc:7f e0 ldir23, 0x0F; 15
3e5de:ce 01 movwr24, r28
3e5e0:47 96 adiwr24, 0x17; 23
3e5e2:0f 94 99 fb call0x3f732; 0x3f732 <__eerd_block_m2560>
if (conf.checksum==0 || chksum((uint16_t*)&conf,CONFSIZE/2)!=0) {
3e5e6:8b a5 lddr24, Y+43; 0x2b
3e5e8:9c a5 lddr25, Y+44; 0x2c
3e5ea:89 2b orr24, r25
3e5ec:01 f5 brne.+64 ; 0x3e62e
conf_t tconf = DEFAULTCONF;
3e5ee:86 e1 ldir24, 0x16; 22
3e5f0:e0 e0 ldir30, 0x00; 0
3e5f2:f2 e0 ldir31, 0x02; 2
3e5f4:de 01 movwr26, r28
3e5f6:11 96 adiwr26, 0x01; 1
3e5f8:01 90 ldr0, Z+
3e5fa:0d 92 stX+, r0
3e5fc:8a 95 decr24
3e5fe:e1 f7 brne.-8 ; 0x3e5f8
tconf.checksum=chksum((uint16_t*)&tconf,CONFSIZE/2-1);
3e600:6a e0 ldir22, 0x0A; 10
3e602:ce 01 movwr24, r28
3e604:01 96 adiwr24, 0x01; 1
3e606:d1 d5 rcall.+2978 ; 0x3f1aa
3e608:9e 8b stdY+22, r25; 0x16
3e60a:8d 8b stdY+21, r24; 0x15
eeprom_write_block((const void*)&tconf,(void*)BASE_ADDRESS,CONFSIZE);
3e60c:46 e1 ldir20, 0x16; 22
3e60e:50 e0 ldir21, 0x00; 0
3e610:69 ee ldir22, 0xE9; 233
3e612:7f e0 ldir23, 0x0F; 15
3e614:ce 01 movwr24, r28
3e616:01 96 adiwr24, 0x01; 1
3e618:0f 94 a9 fb call0x3f752; 0x3f752 <__eewr_block_m2560>
eeprom_read_block((void*)&conf,(void*)BASE_ADDRESS,CONFSIZE);
3e61c:46 e1 ldir20, 0x16; 22
3e61e:50 e0 ldir21, 0x00; 0
3e620:69 ee ldir22, 0xE9; 233
3e622:7f e0 ldir23, 0x0F; 15
3e624:ce 01 movwr24, r28
3e626:47 96 adiwr24, 0x17; 23
3e628:0f 94 99 fb call0x3f732; 0x3f732 <__eerd_block_m2560>
3e62c:06 c0 rjmp.+12 ; 0x3e63a
void netInit(void)
{
conf_t conf;
eeprom_read_block((void*)&conf,(void*)BASE_ADDRESS,CONFSIZE);
if (conf.checksum==0 || chksum((uint16_t*)&conf,CONFSIZE/2)!=0) {
3e62e:6b e0 ldir22, 0x0B; 11
3e630:ce 01 movwr24, r28
3e632:47 96 adiwr24, 0x17; 23
3e634:ba d5 rcall.+2932 ; 0x3f1aa
3e636:89 2b orr24, r25
3e638:d1 f6 brne.-76 ; 0x3e5ee
eeprom_read_block((void*)&conf,(void*)BASE_ADDRESS,CONFSIZE);
}
#if defined(RANDOM_TFTP_DATA_PORT)
while ((tftpTransferPort = TCNT1)<46969);
#else
tftpTransferPort = conf.tftpdataport;
3e63a:89 a5 lddr24, Y+41; 0x29
3e63c:9a a5 lddr25, Y+42; 0x2a
3e63e:90 93 23 02 sts0x0223, r25
3e642:80 93 22 02 sts0x0222, r24
#endif
uint8_t i;
DBG_NET(tracePGMlnNet(mDebugNet_EEPROM);)
3e646:64 e7 ldir22, 0x74; 116
3e648:71 ee ldir23, 0xE1; 225
3e64a:84 e8 ldir24, 0x84; 132
3e64c:91 ee ldir25, 0xE1; 225
3e64e:e3 d4 rcall.+2502 ; 0x3f016
DBG_NET(
3e650:67 e5 ldir22, 0x57; 87
3e652:71 ee ldir23, 0xE1; 225
3e654:84 e8 ldir24, 0x84; 132
3e656:91 ee ldir25, 0xE1; 225
3e658:de d4 rcall.+2492 ; 0x3f016
3e65a:8e 01 movwr16, r28
3e65c:0b 5d subir16, 0xDB; 219
3e65e:1f 4f sbcir17, 0xFF; 255
3e660:f1 2c movr15, r1
3e662:f8 01 movwr30, r16
3e664:61 91 ldr22, Z+
3e666:8f 01 movwr16, r30
3e668:70 e0 ldir23, 0x00; 0
3e66a:80 e0 ldir24, 0x00; 0
3e66c:90 e0 ldir25, 0x00; 0
3e66e:42 e0 ldir20, 0x02; 2
3e670:03 d5 rcall.+2566 ; 0x3f078
3e672:f3 e0 ldir31, 0x03; 3
3e674:ff 16 cpr15, r31
3e676:11 f0 breq.+4 ; 0x3e67c
3e678:8e e2 ldir24, 0x2E; 46
3e67a:33 d5 rcall.+2662 ; 0x3f0e2
3e67c:f3 94 incr15
3e67e:84 e0 ldir24, 0x04; 4
3e680:f8 12 cpser15, r24
3e682:ef cf rjmp.-34 ; 0x3e662
3e684:6c e4 ldir22, 0x4C; 76
3e686:71 ee ldir23, 0xE1; 225
3e688:84 e8 ldir24, 0x84; 132
3e68a:91 ee ldir25, 0xE1; 225
3e68c:c4 d4 rcall.+2440 ; 0x3f016
3e68e:7e 01 movwr14, r28
3e690:9b e1 ldir25, 0x1B; 27
3e692:e9 0e addr14, r25
3e694:f1 1c adcr15, r1
3e696:8e 01 movwr16, r28
3e698:01 5e subir16, 0xE1; 225
3e69a:1f 4f sbcir17, 0xFF; 255
3e69c:f7 01 movwr30, r14
3e69e:61 91 ldr22, Z+
3e6a0:7f 01 movwr14, r30
3e6a2:70 e0 ldir23, 0x00; 0
3e6a4:80 e0 ldir24, 0x00; 0
3e6a6:90 e0 ldir25, 0x00; 0
3e6a8:42 e0 ldir20, 0x02; 2
3e6aa:e6 d4 rcall.+2508 ; 0x3f078
3e6ac:8e e2 ldir24, 0x2E; 46
3e6ae:19 d5 rcall.+2610 ; 0x3f0e2
3e6b0:e0 16 cpr14, r16
3e6b2:f1 06 cpcr15, r17
3e6b4:99 f7 brne.-26 ; 0x3e69c
3e6b6:61 e4 ldir22, 0x41; 65
3e6b8:71 ee ldir23, 0xE1; 225
3e6ba:84 e8 ldir24, 0x84; 132
3e6bc:91 ee ldir25, 0xE1; 225
3e6be:ab d4 rcall.+2390 ; 0x3f016
3e6c0:ce 01 movwr24, r28
3e6c2:47 96 adiwr24, 0x17; 23
3e6c4:7c 01 movwr14, r24
3e6c6:d1 2c movr13, r1
3e6c8:f7 01 movwr30, r14
3e6ca:61 91 ldr22, Z+
3e6cc:7f 01 movwr14, r30
3e6ce:70 e0 ldir23, 0x00; 0
3e6d0:80 e0 ldir24, 0x00; 0
3e6d2:90 e0 ldir25, 0x00; 0
3e6d4:42 e0 ldir20, 0x02; 2
3e6d6:d0 d4 rcall.+2464 ; 0x3f078
3e6d8:f3 e0 ldir31, 0x03; 3
3e6da:df 16 cpr13, r31
3e6dc:11 f0 breq.+4 ; 0x3e6e2
3e6de:8e e2 ldir24, 0x2E; 46
3e6e0:00 d5 rcall.+2560 ; 0x3f0e2
3e6e2:d3 94 incr13
3e6e4:84 e0 ldir24, 0x04; 4
3e6e6:d8 12 cpser13, r24
3e6e8:ef cf rjmp.-34 ; 0x3e6c8
3e6ea:66 e3 ldir22, 0x36; 54
3e6ec:71 ee ldir23, 0xE1; 225
3e6ee:84 e8 ldir24, 0x84; 132
3e6f0:91 ee ldir25, 0xE1; 225
3e6f2:91 d4 rcall.+2338 ; 0x3f016
3e6f4:f1 2c movr15, r1
3e6f6:f8 01 movwr30, r16
3e6f8:61 91 ldr22, Z+
3e6fa:8f 01 movwr16, r30
3e6fc:70 e0 ldir23, 0x00; 0
3e6fe:80 e0 ldir24, 0x00; 0
3e700:90 e0 ldir25, 0x00; 0
3e702:42 e0 ldir20, 0x02; 2
3e704:b9 d4 rcall.+2418 ; 0x3f078
3e706:f5 e0 ldir31, 0x05; 5
3e708:ff 16 cpr15, r31
3e70a:11 f0 breq.+4 ; 0x3e710
3e70c:8e e2 ldir24, 0x2E; 46
3e70e:e9 d4 rcall.+2514 ; 0x3f0e2
3e710:f3 94 incr15
3e712:86 e0 ldir24, 0x06; 6
3e714:f8 12 cpser15, r24
3e716:ef cf rjmp.-34 ; 0x3e6f6
tracenet(conf.mac[i]);
if(i != 5) putch(0x2E);
}
)
/** Configure Wiznet chip. Network settings */
spiWriteReg(0, 0x80); //reset
3e718:60 e8 ldir22, 0x80; 128
3e71a:80 e0 ldir24, 0x00; 0
3e71c:90 e0 ldir25, 0x00; 0
3e71e:ea de rcall.-556 ; 0x3e4f4
3e720:fe 01 movwr30, r28
3e722:77 96 adiwr30, 0x17; 23
3e724:7f 01 movwr14, r30
3e726:00 e0 ldir16, 0x00; 0
3e728:10 e0 ldir17, 0x00; 0
uint8_t* data = (uint8_t*)&conf;
for(i = 0; i < CONFSIZE-4; i++)
spiWriteReg(i+1, data[i]);
3e72a:f7 01 movwr30, r14
3e72c:61 91 ldr22, Z+
3e72e:7f 01 movwr14, r30
3e730:0f 5f subir16, 0xFF; 255
3e732:1f 4f sbcir17, 0xFF; 255
3e734:c8 01 movwr24, r16
3e736:de de rcall.-580 ; 0x3e4f4
}
)
/** Configure Wiznet chip. Network settings */
spiWriteReg(0, 0x80); //reset
uint8_t* data = (uint8_t*)&conf;
for(i = 0; i < CONFSIZE-4; i++)
3e738:02 31 cpir16, 0x12; 18
3e73a:11 05 cpcr17, r1
3e73c:b1 f7 brne.-20 ; 0x3e72a
spiWriteReg(i+1, data[i]);
DBG_NET(tracePGMlnNet(mDebugNet_DONE);)
3e73e:64 e2 ldir22, 0x24; 36
3e740:71 ee ldir23, 0xE1; 225
3e742:84 e8 ldir24, 0x84; 132
3e744:91 ee ldir25, 0xE1; 225
3e746:67 d4 rcall.+2254 ; 0x3f016
}
3e748:ac 96 adiwr28, 0x2c; 44
3e74a:de bf out0x3e, r29; 62
3e74c:cd bf out0x3d, r28; 61
3e74e:df 91 popr29
3e750:cf 91 popr28
3e752:1f 91 popr17
3e754:0f 91 popr16
3e756:ff 90 popr15
3e758:ef 90 popr14
3e75a:df 90 popr13
3e75c:08 95 ret
0003e75e :
uint8_t isW5100(void){
spiWriteReg(0,0x10);
3e75e:60 e1 ldir22, 0x10; 16
3e760:80 e0 ldir24, 0x00; 0
3e762:90 e0 ldir25, 0x00; 0
3e764:c7 de rcall.-626 ; 0x3e4f4
if ( spiReadReg(0)!=0x10)
3e766:80 e0 ldir24, 0x00; 0
3e768:90 e0 ldir25, 0x00; 0
3e76a:ee de rcall.-548 ; 0x3e548
3e76c:80 31 cpir24, 0x10; 16
3e76e:91 f4 brne.+36 ; 0x3e794
return 0;
spiWriteReg(0,0x12);
3e770:62 e1 ldir22, 0x12; 18
3e772:80 e0 ldir24, 0x00; 0
3e774:90 e0 ldir25, 0x00; 0
3e776:be de rcall.-644 ; 0x3e4f4
if ( spiReadReg(0)!=0x12)
3e778:80 e0 ldir24, 0x00; 0
3e77a:90 e0 ldir25, 0x00; 0
3e77c:e5 de rcall.-566 ; 0x3e548
3e77e:82 31 cpir24, 0x12; 18
3e780:49 f4 brne.+18 ; 0x3e794
return 0;
spiWriteReg(0,0x00);
3e782:60 e0 ldir22, 0x00; 0
3e784:80 e0 ldir24, 0x00; 0
3e786:90 e0 ldir25, 0x00; 0
3e788:b5 de rcall.-662 ; 0x3e4f4
if ( spiReadReg(0)!=0x00)
3e78a:80 e0 ldir24, 0x00; 0
3e78c:90 e0 ldir25, 0x00; 0
3e78e:dc de rcall.-584 ; 0x3e548
3e790:91 e0 ldir25, 0x01; 1
3e792:81 11 cpser24, r1
3e794:90 e0 ldir25, 0x00; 0
return 0;
else
return 1;
}
3e796:89 2f movr24, r25
3e798:08 95 ret
0003e79a :
const unsigned char tftp_invalid_image_packet[] PROGMEM = "\0\5" "\0\0" "Invalid image file";
uint16_t lastPacket = 0, highPacket = 0;
static void sockInit(uint16_t port)
{
3e79a:cf 93 pushr28
3e79c:df 93 pushr29
3e79e:ec 01 movwr28, r24
DBG_TFTP(
3e7a0:65 e1 ldir22, 0x15; 21
3e7a2:72 ee ldir23, 0xE2; 226
3e7a4:8a e8 ldir24, 0x8A; 138
3e7a6:93 ee ldir25, 0xE3; 227
3e7a8:36 d4 rcall.+2156 ; 0x3f016
3e7aa:be 01 movwr22, r28
3e7ac:80 e0 ldir24, 0x00; 0
3e7ae:90 e0 ldir25, 0x00; 0
3e7b0:44 e0 ldir20, 0x04; 4
3e7b2:62 d4 rcall.+2244 ; 0x3f078
tracePGMlnTftp(mDebugTftp_SOCK);
tracenum(port);
)
spiWriteReg(REG_S3_CR, CR_CLOSE);
3e7b4:60 e1 ldir22, 0x10; 16
3e7b6:81 e0 ldir24, 0x01; 1
3e7b8:97 e0 ldir25, 0x07; 7
3e7ba:9c de rcall.-712 ; 0x3e4f4
do {
// Write TFTP Port
spiWriteWord(REG_S3_PORT0, port);
3e7bc:be 01 movwr22, r28
3e7be:84 e0 ldir24, 0x04; 4
3e7c0:97 e0 ldir25, 0x07; 7
3e7c2:b1 de rcall.-670 ; 0x3e526
// Write mode
spiWriteReg(REG_S3_MR, MR_UDP);
3e7c4:62 e0 ldir22, 0x02; 2
3e7c6:80 e0 ldir24, 0x00; 0
3e7c8:97 e0 ldir25, 0x07; 7
3e7ca:94 de rcall.-728 ; 0x3e4f4
// Open Socket
spiWriteReg(REG_S3_CR, CR_OPEN);
3e7cc:61 e0 ldir22, 0x01; 1
3e7ce:81 e0 ldir24, 0x01; 1
3e7d0:97 e0 ldir25, 0x07; 7
3e7d2:90 de rcall.-736 ; 0x3e4f4
// Read Status
if(spiReadReg(REG_S3_SR) != SOCK_UDP)
3e7d4:83 e0 ldir24, 0x03; 3
3e7d6:97 e0 ldir25, 0x07; 7
3e7d8:b7 de rcall.-658 ; 0x3e548
3e7da:82 32 cpir24, 0x22; 34
3e7dc:21 f0 breq.+8 ; 0x3e7e6
// Close Socket if it wasn't initialized correctly
spiWriteReg(REG_S3_CR, CR_CLOSE);
3e7de:60 e1 ldir22, 0x10; 16
3e7e0:81 e0 ldir24, 0x01; 1
3e7e2:97 e0 ldir25, 0x07; 7
3e7e4:87 de rcall.-754 ; 0x3e4f4
// If socket correctly opened continue
} while(spiReadReg(REG_S3_SR) != SOCK_UDP);
3e7e6:83 e0 ldir24, 0x03; 3
3e7e8:97 e0 ldir25, 0x07; 7
3e7ea:ae de rcall.-676 ; 0x3e548
3e7ec:82 32 cpir24, 0x22; 34
3e7ee:31 f7 brne.-52 ; 0x3e7bc
}
3e7f0:df 91 popr29
3e7f2:cf 91 popr28
3e7f4:08 95 ret
0003e7f6 :
#if (DEBUG_TFTP > 0)
static uint8_t processPacket(uint16_t packetSize)
#else
static uint8_t processPacket(void)
#endif
{
3e7f6:2f 92 pushr2
3e7f8:3f 92 pushr3
3e7fa:4f 92 pushr4
3e7fc:5f 92 pushr5
3e7fe:6f 92 pushr6
3e800:7f 92 pushr7
3e802:8f 92 pushr8
3e804:9f 92 pushr9
3e806:af 92 pushr10
3e808:bf 92 pushr11
3e80a:cf 92 pushr12
3e80c:df 92 pushr13
3e80e:ef 92 pushr14
3e810:ff 92 pushr15
3e812:0f 93 pushr16
3e814:1f 93 pushr17
3e816:cf 93 pushr28
3e818:df 93 pushr29
3e81a:cd b7 inr28, 0x3d; 61
3e81c:de b7 inr29, 0x3e; 62
3e81e:c5 51 subir28, 0x15; 21
3e820:d2 40 sbcir29, 0x02; 2
3e822:de bf out0x3e, r29; 62
3e824:cd bf out0x3d, r28; 61
3e826:8c 01 movwr16, r24
address_t writeAddr;
// Transfer entire packet to RAM
uint8_t* bufPtr = buffer;
uint16_t count;
DBG_TFTP(
3e828:6f e6 ldir22, 0x6F; 111
3e82a:73 ee ldir23, 0xE3; 227
3e82c:8a e8 ldir24, 0x8A; 138
3e82e:93 ee ldir25, 0xE3; 227
3e830:f2 d3 rcall.+2020 ; 0x3f016
3e832:b8 01 movwr22, r16
3e834:80 e0 ldir24, 0x00; 0
3e836:90 e0 ldir25, 0x00; 0
3e838:44 e0 ldir20, 0x04; 4
3e83a:1e d4 rcall.+2108 ; 0x3f078
3e83c:01 15 cpr16, r1
3e83e:18 40 sbcir17, 0x08; 8
3e840:28 f0 brcs.+10 ; 0x3e84c
3e842:66 e6 ldir22, 0x66; 102
3e844:73 ee ldir23, 0xE3; 227
3e846:8a e8 ldir24, 0x8A; 138
3e848:93 ee ldir25, 0xE3; 227
3e84a:e5 d3 rcall.+1994 ; 0x3f016
DBG_BTN(button();)
)
// Read data from chip to buffer
readPointer = spiReadWord(REG_S3_RX_RD0);
3e84c:88 e2 ldir24, 0x28; 40
3e84e:97 e0 ldir25, 0x07; 7
3e850:95 de rcall.-726 ; 0x3e57c
3e852:8c 01 movwr16, r24
DBG_TFTP_EX(
3e854:69 ef ldir22, 0xF9; 249
3e856:71 ee ldir23, 0xE1; 225
3e858:8a e8 ldir24, 0x8A; 138
3e85a:93 ee ldir25, 0xE3; 227
3e85c:dc d3 rcall.+1976 ; 0x3f016
3e85e:b8 01 movwr22, r16
3e860:80 e0 ldir24, 0x00; 0
3e862:90 e0 ldir25, 0x00; 0
3e864:44 e0 ldir20, 0x04; 4
3e866:08 d4 rcall.+2064 ; 0x3f078
tracePGMlnTftp(mDebugTftp_RPTR);
tracenum(readPointer);
)
if(readPointer == 0) readPointer += S3_RX_START;
3e868:01 15 cpr16, r1
3e86a:11 05 cpcr17, r1
3e86c:11 f4 brne.+4 ; 0x3e872
3e86e:00 e0 ldir16, 0x00; 0
3e870:18 e7 ldir17, 0x78; 120
}
)
*bufPtr++ = spiReadReg(readPointer++);
if(readPointer == S3_RX_END) readPointer = S3_RX_START;
3e872:ce 01 movwr24, r28
3e874:01 96 adiwr24, 0x01; 1
3e876:6c 01 movwr12, r24
3e878:8c e0 ldir24, 0x0C; 12
3e87a:e8 2e movr14, r24
3e87c:82 e0 ldir24, 0x02; 2
3e87e:f8 2e movr15, r24
tracePGMlnTftp(mDebugTftp_RPTR);
tracenum(readPointer);
)
if(readPointer == 0) readPointer += S3_RX_START;
for(count = TFTP_PACKET_MAX_SIZE; count--;) {
3e880:41 e0 ldir20, 0x01; 1
3e882:e4 1a subr14, r20
3e884:f1 08 sbcr15, r1
3e886:30 f1 brcs.+76 ; 0x3e8d4
DBG_TFTP_EX(
3e888:9b e0 ldir25, 0x0B; 11
3e88a:e9 16 cpr14, r25
3e88c:92 e0 ldir25, 0x02; 2
3e88e:f9 06 cpcr15, r25
3e890:19 f0 breq.+6 ; 0x3e898
3e892:e1 14 cpr14, r1
3e894:f1 04 cpcr15, r1
3e896:61 f4 brne.+24 ; 0x3e8b0
3e898:62 ee ldir22, 0xE2; 226
3e89a:71 ee ldir23, 0xE1; 225
3e89c:8a e8 ldir24, 0x8A; 138
3e89e:93 ee ldir25, 0xE3; 227
3e8a0:ba d3 rcall.+1908 ; 0x3f016
3e8a2:c8 01 movwr24, r16
3e8a4:a0 e0 ldir26, 0x00; 0
3e8a6:b0 e0 ldir27, 0x00; 0
3e8a8:44 e0 ldir20, 0x04; 4
3e8aa:bc 01 movwr22, r24
3e8ac:cd 01 movwr24, r26
3e8ae:e4 d3 rcall.+1992 ; 0x3f078
tracePGMlnTftp(mDebugTftp_RPOS);
tracenum(readPointer);
}
)
*bufPtr++ = spiReadReg(readPointer++);
3e8b0:58 01 movwr10, r16
3e8b2:af ef ldir26, 0xFF; 255
3e8b4:aa 1a subr10, r26
3e8b6:ba 0a sbcr11, r26
3e8b8:c8 01 movwr24, r16
3e8ba:46 de rcall.-884 ; 0x3e548
3e8bc:f6 01 movwr30, r12
3e8be:81 93 stZ+, r24
3e8c0:6f 01 movwr12, r30
if(readPointer == S3_RX_END) readPointer = S3_RX_START;
3e8c2:a1 14 cpr10, r1
3e8c4:f0 e8 ldir31, 0x80; 128
3e8c6:bf 06 cpcr11, r31
3e8c8:19 f4 brne.+6 ; 0x3e8d0
3e8ca:a1 2c movr10, r1
3e8cc:18 e7 ldir17, 0x78; 120
3e8ce:b1 2e movr11, r17
3e8d0:85 01 movwr16, r10
3e8d2:d6 cf rjmp.-84 ; 0x3e880
}
spiWriteWord(REG_S3_RX_RD0, readPointer); // Write back new pointer
3e8d4:b8 01 movwr22, r16
3e8d6:88 e2 ldir24, 0x28; 40
3e8d8:97 e0 ldir25, 0x07; 7
3e8da:25 de rcall.-950 ; 0x3e526
spiWriteReg(REG_S3_CR, CR_RECV);
3e8dc:60 e4 ldir22, 0x40; 64
3e8de:81 e0 ldir24, 0x01; 1
3e8e0:97 e0 ldir25, 0x07; 7
3e8e2:08 de rcall.-1008 ; 0x3e4f4
while(spiReadReg(REG_S3_CR));
3e8e4:81 e0 ldir24, 0x01; 1
3e8e6:97 e0 ldir25, 0x07; 7
3e8e8:2f de rcall.-930 ; 0x3e548
3e8ea:81 11 cpser24, r1
3e8ec:fb cf rjmp.-10 ; 0x3e8e4
DBG_TFTP_EX(
3e8ee:66 ed ldir22, 0xD6; 214
3e8f0:71 ee ldir23, 0xE1; 225
3e8f2:8a e8 ldir24, 0x8A; 138
3e8f4:93 ee ldir25, 0xE3; 227
3e8f6:8f d3 rcall.+1822 ; 0x3f016
3e8f8:86 e2 ldir24, 0x26; 38
3e8fa:97 e0 ldir25, 0x07; 7
3e8fc:3f de rcall.-898 ; 0x3e57c
3e8fe:bc 01 movwr22, r24
3e900:80 e0 ldir24, 0x00; 0
3e902:90 e0 ldir25, 0x00; 0
3e904:44 e0 ldir20, 0x04; 4
3e906:b8 d3 rcall.+1904 ; 0x3f078
tracePGMlnTftp(mDebugTftp_BLEFT);
tracenum(spiReadWord(REG_S3_RX_RSR0));
)
// Dump packet
DBG_TFTP_EX(
3e908:82 e1 ldir24, 0x12; 18
3e90a:92 ee ldir25, 0xE2; 226
3e90c:60 d3 rcall.+1728 ; 0x3efce
3e90e:de 01 movwr26, r28
3e910:11 96 adiwr26, 0x01; 1
3e912:7d 01 movwr14, r26
3e914:06 e0 ldir16, 0x06; 6
3e916:11 e0 ldir17, 0x01; 1
3e918:01 50 subir16, 0x01; 1
3e91a:11 09 sbcr17, r1
3e91c:d8 f0 brcs.+54 ; 0x3e954
3e91e:f7 01 movwr30, r14
3e920:60 81 ldr22, Z
3e922:81 81 lddr24, Z+1; 0x01
3e924:70 e0 ldir23, 0x00; 0
3e926:78 2b orr23, r24
3e928:80 e0 ldir24, 0x00; 0
3e92a:90 e0 ldir25, 0x00; 0
3e92c:44 e0 ldir20, 0x04; 4
3e92e:a4 d3 rcall.+1864 ; 0x3f078
3e930:c8 01 movwr24, r16
3e932:87 70 andir24, 0x07; 7
3e934:99 27 eorr25, r25
3e936:89 2b orr24, r25
3e938:39 f4 brne.+14 ; 0x3e948
3e93a:01 15 cpr16, r1
3e93c:11 05 cpcr17, r1
3e93e:21 f0 breq.+8 ; 0x3e948
3e940:82 e1 ldir24, 0x12; 18
3e942:92 ee ldir25, 0xE2; 226
3e944:44 d3 rcall.+1672 ; 0x3efce
3e946:02 c0 rjmp.+4 ; 0x3e94c
3e948:80 e2 ldir24, 0x20; 32
3e94a:cb d3 rcall.+1942 ; 0x3f0e2
3e94c:f2 e0 ldir31, 0x02; 2
3e94e:ef 0e addr14, r31
3e950:f1 1c adcr15, r1
3e952:e2 cf rjmp.-60 ; 0x3e918
3e954:ce 01 movwr24, r28
3e956:01 96 adiwr24, 0x01; 1
3e958:7c 01 movwr14, r24
3e95a:0c e0 ldir16, 0x0C; 12
3e95c:17 e0 ldir17, 0x07; 7
// Set up return IP address and port
uint8_t i;
for(i = 0; i < 6; i++) spiWriteReg(REG_S3_DIPR0 + i, buffer[i]);
3e95e:d7 01 movwr26, r14
3e960:6d 91 ldr22, X+
3e962:7d 01 movwr14, r26
3e964:c8 01 movwr24, r16
3e966:c6 dd rcall.-1140 ; 0x3e4f4
3e968:0f 5f subir16, 0xFF; 255
3e96a:1f 4f sbcir17, 0xFF; 255
3e96c:02 31 cpir16, 0x12; 18
3e96e:b7 e0 ldir27, 0x07; 7
3e970:1b 07 cpcr17, r27
3e972:a9 f7 brne.-22 ; 0x3e95e
DBG_TFTP(tracePGMlnTftp(mDebugTftp_RADDR);)
3e974:60 e5 ldir22, 0x50; 80
3e976:73 ee ldir23, 0xE3; 227
3e978:8a e8 ldir24, 0x8A; 138
3e97a:93 ee ldir25, 0xE3; 227
3e97c:4c d3 rcall.+1688 ; 0x3f016
// Parse packet
uint16_t tftpDataLen = (buffer[6] << 8) + buffer[7];
3e97e:cf 80 lddr12, Y+7; 0x07
3e980:d1 2c movr13, r1
3e982:dc 2c movr13, r12
3e984:cc 24 eorr12, r12
3e986:88 85 lddr24, Y+8; 0x08
3e988:c8 0e addr12, r24
3e98a:d1 1c adcr13, r1
uint16_t tftpOpcode = (buffer[8] << 8) + buffer[9];
3e98c:09 85 lddr16, Y+9; 0x09
3e98e:10 e0 ldir17, 0x00; 0
3e990:10 2f movr17, r16
3e992:00 27 eorr16, r16
3e994:8a 85 lddr24, Y+10; 0x0a
3e996:08 0f addr16, r24
3e998:11 1d adcr17, r1
uint16_t tftpBlock = (buffer[10] << 8) + buffer[11];
3e99a:eb 84 lddr14, Y+11; 0x0b
3e99c:f1 2c movr15, r1
3e99e:fe 2c movr15, r14
3e9a0:ee 24 eorr14, r14
3e9a2:8c 85 lddr24, Y+12; 0x0c
3e9a4:e8 0e addr14, r24
3e9a6:f1 1c adcr15, r1
DBG_TFTP(
3e9a8:61 e4 ldir22, 0x41; 65
3e9aa:73 ee ldir23, 0xE3; 227
3e9ac:8a e8 ldir24, 0x8A; 138
3e9ae:93 ee ldir25, 0xE3; 227
3e9b0:32 d3 rcall.+1636 ; 0x3f016
3e9b2:b7 01 movwr22, r14
3e9b4:80 e0 ldir24, 0x00; 0
3e9b6:90 e0 ldir25, 0x00; 0
3e9b8:44 e0 ldir20, 0x04; 4
3e9ba:5e d3 rcall.+1724 ; 0x3f078
3e9bc:83 e3 ldir24, 0x33; 51
3e9be:93 ee ldir25, 0xE3; 227
3e9c0:06 d3 rcall.+1548 ; 0x3efce
3e9c2:b8 01 movwr22, r16
3e9c4:80 e0 ldir24, 0x00; 0
3e9c6:90 e0 ldir25, 0x00; 0
3e9c8:44 e0 ldir20, 0x04; 4
3e9ca:56 d3 rcall.+1708 ; 0x3f078
3e9cc:81 e2 ldir24, 0x21; 33
3e9ce:93 ee ldir25, 0xE3; 227
3e9d0:fe d2 rcall.+1532 ; 0x3efce
3e9d2:56 01 movwr10, r12
3e9d4:e4 e0 ldir30, 0x04; 4
3e9d6:ae 1a subr10, r30
3e9d8:b1 08 sbcr11, r1
3e9da:25 01 movwr4, r10
3e9dc:61 2c movr6, r1
3e9de:71 2c movr7, r1
3e9e0:44 e0 ldir20, 0x04; 4
3e9e2:c3 01 movwr24, r6
3e9e4:b2 01 movwr22, r4
3e9e6:48 d3 rcall.+1680 ; 0x3f078
tracenum(tftpOpcode);
tracePGM(mDebugTftp_DLEN);
tracenum(tftpDataLen - (TFTP_OPCODE_SIZE + TFTP_BLOCKNO_SIZE));
)
if((tftpOpcode == TFTP_OPCODE_DATA)
3e9e8:03 30 cpir16, 0x03; 3
3e9ea:11 05 cpcr17, r1
3e9ec:99 f4 brne.+38 ; 0x3ea14
&& ((tftpBlock > MAX_ADDR / 0x200) || (tftpBlock < highPacket) || (tftpBlock > highPacket + 1)))
3e9ee:f9 ef ldir31, 0xF9; 249
3e9f0:ef 16 cpr14, r31
3e9f2:f1 e0 ldir31, 0x01; 1
3e9f4:ff 06 cpcr15, r31
3e9f6:60 f4 brcc.+24 ; 0x3ea10
3e9f8:80 91 1a 02 ldsr24, 0x021A
3e9fc:90 91 1b 02 ldsr25, 0x021B
3ea00:e8 16 cpr14, r24
3ea02:f9 06 cpcr15, r25
3ea04:28 f0 brcs.+10 ; 0x3ea10
3ea06:01 96 adiwr24, 0x01; 1
3ea08:8e 15 cpr24, r14
3ea0a:9f 05 cpcr25, r15
3ea0c:08 f0 brcs.+2 ; 0x3ea10
3ea0e:42 c0 rjmp.+132 ; 0x3ea94
tftpOpcode = TFTP_OPCODE_UKN;
3ea10:00 e0 ldir16, 0x00; 0
3ea12:10 e0 ldir17, 0x00; 0
if(tftpDataLen > (0x200 + TFTP_OPCODE_SIZE + TFTP_BLOCKNO_SIZE))
3ea14:45 e0 ldir20, 0x05; 5
3ea16:c4 16 cpr12, r20
3ea18:42 e0 ldir20, 0x02; 2
3ea1a:d4 06 cpcr13, r20
3ea1c:08 f0 brcs.+2 ; 0x3ea20
3ea1e:5c c1 rjmp.+696 ; 0x3ecd8
uint8_t returnCode = ERROR_UNKNOWN;
uint16_t packetLength;
switch(tftpOpcode) {
3ea20:03 30 cpir16, 0x03; 3
3ea22:11 05 cpcr17, r1
3ea24:09 f4 brne.+2 ; 0x3ea28
3ea26:3c c0 rjmp.+120 ; 0x3eaa0
3ea28:50 f5 brcc.+84 ; 0x3ea7e
3ea2a:01 30 cpir16, 0x01; 1
3ea2c:11 05 cpcr17, r1
3ea2e:09 f4 brne.+2 ; 0x3ea32
3ea30:4d c1 rjmp.+666 ; 0x3eccc
3ea32:02 30 cpir16, 0x02; 2
3ea34:11 05 cpcr17, r1
3ea36:09 f0 breq.+2 ; 0x3ea3a
3ea38:51 c1 rjmp.+674 ; 0x3ecdc
case TFTP_OPCODE_WRQ: // Write request
DBG_TFTP(tracePGMlnTftp(mDebugTftp_OPWRQ);)
3ea3a:66 e0 ldir22, 0x06; 6
3ea3c:73 ee ldir23, 0xE3; 227
3ea3e:8a e8 ldir24, 0x8A; 138
3ea40:93 ee ldir25, 0xE3; 227
3ea42:e9 d2 rcall.+1490 ; 0x3f016
sockInit(tftpTransferPort);
3ea44:80 91 22 02 ldsr24, 0x0222
3ea48:90 91 23 02 ldsr25, 0x0223
3ea4c:a6 de rcall.-692 ; 0x3e79a
DBG_TFTP(
3ea4e:6a ee ldir22, 0xEA; 234
3ea50:72 ee ldir23, 0xE2; 226
3ea52:8a e8 ldir24, 0x8A; 138
3ea54:93 ee ldir25, 0xE3; 227
3ea56:df d2 rcall.+1470 ; 0x3f016
3ea58:60 91 22 02 ldsr22, 0x0222
3ea5c:70 91 23 02 ldsr23, 0x0223
3ea60:80 e0 ldir24, 0x00; 0
3ea62:90 e0 ldir25, 0x00; 0
3ea64:44 e0 ldir20, 0x04; 4
3ea66:08 d3 rcall.+1552 ; 0x3f078
tracePGMlnTftp(mDebugTftp_NPORT);
tracenum(tftpTransferPort);
)
lastPacket = highPacket = 0;
3ea68:10 92 1b 02 sts0x021B, r1
3ea6c:10 92 1a 02 sts0x021A, r1
3ea70:10 92 1d 02 sts0x021D, r1
3ea74:10 92 1c 02 sts0x021C, r1
returnCode = ACK; // Send back acknowledge for packet 0
3ea78:e2 e0 ldir30, 0x02; 2
3ea7a:3e 2e movr3, r30
break;
3ea7c:3b c1 rjmp.+630 ; 0x3ecf4
uint8_t returnCode = ERROR_UNKNOWN;
uint16_t packetLength;
switch(tftpOpcode) {
3ea7e:04 30 cpir16, 0x04; 4
3ea80:11 05 cpcr17, r1
3ea82:09 f4 brne.+2 ; 0x3ea86
3ea84:1c c1 rjmp.+568 ; 0x3ecbe
3ea86:05 30 cpir16, 0x05; 5
3ea88:11 05 cpcr17, r1
3ea8a:09 f0 breq.+2 ; 0x3ea8e
3ea8c:27 c1 rjmp.+590 ; 0x3ecdc
break;
// Error signal
case TFTP_OPCODE_ERROR:
DBG_TFTP(tracePGMlnTftp(mDebugTftp_OPERR);)
3ea8e:62 e8 ldir22, 0x82; 130
3ea90:72 ee ldir23, 0xE2; 226
3ea92:17 c1 rjmp.+558 ; 0x3ecc2
if((tftpOpcode == TFTP_OPCODE_DATA)
&& ((tftpBlock > MAX_ADDR / 0x200) || (tftpBlock < highPacket) || (tftpBlock > highPacket + 1)))
tftpOpcode = TFTP_OPCODE_UKN;
if(tftpDataLen > (0x200 + TFTP_OPCODE_SIZE + TFTP_BLOCKNO_SIZE))
3ea94:95 e0 ldir25, 0x05; 5
3ea96:c9 16 cpr12, r25
3ea98:92 e0 ldir25, 0x02; 2
3ea9a:d9 06 cpcr13, r25
3ea9c:08 f0 brcs.+2 ; 0x3eaa0
3ea9e:1c c1 rjmp.+568 ; 0x3ecd8
lastPacket = highPacket = 0;
returnCode = ACK; // Send back acknowledge for packet 0
break;
case TFTP_OPCODE_DATA:
DBG_TFTP(tracePGMlnTftp(mDebugTftp_OPDATA);)
3eaa0:6b ef ldir22, 0xFB; 251
3eaa2:72 ee ldir23, 0xE2; 226
3eaa4:8a e8 ldir24, 0x8A; 138
3eaa6:93 ee ldir25, 0xE3; 227
3eaa8:b6 d2 rcall.+1388 ; 0x3f016
packetLength = tftpDataLen - (TFTP_OPCODE_SIZE + TFTP_BLOCKNO_SIZE);
lastPacket = tftpBlock;
3eaaa:f0 92 1d 02 sts0x021D, r15
3eaae:e0 92 1c 02 sts0x021C, r14
#if defined(RAMPZ)
writeAddr = (((address_t)((tftpBlock - 1)/0x80) << 16) | ((address_t)((tftpBlock - 1)%0x80) << 9));
3eab2:c7 01 movwr24, r14
3eab4:01 97 sbiwr24, 0x01; 1
3eab6:6c 01 movwr12, r24
3eab8:e1 2c movr14, r1
3eaba:f1 2c movr15, r1
3eabc:59 e0 ldir21, 0x09; 9
3eabe:cc 0c addr12, r12
3eac0:dd 1c adcr13, r13
3eac2:ee 1c adcr14, r14
3eac4:ff 1c adcr15, r15
3eac6:5a 95 decr21
3eac8:d1 f7 brne.-12 ; 0x3eabe
3eaca:ee 24 eorr14, r14
3eacc:ff 24 eorr15, r15
3eace:88 0f addr24, r24
3ead0:89 2f movr24, r25
3ead2:88 1f adcr24, r24
3ead4:99 0b sbcr25, r25
3ead6:91 95 negr25
3ead8:a0 e0 ldir26, 0x00; 0
3eada:b0 e0 ldir27, 0x00; 0
3eadc:dc 01 movwr26, r24
3eade:99 27 eorr25, r25
3eae0:88 27 eorr24, r24
3eae2:c8 2a orr12, r24
3eae4:d9 2a orr13, r25
3eae6:ea 2a orr14, r26
3eae8:fb 2a orr15, r27
#else
writeAddr = (address_t)((address_t)(tftpBlock - 1) << 9); // Flash write address for this block
#endif
if((writeAddr + packetLength) > MAX_ADDR) {
3eaea:4c 0c addr4, r12
3eaec:5d 1c adcr5, r13
3eaee:6e 1c adcr6, r14
3eaf0:7f 1c adcr7, r15
3eaf2:81 e0 ldir24, 0x01; 1
3eaf4:48 16 cpr4, r24
3eaf6:80 ef ldir24, 0xF0; 240
3eaf8:58 06 cpcr5, r24
3eafa:83 e0 ldir24, 0x03; 3
3eafc:68 06 cpcr6, r24
3eafe:71 04 cpcr7, r1
3eb00:40 f0 brcs.+16 ; 0x3eb12
// Flash is full - abort with an error before a bootloader overwrite occurs
// Application is now corrupt, so do not hand over.
DBG_TFTP(tracePGMlnTftp(mDebugTftp_FULL);)
3eb02:6c ed ldir22, 0xDC; 220
3eb04:72 ee ldir23, 0xE2; 226
3eb06:8a e8 ldir24, 0x8A; 138
3eb08:93 ee ldir25, 0xE3; 227
3eb0a:85 d2 rcall.+1290 ; 0x3f016
returnCode = ERROR_FULL;
3eb0c:43 e0 ldir20, 0x03; 3
3eb0e:34 2e movr3, r20
3eb10:f1 c0 rjmp.+482 ; 0x3ecf4
} else {
DBG_TFTP(
3eb12:61 ec ldir22, 0xC1; 193
3eb14:72 ee ldir23, 0xE2; 226
3eb16:8a e8 ldir24, 0x8A; 138
3eb18:93 ee ldir25, 0xE3; 227
3eb1a:7d d2 rcall.+1274 ; 0x3f016
3eb1c:46 e0 ldir20, 0x06; 6
3eb1e:c7 01 movwr24, r14
3eb20:b6 01 movwr22, r12
3eb22:aa d2 rcall.+1364 ; 0x3f078
uint8_t* pageBase = buffer + (UDP_HEADER_SIZE + TFTP_OPCODE_SIZE + TFTP_BLOCKNO_SIZE); // Start of block data
uint16_t offset = 0; // Block offset
// Set the return code before packetLength gets rounded up
if(packetLength < TFTP_DATA_SIZE) returnCode = FINAL_ACK;
3eb24:a1 14 cpr10, r1
3eb26:92 e0 ldir25, 0x02; 2
3eb28:b9 06 cpcr11, r25
3eb2a:18 f4 brcc.+6 ; 0x3eb32
3eb2c:34 e0 ldir19, 0x04; 4
3eb2e:33 2e movr3, r19
3eb30:02 c0 rjmp.+4 ; 0x3eb36
else returnCode = ACK;
3eb32:22 e0 ldir18, 0x02; 2
3eb34:32 2e movr3, r18
// Round up packet length to a full flash sector size
while(packetLength % SPM_PAGESIZE) packetLength++;
3eb36:aa 20 andr10, r10
3eb38:21 f0 breq.+8 ; 0x3eb42
3eb3a:af ef ldir26, 0xFF; 255
3eb3c:aa 1a subr10, r26
3eb3e:ba 0a sbcr11, r26
3eb40:fa cf rjmp.-12 ; 0x3eb36
DBG_TFTP(
3eb42:66 ea ldir22, 0xA6; 166
3eb44:72 ee ldir23, 0xE2; 226
3eb46:8a e8 ldir24, 0x8A; 138
3eb48:93 ee ldir25, 0xE3; 227
3eb4a:65 d2 rcall.+1226 ; 0x3f016
3eb4c:c5 01 movwr24, r10
3eb4e:a0 e0 ldir26, 0x00; 0
3eb50:b0 e0 ldir27, 0x00; 0
3eb52:44 e0 ldir20, 0x04; 4
3eb54:bc 01 movwr22, r24
3eb56:cd 01 movwr24, r26
3eb58:8f d2 rcall.+1310 ; 0x3f078
tracePGMlnTftp(mDebugTftp_PLEN);
tracenum(packetLength);
)
if(writeAddr == 0) {
3eb5a:c1 14 cpr12, r1
3eb5c:d1 04 cpcr13, r1
3eb5e:e1 04 cpcr14, r1
3eb60:f1 04 cpcr15, r1
3eb62:19 f4 brne.+6 ; 0x3eb6a
// First sector - validate
if(!validImage(pageBase)) {
3eb64:ce 01 movwr24, r28
3eb66:0d 96 adiwr24, 0x0d; 13
3eb68:d8 d1 rcall.+944 ; 0x3ef1a
3eb6a:9e 01 movwr18, r28
3eb6c:23 5f subir18, 0xF3; 243
3eb6e:3f 4f sbcir19, 0xFF; 255
uint8_t* pageBase = buffer + (UDP_HEADER_SIZE + TFTP_OPCODE_SIZE + TFTP_BLOCKNO_SIZE); // Start of block data
uint16_t offset = 0; // Block offset
// Set the return code before packetLength gets rounded up
if(packetLength < TFTP_DATA_SIZE) returnCode = FINAL_ACK;
3eb70:00 e0 ldir16, 0x00; 0
3eb72:10 e0 ldir17, 0x00; 0
uint16_t writeValue;
for(offset = 0; offset < packetLength;) {
writeValue = (pageBase[offset]) | (pageBase[offset + 1] << 8);
boot_page_fill(writeAddr + offset, writeValue);
DBG_TFTP_EX(
3eb74:f5 01 movwr30, r10
3eb76:32 97 sbiwr30, 0x02; 2
3eb78:c3 5f subir28, 0xF3; 243
3eb7a:dd 4f sbcir29, 0xFD; 253
3eb7c:f9 83 stdY+1, r31; 0x01
3eb7e:e8 83 stY, r30
3eb80:cd 50 subir28, 0x0D; 13
3eb82:d2 40 sbcir29, 0x02; 2
)
offset += 2;
if(offset % SPM_PAGESIZE == 0) {
boot_page_erase(writeAddr + offset - SPM_PAGESIZE);
3eb84:d7 01 movwr26, r14
3eb86:c6 01 movwr24, r12
3eb88:91 50 subir25, 0x01; 1
3eb8a:a1 09 sbcr26, r1
3eb8c:b1 09 sbcr27, r1
3eb8e:c1 5f subir28, 0xF1; 241
3eb90:dd 4f sbcir29, 0xFD; 253
3eb92:88 83 stY, r24
3eb94:99 83 stdY+1, r25; 0x01
3eb96:aa 83 stdY+2, r26; 0x02
3eb98:bb 83 stdY+3, r27; 0x03
3eb9a:cf 50 subir28, 0x0F; 15
3eb9c:d2 40 sbcir29, 0x02; 2
boot_spm_busy_wait();
boot_page_write(writeAddr + offset - SPM_PAGESIZE);
3eb9e:55 e0 ldir21, 0x05; 5
boot_spm_busy_wait();
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
3eba0:91 e1 ldir25, 0x11; 17
3eba2:29 2e movr2, r25
}
}
// Flash packets
uint16_t writeValue;
for(offset = 0; offset < packetLength;) {
3eba4:0a 15 cpr16, r10
3eba6:1b 05 cpcr17, r11
3eba8:08 f0 brcs.+2 ; 0x3ebac
3ebaa:80 c0 rjmp.+256 ; 0x3ecac
3ebac:e1 e0 ldir30, 0x01; 1
3ebae:f0 e0 ldir31, 0x00; 0
3ebb0:ec 0f addr30, r28
3ebb2:fd 1f adcr31, r29
3ebb4:e0 0f addr30, r16
3ebb6:f1 1f adcr31, r17
writeValue = (pageBase[offset]) | (pageBase[offset + 1] << 8);
3ebb8:85 84 lddr8, Z+13; 0x0d
3ebba:91 2c movr9, r1
3ebbc:98 2c movr9, r8
3ebbe:88 24 eorr8, r8
3ebc0:d9 01 movwr26, r18
3ebc2:8c 91 ldr24, X
3ebc4:88 2a orr8, r24
boot_page_fill(writeAddr + offset, writeValue);
3ebc6:26 01 movwr4, r12
3ebc8:37 01 movwr6, r14
3ebca:40 0e addr4, r16
3ebcc:51 1e adcr5, r17
3ebce:61 1c adcr6, r1
3ebd0:71 1c adcr7, r1
3ebd2:b1 e0 ldir27, 0x01; 1
3ebd4:04 01 movwr0, r8
3ebd6:f2 01 movwr30, r4
3ebd8:60 92 5b 00 sts0x005B, r6
3ebdc:b0 93 57 00 sts0x0057, r27
3ebe0:e8 95 spm
3ebe2:11 24 eorr1, r1
DBG_TFTP_EX(
3ebe4:01 15 cpr16, r1
3ebe6:11 05 cpcr17, r1
3ebe8:49 f0 breq.+18 ; 0x3ebfc
3ebea:c3 5f subir28, 0xF3; 243
3ebec:dd 4f sbcir29, 0xFD; 253
3ebee:e8 81 ldr30, Y
3ebf0:f9 81 lddr31, Y+1; 0x01
3ebf2:cd 50 subir28, 0x0D; 13
3ebf4:d2 40 sbcir29, 0x02; 2
3ebf6:0e 17 cpr16, r30
3ebf8:1f 07 cpcr17, r31
3ebfa:79 f5 brne.+94 ; 0x3ec5a
3ebfc:6d ec ldir22, 0xCD; 205
3ebfe:71 ee ldir23, 0xE1; 225
3ec00:8a e8 ldir24, 0x8A; 138
3ec02:93 ee ldir25, 0xE3; 227
3ec04:cd 5e subir28, 0xED; 237
3ec06:dd 4f sbcir29, 0xFD; 253
3ec08:28 83 stY, r18
3ec0a:c3 51 subir28, 0x13; 19
3ec0c:d2 40 sbcir29, 0x02; 2
3ec0e:cc 5e subir28, 0xEC; 236
3ec10:dd 4f sbcir29, 0xFD; 253
3ec12:38 83 stY, r19
3ec14:c4 51 subir28, 0x14; 20
3ec16:d2 40 sbcir29, 0x02; 2
3ec18:cb 5e subir28, 0xEB; 235
3ec1a:dd 4f sbcir29, 0xFD; 253
3ec1c:58 83 stY, r21
3ec1e:c5 51 subir28, 0x15; 21
3ec20:d2 40 sbcir29, 0x02; 2
3ec22:f9 d1 rcall.+1010 ; 0x3f016
3ec24:b4 01 movwr22, r8
3ec26:80 e0 ldir24, 0x00; 0
3ec28:90 e0 ldir25, 0x00; 0
3ec2a:44 e0 ldir20, 0x04; 4
3ec2c:25 d2 rcall.+1098 ; 0x3f078
3ec2e:81 ec ldir24, 0xC1; 193
3ec30:91 ee ldir25, 0xE1; 225
3ec32:cd d1 rcall.+922 ; 0x3efce
3ec34:44 e0 ldir20, 0x04; 4
3ec36:c3 01 movwr24, r6
3ec38:b2 01 movwr22, r4
3ec3a:1e d2 rcall.+1084 ; 0x3f078
3ec3c:cb 5e subir28, 0xEB; 235
3ec3e:dd 4f sbcir29, 0xFD; 253
3ec40:58 81 ldr21, Y
3ec42:c5 51 subir28, 0x15; 21
3ec44:d2 40 sbcir29, 0x02; 2
3ec46:cc 5e subir28, 0xEC; 236
3ec48:dd 4f sbcir29, 0xFD; 253
3ec4a:38 81 ldr19, Y
3ec4c:c4 51 subir28, 0x14; 20
3ec4e:d2 40 sbcir29, 0x02; 2
3ec50:cd 5e subir28, 0xED; 237
3ec52:dd 4f sbcir29, 0xFD; 253
3ec54:28 81 ldr18, Y
3ec56:c3 51 subir28, 0x13; 19
3ec58:d2 40 sbcir29, 0x02; 2
tracePGM(mDebugTftp_OFFSET);
tracenum(writeAddr + offset);
}
)
offset += 2;
3ec5a:0e 5f subir16, 0xFE; 254
3ec5c:1f 4f sbcir17, 0xFF; 255
if(offset % SPM_PAGESIZE == 0) {
3ec5e:01 11 cpser16, r1
3ec60:22 c0 rjmp.+68 ; 0x3eca6
boot_page_erase(writeAddr + offset - SPM_PAGESIZE);
3ec62:c1 5f subir28, 0xF1; 241
3ec64:dd 4f sbcir29, 0xFD; 253
3ec66:88 81 ldr24, Y
3ec68:99 81 lddr25, Y+1; 0x01
3ec6a:aa 81 lddr26, Y+2; 0x02
3ec6c:bb 81 lddr27, Y+3; 0x03
3ec6e:cf 50 subir28, 0x0F; 15
3ec70:d2 40 sbcir29, 0x02; 2
3ec72:80 0f addr24, r16
3ec74:91 1f adcr25, r17
3ec76:a1 1d adcr26, r1
3ec78:b1 1d adcr27, r1
3ec7a:43 e0 ldir20, 0x03; 3
3ec7c:fc 01 movwr30, r24
3ec7e:a0 93 5b 00 sts0x005B, r26
3ec82:40 93 57 00 sts0x0057, r20
3ec86:e8 95 spm
boot_spm_busy_wait();
3ec88:07 b6 inr0, 0x37; 55
3ec8a:00 fc sbrcr0, 0
3ec8c:fd cf rjmp.-6 ; 0x3ec88
boot_page_write(writeAddr + offset - SPM_PAGESIZE);
3ec8e:fc 01 movwr30, r24
3ec90:a0 93 5b 00 sts0x005B, r26
3ec94:50 93 57 00 sts0x0057, r21
3ec98:e8 95 spm
boot_spm_busy_wait();
3ec9a:07 b6 inr0, 0x37; 55
3ec9c:00 fc sbrcr0, 0
3ec9e:fd cf rjmp.-6 ; 0x3ec9a
#if defined(RWWSRE)
// Reenable read access to flash
boot_rww_enable();
3eca0:20 92 57 00 sts0x0057, r2
3eca4:e8 95 spm
3eca6:2e 5f subir18, 0xFE; 254
3eca8:3f 4f sbcir19, 0xFF; 255
3ecaa:7c cf rjmp.-264 ; 0x3eba4
#endif
}
}
if(returnCode == FINAL_ACK) {
3ecac:84 e0 ldir24, 0x04; 4
3ecae:38 12 cpser3, r24
3ecb0:21 c0 rjmp.+66 ; 0x3ecf4
// Flash is complete
// Hand over to application
DBG_TFTP(tracePGMlnTftp(mDebugTftp_DONE);)
3ecb2:64 e9 ldir22, 0x94; 148
3ecb4:72 ee ldir23, 0xE2; 226
3ecb6:8a e8 ldir24, 0x8A; 138
3ecb8:93 ee ldir25, 0xE3; 227
3ecba:ad d1 rcall.+858 ; 0x3f016
3ecbc:1b c0 rjmp.+54 ; 0x3ecf4
break;
// Acknowledgment
case TFTP_OPCODE_ACK:
DBG_TFTP(tracePGMlnTftp(mDebugTftp_OPACK);)
3ecbe:68 e8 ldir22, 0x88; 136
3ecc0:72 ee ldir23, 0xE2; 226
break;
// Error signal
case TFTP_OPCODE_ERROR:
DBG_TFTP(tracePGMlnTftp(mDebugTftp_OPERR);)
3ecc2:8a e8 ldir24, 0x8A; 138
3ecc4:93 ee ldir25, 0xE3; 227
3ecc6:a7 d1 rcall.+846 ; 0x3f016
tftpOpcode = TFTP_OPCODE_UKN;
if(tftpDataLen > (0x200 + TFTP_OPCODE_SIZE + TFTP_BLOCKNO_SIZE))
tftpOpcode = TFTP_OPCODE_UKN;
uint8_t returnCode = ERROR_UNKNOWN;
3ecc8:31 2c movr3, r1
case TFTP_OPCODE_ERROR:
DBG_TFTP(tracePGMlnTftp(mDebugTftp_OPERR);)
/* FIXME: Resetting might be needed here too */
break;
3ecca:14 c0 rjmp.+40 ; 0x3ecf4
case TFTP_OPCODE_RRQ: // Read request
DBG_TFTP(tracePGMlnTftp(mDebugTftp_OPRRQ);)
3eccc:64 e1 ldir22, 0x14; 20
3ecce:73 ee ldir23, 0xE3; 227
3ecd0:8a e8 ldir24, 0x8A; 138
3ecd2:93 ee ldir25, 0xE3; 227
3ecd4:a0 d1 rcall.+832 ; 0x3f016
3ecd6:02 c0 rjmp.+4 ; 0x3ecdc
if((tftpOpcode == TFTP_OPCODE_DATA)
&& ((tftpBlock > MAX_ADDR / 0x200) || (tftpBlock < highPacket) || (tftpBlock > highPacket + 1)))
tftpOpcode = TFTP_OPCODE_UKN;
if(tftpDataLen > (0x200 + TFTP_OPCODE_SIZE + TFTP_BLOCKNO_SIZE))
tftpOpcode = TFTP_OPCODE_UKN;
3ecd8:00 e0 ldir16, 0x00; 0
3ecda:10 e0 ldir17, 0x00; 0
break;
case TFTP_OPCODE_RRQ: // Read request
DBG_TFTP(tracePGMlnTftp(mDebugTftp_OPRRQ);)
default:
DBG_TFTP(
3ecdc:62 e7 ldir22, 0x72; 114
3ecde:72 ee ldir23, 0xE2; 226
3ece0:8a e8 ldir24, 0x8A; 138
3ece2:93 ee ldir25, 0xE3; 227
3ece4:98 d1 rcall.+816 ; 0x3f016
3ece6:b8 01 movwr22, r16
3ece8:80 e0 ldir24, 0x00; 0
3ecea:90 e0 ldir25, 0x00; 0
3ecec:44 e0 ldir20, 0x04; 4
3ecee:c4 d1 rcall.+904 ; 0x3f078
tracePGMlnTftp(mDebugTftp_INVOP);
tracenum(tftpOpcode);
)
// Invalid - return error
returnCode = ERROR_INVALID;
3ecf0:33 24 eorr3, r3
3ecf2:33 94 incr3
break;
}
return(returnCode);
}
3ecf4:83 2d movr24, r3
3ecf6:cb 5e subir28, 0xEB; 235
3ecf8:dd 4f sbcir29, 0xFD; 253
3ecfa:de bf out0x3e, r29; 62
3ecfc:cd bf out0x3d, r28; 61
3ecfe:df 91 popr29
3ed00:cf 91 popr28
3ed02:1f 91 popr17
3ed04:0f 91 popr16
3ed06:ff 90 popr15
3ed08:ef 90 popr14
3ed0a:df 90 popr13
3ed0c:cf 90 popr12
3ed0e:bf 90 popr11
3ed10:af 90 popr10
3ed12:9f 90 popr9
3ed14:8f 90 popr8
3ed16:7f 90 popr7
3ed18:6f 90 popr6
3ed1a:5f 90 popr5
3ed1c:4f 90 popr4
3ed1e:3f 90 popr3
3ed20:2f 90 popr2
3ed22:08 95 ret
0003ed24 :
* Initializes the network controller
*/
void tftpInit(void)
{
// Open socket
sockInit(TFTP_PORT);
3ed24:85 e4 ldir24, 0x45; 69
3ed26:90 e0 ldir25, 0x00; 0
3ed28:38 dd rcall.-1424 ; 0x3e79a
DBG_TFTP(
3ed2a:66 e3 ldir22, 0x36; 54
3ed2c:72 ee ldir23, 0xE2; 226
3ed2e:8a e8 ldir24, 0x8A; 138
3ed30:93 ee ldir25, 0xE3; 227
3ed32:71 d1 rcall.+738 ; 0x3f016
3ed34:6a e2 ldir22, 0x2A; 42
3ed36:72 ee ldir23, 0xE2; 226
3ed38:8a e8 ldir24, 0x8A; 138
3ed3a:93 ee ldir25, 0xE3; 227
3ed3c:6c d1 rcall.+728 ; 0x3f016
3ed3e:60 91 22 02 ldsr22, 0x0222
3ed42:70 91 23 02 ldsr23, 0x0223
3ed46:80 e0 ldir24, 0x00; 0
3ed48:90 e0 ldir25, 0x00; 0
3ed4a:44 e0 ldir20, 0x04; 4
3ed4c:95 c1 rjmp.+810 ; 0x3f078
0003ed4e :
/**
* Looks for a connection
*/
uint8_t tftpPoll(void)
{
3ed4e:af 92 pushr10
3ed50:bf 92 pushr11
3ed52:cf 92 pushr12
3ed54:df 92 pushr13
3ed56:ef 92 pushr14
3ed58:ff 92 pushr15
3ed5a:0f 93 pushr16
3ed5c:1f 93 pushr17
3ed5e:cf 93 pushr28
3ed60:df 93 pushr29
3ed62:cd b7 inr28, 0x3d; 61
3ed64:de b7 inr29, 0x3e; 62
3ed66:c4 56 subir28, 0x64; 100
3ed68:d1 09 sbcr29, r1
3ed6a:de bf out0x3e, r29; 62
3ed6c:cd bf out0x3d, r28; 61
uint8_t response = ACK;
// Get the size of the recieved data
uint16_t packetSize = spiReadWord(REG_S3_RX_RSR0);
3ed6e:86 e2 ldir24, 0x26; 38
3ed70:97 e0 ldir25, 0x07; 7
3ed72:04 dc rcall.-2040 ; 0x3e57c
if (packetSize==0x800) {
3ed74:81 15 cpr24, r1
3ed76:28 e0 ldir18, 0x08; 8
3ed78:92 07 cpcr25, r18
3ed7a:41 f4 brne.+16 ; 0x3ed8c
sockInit(tftpTransferPort);
3ed7c:80 91 22 02 ldsr24, 0x0222
3ed80:90 91 23 02 ldsr25, 0x0223
3ed84:0a dd rcall.-1516 ; 0x3e79a
uint16_t retry=65536;
while ((packetSize=spiReadWord(REG_S3_RX_RSR0))==0&&retry-->0);
3ed86:86 e2 ldir24, 0x26; 38
3ed88:97 e0 ldir25, 0x07; 7
3ed8a:f8 db rcall.-2064 ; 0x3e57c
}
packetSize=packetSize&0x07FF;
3ed8c:8c 01 movwr16, r24
3ed8e:17 70 andir17, 0x07; 7
if(packetSize) {
3ed90:01 15 cpr16, r1
3ed92:11 05 cpcr17, r1
3ed94:09 f4 brne.+2 ; 0x3ed98
3ed96:9f c0 rjmp.+318 ; 0x3eed6
tftpFlashing = TRUE;
3ed98:81 e0 ldir24, 0x01; 1
3ed9a:80 93 25 02 sts0x0225, r24
resetTick();
3ed9e:e6 d1 rcall.+972 ; 0x3f16c
// Process Packet and get TFTP response code
#if (DEBUG_TFTP > 0)
response = processPacket(packetSize);
3eda0:c8 01 movwr24, r16
3eda2:29 dd rcall.-1454 ; 0x3e7f6
3eda4:f8 2e movr15, r24
uint8_t txBuffer[100];
uint8_t* txPtr = txBuffer;
uint8_t packetLength;
uint16_t writePointer;
writePointer = spiReadWord(REG_S3_TX_WR0) + S3_TX_START;
3eda6:84 e2 ldir24, 0x24; 36
3eda8:97 e0 ldir25, 0x07; 7
3edaa:e8 db rcall.-2096 ; 0x3e57c
3edac:8c 01 movwr16, r24
3edae:18 5a subir17, 0xA8; 168
switch(response) {
3edb0:33 e0 ldir19, 0x03; 3
3edb2:f3 16 cpr15, r19
3edb4:81 f1 breq.+96 ; 0x3ee16
3edb6:3f 15 cpr19, r15
3edb8:40 f0 brcs.+16 ; 0x3edca
3edba:81 e0 ldir24, 0x01; 1
3edbc:f8 16 cpr15, r24
3edbe:f1 f0 breq.+60 ; 0x3edfc
3edc0:e2 e0 ldir30, 0x02; 2
3edc2:fe 16 cpr15, r30
3edc4:09 f4 brne.+2 ; 0x3edc8
3edc6:41 c0 rjmp.+130 ; 0x3ee4a
3edc8:07 c0 rjmp.+14 ; 0x3edd8
3edca:f4 e0 ldir31, 0x04; 4
3edcc:ff 16 cpr15, r31
3edce:09 f4 brne.+2 ; 0x3edd2
3edd0:92 c0 rjmp.+292 ; 0x3eef6
3edd2:25 e0 ldir18, 0x05; 5
3edd4:f2 16 cpr15, r18
3edd6:61 f1 breq.+88 ; 0x3ee30
case ERROR_UNKNOWN:
// Send unknown error packet
packetLength = TFTP_UNKNOWN_ERROR_LEN;
#if (FLASHEND > 0x10000)
memcpy_PF(txBuffer, PROGMEM_OFFSET + (uint32_t)(uint16_t)tftp_unknown_error_packet, packetLength);
3edd8:42 ea ldir20, 0xA2; 162
3edda:51 ee ldir21, 0xE1; 225
3eddc:60 e0 ldir22, 0x00; 0
3edde:70 e0 ldir23, 0x00; 0
3ede0:6d 5f subir22, 0xFD; 253
3ede2:7f 4f sbcir23, 0xFF; 255
3ede4:2a e0 ldir18, 0x0A; 10
3ede6:30 e0 ldir19, 0x00; 0
3ede8:ce 01 movwr24, r28
3edea:01 96 adiwr24, 0x01; 1
3edec:98 d4 rcall.+2352 ; 0x3f71e
switch(response) {
default:
case ERROR_UNKNOWN:
// Send unknown error packet
packetLength = TFTP_UNKNOWN_ERROR_LEN;
3edee:8a e0 ldir24, 0x0A; 10
txPtr = txBuffer;
while(packetLength--) {
spiWriteReg(writePointer++, *txPtr++);
if(writePointer == S3_TX_END) writePointer = S3_TX_START;
3edf0:fe 01 movwr30, r28
3edf2:31 96 adiwr30, 0x01; 1
3edf4:6f 01 movwr12, r30
3edf6:e8 2e movr14, r24
3edf8:ee 0e addr14, r30
3edfa:57 c0 rjmp.+174 ; 0x3eeaa
case ERROR_INVALID:
// Send invalid opcode packet
packetLength = TFTP_OPCODE_ERROR_LEN;
#if (FLASHEND > 0x10000)
memcpy_PF(txBuffer, PROGMEM_OFFSET + (uint32_t)(uint16_t)tftp_opcode_error_packet, packetLength);
3edfc:45 eb ldir20, 0xB5; 181
3edfe:51 ee ldir21, 0xE1; 225
3ee00:60 e0 ldir22, 0x00; 0
3ee02:70 e0 ldir23, 0x00; 0
3ee04:6d 5f subir22, 0xFD; 253
3ee06:7f 4f sbcir23, 0xFF; 255
3ee08:2c e0 ldir18, 0x0C; 12
3ee0a:30 e0 ldir19, 0x00; 0
3ee0c:ce 01 movwr24, r28
3ee0e:01 96 adiwr24, 0x01; 1
3ee10:86 d4 rcall.+2316 ; 0x3f71e
#endif
break;
case ERROR_INVALID:
// Send invalid opcode packet
packetLength = TFTP_OPCODE_ERROR_LEN;
3ee12:8c e0 ldir24, 0x0C; 12
3ee14:ed cf rjmp.-38 ; 0x3edf0
case ERROR_FULL:
// Send unknown error packet
packetLength = TFTP_FULL_ERROR_LEN;
#if (FLASHEND > 0x10000)
memcpy_PF(txBuffer, PROGMEM_OFFSET + (uint32_t)(uint16_t)tftp_full_error_packet, packetLength);
3ee16:4c ea ldir20, 0xAC; 172
3ee18:51 ee ldir21, 0xE1; 225
3ee1a:60 e0 ldir22, 0x00; 0
3ee1c:70 e0 ldir23, 0x00; 0
3ee1e:6d 5f subir22, 0xFD; 253
3ee20:7f 4f sbcir23, 0xFF; 255
3ee22:29 e0 ldir18, 0x09; 9
3ee24:30 e0 ldir19, 0x00; 0
3ee26:ce 01 movwr24, r28
3ee28:01 96 adiwr24, 0x01; 1
3ee2a:79 d4 rcall.+2290 ; 0x3f71e
#endif
break;
case ERROR_FULL:
// Send unknown error packet
packetLength = TFTP_FULL_ERROR_LEN;
3ee2c:89 e0 ldir24, 0x09; 9
3ee2e:e0 cf rjmp.-64 ; 0x3edf0
#endif
break;
case INVALID_IMAGE:
packetLength = TFTP_INVALID_IMAGE_LEN;
#if (FLASHEND > 0x10000)
memcpy_PF(txBuffer, PROGMEM_OFFSET + (uint32_t)(uint16_t)tftp_invalid_image_packet, packetLength);
3ee30:4b e8 ldir20, 0x8B; 139
3ee32:51 ee ldir21, 0xE1; 225
3ee34:60 e0 ldir22, 0x00; 0
3ee36:70 e0 ldir23, 0x00; 0
3ee38:6d 5f subir22, 0xFD; 253
3ee3a:7f 4f sbcir23, 0xFF; 255
3ee3c:27 e1 ldir18, 0x17; 23
3ee3e:30 e0 ldir19, 0x00; 0
3ee40:ce 01 movwr24, r28
3ee42:01 96 adiwr24, 0x01; 1
3ee44:6c d4 rcall.+2264 ; 0x3f71e
#else
memcpy_P(txBuffer, tftp_full_error_packet, packetLength);
#endif
break;
case INVALID_IMAGE:
packetLength = TFTP_INVALID_IMAGE_LEN;
3ee46:87 e1 ldir24, 0x17; 23
3ee48:d3 cf rjmp.-90 ; 0x3edf0
#else
memcpy_P(txBuffer, tftp_invalid_image_packet, packetLength);
#endif
break;
case ACK:
if(lastPacket > highPacket) highPacket = lastPacket;
3ee4a:80 91 1c 02 ldsr24, 0x021C
3ee4e:90 91 1d 02 ldsr25, 0x021D
3ee52:20 91 1a 02 ldsr18, 0x021A
3ee56:30 91 1b 02 ldsr19, 0x021B
3ee5a:28 17 cpr18, r24
3ee5c:39 07 cpcr19, r25
3ee5e:20 f4 brcc.+8 ; 0x3ee68
3ee60:90 93 1b 02 sts0x021B, r25
3ee64:80 93 1a 02 sts0x021A, r24
DBG_TFTP(tracePGMlnTftp(mDebugTftp_SACK);)
3ee68:69 e6 ldir22, 0x69; 105
3ee6a:72 ee ldir23, 0xE2; 226
3ee6c:8a e8 ldir24, 0x8A; 138
3ee6e:93 ee ldir25, 0xE3; 227
3ee70:d2 d0 rcall.+420 ; 0x3f016
if(response == FINAL_ACK)
tracePGMlnTftp(mDebugTftp_SFACK);
)
packetLength = 4;
*txPtr++ = TFTP_OPCODE_ACK >> 8;
3ee72:19 82 stdY+1, r1; 0x01
*txPtr++ = TFTP_OPCODE_ACK & 0xff;
3ee74:84 e0 ldir24, 0x04; 4
3ee76:8a 83 stdY+2, r24; 0x02
// lastPacket is block code
*txPtr++ = lastPacket >> 8;
3ee78:80 91 1c 02 ldsr24, 0x021C
3ee7c:90 91 1d 02 ldsr25, 0x021D
3ee80:9b 83 stdY+3, r25; 0x03
*txPtr = lastPacket & 0xff;
3ee82:8c 83 stdY+4, r24; 0x04
DBG_TFTP(
if(response == FINAL_ACK)
tracePGMlnTftp(mDebugTftp_SFACK);
)
packetLength = 4;
3ee84:84 e0 ldir24, 0x04; 4
3ee86:b4 cf rjmp.-152 ; 0x3edf0
}
txPtr = txBuffer;
while(packetLength--) {
spiWriteReg(writePointer++, *txPtr++);
3ee88:f6 01 movwr30, r12
3ee8a:61 91 ldr22, Z+
3ee8c:6f 01 movwr12, r30
3ee8e:58 01 movwr10, r16
3ee90:ff ef ldir31, 0xFF; 255
3ee92:af 1a subr10, r31
3ee94:bf 0a sbcr11, r31
3ee96:c8 01 movwr24, r16
3ee98:2d db rcall.-2470 ; 0x3e4f4
if(writePointer == S3_TX_END) writePointer = S3_TX_START;
3ee9a:a1 14 cpr10, r1
3ee9c:20 e6 ldir18, 0x60; 96
3ee9e:b2 06 cpcr11, r18
3eea0:19 f4 brne.+6 ; 0x3eea8
3eea2:a1 2c movr10, r1
3eea4:28 e5 ldir18, 0x58; 88
3eea6:b2 2e movr11, r18
3eea8:85 01 movwr16, r10
break;
}
txPtr = txBuffer;
while(packetLength--) {
3eeaa:ec 10 cpser14, r12
3eeac:ed cf rjmp.-38 ; 0x3ee88
spiWriteReg(writePointer++, *txPtr++);
if(writePointer == S3_TX_END) writePointer = S3_TX_START;
}
spiWriteWord(REG_S3_TX_WR0, writePointer - S3_TX_START);
3eeae:b8 01 movwr22, r16
3eeb0:78 55 subir23, 0x58; 88
3eeb2:84 e2 ldir24, 0x24; 36
3eeb4:97 e0 ldir25, 0x07; 7
3eeb6:37 db rcall.-2450 ; 0x3e526
spiWriteReg(REG_S3_CR, CR_SEND);
3eeb8:60 e2 ldir22, 0x20; 32
3eeba:81 e0 ldir24, 0x01; 1
3eebc:97 e0 ldir25, 0x07; 7
3eebe:1a db rcall.-2508 ; 0x3e4f4
while(spiReadReg(REG_S3_CR));
3eec0:81 e0 ldir24, 0x01; 1
3eec2:97 e0 ldir25, 0x07; 7
3eec4:41 db rcall.-2430 ; 0x3e548
3eec6:81 11 cpser24, r1
3eec8:fb cf rjmp.-10 ; 0x3eec0
DBG_TFTP(tracePGMlnTftp(mDebugTftp_RESP);)
3eeca:6c e4 ldir22, 0x4C; 76
3eecc:72 ee ldir23, 0xE2; 226
3eece:8a e8 ldir24, 0x8A; 138
3eed0:93 ee ldir25, 0xE3; 227
3eed2:a1 d0 rcall.+322 ; 0x3f016
3eed4:02 c0 rjmp.+4 ; 0x3eeda
/**
* Looks for a connection
*/
uint8_t tftpPoll(void)
{
uint8_t response = ACK;
3eed6:92 e0 ldir25, 0x02; 2
3eed8:f9 2e movr15, r25
#endif
// Send the response
sendResponse(response);
}
if(response == FINAL_ACK || response == INVALID_IMAGE) {
3eeda:8c ef ldir24, 0xFC; 252
3eedc:8f 0d addr24, r15
3eede:82 30 cpir24, 0x02; 2
3eee0:40 f4 brcc.+16 ; 0x3eef2
spiWriteReg(REG_S3_CR, CR_CLOSE);
3eee2:60 e1 ldir22, 0x10; 16
3eee4:81 e0 ldir24, 0x01; 1
3eee6:97 e0 ldir25, 0x07; 7
3eee8:05 db rcall.-2550 ; 0x3e4f4
tftpFlashing=FALSE;
3eeea:10 92 25 02 sts0x0225, r1
// Complete
return(0);
3eeee:80 e0 ldir24, 0x00; 0
3eef0:05 c0 rjmp.+10 ; 0x3eefc
}
// Tftp continues
return(1);
3eef2:81 e0 ldir24, 0x01; 1
3eef4:03 c0 rjmp.+6 ; 0x3eefc
DBG_TFTP(tracePGMlnTftp(mDebugTftp_SACK);)
/* no break */
case FINAL_ACK:
DBG_TFTP(
3eef6:6a e5 ldir22, 0x5A; 90
3eef8:72 ee ldir23, 0xE2; 226
3eefa:b8 cf rjmp.-144 ; 0x3ee6c
return(0);
}
// Tftp continues
return(1);
}
3eefc:cc 59 subir28, 0x9C; 156
3eefe:df 4f sbcir29, 0xFF; 255
3ef00:de bf out0x3e, r29; 62
3ef02:cd bf out0x3d, r28; 61
3ef04:df 91 popr29
3ef06:cf 91 popr28
3ef08:1f 91 popr17
3ef0a:0f 91 popr16
3ef0c:ff 90 popr15
3ef0e:ef 90 popr14
3ef10:df 90 popr13
3ef12:cf 90 popr12
3ef14:bf 90 popr11
3ef16:af 90 popr10
3ef18:08 95 ret
0003ef1a :
#include "serial.h"
#include "debug.h"
#include "debug_vald.h"
uint8_t validImage(uint8_t* base)
{
3ef1a:ff 92 pushr15
3ef1c:0f 93 pushr16
3ef1e:1f 93 pushr17
3ef20:cf 93 pushr28
3ef22:df 93 pushr29
3ef24:ec 01 movwr28, r24
3ef26:8c 01 movwr16, r24
3ef28:0f 5f subir16, 0xFF; 255
3ef2a:1f 4f sbcir17, 0xFF; 255
/* Check that a jump table is present in the first flash sector */
uint8_t i;
for(i = 0; i < 0x34; i += 4) {
3ef2c:f1 2c movr15, r1
// For each vector, check it is of the form:
// 0x0C 0x94 0xWX 0xYZ ; JMP 0xWXYZ
if(base[i] != 0x0c) {
3ef2e:88 81 ldr24, Y
3ef30:8c 30 cpir24, 0x0C; 12
3ef32:b9 f0 breq.+46 ; 0x3ef62
DBG_VALD(
3ef34:6a eb ldir22, 0xBA; 186
3ef36:73 ee ldir23, 0xE3; 227
3ef38:81 ed ldir24, 0xD1; 209
3ef3a:93 ee ldir25, 0xE3; 227
3ef3c:6c d0 rcall.+216 ; 0x3f016
3ef3e:6f 2d movr22, r15
3ef40:70 e0 ldir23, 0x00; 0
3ef42:80 e0 ldir24, 0x00; 0
3ef44:90 e0 ldir25, 0x00; 0
3ef46:44 e0 ldir20, 0x04; 4
3ef48:97 d0 rcall.+302 ; 0x3f078
3ef4a:83 eb ldir24, 0xB3; 179
3ef4c:93 ee ldir25, 0xE3; 227
3ef4e:3f d0 rcall.+126 ; 0x3efce
3ef50:68 81 ldr22, Y
3ef52:70 e0 ldir23, 0x00; 0
3ef54:80 e0 ldir24, 0x00; 0
3ef56:90 e0 ldir25, 0x00; 0
3ef58:44 e0 ldir20, 0x04; 4
3ef5a:8e d0 rcall.+284 ; 0x3f078
3ef5c:82 ea ldir24, 0xA2; 162
3ef5e:93 ee ldir25, 0xE3; 227
3ef60:1f c0 rjmp.+62 ; 0x3efa0
tracePGM(mDebugVald_0x0C);
)
return(0);
}
if(base[i + 1] != 0x94) {
3ef62:f8 01 movwr30, r16
3ef64:80 81 ldr24, Z
3ef66:84 39 cpir24, 0x94; 148
3ef68:f1 f0 breq.+60 ; 0x3efa6
DBG_VALD(
3ef6a:6a eb ldir22, 0xBA; 186
3ef6c:73 ee ldir23, 0xE3; 227
3ef6e:81 ed ldir24, 0xD1; 209
3ef70:93 ee ldir25, 0xE3; 227
3ef72:51 d0 rcall.+162 ; 0x3f016
3ef74:6f 2d movr22, r15
3ef76:70 e0 ldir23, 0x00; 0
3ef78:6f 5f subir22, 0xFF; 255
3ef7a:7f 4f sbcir23, 0xFF; 255
3ef7c:88 27 eorr24, r24
3ef7e:77 fd sbrcr23, 7
3ef80:80 95 comr24
3ef82:98 2f movr25, r24
3ef84:44 e0 ldir20, 0x04; 4
3ef86:78 d0 rcall.+240 ; 0x3f078
3ef88:83 eb ldir24, 0xB3; 179
3ef8a:93 ee ldir25, 0xE3; 227
3ef8c:20 d0 rcall.+64 ; 0x3efce
3ef8e:f8 01 movwr30, r16
3ef90:60 81 ldr22, Z
3ef92:70 e0 ldir23, 0x00; 0
3ef94:80 e0 ldir24, 0x00; 0
3ef96:90 e0 ldir25, 0x00; 0
3ef98:44 e0 ldir20, 0x04; 4
3ef9a:6e d0 rcall.+220 ; 0x3f078
3ef9c:81 e9 ldir24, 0x91; 145
3ef9e:93 ee ldir25, 0xE3; 227
3efa0:16 d0 rcall.+44 ; 0x3efce
tracenum(i + 1);
tracePGM(mDebugVald_WITH);
tracenum(base[i + 1]);
tracePGM(mDebugVald_0x94);
)
return(0);
3efa2:80 e0 ldir24, 0x00; 0
3efa4:0e c0 rjmp.+28 ; 0x3efc2
uint8_t validImage(uint8_t* base)
{
/* Check that a jump table is present in the first flash sector */
uint8_t i;
for(i = 0; i < 0x34; i += 4) {
3efa6:f4 e0 ldir31, 0x04; 4
3efa8:ff 0e addr15, r31
3efaa:24 96 adiwr28, 0x04; 4
3efac:0c 5f subir16, 0xFC; 252
3efae:1f 4f sbcir17, 0xFF; 255
3efb0:84 e3 ldir24, 0x34; 52
3efb2:f8 12 cpser15, r24
3efb4:bc cf rjmp.-136 ; 0x3ef2e
)
return(0);
}
}
DBG_VALD(tracePGMlnVald(mDebugVald_VALID);)
3efb6:65 ec ldir22, 0xC5; 197
3efb8:73 ee ldir23, 0xE3; 227
3efba:81 ed ldir24, 0xD1; 209
3efbc:93 ee ldir25, 0xE3; 227
3efbe:2b d0 rcall.+86 ; 0x3f016
return(1);
3efc0:81 e0 ldir24, 0x01; 1
}
3efc2:df 91 popr29
3efc4:cf 91 popr28
3efc6:1f 91 popr17
3efc8:0f 91 popr16
3efca:ff 90 popr15
3efcc:08 95 ret
0003efce :
*/
const unsigned char mDebug_NEWLINE[]PROGMEM ="\r\n";
const unsigned char mDebug_HEXPREF[]PROGMEM ="0x";
void tracePGM(const void* p_msg)
{
3efce:cf 92 pushr12
3efd0:df 92 pushr13
3efd2:ef 92 pushr14
3efd4:ff 92 pushr15
3efd6:cf 93 pushr28
3efd8:df 93 pushr29
uint8_tc = 1, i = 0;
3efda:d0 e0 ldir29, 0x00; 0
#if (FLASHEND > 0x10000)
/* 0x30000 was added to fix the issues of progmem with >64Kb flash.
* 0x30000 is specific to atmega2560 and won't work on smaller or larger flashes.
* I should find a way to macro the calculation of this value
*/
c = pgm_read_byte_far(PROGMEM_OFFSET + (uint32_t)(uint16_t)p_msg + i);
3efdc:6c 01 movwr12, r24
3efde:e1 2c movr14, r1
3efe0:f1 2c movr15, r1
3efe2:83 e0 ldir24, 0x03; 3
3efe4:e8 0e addr14, r24
3efe6:f1 1c adcr15, r1
3efe8:d7 01 movwr26, r14
3efea:c6 01 movwr24, r12
3efec:8d 0f addr24, r29
3efee:91 1d adcr25, r1
3eff0:a1 1d adcr26, r1
3eff2:b1 1d adcr27, r1
3eff4:ab bf out0x3b, r26; 59
3eff6:fc 01 movwr30, r24
3eff8:c7 91 elpmr28, Z+
#else
c = pgm_read_byte_near((uint16_t)p_msg + i);
#endif
if (c != 0) putch(c);
3effa:cc 23 andr28, r28
3effc:11 f0 breq.+4 ; 0x3f002
3effe:8c 2f movr24, r28
3f000:70 d0 rcall.+224 ; 0x3f0e2
i++;
3f002:df 5f subir29, 0xFF; 255
void tracePGM(const void* p_msg)
{
uint8_tc = 1, i = 0;
while(c != 0){
3f004:c1 11 cpser28, r1
3f006:f0 cf rjmp.-32 ; 0x3efe8
c = pgm_read_byte_near((uint16_t)p_msg + i);
#endif
if (c != 0) putch(c);
i++;
}
}
3f008:df 91 popr29
3f00a:cf 91 popr28
3f00c:ff 90 popr15
3f00e:ef 90 popr14
3f010:df 90 popr13
3f012:cf 90 popr12
3f014:08 95 ret
0003f016 :
void tracePGMln(const void* p_prefix, const void* p_msg)
{
3f016:0f 93 pushr16
3f018:1f 93 pushr17
3f01a:cf 93 pushr28
3f01c:df 93 pushr29
3f01e:ec 01 movwr28, r24
3f020:8b 01 movwr16, r22
tracePGM(mDebug_NEWLINE);
3f022:8b ed ldir24, 0xDB; 219
3f024:93 ee ldir25, 0xE3; 227
3f026:d3 df rcall.-90 ; 0x3efce
tracePGM(p_prefix);
3f028:ce 01 movwr24, r28
3f02a:d1 df rcall.-94 ; 0x3efce
tracePGM(p_msg);
3f02c:c8 01 movwr24, r16
}
3f02e:df 91 popr29
3f030:cf 91 popr28
3f032:1f 91 popr17
3f034:0f 91 popr16
void tracePGMln(const void* p_prefix, const void* p_msg)
{
tracePGM(mDebug_NEWLINE);
tracePGM(p_prefix);
tracePGM(p_msg);
3f036:cb cf rjmp.-106 ; 0x3efce
0003f038 :
}
void trace(char* msg)
{
3f038:cf 93 pushr28
3f03a:df 93 pushr29
uint8_t c;
if(*msg != '\0') {
3f03c:fc 01 movwr30, r24
3f03e:20 81 ldr18, Z
3f040:22 23 andr18, r18
3f042:31 f0 breq.+12 ; 0x3f050
3f044:ec 01 movwr28, r24
while((c = *msg++)) putch(c);
3f046:89 91 ldr24, Y+
3f048:88 23 andr24, r24
3f04a:11 f0 breq.+4 ; 0x3f050
3f04c:4a d0 rcall.+148 ; 0x3f0e2
3f04e:fb cf rjmp.-10 ; 0x3f046
}
}
3f050:df 91 popr29
3f052:cf 91 popr28
3f054:08 95 ret
0003f056 :
void traceln(const void* p_prefix, char* msg)
{
3f056:0f 93 pushr16
3f058:1f 93 pushr17
3f05a:cf 93 pushr28
3f05c:df 93 pushr29
3f05e:ec 01 movwr28, r24
3f060:8b 01 movwr16, r22
tracePGM(mDebug_NEWLINE);
3f062:8b ed ldir24, 0xDB; 219
3f064:93 ee ldir25, 0xE3; 227
3f066:b3 df rcall.-154 ; 0x3efce
tracePGM(p_prefix);
3f068:ce 01 movwr24, r28
3f06a:b1 df rcall.-158 ; 0x3efce
trace(msg);
3f06c:c8 01 movwr24, r16
}
3f06e:df 91 popr29
3f070:cf 91 popr28
3f072:1f 91 popr17
3f074:0f 91 popr16
void traceln(const void* p_prefix, char* msg)
{
tracePGM(mDebug_NEWLINE);
tracePGM(p_prefix);
trace(msg);
3f076:e0 cf rjmp.-64 ; 0x3f038
0003f078 :
}
void tracehex(uint32_t num, uint8_t len)
{
3f078:cf 92 pushr12
3f07a:df 92 pushr13
3f07c:ef 92 pushr14
3f07e:ff 92 pushr15
3f080:cf 93 pushr28
3f082:6b 01 movwr12, r22
3f084:7c 01 movwr14, r24
3f086:c4 2f movr28, r20
tracePGM(mDebug_HEXPREF);
3f088:88 ed ldir24, 0xD8; 216
3f08a:93 ee ldir25, 0xE3; 227
3f08c:a0 df rcall.-192 ; 0x3efce
while(len > 0) {
3f08e:cc 23 andr28, r28
3f090:a9 f0 breq.+42 ; 0x3f0bc
puthex(num >> (4 * (len - 1)));
3f092:8c 2f movr24, r28
3f094:90 e0 ldir25, 0x00; 0
3f096:01 97 sbiwr24, 0x01; 1
3f098:88 0f addr24, r24
3f09a:99 1f adcr25, r25
3f09c:88 0f addr24, r24
3f09e:99 1f adcr25, r25
3f0a0:a7 01 movwr20, r14
3f0a2:96 01 movwr18, r12
3f0a4:04 c0 rjmp.+8 ; 0x3f0ae
3f0a6:56 95 lsrr21
3f0a8:47 95 rorr20
3f0aa:37 95 rorr19
3f0ac:27 95 rorr18
3f0ae:8a 95 decr24
3f0b0:d2 f7 brpl.-12 ; 0x3f0a6
3f0b2:da 01 movwr26, r20
3f0b4:c9 01 movwr24, r18
3f0b6:1c d0 rcall.+56 ; 0x3f0f0
len--;
3f0b8:c1 50 subir28, 0x01; 1
3f0ba:e9 cf rjmp.-46 ; 0x3f08e
}
}
3f0bc:cf 91 popr28
3f0be:ff 90 popr15
3f0c0:ef 90 popr14
3f0c2:df 90 popr13
3f0c4:cf 90 popr12
3f0c6:08 95 ret
0003f0c8 :
void serialInit(void)
{
// Double speed mode USART0
UART_STATUS_REG= _BV(UART_DOUBLE_SPEED);
3f0c8:82 e0 ldir24, 0x02; 2
3f0ca:80 93 c0 00 sts0x00C0, r24
// Enable receiver and transiter on USART0
UART_CONTROL_REG= _BV(UART_ENABLE_RECEIVER) | _BV(UART_ENABLE_TRANSMITTER);
3f0ce:88 e1 ldir24, 0x18; 24
3f0d0:80 93 c1 00 sts0x00C1, r24
// Set 8bit character length on USART0
UART_MODE_REG= _BV(UART_CHAR_SIZE_LOW) | _BV(UART_CHAR_SIZE_MID);
3f0d4:86 e0 ldir24, 0x06; 6
3f0d6:80 93 c2 00 sts0x00C2, r24
// Set USART0 baud rate
UART_BAUD_RATE_LOW= (uint8_t)((F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1);
3f0da:80 e1 ldir24, 0x10; 16
3f0dc:80 93 c4 00 sts0x00C4, r24
3f0e0:08 95 ret
0003f0e2 :
}
void putch(uint8_t c)
{
while(!(UART_STATUS_REG & _BV(UART_DATA_REG_EMPTY)));
3f0e2:90 91 c0 00 ldsr25, 0x00C0
3f0e6:95 ff sbrsr25, 5
3f0e8:fc cf rjmp.-8 ; 0x3f0e2
UART_DATA_REG = c;
3f0ea:80 93 c6 00 sts0x00C6, r24
3f0ee:08 95 ret
0003f0f0 :
}
void puthex(uint8_t c)
{
c &= 0xf;
3f0f0:8f 70 andir24, 0x0F; 15
if(c > 9) c += 7;
3f0f2:8a 30 cpir24, 0x0A; 10
3f0f4:08 f0 brcs.+2 ; 0x3f0f8
3f0f6:89 5f subir24, 0xF9; 249
//while(!(UART_STATUS_REG & _BV(UART_DATA_REG_EMPTY)));
//UART_DATA_REG = c + '0';
putch(c + '0');
3f0f8:80 5d subir24, 0xD0; 208
3f0fa:f3 cf rjmp.-26 ; 0x3f0e2
0003f0fc :
uint8_t getch(void)
{
//uint8_t ch;
while(!(UART_STATUS_REG & _BV(UART_RECEIVE_COMPLETE)));
3f0fc:80 91 c0 00 ldsr24, 0x00C0
3f100:87 ff sbrsr24, 7
3f102:fc cf rjmp.-8 ; 0x3f0fc
if(!(UART_STATUS_REG & _BV(UART_FRAME_ERROR))) {
3f104:80 91 c0 00 ldsr24, 0x00C0
3f108:84 fd sbrcr24, 4
3f10a:01 c0 rjmp.+2 ; 0x3f10e
* expects to be talking to the application, and DON'T reset the
* watchdog. This should cause the bootloader to abort and run
* the application "soon", if it keeps happening. (Note that we
* don't care that an invalid char is returned...)
*/
wdt_reset();
3f10c:a8 95 wdr
}
//ch = UART_DATA_REG;
//return ch;
return(UART_DATA_REG);
3f10e:80 91 c6 00 ldsr24, 0x00C6
}
3f112:08 95 ret
0003f114 :
uint8_t serialPoll(void)
{
if(UART_STATUS_REG & _BV(UART_RECEIVE_COMPLETE)) {
3f114:80 91 c0 00 ldsr24, 0x00C0
3f118:87 ff sbrsr24, 7
3f11a:05 c0 rjmp.+10 ; 0x3f126
resetTick();
3f11c:27 d0 rcall.+78 ; 0x3f16c
serialFlashing = TRUE;
3f11e:81 e0 ldir24, 0x01; 1
3f120:80 93 24 02 sts0x0224, r24
#if defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__)
return(processOptiboot());
#elif defined(__AVR_ATmega2560__)
return(processStk500boot());
3f124:58 c0 rjmp.+176 ; 0x3f1d6
#endif
}
return(1);
}
3f126:81 e0 ldir24, 0x01; 1
3f128:08 95 ret
0003f12a :
static uint16_t tick = 0;
uint8_t timeout;
void updateLed(void)
{
uint16_t next_timer_1 = TCNT1;
3f12a:80 91 84 00 ldsr24, 0x0084
3f12e:90 91 85 00 ldsr25, 0x0085
if(next_timer_1 & 0x800) LED_PORT ^= _BV(LED); // Led pin high
3f132:93 ff sbrsr25, 3
3f134:04 c0 rjmp.+8 ; 0x3f13e
3f136:25 b1 inr18, 0x05; 5
3f138:20 58 subir18, 0x80; 128
3f13a:25 b9 out0x05, r18; 5
3f13c:01 c0 rjmp.+2 ; 0x3f140
else LED_PORT &= ~_BV(LED); // Led pin low
3f13e:2f 98 cbi0x05, 7; 5
if(next_timer_1 < last_timer_1) {
3f140:20 91 20 02 ldsr18, 0x0220
3f144:30 91 21 02 ldsr19, 0x0221
3f148:82 17 cpr24, r18
3f14a:93 07 cpcr25, r19
3f14c:50 f4 brcc.+20 ; 0x3f162
tick++;
3f14e:20 91 1e 02 ldsr18, 0x021E
3f152:30 91 1f 02 ldsr19, 0x021F
3f156:2f 5f subir18, 0xFF; 255
3f158:3f 4f sbcir19, 0xFF; 255
3f15a:30 93 1f 02 sts0x021F, r19
3f15e:20 93 1e 02 sts0x021E, r18
tracePGMlnUtil(mDebugUtil_LAST);
tracenum(last_timer_1);
)
}
last_timer_1 = next_timer_1;
3f162:90 93 21 02 sts0x0221, r25
3f166:80 93 20 02 sts0x0220, r24
3f16a:08 95 ret
0003f16c :
}
void resetTick(void)
{
TCNT1 = 0;
3f16c:10 92 85 00 sts0x0085, r1
3f170:10 92 84 00 sts0x0084, r1
tick = 0;
3f174:10 92 1f 02 sts0x021F, r1
3f178:10 92 1e 02 sts0x021E, r1
3f17c:08 95 ret
0003f17e :
uint8_t timedOut(void)
{
// Never timeout if there is no code in Flash
#if (FLASHEND > 0x10000)
if(pgm_read_word_far(0x0000) == 0xFFFF) return(0);
3f17e:80 e0 ldir24, 0x00; 0
3f180:90 e0 ldir25, 0x00; 0
3f182:dc 01 movwr26, r24
3f184:ab bf out0x3b, r26; 59
3f186:fc 01 movwr30, r24
3f188:87 91 elpmr24, Z+
3f18a:96 91 elpmr25, Z
3f18c:01 96 adiwr24, 0x01; 1
3f18e:59 f0 breq.+22 ; 0x3f1a6
#else
if(pgm_read_word_near(0x0000) == 0xFFFF) return(0);
#endif
if(tick >= timeout) return(1);
3f190:20 91 26 02 ldsr18, 0x0226
3f194:30 e0 ldir19, 0x00; 0
3f196:81 e0 ldir24, 0x01; 1
3f198:40 91 1e 02 ldsr20, 0x021E
3f19c:50 91 1f 02 ldsr21, 0x021F
3f1a0:42 17 cpr20, r18
3f1a2:53 07 cpcr21, r19
3f1a4:08 f4 brcc.+2 ; 0x3f1a8
uint8_t timedOut(void)
{
// Never timeout if there is no code in Flash
#if (FLASHEND > 0x10000)
if(pgm_read_word_far(0x0000) == 0xFFFF) return(0);
3f1a6:80 e0 ldir24, 0x00; 0
if(pgm_read_word_near(0x0000) == 0xFFFF) return(0);
#endif
if(tick >= timeout) return(1);
else return(0);
}
3f1a8:08 95 ret
0003f1aa :
uint16_t chksum(uint16_t data[],uint8_t size) {
uint16_t sum = 0;
for (uint16_t i=0;i
3f1aa:40 e0 ldir20, 0x00; 0
3f1ac:50 e0 ldir21, 0x00; 0
if(tick >= timeout) return(1);
else return(0);
}
uint16_t chksum(uint16_t data[],uint8_t size) {
uint16_t sum = 0;
3f1ae:20 e0 ldir18, 0x00; 0
3f1b0:30 e0 ldir19, 0x00; 0
for (uint16_t i=0;i
3f1b2:70 e0 ldir23, 0x00; 0
3f1b4:46 17 cpr20, r22
3f1b6:57 07 cpcr21, r23
3f1b8:48 f4 brcc.+18 ; 0x3f1cc
sum += data[i];
3f1ba:dc 01 movwr26, r24
3f1bc:ed 91 ldr30, X+
3f1be:fd 91 ldr31, X+
3f1c0:cd 01 movwr24, r26
3f1c2:2e 0f addr18, r30
3f1c4:3f 1f adcr19, r31
else return(0);
}
uint16_t chksum(uint16_t data[],uint8_t size) {
uint16_t sum = 0;
for (uint16_t i=0;i
3f1c6:4f 5f subir20, 0xFF; 255
3f1c8:5f 4f sbcir21, 0xFF; 255
3f1ca:f4 cf rjmp.-24 ; 0x3f1b4
sum += data[i];
}
return ~sum+1;
}
3f1cc:88 27 eorr24, r24
3f1ce:99 27 eorr25, r25
3f1d0:82 1b subr24, r18
3f1d2:93 0b sbcr25, r19
3f1d4:08 95 ret
0003f1d6 :
// return UART_DATA_REG;
// }
uint8_t processStk500boot(void)
{
3f1d6:2f 92 pushr2
3f1d8:3f 92 pushr3
3f1da:4f 92 pushr4
3f1dc:5f 92 pushr5
3f1de:6f 92 pushr6
3f1e0:7f 92 pushr7
3f1e2:8f 92 pushr8
3f1e4:9f 92 pushr9
3f1e6:af 92 pushr10
3f1e8:bf 92 pushr11
3f1ea:cf 92 pushr12
3f1ec:df 92 pushr13
3f1ee:ef 92 pushr14
3f1f0:ff 92 pushr15
3f1f2:0f 93 pushr16
3f1f4:1f 93 pushr17
3f1f6:cf 93 pushr28
3f1f8:df 93 pushr29
3f1fa:cd b7 inr28, 0x3d; 61
3f1fc:de b7 inr29, 0x3e; 62
3f1fe:c0 52 subir28, 0x20; 32
3f200:d1 40 sbcir29, 0x01; 1
3f202:de bf out0x3e, r29; 62
3f204:cd bf out0x3d, r28; 61
address_taddress=0;
address_teraseAddress=0;
unsigned charmsgParseState;
unsigned intii=0;
unsigned charchecksum=0;
unsigned charseqNum=0;
3f206:c2 5e subir28, 0xE2; 226
3f208:de 4f sbcir29, 0xFE; 254
3f20a:18 82 stY, r1
3f20c:ce 51 subir28, 0x1E; 30
3f20e:d1 40 sbcir29, 0x01; 1
{
address_taddress=0;
address_teraseAddress=0;
unsigned charmsgParseState;
unsigned intii=0;
unsigned charchecksum=0;
3f210:81 2c movr8, r1
uint8_t processStk500boot(void)
{
address_taddress=0;
address_teraseAddress=0;
unsigned charmsgParseState;
unsigned intii=0;
3f212:21 2c movr2, r1
3f214:31 2c movr3, r1
uint8_t processStk500boot(void)
{
address_taddress=0;
address_teraseAddress=0;
3f216:41 2c movr4, r1
3f218:51 2c movr5, r1
3f21a:32 01 movwr6, r4
// }
uint8_t processStk500boot(void)
{
address_taddress=0;
3f21c:c1 2c movr12, r1
3f21e:d1 2c movr13, r1
3f220:76 01 movwr14, r12
// return UART_DATA_REG;
// }
uint8_t processStk500boot(void)
{
3f222:00 e0 ldir16, 0x00; 0
3f224:10 e0 ldir17, 0x00; 0
case ST_GET_CHECK:
if(c == checksum) {
msgParseState=ST_PROCESS;
} else {
msgParseState=ST_START;
3f226:40 e0 ldir20, 0x00; 0
msgParseState=ST_START;
while(msgParseState != ST_PROCESS) {
// if(boot_state == 1) {
// boot_state=0;
c=getch();
3f228:c1 5e subir28, 0xE1; 225
3f22a:de 4f sbcir29, 0xFE; 254
3f22c:48 83 stY, r20
3f22e:cf 51 subir28, 0x1F; 31
3f230:d1 40 sbcir29, 0x01; 1
3f232:64 df rcall.-312 ; 0x3f0fc
// } else {
// //c=recchar();
// c = recchar_timeout();
// }
switch(msgParseState) {
3f234:c1 5e subir28, 0xE1; 225
3f236:de 4f sbcir29, 0xFE; 254
3f238:48 81 ldr20, Y
3f23a:cf 51 subir28, 0x1F; 31
3f23c:d1 40 sbcir29, 0x01; 1
3f23e:43 30 cpir20, 0x03; 3
3f240:01 f1 breq.+64 ; 0x3f282
3f242:20 f4 brcc.+8 ; 0x3f24c
3f244:41 30 cpir20, 0x01; 1
3f246:71 f0 breq.+28 ; 0x3f264
3f248:38 f0 brcs.+14 ; 0x3f258
3f24a:14 c0 rjmp.+40 ; 0x3f274
3f24c:45 30 cpir20, 0x05; 5
3f24e:21 f1 breq.+72 ; 0x3f298
3f250:e0 f0 brcs.+56 ; 0x3f28a
3f252:46 30 cpir20, 0x06; 6
3f254:91 f1 breq.+100 ; 0x3f2ba
3f256:7c c0 rjmp.+248 ; 0x3f350
case ST_START:
if(c == MESSAGE_START) {
3f258:8b 31 cpir24, 0x1B; 27
3f25a:31 f7 brne.-52 ; 0x3f228
msgParseState=ST_GET_SEQ_NUM;
checksum=MESSAGE_START ^ 0;
3f25c:8b e1 ldir24, 0x1B; 27
3f25e:88 2e movr8, r24
switch(msgParseState) {
case ST_START:
if(c == MESSAGE_START) {
msgParseState=ST_GET_SEQ_NUM;
3f260:41 e0 ldir20, 0x01; 1
3f262:e2 cf rjmp.-60 ; 0x3f228
case ST_GET_SEQ_NUM:
#ifdef _FIX_ISSUE_505_
seqNum=c;
msgParseState=ST_MSG_SIZE_1;
checksum^=c;
3f264:88 26 eorr8, r24
msgParseState=ST_START;
while(msgParseState != ST_PROCESS) {
// if(boot_state == 1) {
// boot_state=0;
c=getch();
3f266:c2 5e subir28, 0xE2; 226
3f268:de 4f sbcir29, 0xFE; 254
3f26a:88 83 stY, r24
3f26c:ce 51 subir28, 0x1E; 30
3f26e:d1 40 sbcir29, 0x01; 1
break;
case ST_GET_SEQ_NUM:
#ifdef _FIX_ISSUE_505_
seqNum=c;
msgParseState=ST_MSG_SIZE_1;
3f270:42 e0 ldir20, 0x02; 2
} else {
msgParseState=ST_START;
}
#endif
break;
3f272:da cf rjmp.-76 ; 0x3f228
case ST_MSG_SIZE_1:
msgLength=c << 8;
3f274:08 2f movr16, r24
3f276:10 e0 ldir17, 0x00; 0
3f278:10 2f movr17, r16
3f27a:00 27 eorr16, r16
msgParseState=ST_MSG_SIZE_2;
checksum^=c;
3f27c:88 26 eorr8, r24
#endif
break;
case ST_MSG_SIZE_1:
msgLength=c << 8;
msgParseState=ST_MSG_SIZE_2;
3f27e:43 e0 ldir20, 0x03; 3
checksum^=c;
break;
3f280:d3 cf rjmp.-90 ; 0x3f228
case ST_MSG_SIZE_2:
msgLength|=c;
3f282:08 2b orr16, r24
msgParseState=ST_GET_TOKEN;
checksum^=c;
3f284:88 26 eorr8, r24
checksum^=c;
break;
case ST_MSG_SIZE_2:
msgLength|=c;
msgParseState=ST_GET_TOKEN;
3f286:44 e0 ldir20, 0x04; 4
checksum^=c;
break;
3f288:cf cf rjmp.-98 ; 0x3f228
case ST_GET_TOKEN:
if(c == TOKEN) {
3f28a:8e 30 cpir24, 0x0E; 14
3f28c:61 f6 brne.-104 ; 0x3f226
msgParseState=ST_GET_DATA;
checksum^=c;
3f28e:88 26 eorr8, r24
ii=0;
3f290:21 2c movr2, r1
3f292:31 2c movr3, r1
break;
case ST_GET_TOKEN:
if(c == TOKEN) {
msgParseState=ST_GET_DATA;
3f294:45 e0 ldir20, 0x05; 5
3f296:c8 cf rjmp.-112 ; 0x3f228
}
break;
case ST_GET_DATA:
msgBuffer[ii++]=c;
3f298:91 01 movwr18, r2
3f29a:2f 5f subir18, 0xFF; 255
3f29c:3f 4f sbcir19, 0xFF; 255
3f29e:e1 e0 ldir30, 0x01; 1
3f2a0:f0 e0 ldir31, 0x00; 0
3f2a2:ec 0f addr30, r28
3f2a4:fd 1f adcr31, r29
3f2a6:e2 0d addr30, r2
3f2a8:f3 1d adcr31, r3
3f2aa:80 83 stZ, r24
checksum^=c;
3f2ac:88 26 eorr8, r24
if(ii == msgLength) {
3f2ae:20 17 cpr18, r16
3f2b0:31 07 cpcr19, r17
3f2b2:09 f4 brne.+2 ; 0x3f2b6
3f2b4:31 c2 rjmp.+1122 ; 0x3f718
3f2b6:19 01 movwr2, r18
3f2b8:b7 cf rjmp.-146 ; 0x3f228
break;
case ST_GET_CHECK:
if(c == checksum) {
3f2ba:88 11 cpser24, r8
3f2bc:b4 cf rjmp.-152 ; 0x3f226
/*
* Now process the STK500 commands, see Atmel Appnote AVR068
*/
switch(msgBuffer[0]) {
3f2be:49 81 lddr20, Y+1; 0x01
3f2c0:43 31 cpir20, 0x13; 19
3f2c2:09 f4 brne.+2 ; 0x3f2c6
3f2c4:e2 c0 rjmp.+452 ; 0x3f48a
3f2c6:60 f5 brcc.+88 ; 0x3f320
3f2c8:46 30 cpir20, 0x06; 6
3f2ca:09 f4 brne.+2 ; 0x3f2ce
3f2cc:cb c0 rjmp.+406 ; 0x3f464
3f2ce:00 f5 brcc.+64 ; 0x3f310
3f2d0:42 30 cpir20, 0x02; 2
3f2d2:09 f4 brne.+2 ; 0x3f2d6
3f2d4:41 c0 rjmp.+130 ; 0x3f358
3f2d6:43 30 cpir20, 0x03; 3
3f2d8:09 f4 brne.+2 ; 0x3f2dc
3f2da:6b c0 rjmp.+214 ; 0x3f3b2
3f2dc:41 30 cpir20, 0x01; 1
3f2de:09 f0 breq.+2 ; 0x3f2e2
3f2e0:9d c1 rjmp.+826 ; 0x3f61c
}
break;
#endif
case CMD_SIGN_ON:
msgLength=11;
msgBuffer[1] =STATUS_CMD_OK;
3f2e2:1a 82 stdY+2, r1; 0x02
msgBuffer[2] =8;
3f2e4:88 e0 ldir24, 0x08; 8
3f2e6:8b 83 stdY+3, r24; 0x03
msgBuffer[3] ='A';
3f2e8:81 e4 ldir24, 0x41; 65
3f2ea:8c 83 stdY+4, r24; 0x04
msgBuffer[4] ='V';
3f2ec:86 e5 ldir24, 0x56; 86
3f2ee:8d 83 stdY+5, r24; 0x05
msgBuffer[5] ='R';
3f2f0:82 e5 ldir24, 0x52; 82
3f2f2:8e 83 stdY+6, r24; 0x06
msgBuffer[6] ='I';
3f2f4:89 e4 ldir24, 0x49; 73
3f2f6:8f 83 stdY+7, r24; 0x07
msgBuffer[7] ='S';
3f2f8:83 e5 ldir24, 0x53; 83
3f2fa:88 87 stdY+8, r24; 0x08
msgBuffer[8] ='P';
3f2fc:80 e5 ldir24, 0x50; 80
3f2fe:89 87 stdY+9, r24; 0x09
msgBuffer[9] ='_';
3f300:8f e5 ldir24, 0x5F; 95
3f302:8a 87 stdY+10, r24; 0x0a
msgBuffer[10]='2';
3f304:82 e3 ldir24, 0x32; 50
3f306:8b 87 stdY+11, r24; 0x0b
break;
3f308:20 e0 ldir18, 0x00; 0
}
}
break;
#endif
case CMD_SIGN_ON:
msgLength=11;
3f30a:0b e0 ldir16, 0x0B; 11
3f30c:10 e0 ldir17, 0x00; 0
msgBuffer[6] ='I';
msgBuffer[7] ='S';
msgBuffer[8] ='P';
msgBuffer[9] ='_';
msgBuffer[10]='2';
break;
3f30e:8b c1 rjmp.+790 ; 0x3f626
/*
* Now process the STK500 commands, see Atmel Appnote AVR068
*/
switch(msgBuffer[0]) {
3f310:41 31 cpir20, 0x11; 17
3f312:09 f4 brne.+2 ; 0x3f316
3f314:5b c0 rjmp.+182 ; 0x3f3cc
3f316:08 f0 brcs.+2 ; 0x3f31a
3f318:9c c0 rjmp.+312 ; 0x3f452
3f31a:40 31 cpir20, 0x10; 16
3f31c:e9 f0 breq.+58 ; 0x3f358
3f31e:7e c1 rjmp.+764 ; 0x3f61c
3f320:48 31 cpir20, 0x18; 24
3f322:09 f4 brne.+2 ; 0x3f326
3f324:6e c0 rjmp.+220 ; 0x3f402
3f326:48 f4 brcc.+18 ; 0x3f33a
3f328:45 31 cpir20, 0x15; 21
3f32a:09 f4 brne.+2 ; 0x3f32e
3f32c:ae c0 rjmp.+348 ; 0x3f48a
3f32e:08 f4 brcc.+2 ; 0x3f332
3f330:25 c1 rjmp.+586 ; 0x3f57c
3f332:46 31 cpir20, 0x16; 22
3f334:09 f4 brne.+2 ; 0x3f338
3f336:22 c1 rjmp.+580 ; 0x3f57c
3f338:71 c1 rjmp.+738 ; 0x3f61c
3f33a:4a 31 cpir20, 0x1A; 26
3f33c:09 f4 brne.+2 ; 0x3f340
3f33e:54 c0 rjmp.+168 ; 0x3f3e8
3f340:08 f4 brcc.+2 ; 0x3f344
3f342:75 c0 rjmp.+234 ; 0x3f42e
3f344:4b 31 cpir20, 0x1B; 27
3f346:09 f4 brne.+2 ; 0x3f34a
3f348:44 c0 rjmp.+136 ; 0x3f3d2
3f34a:4d 31 cpir20, 0x1D; 29
3f34c:39 f0 breq.+14 ; 0x3f35c
3f34e:66 c1 rjmp.+716 ; 0x3f61c
/*
* Collect received bytes to a complete message
*/
msgParseState=ST_START;
while(msgParseState != ST_PROCESS) {
3f350:47 30 cpir20, 0x07; 7
3f352:09 f4 brne.+2 ; 0x3f356
3f354:b4 cf rjmp.-152 ; 0x3f2be
3f356:68 cf rjmp.-304 ; 0x3f228
/*
* Now process the STK500 commands, see Atmel Appnote AVR068
*/
switch(msgBuffer[0]) {
3f358:20 e0 ldir18, 0x00; 0
3f35a:39 c0 rjmp.+114 ; 0x3f3ce
#ifndef REMOVE_CMD_SPI_MULTI
case CMD_SPI_MULTI: {
unsigned char answerByte;
unsigned char flag = 0;
if(msgBuffer[4] == 0x30) {
3f35c:8d 81 lddr24, Y+5; 0x05
3f35e:80 33 cpir24, 0x30; 48
3f360:39 f4 brne.+14 ; 0x3f370
unsigned char signatureIndex=msgBuffer[6];
3f362:9f 81 lddr25, Y+7; 0x07
if(signatureIndex == 0) {
3f364:99 23 andr25, r25
3f366:b1 f0 breq.+44 ; 0x3f394
//answerByte=(SIGNATURE_BYTES >> 16) & 0x000000FF;
answerByte=SIGNATURE_0;
} else if(signatureIndex == 1) {
3f368:91 30 cpir25, 0x01; 1
3f36a:b1 f4 brne.+44 ; 0x3f398
//answerByte=(SIGNATURE_BYTES >> 8) & 0x000000FF;
answerByte=SIGNATURE_1;
3f36c:98 e9 ldir25, 0x98; 152
3f36e:17 c0 rjmp.+46 ; 0x3f39e
} else {
//answerByte=SIGNATURE_BYTES & 0x000000FF;
answerByte=SIGNATURE_2;
}
} else if(msgBuffer[4] & 0x50) {
3f370:98 2f movr25, r24
3f372:90 75 andir25, 0x50; 80
3f374:99 f0 breq.+38 ; 0x3f39c
//*Issue 544: stk500v2 bootloader doesn't support reading fuses
//*I cant find the docs that say what these are supposed to be but this was figured out by trial and error
//answerByte=boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS);
//answerByte=boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
//answerByte=boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS);
if(msgBuffer[4] == 0x50) {
3f376:80 35 cpir24, 0x50; 80
3f378:21 f4 brne.+8 ; 0x3f382
answerByte=boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS);
3f37a:99 e0 ldir25, 0x09; 9
3f37c:e0 e0 ldir30, 0x00; 0
3f37e:f0 e0 ldir31, 0x00; 0
3f380:05 c0 rjmp.+10 ; 0x3f38c
} else if(msgBuffer[4] == 0x58) {
3f382:88 35 cpir24, 0x58; 88
3f384:59 f4 brne.+22 ; 0x3f39c
answerByte=boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
3f386:e3 e0 ldir30, 0x03; 3
3f388:f0 e0 ldir31, 0x00; 0
3f38a:99 e0 ldir25, 0x09; 9
3f38c:90 93 57 00 sts0x0057, r25
3f390:94 91 lpmr25, Z
3f392:05 c0 rjmp.+10 ; 0x3f39e
if(msgBuffer[4] == 0x30) {
unsigned char signatureIndex=msgBuffer[6];
if(signatureIndex == 0) {
//answerByte=(SIGNATURE_BYTES >> 16) & 0x000000FF;
answerByte=SIGNATURE_0;
3f394:9e e1 ldir25, 0x1E; 30
3f396:03 c0 rjmp.+6 ; 0x3f39e
} else if(signatureIndex == 1) {
//answerByte=(SIGNATURE_BYTES >> 8) & 0x000000FF;
answerByte=SIGNATURE_1;
} else {
//answerByte=SIGNATURE_BYTES & 0x000000FF;
answerByte=SIGNATURE_2;
3f398:91 e0 ldir25, 0x01; 1
3f39a:01 c0 rjmp.+2 ; 0x3f39e
answerByte=boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
} else {
answerByte=0;
}
} else {
answerByte=0; // for all others command are not implemented, return dummy value for AVRDUDE happy
3f39c:90 e0 ldir25, 0x00; 0
}
if(!flag) {
msgLength=7;
msgBuffer[1]=STATUS_CMD_OK;
3f39e:1a 82 stdY+2, r1; 0x02
msgBuffer[2]=0;
3f3a0:1b 82 stdY+3, r1; 0x03
msgBuffer[3]=msgBuffer[4];
3f3a2:8c 83 stdY+4, r24; 0x04
msgBuffer[4]=0;
3f3a4:1d 82 stdY+5, r1; 0x05
msgBuffer[5]=answerByte;
3f3a6:9e 83 stdY+6, r25; 0x06
msgBuffer[6]=STATUS_CMD_OK;
3f3a8:1f 82 stdY+7, r1; 0x07
3f3aa:20 e0 ldir18, 0x00; 0
} else {
answerByte=0; // for all others command are not implemented, return dummy value for AVRDUDE happy
}
if(!flag) {
msgLength=7;
3f3ac:07 e0 ldir16, 0x07; 7
3f3ae:10 e0 ldir17, 0x00; 0
3f3b0:3a c1 rjmp.+628 ; 0x3f626
3f3b2:ea 81 lddr30, Y+2; 0x02
3f3b4:e0 59 subir30, 0x90; 144
3f3b6:e3 30 cpir30, 0x03; 3
3f3b8:28 f4 brcc.+10 ; 0x3f3c4
3f3ba:f0 e0 ldir31, 0x00; 0
3f3bc:ea 5e subir30, 0xEA; 234
3f3be:fd 4f sbcir31, 0xFD; 253
3f3c0:80 81 ldr24, Z
3f3c2:01 c0 rjmp.+2 ; 0x3f3c6
break;
case CMD_GET_PARAMETER: {
unsigned char value;
switch(msgBuffer[1]) {
3f3c4:80 e0 ldir24, 0x00; 0
value=0;
break;
}
msgLength=3;
msgBuffer[1]=STATUS_CMD_OK;
3f3c6:1a 82 stdY+2, r1; 0x02
msgBuffer[2]=value;
3f3c8:8b 83 stdY+3, r24; 0x03
3f3ca:3f c0 rjmp.+126 ; 0x3f44a
}
break;
case CMD_LEAVE_PROGMODE_ISP:
isLeave=1;
3f3cc:21 e0 ldir18, 0x01; 1
//*fall thru
case CMD_SET_PARAMETER:
case CMD_ENTER_PROGMODE_ISP:
msgLength=2;
msgBuffer[1]=STATUS_CMD_OK;
3f3ce:1a 82 stdY+2, r1; 0x02
3f3d0:28 c1 rjmp.+592 ; 0x3f622
break;
case CMD_READ_SIGNATURE_ISP: {
unsigned char signatureIndex=msgBuffer[4];
3f3d2:8d 81 lddr24, Y+5; 0x05
unsigned char signature;
if(signatureIndex == 0)
3f3d4:88 23 andr24, r24
3f3d6:21 f0 breq.+8 ; 0x3f3e0
//signature=(SIGNATURE_BYTES >> 16) & 0x000000FF;
signature=SIGNATURE_0;
else if(signatureIndex == 1)
3f3d8:81 30 cpir24, 0x01; 1
3f3da:21 f4 brne.+8 ; 0x3f3e4
//signature=(SIGNATURE_BYTES >> 8) & 0x000000FF;
signature=SIGNATURE_1;
3f3dc:88 e9 ldir24, 0x98; 152
3f3de:24 c0 rjmp.+72 ; 0x3f428
unsigned char signatureIndex=msgBuffer[4];
unsigned char signature;
if(signatureIndex == 0)
//signature=(SIGNATURE_BYTES >> 16) & 0x000000FF;
signature=SIGNATURE_0;
3f3e0:8e e1 ldir24, 0x1E; 30
3f3e2:22 c0 rjmp.+68 ; 0x3f428
else if(signatureIndex == 1)
//signature=(SIGNATURE_BYTES >> 8) & 0x000000FF;
signature=SIGNATURE_1;
else
//signature=SIGNATURE_BYTES & 0x000000FF;
signature=SIGNATURE_2;
3f3e4:81 e0 ldir24, 0x01; 1
3f3e6:20 c0 rjmp.+64 ; 0x3f428
}
break;
case CMD_READ_LOCK_ISP:
msgLength=4;
msgBuffer[1]=STATUS_CMD_OK;
3f3e8:1a 82 stdY+2, r1; 0x02
msgBuffer[2]=boot_lock_fuse_bits_get(GET_LOCK_BITS);
3f3ea:e1 e0 ldir30, 0x01; 1
3f3ec:f0 e0 ldir31, 0x00; 0
3f3ee:89 e0 ldir24, 0x09; 9
3f3f0:80 93 57 00 sts0x0057, r24
3f3f4:e4 91 lpmr30, Z
3f3f6:eb 83 stdY+3, r30; 0x03
msgBuffer[3]=STATUS_CMD_OK;
3f3f8:1c 82 stdY+4, r1; 0x04
break;
3f3fa:20 e0 ldir18, 0x00; 0
msgBuffer[3]=STATUS_CMD_OK;
}
break;
case CMD_READ_LOCK_ISP:
msgLength=4;
3f3fc:04 e0 ldir16, 0x04; 4
3f3fe:10 e0 ldir17, 0x00; 0
msgBuffer[1]=STATUS_CMD_OK;
msgBuffer[2]=boot_lock_fuse_bits_get(GET_LOCK_BITS);
msgBuffer[3]=STATUS_CMD_OK;
break;
3f400:12 c1 rjmp.+548 ; 0x3f626
case CMD_READ_FUSE_ISP: {
unsigned char fuseBits;
if(msgBuffer[2] == 0x50) {
3f402:8b 81 lddr24, Y+3; 0x03
3f404:80 35 cpir24, 0x50; 80
3f406:51 f4 brne.+20 ; 0x3f41c
if(msgBuffer[3] == 0x08)
3f408:8c 81 lddr24, Y+4; 0x04
3f40a:88 30 cpir24, 0x08; 8
3f40c:19 f4 brne.+6 ; 0x3f414
fuseBits=boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS);
3f40e:e2 e0 ldir30, 0x02; 2
3f410:f0 e0 ldir31, 0x00; 0
3f412:06 c0 rjmp.+12 ; 0x3f420
else
fuseBits=boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS);
3f414:89 e0 ldir24, 0x09; 9
3f416:e0 e0 ldir30, 0x00; 0
3f418:f0 e0 ldir31, 0x00; 0
3f41a:03 c0 rjmp.+6 ; 0x3f422
} else {
fuseBits=boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
3f41c:e3 e0 ldir30, 0x03; 3
3f41e:f0 e0 ldir31, 0x00; 0
3f420:89 e0 ldir24, 0x09; 9
3f422:80 93 57 00 sts0x0057, r24
3f426:84 91 lpmr24, Z
}
msgLength=4;
msgBuffer[1]=STATUS_CMD_OK;
3f428:1a 82 stdY+2, r1; 0x02
msgBuffer[2]=fuseBits;
3f42a:8b 83 stdY+3, r24; 0x03
3f42c:e5 cf rjmp.-54 ; 0x3f3f8
#ifndef REMOVE_PROGRAM_LOCK_BIT_SUPPORT
case CMD_PROGRAM_LOCK_ISP: {
unsigned char lockBits=msgBuffer[4];
lockBits=(~lockBits) & 0x3C;// mask BLBxx bits
3f42e:8d 81 lddr24, Y+5; 0x05
boot_lock_bits_set(lockBits);// and program it
3f430:83 6c orir24, 0xC3; 195
3f432:99 e0 ldir25, 0x09; 9
3f434:e1 e0 ldir30, 0x01; 1
3f436:f0 e0 ldir31, 0x00; 0
3f438:08 2e movr0, r24
3f43a:90 93 57 00 sts0x0057, r25
3f43e:e8 95 spm
boot_spm_busy_wait();
3f440:07 b6 inr0, 0x37; 55
3f442:00 fc sbrcr0, 0
3f444:fd cf rjmp.-6 ; 0x3f440
msgLength=3;
msgBuffer[1]=STATUS_CMD_OK;
3f446:1a 82 stdY+2, r1; 0x02
msgBuffer[2]=STATUS_CMD_OK;
3f448:1b 82 stdY+3, r1; 0x03
}
break;
3f44a:20 e0 ldir18, 0x00; 0
lockBits=(~lockBits) & 0x3C;// mask BLBxx bits
boot_lock_bits_set(lockBits);// and program it
boot_spm_busy_wait();
msgLength=3;
3f44c:03 e0 ldir16, 0x03; 3
3f44e:10 e0 ldir17, 0x00; 0
msgBuffer[1]=STATUS_CMD_OK;
msgBuffer[2]=STATUS_CMD_OK;
}
break;
3f450:ea c0 rjmp.+468 ; 0x3f626
#endif
case CMD_CHIP_ERASE_ISP:
eraseAddress=0;
msgLength=2;
//msgBuffer[1]=STATUS_CMD_OK;
msgBuffer[1]=STATUS_CMD_FAILED;//*isue 543, return FAILED instead of OK
3f452:80 ec ldir24, 0xC0; 192
3f454:8a 83 stdY+2, r24; 0x02
break;
3f456:20 e0 ldir18, 0x00; 0
}
break;
#endif
case CMD_CHIP_ERASE_ISP:
eraseAddress=0;
msgLength=2;
3f458:02 e0 ldir16, 0x02; 2
3f45a:10 e0 ldir17, 0x00; 0
msgBuffer[2]=STATUS_CMD_OK;
}
break;
#endif
case CMD_CHIP_ERASE_ISP:
eraseAddress=0;
3f45c:41 2c movr4, r1
3f45e:51 2c movr5, r1
3f460:32 01 movwr6, r4
msgLength=2;
//msgBuffer[1]=STATUS_CMD_OK;
msgBuffer[1]=STATUS_CMD_FAILED;//*isue 543, return FAILED instead of OK
break;
3f462:e1 c0 rjmp.+450 ; 0x3f626
case CMD_LOAD_ADDRESS:
#if defined(RAMPZ)
address=(((address_t)(msgBuffer[1]) << 24) | ((address_t)(msgBuffer[2]) << 16) | ((address_t)(msgBuffer[3]) << 8) | (msgBuffer[4])) << 1;
3f464:8a 81 lddr24, Y+2; 0x02
3f466:cb 80 lddr12, Y+3; 0x03
3f468:d1 2c movr13, r1
3f46a:e1 2c movr14, r1
3f46c:f1 2c movr15, r1
3f46e:76 01 movwr14, r12
3f470:dd 24 eorr13, r13
3f472:cc 24 eorr12, r12
3f474:f8 2a orr15, r24
3f476:8d 81 lddr24, Y+5; 0x05
3f478:c8 2a orr12, r24
3f47a:8c 81 lddr24, Y+4; 0x04
3f47c:d8 2a orr13, r24
3f47e:cc 0c addr12, r12
3f480:dd 1c adcr13, r13
3f482:ee 1c adcr14, r14
3f484:ff 1c adcr15, r15
#else
address=(((msgBuffer[3]) << 8) | (msgBuffer[4])) << 1;//convert word to byte address
#endif
msgLength=2;
msgBuffer[1]=STATUS_CMD_OK;
3f486:1a 82 stdY+2, r1; 0x02
3f488:cb c0 rjmp.+406 ; 0x3f620
break;
case CMD_PROGRAM_FLASH_ISP:
case CMD_PROGRAM_EEPROM_ISP: {
unsigned intsize=((msgBuffer[1]) << 8) | msgBuffer[2];
3f48a:8a 81 lddr24, Y+2; 0x02
3f48c:90 e0 ldir25, 0x00; 0
3f48e:98 2f movr25, r24
3f490:88 27 eorr24, r24
3f492:2b 81 lddr18, Y+3; 0x03
3f494:82 2b orr24, r18
unsigned intdata;
unsigned charhighByte, lowByte;
address_ttempaddress=address;
if(msgBuffer[0] == CMD_PROGRAM_FLASH_ISP) {
3f496:43 31 cpir20, 0x13; 19
3f498:09 f0 breq.+2 ; 0x3f49c
3f49a:45 c0 rjmp.+138 ; 0x3f526
// erase only main section (bootloader protection)
if(eraseAddress < APP_END) {
3f49c:41 14 cpr4, r1
3f49e:f0 ec ldir31, 0xC0; 192
3f4a0:5f 06 cpcr5, r31
3f4a2:f3 e0 ldir31, 0x03; 3
3f4a4:6f 06 cpcr6, r31
3f4a6:71 04 cpcr7, r1
3f4a8:70 f4 brcc.+28 ; 0x3f4c6
boot_page_erase(eraseAddress);// Perform page erase
3f4aa:23 e0 ldir18, 0x03; 3
3f4ac:f2 01 movwr30, r4
3f4ae:60 92 5b 00 sts0x005B, r6
3f4b2:20 93 57 00 sts0x0057, r18
3f4b6:e8 95 spm
boot_spm_busy_wait();// Wait until the memory is erased.
3f4b8:07 b6 inr0, 0x37; 55
3f4ba:00 fc sbrcr0, 0
3f4bc:fd cf rjmp.-6 ; 0x3f4b8
eraseAddress += SPM_PAGESIZE;// point to next page to be erase
3f4be:4f ef ldir20, 0xFF; 255
3f4c0:54 1a subr5, r20
3f4c2:64 0a sbcr6, r20
3f4c4:74 0a sbcr7, r20
3f4c6:4b 85 lddr20, Y+11; 0x0b
else if(signatureIndex == 1)
//signature=(SIGNATURE_BYTES >> 8) & 0x000000FF;
signature=SIGNATURE_1;
else
//signature=SIGNATURE_BYTES & 0x000000FF;
signature=SIGNATURE_2;
3f4c8:46 01 movwr8, r12
3f4ca:57 01 movwr10, r14
3f4cc:9e 01 movwr18, r28
3f4ce:25 5f subir18, 0xF5; 245
3f4d0:3f 4f sbcir19, 0xFF; 255
3f4d2:d9 01 movwr26, r18
3f4d4:12 96 adiwr26, 0x02; 2
3f4d6:9d 01 movwr18, r26
3f4d8:fd 01 movwr30, r26
3f4da:31 97 sbiwr30, 0x01; 1
/* Write FLASH */
do {
lowByte=*p++;
highByte =*p++;
data=(highByte << 8) | lowByte;
3f4dc:60 81 ldr22, Z
3f4de:50 e0 ldir21, 0x00; 0
3f4e0:56 2b orr21, r22
boot_page_fill(address, data);
3f4e2:61 e0 ldir22, 0x01; 1
3f4e4:0a 01 movwr0, r20
3f4e6:f4 01 movwr30, r8
3f4e8:a0 92 5b 00 sts0x005B, r10
3f4ec:60 93 57 00 sts0x0057, r22
3f4f0:e8 95 spm
3f4f2:11 24 eorr1, r1
address=address + 2;// Select next word in memory
3f4f4:e2 e0 ldir30, 0x02; 2
3f4f6:8e 0e addr8, r30
3f4f8:91 1c adcr9, r1
3f4fa:a1 1c adcr10, r1
3f4fc:b1 1c adcr11, r1
size-=2;// Reduce number of bytes to write by two
3f4fe:02 97 sbiwr24, 0x02; 2
} while(size);// Loop until all bytes written
3f500:00 97 sbiwr24, 0x00; 0
3f502:11 f0 breq.+4 ; 0x3f508
}
/* Write FLASH */
do {
lowByte=*p++;
highByte =*p++;
3f504:4c 91 ldr20, X
3f506:e5 cf rjmp.-54 ; 0x3f4d2
address=address + 2;// Select next word in memory
size-=2;// Reduce number of bytes to write by two
} while(size);// Loop until all bytes written
boot_page_write(tempaddress);
3f508:85 e0 ldir24, 0x05; 5
3f50a:f6 01 movwr30, r12
3f50c:e0 92 5b 00 sts0x005B, r14
3f510:80 93 57 00 sts0x0057, r24
3f514:e8 95 spm
boot_spm_busy_wait();
3f516:07 b6 inr0, 0x37; 55
3f518:00 fc sbrcr0, 0
3f51a:fd cf rjmp.-6 ; 0x3f516
boot_rww_enable();// Re-enable the RWW section
3f51c:81 e1 ldir24, 0x11; 17
3f51e:80 93 57 00 sts0x0057, r24
3f522:e8 95 spm
3f524:27 c0 rjmp.+78 ; 0x3f574
3f526:fe 01 movwr30, r28
3f528:3b 96 adiwr30, 0x0b; 11
unsigned intdata;
unsigned charhighByte, lowByte;
address_ttempaddress=address;
if(msgBuffer[0] == CMD_PROGRAM_FLASH_ISP) {
3f52a:9c 01 movwr18, r24
3f52c:b7 01 movwr22, r14
3f52e:a6 01 movwr20, r12
//*issue 543, this should work, It has not been tested.
//#if (!defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__) && !defined(__AVR_ATmega2561__) && !defined(__AVR_ATmega1284P__) && !defined(__AVR_ATmega640__))
#if (defined(EEARL) && defined(EEARH) && defined(EEMWE) && defined(EEWE) && defined(EEDR))
/* write EEPROM */
do {
EEARL=address;// Setup EEPROM address
3f530:41 bd out0x21, r20; 33
EEARH=(address >> 8);
3f532:85 2e movr8, r21
3f534:96 2e movr9, r22
3f536:a7 2e movr10, r23
3f538:bb 24 eorr11, r11
3f53a:82 bc out0x22, r8; 34
address++;// Select next EEPROM byte
3f53c:4f 5f subir20, 0xFF; 255
3f53e:5f 4f sbcir21, 0xFF; 255
3f540:6f 4f sbcir22, 0xFF; 255
3f542:7f 4f sbcir23, 0xFF; 255
EEDR=*p++;// get byte from buffer
3f544:a1 91 ldr26, Z+
3f546:a0 bd out0x20, r26; 32
EECR|=(1 << EEMWE);// Write data into EEPROM
3f548:fa 9a sbi0x1f, 2; 31
EECR|=(1 << EEWE);
3f54a:f9 9a sbi0x1f, 1; 31
while(EECR & (1 << EEWE))
3f54c:f9 99 sbic0x1f, 1; 31
3f54e:fe cf rjmp.-4 ; 0x3f54c
;// Wait for write operation to finish
size--;// Decrease number of bytes to write
3f550:21 50 subir18, 0x01; 1
3f552:31 09 sbcr19, r1
} while(size);// Loop until all bytes written
3f554:21 15 cpr18, r1
3f556:31 05 cpcr19, r1
3f558:59 f7 brne.-42 ; 0x3f530
3f55a:01 97 sbiwr24, 0x01; 1
3f55c:4c 01 movwr8, r24
3f55e:a1 2c movr10, r1
3f560:b1 2c movr11, r1
3f562:ff ef ldir31, 0xFF; 255
3f564:8f 1a subr8, r31
3f566:9f 0a sbcr9, r31
3f568:af 0a sbcr10, r31
3f56a:bf 0a sbcr11, r31
3f56c:8c 0c addr8, r12
3f56e:9d 1c adcr9, r13
3f570:ae 1c adcr10, r14
3f572:bf 1c adcr11, r15
#endif
}
msgLength=2;
msgBuffer[1]=STATUS_CMD_OK;
3f574:1a 82 stdY+2, r1; 0x02
}
break;
3f576:75 01 movwr14, r10
3f578:64 01 movwr12, r8
3f57a:52 c0 rjmp.+164 ; 0x3f620
case CMD_READ_FLASH_ISP:
case CMD_READ_EEPROM_ISP: {
unsigned intsize=((msgBuffer[1]) << 8) | msgBuffer[2];
3f57c:2a 81 lddr18, Y+2; 0x02
3f57e:30 e0 ldir19, 0x00; 0
3f580:32 2f movr19, r18
3f582:22 27 eorr18, r18
3f584:8b 81 lddr24, Y+3; 0x03
3f586:28 2b orr18, r24
unsigned char*p=msgBuffer + 1;
msgLength=size + 3;
3f588:89 01 movwr16, r18
3f58a:0d 5f subir16, 0xFD; 253
3f58c:1f 4f sbcir17, 0xFF; 255
*p++=STATUS_CMD_OK;
3f58e:1a 82 stdY+2, r1; 0x02
if(msgBuffer[0] == CMD_READ_FLASH_ISP) {
3f590:44 31 cpir20, 0x14; 20
3f592:b1 f4 brne.+44 ; 0x3f5c0
3f594:de 01 movwr26, r28
3f596:13 96 adiwr26, 0x03; 3
// Read FLASH
do {
//#if defined(RAMPZ)
#if (FLASHEND > 0x10000)
data=pgm_read_word_far(address);
3f598:eb be out0x3b, r14; 59
3f59a:f6 01 movwr30, r12
3f59c:87 91 elpmr24, Z+
3f59e:96 91 elpmr25, Z
#else
data=pgm_read_word_near(address);
#endif
*p++=(unsigned char)data;//LSB
3f5a0:8c 93 stX, r24
3f5a2:12 96 adiwr26, 0x02; 2
3f5a4:fd 01 movwr30, r26
3f5a6:31 97 sbiwr30, 0x01; 1
*p++=(unsigned char)(data >> 8);//MSB
3f5a8:90 83 stZ, r25
address+=2;// Select next word in memory
3f5aa:42 e0 ldir20, 0x02; 2
3f5ac:c4 0e addr12, r20
3f5ae:d1 1c adcr13, r1
3f5b0:e1 1c adcr14, r1
3f5b2:f1 1c adcr15, r1
size-=2;
3f5b4:22 50 subir18, 0x02; 2
3f5b6:31 09 sbcr19, r1
} while(size);
3f5b8:21 15 cpr18, r1
3f5ba:31 05 cpcr19, r1
3f5bc:69 f7 brne.-38 ; 0x3f598
3f5be:2b c0 rjmp.+86 ; 0x3f616
3f5c0:ce 01 movwr24, r28
3f5c2:03 96 adiwr24, 0x03; 3
3f5c4:5c 01 movwr10, r24
unsigned char*p=msgBuffer + 1;
msgLength=size + 3;
*p++=STATUS_CMD_OK;
if(msgBuffer[0] == CMD_READ_FLASH_ISP) {
3f5c6:49 01 movwr8, r18
3f5c8:d7 01 movwr26, r14
3f5ca:c6 01 movwr24, r12
size-=2;
} while(size);
} else {
/* Read EEPROM */
do {
EEARL=address;// Setup EEPROM address
3f5cc:81 bd out0x21, r24; 33
EEARH=((address >> 8));
3f5ce:49 2f movr20, r25
3f5d0:5a 2f movr21, r26
3f5d2:6b 2f movr22, r27
3f5d4:77 27 eorr23, r23
3f5d6:42 bd out0x22, r20; 34
address++;// Select next EEPROM byte
3f5d8:01 96 adiwr24, 0x01; 1
3f5da:a1 1d adcr26, r1
3f5dc:b1 1d adcr27, r1
EECR|=(1 << EERE);// Read EEPROM
3f5de:f8 9a sbi0x1f, 0; 31
*p++=EEDR;// Send EEPROM data
3f5e0:40 b5 inr20, 0x20; 32
3f5e2:f5 01 movwr30, r10
3f5e4:41 93 stZ+, r20
3f5e6:5f 01 movwr10, r30
size--;
3f5e8:f1 e0 ldir31, 0x01; 1
3f5ea:8f 1a subr8, r31
3f5ec:91 08 sbcr9, r1
} while(size);
3f5ee:81 14 cpr8, r1
3f5f0:91 04 cpcr9, r1
3f5f2:61 f7 brne.-40 ; 0x3f5cc
3f5f4:c9 01 movwr24, r18
3f5f6:01 97 sbiwr24, 0x01; 1
3f5f8:a0 e0 ldir26, 0x00; 0
3f5fa:b0 e0 ldir27, 0x00; 0
3f5fc:01 96 adiwr24, 0x01; 1
3f5fe:a1 1d adcr26, r1
3f600:b1 1d adcr27, r1
3f602:c8 0e addr12, r24
3f604:d9 1e adcr13, r25
3f606:ea 1e adcr14, r26
3f608:fb 1e adcr15, r27
3f60a:a3 e0 ldir26, 0x03; 3
3f60c:b0 e0 ldir27, 0x00; 0
3f60e:ac 0f addr26, r28
3f610:bd 1f adcr27, r29
3f612:a2 0f addr26, r18
3f614:b3 1f adcr27, r19
}
*p++=STATUS_CMD_OK;
3f616:1c 92 stX, r1
}
break;
3f618:20 e0 ldir18, 0x00; 0
3f61a:05 c0 rjmp.+10 ; 0x3f626
default:
msgLength=2;
msgBuffer[1]=STATUS_CMD_FAILED;
3f61c:80 ec ldir24, 0xC0; 192
3f61e:8a 83 stdY+2, r24; 0x02
break;
3f620:20 e0 ldir18, 0x00; 0
*p++=STATUS_CMD_OK;
}
break;
default:
msgLength=2;
3f622:02 e0 ldir16, 0x02; 2
3f624:10 e0 ldir17, 0x00; 0
}
/*
* Now send answer message back
*/
putch(MESSAGE_START);
3f626:8b e1 ldir24, 0x1B; 27
3f628:c0 5e subir28, 0xE0; 224
3f62a:de 4f sbcir29, 0xFE; 254
3f62c:28 83 stY, r18
3f62e:c0 52 subir28, 0x20; 32
3f630:d1 40 sbcir29, 0x01; 1
3f632:57 dd rcall.-1362 ; 0x3f0e2
checksum=MESSAGE_START ^ 0;
putch(seqNum);
3f634:c2 5e subir28, 0xE2; 226
3f636:de 4f sbcir29, 0xFE; 254
3f638:88 81 ldr24, Y
3f63a:ce 51 subir28, 0x1E; 30
3f63c:d1 40 sbcir29, 0x01; 1
3f63e:51 dd rcall.-1374 ; 0x3f0e2
checksum^=seqNum;
c=((msgLength >> 8) & 0xFF);
3f640:a1 2e movr10, r17
3f642:bb 24 eorr11, r11
putch(c);
3f644:8a 2d movr24, r10
3f646:4d dd rcall.-1382 ; 0x3f0e2
checksum^=c;
c=msgLength & 0x00FF;
putch(c);
3f648:80 2f movr24, r16
3f64a:4b dd rcall.-1386 ; 0x3f0e2
checksum ^= c;
putch(TOKEN);
3f64c:8e e0 ldir24, 0x0E; 14
3f64e:49 dd rcall.-1390 ; 0x3f0e2
putch(seqNum);
checksum^=seqNum;
c=((msgLength >> 8) & 0xFF);
putch(c);
checksum^=c;
3f650:25 e1 ldir18, 0x15; 21
3f652:82 2e movr8, r18
3f654:c2 5e subir28, 0xE2; 226
3f656:de 4f sbcir29, 0xFE; 254
3f658:48 81 ldr20, Y
3f65a:ce 51 subir28, 0x1E; 30
3f65c:d1 40 sbcir29, 0x01; 1
3f65e:84 26 eorr8, r20
c=msgLength & 0x00FF;
putch(c);
checksum ^= c;
3f660:80 26 eorr8, r16
putch(TOKEN);
checksum ^= TOKEN;
3f662:8a 24 eorr8, r10
3f664:ce 01 movwr24, r28
3f666:01 96 adiwr24, 0x01; 1
3f668:5c 01 movwr10, r24
3f66a:08 0f addr16, r24
3f66c:19 1f adcr17, r25
p=msgBuffer;
while(msgLength) {
c=*p++;
putch(c);
checksum ^= c;
3f66e:c0 5e subir28, 0xE0; 224
3f670:de 4f sbcir29, 0xFE; 254
3f672:28 81 ldr18, Y
3f674:c0 52 subir28, 0x20; 32
3f676:d1 40 sbcir29, 0x01; 1
putch(TOKEN);
checksum ^= TOKEN;
p=msgBuffer;
while(msgLength) {
3f678:a0 16 cpr10, r16
3f67a:b1 06 cpcr11, r17
3f67c:b1 f0 breq.+44 ; 0x3f6aa
c=*p++;
3f67e:f5 01 movwr30, r10
3f680:31 91 ldr19, Z+
3f682:5f 01 movwr10, r30
putch(c);
3f684:83 2f movr24, r19
3f686:c0 5e subir28, 0xE0; 224
3f688:de 4f sbcir29, 0xFE; 254
3f68a:28 83 stY, r18
3f68c:c0 52 subir28, 0x20; 32
3f68e:d1 40 sbcir29, 0x01; 1
3f690:c1 5e subir28, 0xE1; 225
3f692:de 4f sbcir29, 0xFE; 254
3f694:38 83 stY, r19
3f696:cf 51 subir28, 0x1F; 31
3f698:d1 40 sbcir29, 0x01; 1
3f69a:23 dd rcall.-1466 ; 0x3f0e2
checksum ^= c;
3f69c:c1 5e subir28, 0xE1; 225
3f69e:de 4f sbcir29, 0xFE; 254
3f6a0:38 81 ldr19, Y
3f6a2:cf 51 subir28, 0x1F; 31
3f6a4:d1 40 sbcir29, 0x01; 1
3f6a6:83 26 eorr8, r19
3f6a8:e2 cf rjmp.-60 ; 0x3f66e
msgLength--;
}
putch(checksum);
3f6aa:88 2d movr24, r8
3f6ac:c0 5e subir28, 0xE0; 224
3f6ae:de 4f sbcir29, 0xFE; 254
3f6b0:28 83 stY, r18
3f6b2:c0 52 subir28, 0x20; 32
3f6b4:d1 40 sbcir29, 0x01; 1
3f6b6:15 dd rcall.-1494 ; 0x3f0e2
seqNum++;
3f6b8:c2 5e subir28, 0xE2; 226
3f6ba:de 4f sbcir29, 0xFE; 254
3f6bc:48 81 ldr20, Y
3f6be:ce 51 subir28, 0x1E; 30
3f6c0:d1 40 sbcir29, 0x01; 1
3f6c2:4f 5f subir20, 0xFF; 255
3f6c4:c2 5e subir28, 0xE2; 226
3f6c6:de 4f sbcir29, 0xFE; 254
3f6c8:48 83 stY, r20
3f6ca:ce 51 subir28, 0x1E; 30
3f6cc:d1 40 sbcir29, 0x01; 1
unsigned intmsgLength=0;
unsigned charmsgBuffer[285];
unsigned charc, *p;
unsigned char isLeave = 0;
while(!isLeave) {
3f6ce:c0 5e subir28, 0xE0; 224
3f6d0:de 4f sbcir29, 0xFE; 254
3f6d2:28 81 ldr18, Y
3f6d4:c0 52 subir28, 0x20; 32
3f6d6:d1 40 sbcir29, 0x01; 1
3f6d8:22 23 andr18, r18
3f6da:09 f4 brne.+2 ; 0x3f6de
3f6dc:a2 cd rjmp.-1212 ; 0x3f222
putch(checksum);
seqNum++;
}
asm volatile("nop");// wait until port has changed
3f6de:00 00 nop
* Now leave bootloader
*/
//TODO: find out what this does
//UART_STATUS_REG&=0xfd;
#if defined(RWWSRE)
boot_rww_enable();// enable application section
3f6e0:81 e1 ldir24, 0x11; 17
3f6e2:80 93 57 00 sts0x0057, r24
3f6e6:e8 95 spm
#endif
return(0);
}
3f6e8:80 e0 ldir24, 0x00; 0
3f6ea:c0 5e subir28, 0xE0; 224
3f6ec:de 4f sbcir29, 0xFE; 254
3f6ee:de bf out0x3e, r29; 62
3f6f0:cd bf out0x3d, r28; 61
3f6f2:df 91 popr29
3f6f4:cf 91 popr28
3f6f6:1f 91 popr17
3f6f8:0f 91 popr16
3f6fa:ff 90 popr15
3f6fc:ef 90 popr14
3f6fe:df 90 popr13
3f700:cf 90 popr12
3f702:bf 90 popr11
3f704:af 90 popr10
3f706:9f 90 popr9
3f708:8f 90 popr8
3f70a:7f 90 popr7
3f70c:6f 90 popr6
3f70e:5f 90 popr5
3f710:4f 90 popr4
3f712:3f 90 popr3
3f714:2f 90 popr2
3f716:08 95 ret
3f718:18 01 movwr2, r16
case ST_GET_DATA:
msgBuffer[ii++]=c;
checksum^=c;
if(ii == msgLength) {
msgParseState=ST_GET_CHECK;
3f71a:46 e0 ldir20, 0x06; 6
3f71c:85 cd rjmp.-1270 ; 0x3f228
0003f71e :
3f71e:6b bf out0x3b, r22; 59
3f720:fa 01 movwr30, r20
3f722:dc 01 movwr26, r24
3f724:02 c0 rjmp.+4 ; 0x3f72a
3f726:07 90 elpmr0, Z+
3f728:0d 92 stX+, r0
3f72a:21 50 subir18, 0x01; 1
3f72c:30 40 sbcir19, 0x00; 0
3f72e:d8 f7 brcc.-10 ; 0x3f726
3f730:08 95 ret
0003f732 <__eerd_block_m2560>:
3f732:dc 01 movwr26, r24
3f734:cb 01 movwr24, r22
0003f736 <__eerd_blraw_m2560>:
3f736:fc 01 movwr30, r24
3f738:f9 99 sbic0x1f, 1; 31
3f73a:fe cf rjmp.-4 ; 0x3f738 <__eerd_blraw_m2560>
3f73c:06 c0 rjmp.+12 ; 0x3f74a <__eerd_blraw_m2560>
3f73e:f2 bd out0x22, r31; 34
3f740:e1 bd out0x21, r30; 33
3f742:f8 9a sbi0x1f, 0; 31
3f744:31 96 adiwr30, 0x01; 1
3f746:00 b4 inr0, 0x20; 32
3f748:0d 92 stX+, r0
3f74a:41 50 subir20, 0x01; 1
3f74c:50 40 sbcir21, 0x00; 0
3f74e:b8 f7 brcc.-18 ; 0x3f73e <__eerd_blraw_m2560>
3f750:08 95 ret
0003f752 <__eewr_block_m2560>:
3f752:dc 01 movwr26, r24
3f754:cb 01 movwr24, r22
3f756:02 c0 rjmp.+4 ; 0x3f75c <__eewr_block_m2560>
3f758:2d 91 ldr18, X+
3f75a:05 d0 rcall.+10 ; 0x3f766 <__eewr_r18_m2560>
3f75c:41 50 subir20, 0x01; 1
3f75e:50 40 sbcir21, 0x00; 0
3f760:d8 f7 brcc.-10 ; 0x3f758 <__eewr_block_m2560>
3f762:08 95 ret
0003f764 <__eewr_byte_m2560>:
3f764:26 2f movr18, r22
0003f766 <__eewr_r18_m2560>:
3f766:f9 99 sbic0x1f, 1; 31
3f768:fe cf rjmp.-4 ; 0x3f766 <__eewr_r18_m2560>
3f76a:1f ba out0x1f, r1; 31
3f76c:92 bd out0x22, r25; 34
3f76e:81 bd out0x21, r24; 33
3f770:20 bd out0x20, r18; 32
3f772:0f b6 inr0, 0x3f; 63
3f774:f8 94 cli
3f776:fa 9a sbi0x1f, 2; 31
3f778:f9 9a sbi0x1f, 1; 31
3f77a:0f be out0x3f, r0; 63
3f77c:01 96 adiwr24, 0x01; 1
3f77e:08 95 ret
0003f780 <_exit>:
3f780:f8 94 cli
0003f782 <__stop_program>:
3f782:ff cf rjmp.-2 ; 0x3f782 <__stop_program>