|
@@ -101,7 +101,9 @@ void lpc_write(struct lpc_device *dev, const struct sprog_data *d) {
|
|
|
|
|
|
chunk.data = NULL;
|
|
|
|
|
|
- i = dev->part->flash/4; /* number of sectors = Flash size / 4kB */
|
|
|
+ lpc_command(dev, "U 23130\r\n"); /* unlock the device */
|
|
|
+
|
|
|
+ i = dev->part->flash/4 - 1; /* last sector = Flash size / 4kB - 1 */
|
|
|
lpc_command(dev, "P 0 %d\r\n", i);
|
|
|
|
|
|
sprog_info("Erasing Flash memory... ");
|
|
@@ -110,7 +112,7 @@ void lpc_write(struct lpc_device *dev, const struct sprog_data *d) {
|
|
|
else
|
|
|
sprog_info("OK\n");
|
|
|
|
|
|
- i = d->size/4096;
|
|
|
+ i = d->size/4096 - 1;
|
|
|
lpc_command(dev, "P 0 %d\r\n", i); /* prepare sectors for write */
|
|
|
|
|
|
while(d->size-offset>0) {
|