From cd89b3b3f30bdd98b725de0ea565f45fb4d9567c Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Thu, 7 Sep 2017 14:25:39 +0200 Subject: minor bug fix for ROM programmer --- sw/programmer/avr/main.c | 9 +++++++-- sw/programmer/linux/config.h | 26 -------------------------- sw/programmer/linux/src/flash.c | 15 ++++++++++----- sw/programmer/linux/src/ui.c | 1 + 4 files changed, 18 insertions(+), 33 deletions(-) delete mode 100644 sw/programmer/linux/config.h (limited to 'sw') diff --git a/sw/programmer/avr/main.c b/sw/programmer/avr/main.c index 9cdc35d..4f39100 100644 --- a/sw/programmer/avr/main.c +++ b/sw/programmer/avr/main.c @@ -98,16 +98,21 @@ void eeprom_write(uint16_t addr, uint8_t byte) /* set data */ EEPROMDR = byte; + + // because EEPROMDR0 and EEPROMDR1 are used by Tx and Rx + EEPROMCR = (PINC & 0x07) | (byte & 0x03)<<3; EEPROMCR &= ~(_BV(ADDR_EH) | _BV(ADDR_EL)); /* write eeprom */ EEPROMCR &= ~_BV(EEPROM_WR); - eeprom_tick(); + + // eeprom_tick(); EEPROMCR |= _BV(EEPROM_WR); EEPROMCR |= _BV(ADDR_EH) | _BV(ADDR_EL); } +#if 0 /* pulse the clock line for the eeprom */ void eeprom_tick() { @@ -116,4 +121,4 @@ void eeprom_tick() EEPROMCR &= ~_BV(EEPROM_CLK); _delay_ms(EEPROM_TICK_MS); } - +#endif \ No newline at end of file diff --git a/sw/programmer/linux/config.h b/sw/programmer/linux/config.h deleted file mode 100644 index d319f43..0000000 --- a/sw/programmer/linux/config.h +++ /dev/null @@ -1,26 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Name of package */ -#define PACKAGE "z80prog" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "naopross@tharcway.org" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "z80prog" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "z80prog 0.1" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "z80prog" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "0.1" - -/* Version number of package */ -#define VERSION "0.1" 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); } diff --git a/sw/programmer/linux/src/ui.c b/sw/programmer/linux/src/ui.c index 87dc0c7..b53ff0b 100644 --- a/sw/programmer/linux/src/ui.c +++ b/sw/programmer/linux/src/ui.c @@ -18,6 +18,7 @@ void ui_init(int *argc, char **argv[]) /* connect objects to callbacks */ window = GTK_WINDOW(gtk_builder_get_object(ui_builder, "window")); + g_signal_connect(window, "delete_event", G_CALLBACK(flash_close), NULL); g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); connectbtn = GTK_BUTTON(gtk_builder_get_object(ui_builder, "connectbtn")); -- cgit v1.2.1