From 57640a10a66a97a07b954a25e976ff0d3a5d28b0 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Thu, 19 Oct 2017 17:56:29 +0200 Subject: Got a real rom programmer, this code is still broken but I don't care --- sw/programmer/linux/src/flash.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'sw/programmer/linux/src/flash.c') diff --git a/sw/programmer/linux/src/flash.c b/sw/programmer/linux/src/flash.c index 24d5269..3527de8 100644 --- a/sw/programmer/linux/src/flash.c +++ b/sw/programmer/linux/src/flash.c @@ -15,6 +15,7 @@ int flash_open(const char *path, unsigned long baudrate) int flash_write(const char *romfile, void (*log)(const char *)) { int romfd; + int v; ssize_t written; struct stat romst; @@ -33,7 +34,11 @@ int flash_write(const char *romfile, void (*log)(const char *)) break; } - head.addr = (uint16_t) lseek(romfd, 0, SEEK_CUR); + head.addr = (uint16_t) lseek(romfd, 0, SEEK_CUR) - head.size; + + char logbuf[64]; + sprintf(logbuf, "[@] Writing a block of size %d at addr %d\n", head.size, head.addr); + log(logbuf); written = write(flash_serial_fd, &head, sizeof(struct flash_blk)); if (written != sizeof(struct flash_blk)) { @@ -45,8 +50,9 @@ int flash_write(const char *romfile, void (*log)(const char *)) log("[#] Some bytes might not have been written\n"); } - char logbuf[64]; - sprintf(logbuf, "[@] Written %d bytes at address %d\n", head.size, head.addr); + while (!read(flash_serial_fd, &v, 1)); + + sprintf(logbuf, "[@] Written %d bytes at address %d\n", head.size, head.addr); log(logbuf); } -- cgit v1.2.1