diff -urpN uisp-20020303/src/MotIntl.C uisp-20020303-srec-ihex-fix/src/MotIntl.C --- uisp-20020303/src/MotIntl.C Tue Oct 23 03:26:37 2001 +++ uisp-20020303-srec-ihex-fix/src/MotIntl.C Mon Apr 8 23:15:50 2002 @@ -124,14 +124,25 @@ void TMotIntl::UploadMotorola(){ } } } break; - + + case '7': + case '8': case '9':{ if (upload){device->FlushWriteBuffer();} gettimeofday(&t2, NULL); timersub(&t2, &t1, &t2); float elapsed = t2.tv_sec + t2.tv_usec*1e-6; ReportStats(elapsed, total_bytes_uploaded); + + /* verify check sum */ + for (int i=0;iTellActiveSegment()); @@ -176,39 +189,60 @@ void TMotIntl::UploadIntel(){ if (line_buf[0]!=':'){throw Error_Device("Bad Intel file format.");} cc_sum = 0; - srec_len = Htoi(&line_buf[1]); + ihex_len = Htoi(&line_buf[1]); p = &line_buf[3]; /* Load address */ addr = Htoi(p); p+=2; addr <<= 8; addr += Htoi(p); p+=2; - Htoi(p); p+=2; /* read control byte: 00-data, 01-end */ + rec_type = Htoi(p); p+=2; /* read control byte: 00-data, 01-end, 02-seg_offset */ - /* Upload/Verify bytes */ - total_bytes_uploaded += srec_len; - while(srec_len-->0){ - byte = Htoi(p); - if (upload){device->WriteByte(addr, byte, false);} - if (verify){ - TByte rbyte = device->ReadByte(addr); - if (rbyte != byte){ - Info(0, "%s error at address 0x%x: file=0x%02x, mem=0x%02x\n", - device->TellActiveSegment(), addr, - (int) byte, (int) rbyte); - } + addr += seg_offset; /* this allows access to more than 64K */ + + switch(rec_type) + { + case 0x00:{ + /* Upload/Verify bytes */ + total_bytes_uploaded += ihex_len; + while(ihex_len-->0){ + byte = Htoi(p); + if (upload){device->WriteByte(addr, byte, false);} + if (verify){ + TByte rbyte = device->ReadByte(addr); + if (rbyte != byte){ + Info(0, "%s error at address 0x%x: file=0x%02x, mem=0x%02x\n", + device->TellActiveSegment(), addr, + (int) byte, (int) rbyte); + } + } + p+=2; addr++; + if (total_bytes_uploaded >= hash_cnt+hash_marker){ + Info(2, "#"); + hash_cnt+=hash_marker; + } + } + } break; + + case 0x01:{ + /* don't need to do anything, this is the end */ + } break; + + case 0x02:{ + seg_offset = Htoi(p); p+=2; seg_offset <<=8; + seg_offset += Htoi(p); p+=2; + + /* seg_offset is bits 4-19 of addr, so shift to that. */ + seg_offset <<=4; + } break; + + default: throw Error_Device("Bad Intel Hex record.\n"); } - p+=2; addr++; - if (total_bytes_uploaded >= hash_cnt+hash_marker){ - Info(2, "#"); - hash_cnt+=hash_marker; - } - } /* Read Check Sum and give a report */ - srec_cc_sum = Htoi(p); + ihex_cc_sum = Htoi(p); if (cc_sum != 0x0){ Info(2, "Intel check sum: %d uisp check sum: %d\n", - (unsigned)srec_cc_sum, (unsigned)cc_sum); + (unsigned)ihex_cc_sum, (unsigned)cc_sum); throw Error_Device("Check sum error.\n"); }