|
@@ -152,7 +152,7 @@ void lpc_write(struct lpc_device *dev, const struct sprog_data *d) {
|
|
|
chunk.size = chunk_size;
|
|
|
|
|
|
if(offset==0) {
|
|
|
- /* calculate the checksum and put it at 0x1c in the vector table */
|
|
|
+ /* 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;
|
|
@@ -186,6 +186,7 @@ void lpc_exec(struct lpc_device *dev, const struct sprog_data *d) {
|
|
|
}
|
|
|
|
|
|
void lpc_write_ram(struct lpc_device *dev, const struct sprog_data *d, unsigned int addr) {
|
|
|
+ struct sprog_data tmp;
|
|
|
int last_offset;
|
|
|
int last_i;
|
|
|
int offset;
|
|
@@ -194,13 +195,20 @@ void lpc_write_ram(struct lpc_device *dev, const struct sprog_data *d, unsigned
|
|
|
int i;
|
|
|
int j;
|
|
|
|
|
|
+ sprog_info("Writing %d bytes\n", d->size);
|
|
|
/* align data size to 4 */
|
|
|
- i = d->size;
|
|
|
- if(i & 3)
|
|
|
- i = (i & ~3) + 4;
|
|
|
+ if(d->size & 3) {
|
|
|
+ tmp.data = NULL;
|
|
|
+ sprog_alloc_data(&tmp, d->size + 4);
|
|
|
+ for(i=0; i<d->size; i++)
|
|
|
+ tmp.data[i] = d->data[i];
|
|
|
+ for(i=d->size; i & 3; i++)
|
|
|
+ tmp.data[i] = 0;
|
|
|
+ tmp.size = i;
|
|
|
+ d = &tmp;
|
|
|
+ }
|
|
|
|
|
|
- lpc_command(dev, "W %u %u\r\n", addr, i);
|
|
|
- sprog_info("Writing %d bytes\n", d->size);
|
|
|
+ lpc_command(dev, "W %u %u\r\n", addr, d->size);
|
|
|
|
|
|
last_i = 0;
|
|
|
last_offset = 0;
|