|
@@ -147,10 +147,22 @@ void lpc_write(struct lpc_device *dev, const struct sprog_data *d) {
|
|
|
chunk.data[i] = d->data[offset+i];
|
|
|
|
|
|
for(i=data_size; i<chunk_size; i++)
|
|
|
- chunk.data[i] = 0;
|
|
|
+ chunk.data[i] = 0xff;
|
|
|
|
|
|
chunk.size = chunk_size;
|
|
|
|
|
|
+ if(offset==0) {
|
|
|
+ /* calculate the checksum and put it at 0x1c in the vector table */
|
|
|
+ j = 0;
|
|
|
+ for(i=0; i<0x1c; i+=4)
|
|
|
+ j += chunk.data[i] | chunk.data[i+1]<<8 | chunk.data[i+2]<<16 | chunk.data[i+3]<<24;
|
|
|
+ j = -j;
|
|
|
+ for(i=0; i<4; i++) {
|
|
|
+ chunk.data[0x1c+i] = j & 0xff;
|
|
|
+ j >>= 8;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
lpc_write_ram(dev, &chunk, 0x10000400);
|
|
|
|
|
|
sprog_info("Copying to Flash...\n");
|