From b927fbf93b05b11032ba3594d1225c00d6c4172b Mon Sep 17 00:00:00 2001 From: Tobias Pflug Date: Sun, 25 Oct 2009 01:34:03 +0200 Subject: [PATCH] - qdips: patch chunk upload working but fw transfer bug remains usb bulk transfers copy the last byte of the chunk to SRAM twice. --- avr/usbload/config.h | 2 +- avr/usbload/main.c | 2 +- tools/qdips/qdips.c | 36 +++++++++++++++--------------------- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/avr/usbload/config.h b/avr/usbload/config.h index d51bf05..70516b4 100644 --- a/avr/usbload/config.h +++ b/avr/usbload/config.h @@ -50,7 +50,7 @@ #define DO_CRC_CHECK_LOADER 0 #define DO_CRC_CHECK 0 -#define DO_SHM_SCRATCHPAD 1 +#define DO_SHM_SCRATCHPAD 0 #define DO_SHM 0 #define DO_TIMER 0 #define DO_SHELL 1 diff --git a/avr/usbload/main.c b/avr/usbload/main.c index 50491cc..e60858f 100644 --- a/avr/usbload/main.c +++ b/avr/usbload/main.c @@ -305,7 +305,7 @@ int main(void) system_set_bus_avr(); system_send_snes_reset(); } - globals_init(); + /*globals_init();*/ } return 0; } diff --git a/tools/qdips/qdips.c b/tools/qdips/qdips.c index 3ce3447..7ba0aa2 100644 --- a/tools/qdips/qdips.c +++ b/tools/qdips/qdips.c @@ -44,9 +44,9 @@ typedef struct _ips_tag { - uint32_t ofs; /* offset in file to patch */ + uint32_t ofs; /* offset in file to patch */ uint16_t len; /* number of bytes in this chunk */ - uint8_t* data; /* chunk data */ + uint8_t* data; /* chunk data */ } ips_tag_t; int qd16_apply_ips_chunk(ips_tag_t* ips_tag); @@ -120,8 +120,6 @@ int main(int argc, char * argv[]) fprintf(stderr,"Error during init. Exiting!\n"); exit(1); } - qd16_finish(); - exit(0); fname = argv[optind]; patch_file = fopen(fname,"rb"); @@ -177,20 +175,11 @@ int main(int argc, char * argv[]) int qd16_apply_ips_chunk(ips_tag_t* ips_tag) { - return 0; int addr_hi = (ips_tag->ofs)>>16; int addr_lo = (ips_tag->ofs)&0xffff; - printf("hi:%x lo:%x\n",addr_hi,addr_lo); - + printf("hi:%x lo:%x len:%d\n",addr_hi,addr_lo,ips_tag->len); int ret = QD16_SEND_ADDR(addr_hi,addr_lo,ips_tag->data,ips_tag->len); - /*int ret = QD16_SEND_ADDR(addr_hi,addr_lo,dummy,128);*/ - if (ret<0){ - printf("error executing command!:%s\n",usb_strerror()); - } - - ret = QD16_SEND_DATA(addr_hi,addr_lo,ips_tag->data,ips_tag->len); - /*int ret = QD16_SEND_ADDR(addr_hi,addr_lo,dummy,128);*/ if (ret<0){ printf("error executing command!:%s\n",usb_strerror()); } @@ -200,7 +189,6 @@ int qd16_apply_ips_chunk(ips_tag_t* ips_tag) void qd16_finish(void) { -#if 0 cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, USB_BULK_UPLOAD_END, 0, 0, NULL, @@ -209,12 +197,12 @@ void qd16_finish(void) if (cnt<0) { printf("USB_BULK_UPLOAD_END failed: %s\n",usb_strerror()); } -#endif - cnt = usb_control_msg(handle, + + cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | - USB_ENDPOINT_OUT, USB_SET_LOADER, 0, 0, NULL, + USB_ENDPOINT_OUT, USB_SET_LOADER, 1, 1, NULL, 0, 5000); - + cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, USB_MODE_SNES, 0, 0, NULL, @@ -237,6 +225,14 @@ int qd16_init(void) return 1; } + cnt = usb_control_msg(handle, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | + USB_ENDPOINT_OUT, USB_SET_LOADER, 0, 0, NULL, + 0, 5000); + + if (cnt<0) { + printf("USB_SET_LOADER failed: %s\n",usb_strerror()); + } cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | @@ -249,7 +245,6 @@ int qd16_init(void) usleep(500000); -#if 0 cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, USB_BULK_UPLOAD_INIT, @@ -260,7 +255,6 @@ int qd16_init(void) if (cnt<0) { printf("USB_BULK_UPLOAD_INIT failed: %s\n",usb_strerror()); } -#endif return 0; }