summaryrefslogtreecommitdiffstats
path: root/sw/programmer/linux/src/flash.c
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2017-09-07 14:25:39 +0200
committerNao Pross <naopross@thearcway.org>2017-09-07 14:25:39 +0200
commitcd89b3b3f30bdd98b725de0ea565f45fb4d9567c (patch)
treecea860c15430256cf0daebf903db10aae5879a23 /sw/programmer/linux/src/flash.c
parentadd test program for z80 (diff)
downloadz80uPC-cd89b3b3f30bdd98b725de0ea565f45fb4d9567c.tar.gz
z80uPC-cd89b3b3f30bdd98b725de0ea565f45fb4d9567c.zip
minor bug fix for ROM programmer
Diffstat (limited to 'sw/programmer/linux/src/flash.c')
-rw-r--r--sw/programmer/linux/src/flash.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/sw/programmer/linux/src/flash.c b/sw/programmer/linux/src/flash.c
index 48189da..6fcd09f 100644
--- a/sw/programmer/linux/src/flash.c
+++ b/sw/programmer/linux/src/flash.c
@@ -28,19 +28,24 @@ int flash_write(const char *romfile, void (*log)(const char *))
goto exit_romfd;
while ((head.size = read(romfd, buffer, FLASH_BLOCK_SIZE))) {
+ if (head.size < 0) {
+ log("[!] Error while reading from file\n");
+ break;
+ }
+
head.addr = (uint16_t) lseek(romfd, 0, SEEK_CUR);
written = write(flash_serial_fd, &head, sizeof(struct flash_blk));
- if (written < 0) {
- // error
+ if (written != sizeof(struct flash_blk)) {
+ log("[!] Some bytes of flash_blk haven't been written\n");
}
written = write(flash_serial_fd, buffer, head.size);
- if (written < 0) {
- // error
+ if (written != head.size) {
+ log("[#] Some bytes might not have been written\n");
}
- char logbuf[64];
+ char logbuf[64];
sprintf(logbuf, "[@] Written %d bytes at address %d\n", head.size, head.addr);
log(logbuf);
}