diff options
author | Nao Pross <naopross@thearcway.org> | 2017-10-19 17:56:29 +0200 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2017-10-19 17:56:29 +0200 |
commit | 57640a10a66a97a07b954a25e976ff0d3a5d28b0 (patch) | |
tree | 0d0bb15f54b781c03a25adfbf39979dbc2d657a6 /sw/programmer/linux/src/flash.c | |
parent | Fix for PIO driver and its test and deletes build files (diff) | |
download | z80uPC-57640a10a66a97a07b954a25e976ff0d3a5d28b0.tar.gz z80uPC-57640a10a66a97a07b954a25e976ff0d3a5d28b0.zip |
Got a real rom programmer, this code is still broken but I don't care
Diffstat (limited to '')
-rw-r--r-- | sw/programmer/linux/src/flash.c | 12 |
1 files changed, 9 insertions, 3 deletions
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); } |