| Line 21... |
Line 21... |
| 21 |
echo uf > com1 |
21 |
echo uf > com1 |
| 22 |
ping 1.1.1.1 -n 1 -w 100 > nul |
22 |
ping 1.1.1.1 -n 1 -w 100 > nul |
| 23 |
FOR /F "tokens=1*" %%i in (bltest.hex) do @echo %%i > com1 & ping 1.1.1.1 -n 1 -w 100 > nul |
23 |
FOR /F "tokens=1*" %%i in (bltest.hex) do @echo %%i > com1 & ping 1.1.1.1 -n 1 -w 100 > nul |
| 24 |
*/ |
24 |
*/ |
| 25 |
|
25 |
|
| 26 |
#define ID "$Id: bloader.c 2897 2013-04-09 21:20:28Z kakl $" |
26 |
#define ID "$Id: bloader.c 2898 2013-04-09 22:15:55Z kakl $" |
| 27 |
|
27 |
|
| 28 |
#CASE // Case sensitive compiler |
28 |
#CASE // Case sensitive compiler |
| 29 |
|
29 |
|
| 30 |
#define ERR_BUFFER_OVERRUN 1 // Error 1 - Buffer Overrun |
30 |
#define ERR_BUFFER_OVERRUN 1 // Error 1 - Buffer Overrun |
| 31 |
#define ERR_CHECKSUM 2 // Error 2 - Bad CheckSum |
31 |
#define ERR_CHECKSUM 2 // Error 2 - Bad CheckSum |
| Line 193... |
Line 193... |
| 193 |
buffidx = 0; // Read into the buffer until CR is received or buffer is full |
193 |
buffidx = 0; // Read into the buffer until CR is received or buffer is full |
| 194 |
do |
194 |
do |
| 195 |
{ |
195 |
{ |
| 196 |
buffer[buffidx] = getc(); |
196 |
buffer[buffidx] = getc(); |
| 197 |
putc(buffer[buffidx]); |
197 |
putc(buffer[buffidx]); |
| 198 |
} while ( (buffer[buffidx++] != '\r') && (buffidx < BUFFER_LEN_LOD) ); |
198 |
} while ( (buffer[buffidx] != '\r') && (buffer[buffidx] != '\n') && (buffer[buffidx] != ' ') && (++buffidx < BUFFER_LEN_LOD) ); |
| 199 |
assert(buffidx == BUFFER_LEN_LOD, ERR_BUFFER_OVERRUN); // Error 1 - Buffer Overrun |
199 |
assert(buffidx == BUFFER_LEN_LOD, ERR_BUFFER_OVERRUN); // Error 1 - Buffer Overrun |
| 200 |
|
200 |
|
| 201 |
//---WDT |
201 |
//---WDT |
| 202 |
restart_wdt(); |
202 |
restart_wdt(); |
| 203 |
|
203 |
|
| 204 |
checksum = 0; // Sum the bytes to find the check sum value |
204 |
checksum = 0; // Sum the bytes to find the check sum value |
| 205 |
for (i=0; i<(buffidx-3); i+=2) |
205 |
for (i=0; i<(buffidx-1); i+=2) |
| 206 |
{ |
206 |
{ |
| 207 |
checksum += atoi_b16 (&buffer[i]); |
207 |
checksum += atoi_b16 (&buffer[i]); |
| 208 |
//!!! printf(".%x",checksum); |
208 |
//!!! printf(".%x",checksum); |
| 209 |
} |
209 |
} |
| 210 |
assert(checksum != 0, ERR_CHECKSUM); // Error 2 - Bad CheckSum |
210 |
assert(checksum != 0, ERR_CHECKSUM); // Error 2 - Bad CheckSum |
| Line 234... |
Line 234... |
| 234 |
// Read old program memory content |
234 |
// Read old program memory content |
| 235 |
for (i=0,next_addr=addr;i<8;i++) |
235 |
for (i=0,next_addr=addr;i<8;i++) |
| 236 |
data.i16[i]=read_program_eeprom(next_addr++); |
236 |
data.i16[i]=read_program_eeprom(next_addr++); |
| 237 |
// Loops through all of the data and stores it in data |
237 |
// Loops through all of the data and stores it in data |
| 238 |
// The last 2 bytes are the check sum, hence buffidx-4 |
238 |
// The last 2 bytes are the check sum, hence buffidx-4 |
| 239 |
for (i=8,dataidx=0; i < (buffidx-5); i += 2) |
239 |
for (i=8,dataidx=0; i < (buffidx-3); i += 2) |
| 240 |
data.i8[dataidx++]=atoi_b16(&buffer[i]); |
240 |
data.i8[dataidx++]=atoi_b16(&buffer[i]); |
| 241 |
|
241 |
|
| 242 |
if (addr == 0) |
242 |
if (addr == 0) |
| 243 |
{ |
243 |
{ |
| 244 |
// Write 8 words to the Loader location (jump to the main()) |
244 |
// Write 8 words to the Loader location (jump to the main()) |