From 9b95085363e65abae7c6044d9852150fa9c8cf4c Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 30 Mar 2009 21:31:57 +0000 Subject: [PATCH] add padding, bump ver --- mx/linux/mx_flasher.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mx/linux/mx_flasher.c b/mx/linux/mx_flasher.c index e831d3c..9cb5e3c 100644 --- a/mx/linux/mx_flasher.c +++ b/mx/linux/mx_flasher.c @@ -45,7 +45,7 @@ static const struct { { 0x03eb, 0x202d, "32MX+UF Game Device" }, }; -#define VERSION "0.9" +#define VERSION "0.91" #define IO_BLK_SIZE 0x2000 /* 8K */ #define IO_RAM_BLK_SIZE 256 @@ -490,7 +490,7 @@ static int read_write_rom(struct usb_dev_handle *dev, u32 addr, void *buffer, in print_progress(total_bytes, total_bytes); } - if (count & 1) + if ((count & 1) && !is_write) /* work around rw_dev_block() limitation 3 (works for reads only?) */ rw_dev_block(dev, 0, dummy, sizeof(dummy), 0); @@ -1013,6 +1013,19 @@ breakloop: if (ret < 0) return 1; + /* align size to 64 */ + ret = (w_fsize + 63) & ~63; + if (w_fsize != ret) { + printf("ROM image size is %d, padding to %d\n", w_fsize, ret); + w_fdata = realloc(w_fdata, ret); + if (w_fdata == NULL) { + fprintf(stderr, "low mem\n"); + return 1; + } + memset((char *)w_fdata + w_fsize, 0, ret - w_fsize); + w_fsize = ret; + } + if (do_erase_size < w_fsize) do_erase_size = w_fsize; } -- 2.39.2