Line 16... |
Line 16... |
16 |
sed -i 's/^/pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp/' ./bltest.hex |
16 |
sed -i 's/^/pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp/' ./bltest.hex |
17 |
sed -i 1i"uf" ./bltest.hex |
17 |
sed -i 1i"uf" ./bltest.hex |
18 |
|
18 |
|
19 |
*/ |
19 |
*/ |
20 |
|
20 |
|
21 |
#define ID "$Id: bloader.c 2812 2013-03-10 08:00:23Z kakl $" |
21 |
#define ID "$Id: bloader.c 2813 2013-03-10 10:21:54Z kakl $" |
22 |
|
22 |
|
23 |
#CASE // Case sensitive compiler |
23 |
#CASE // Case sensitive compiler |
24 |
|
24 |
|
25 |
#define FLASH_BLOCK_SIZE getenv("FLASH_ERASE_SIZE")/2 // Minimal length of Flash Block Size |
25 |
#define FLASH_BLOCK_SIZE getenv("FLASH_ERASE_SIZE")/2 // Minimal length of Flash Block Size |
26 |
#define RESERVED_BLOCKS 53 // Number of reserved flash blocks for BootLoader |
26 |
#define RESERVED_BLOCKS 49 // Number of reserved flash blocks for BootLoader |
27 |
#define LOADER_RESERVED (getenv("PROGRAM_MEMORY")-(RESERVED_BLOCKS*FLASH_BLOCK_SIZE)) // begining of BootLoader |
27 |
#define LOADER_RESERVED (getenv("PROGRAM_MEMORY")-(RESERVED_BLOCKS*FLASH_BLOCK_SIZE)) // begining of BootLoader |
28 |
#define BUFFER_LEN_LOD 46 // Length of Working buffer for HEX |
28 |
#define BUFFER_LEN_LOD 46 // Length of Working buffer for HEX |
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 241... |
Line 241... |
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()) |
245 |
addr=LOADER_RESERVED; |
245 |
addr=LOADER_RESERVED; |
246 |
write_program_memory(addr, &data.i8[0], 16); |
246 |
write_program_memory(addr, &data.i8[0], 16); // It works only with 16 !!! |
247 |
putchar('%'); |
247 |
putchar('%'); |
248 |
} |
248 |
} |
249 |
else |
249 |
else |
250 |
if ( (addr > 7) && (addr <= (LOADER_RESERVED-16)) ) // Do not overwrite BootLoader |
250 |
if ( (addr > 7) && (addr <= (LOADER_RESERVED-16)) ) // Do not overwrite BootLoader |
251 |
{ |
251 |
{ |
252 |
// Write program |
252 |
// Write program |
253 |
write_program_memory(addr, &data.i8[0], 16); |
253 |
write_program_memory(addr, &data.i8[0], 16); // It works only with 16 !!! |
254 |
putchar('$'); |
254 |
putchar('$'); |
255 |
} |
255 |
} |
256 |
else putchar('.'); // Possibly there was prevented write to the location of BootLoader |
256 |
else putchar('.'); // Possibly there was prevented write to the location of BootLoader |
257 |
putc('\r'); putc('\n'); |
257 |
putc('\r'); putc('\n'); |
258 |
|
258 |
|