diff --git a/avr/usbload/commandline/snesuploader b/avr/usbload/commandline/snesuploader index ff16443..69070b2 100755 Binary files a/avr/usbload/commandline/snesuploader and b/avr/usbload/commandline/snesuploader differ diff --git a/avr/usbload/commandline/snesuploader.c b/avr/usbload/commandline/snesuploader.c index a9bb01e..2ac9864 100644 --- a/avr/usbload/commandline/snesuploader.c +++ b/avr/usbload/commandline/snesuploader.c @@ -15,8 +15,8 @@ */ -#define READ_BUFFER_SIZE 1024 -#define SEND_BUFFER_SIZE 0x200 +#define READ_BUFFER_SIZE (1024 * 32) +#define SEND_BUFFER_SIZE 128 #define BUFFER_CRC (1024 * 32) #define BANK_SIZE (1<<15) #define BANK_SIZE_SHIFT 15 @@ -170,7 +170,6 @@ int main(int argc, char **argv) crc_buffer = (unsigned char *) malloc(BUFFER_CRC); memset(crc_buffer, 0, BUFFER_CRC); addr = 0x000000; - usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, USB_UPLOAD_INIT, BANK_SIZE_SHIFT , 0, NULL, 0, 5000); @@ -192,11 +191,13 @@ int main(int argc, char **argv) if (cnt < 0) { fprintf(stderr, "USB error: %s\n", usb_strerror()); + usb_close(handle); exit(-1); } addr += SEND_BUFFER_SIZE; + break; } - dump_packet(0x00000,READ_BUFFER_SIZE, read_buffer); + dump_packet(0x00000,SEND_BUFFER_SIZE, read_buffer); memcpy(crc_buffer + cnt_crc, read_buffer, READ_BUFFER_SIZE); cnt_crc += READ_BUFFER_SIZE; if (cnt_crc >= READ_BUFFER_SIZE) { @@ -206,6 +207,7 @@ int main(int argc, char **argv) bank++; cnt_crc = 0; } + break; } diff --git a/avr/usbload/debug.c b/avr/usbload/debug.c index 17f77b8..86910d2 100644 --- a/avr/usbload/debug.c +++ b/avr/usbload/debug.c @@ -5,6 +5,7 @@ #include "uart.h" + extern FILE uart_stdout; extern int debug_level; /* the higher, the more messages... */ @@ -21,9 +22,10 @@ void debug(int level, char* format, ...) { if (!(debug_level & level)) return; va_start(args, format); - printf(format, args); + vprintf(format, args); va_end(args); #endif /* NDEBUG */ #endif /* NDEBUG && __GNUC__ */ } + diff --git a/avr/usbload/debug.h b/avr/usbload/debug.h index fc3af63..d62aaf6 100644 --- a/avr/usbload/debug.h +++ b/avr/usbload/debug.h @@ -18,4 +18,4 @@ void debug(int level, char *format, ...); #endif /* DEBUG_H */ - \ No newline at end of file + diff --git a/avr/usbload/dump.c b/avr/usbload/dump.c index f608334..d242a98 100644 --- a/avr/usbload/dump.c +++ b/avr/usbload/dump.c @@ -47,14 +47,19 @@ void dump_memory(uint32_t bottom_addr, uint32_t top_addr) { uint32_t addr; uint8_t byte; - sram_bulk_read_start(bottom_addr); + + //sram_bulk_read_start(bottom_addr); + bottom_addr = 0x00; + top_addr = 0x80; + + printf("%08lx - %08lx\n",bottom_addr, top_addr); printf("%08lx:", bottom_addr); for ( addr = bottom_addr; addr < top_addr; addr++) { - if (addr%0x16 == 0) - printf("\n%08lx:", bottom_addr); - byte = sram_bulk_read(); - sram_bulk_read_next(); + if (addr%0x10 == 0) + printf("\n%08lx:", addr); + byte = sram_read(addr); + //sram_bulk_read_next(); printf(" %02x", byte); } - sram_bulk_read_end(); + //sram_bulk_read_end(); } diff --git a/avr/usbload/dump.h b/avr/usbload/dump.h index a748341..cda4113 100644 --- a/avr/usbload/dump.h +++ b/avr/usbload/dump.h @@ -5,8 +5,9 @@ #include #include -void dump_packet(uint32_t addr,uint32_t len,uint8_t *packet); void dump_memory(uint32_t bottom_addr, uint32_t top_addr); +void dump_packet(uint32_t addr,uint32_t len,uint8_t *packet); + #endif \ No newline at end of file diff --git a/avr/usbload/main.c b/avr/usbload/main.c index d07e9d4..cfd86d5 100644 --- a/avr/usbload/main.c +++ b/avr/usbload/main.c @@ -17,7 +17,7 @@ extern FILE uart_stdout; -uint8_t debug_level = ( DEBUG | DEBUG_USB ); +uint8_t debug_level = ( DEBUG | DEBUG_USB | DEBUG_USB_TRANS | DEBUG_SRAM); uint8_t read_buffer[TRANSFER_BUFFER_SIZE]; uint32_t req_addr = 0; @@ -231,6 +231,7 @@ void test_read_write(){ } + void test_bulk_read_write(){ uint8_t i; @@ -250,7 +251,7 @@ void test_bulk_read_write(){ while (addr <= 0x3fffff){ printf("addr=0x%08lx %x\n",addr,sram_bulk_read()); sram_bulk_read_next(); - addr ++; + addr++; } sram_bulk_read_end(); } @@ -318,17 +319,21 @@ int main(void) printf("USB poll done\n"); usbDeviceDisconnect(); printf("USB disconnect\n"); - crc_check_bulk_memory(0x000000,0x1000); + + crc_check_bulk_memory(0x000000,0x8000); + + dump_memory(0x00,0x80); printf("Disable snes WR\n"); snes_wr_disable(); + printf("Use Snes lowrom\n"); snes_lorom(); + printf("Activate Snes bus\n"); snes_bus_active(); - - while(1); + return 0; } diff --git a/avr/usbload/usb_bulk.c b/avr/usbload/usb_bulk.c index ab8fe66..e083d65 100644 --- a/avr/usbload/usb_bulk.c +++ b/avr/usbload/usb_bulk.c @@ -42,6 +42,8 @@ uint8_t usbFunctionWrite(uint8_t * data, uint8_t len) rx_remaining -= len; debug(DEBUG_USB_TRANS,"usbFunctionWrite REQ_STATUS_UPLOAD addr: 0x%08lx len: %i rx_remaining=%i\n", req_addr, len, rx_remaining); + debug(DEBUG_USB_TRANS,"usbFunctionWrite %02x %02x %02x %02x %02x %02x %02x %x\n", + data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]); sram_copy(req_addr, data, len); req_addr += len; } else if (req_state == REQ_STATUS_BULK_UPLOAD) { diff --git a/avr/usbload/usbconfig.h b/avr/usbload/usbconfig.h index 589a846..85d1934 100644 --- a/avr/usbload/usbconfig.h +++ b/avr/usbload/usbconfig.h @@ -114,7 +114,7 @@ section at the end of this file). /* Define this to 1 if the device has its own power supply. Set it to 0 if the * device is powered from the USB bus. */ -#define USB_CFG_MAX_BUS_POWER 300 +#define USB_CFG_MAX_BUS_POWER 200 /* Set this variable to the maximum USB bus power consumption of your device. * The value is in milliamperes. [It will be divided by two since USB * communicates power requirements in units of 2 mA.]