|
@@ -69,7 +69,7 @@ void lpc_init(struct lpc_device *dev) {
|
|
|
char buf[4096];
|
|
|
|
|
|
lpc_printf(dev, "?");
|
|
|
- fflush(dev->port->f);
|
|
|
+ serial_drain(dev->port);
|
|
|
|
|
|
if(lpc_await_reply(dev, "Synchronized", NULL)==1) {
|
|
|
sprog_info("Synchronization successful\n");
|
|
@@ -81,7 +81,7 @@ void lpc_init(struct lpc_device *dev) {
|
|
|
sprog_error("Expected OK, received '%s'\n", buf);
|
|
|
} else {
|
|
|
lpc_printf(dev, "\r\n");
|
|
|
- if(lpc_await_reply(dev, "OK", NULL)==1)
|
|
|
+ if(lpc_await_reply(dev, "?", NULL)==1)
|
|
|
sprog_info("The device appears to be already synchronized\n");
|
|
|
else
|
|
|
sprog_error("Invalid device response\n");
|
|
@@ -102,7 +102,7 @@ void lpc_write(struct lpc_device *dev, const struct sprog_data *d) {
|
|
|
|
|
|
chunk.data = NULL;
|
|
|
|
|
|
- i = 7; /* dev->part->flash/4; /* number of sectors = Flash size / 4kB */
|
|
|
+ i = dev->part->flash/4; /* number of sectors = Flash size / 4kB */
|
|
|
lpc_command(dev, "P 0 %d\r\n", i);
|
|
|
|
|
|
sprog_info("Erasing Flash memory... ");
|
|
@@ -119,10 +119,10 @@ void lpc_write(struct lpc_device *dev, const struct sprog_data *d) {
|
|
|
for(i=0; chunk_sizes[i]; i++) {
|
|
|
if(chunk_sizes[i]>=chunk_size)
|
|
|
break;
|
|
|
- /*if(chunk_sizes[i]+1024 > dev->part->ram) {
|
|
|
+ if(chunk_sizes[i]+1024 > dev->part->ram) {
|
|
|
i--;
|
|
|
break;
|
|
|
- }*/
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
chunk_size = chunk_sizes[i];
|